summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayne Chen <shayne.chen@mediatek.com>2021-01-05 16:55:25 +0800
committerFelix Fietkau <nbd@nbd.name>2021-01-26 20:07:48 +0100
commitba4590942e293886d70ef3c8a34173b562de2402 (patch)
tree0975b7523f60630ab8e4e46ab927c56e1291d249
parentb8cbdb97437c0e0c8370c650d51a7bcb165e5fed (diff)
mt76: testmode: make tx queued limit adjustable
Originally, tx queued limit is set to 1000 to prevent from running out of tx token. If a new testmode tx is triggered while the previous one hasn't finished yet, we'll wait a period of time until tx_done equals to tx_queued. Normally, current queued limit can finish in 10 seconds. However, if ipg is configured to a larger value, less than 1000 packets can be done in the default timeout period, which may lead to a crash when a new testmode tx triggered. To deal with this, make tx queued limit dynamically adjusted according to ipg value. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76.h1
-rw-r--r--drivers/net/wireless/mediatek/mt76/testmode.c9
-rw-r--r--drivers/net/wireless/mediatek/mt76/testmode.h2
3 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index c65f92694b99..598c09b9b8f6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -552,6 +552,7 @@ struct mt76_testmode_data {
u32 tx_pending;
u32 tx_queued;
+ u16 tx_queued_limit;
u32 tx_done;
struct {
u64 packets[__MT_RXQ_MAX];
diff --git a/drivers/net/wireless/mediatek/mt76/testmode.c b/drivers/net/wireless/mediatek/mt76/testmode.c
index 74cadf51df55..cc769645afa5 100644
--- a/drivers/net/wireless/mediatek/mt76/testmode.c
+++ b/drivers/net/wireless/mediatek/mt76/testmode.c
@@ -30,6 +30,7 @@ void mt76_testmode_tx_pending(struct mt76_phy *phy)
struct mt76_wcid *wcid = &dev->global_wcid;
struct sk_buff *skb = td->tx_skb;
struct mt76_queue *q;
+ u16 tx_queued_limit;
int qid;
if (!skb || !td->tx_pending)
@@ -38,9 +39,12 @@ void mt76_testmode_tx_pending(struct mt76_phy *phy)
qid = skb_get_queue_mapping(skb);
q = phy->q_tx[qid];
+ tx_queued_limit = td->tx_queued_limit ? td->tx_queued_limit : 1000;
+
spin_lock_bh(&q->lock);
- while (td->tx_pending > 0 && td->tx_queued - td->tx_done < 1000 &&
+ while (td->tx_pending > 0 &&
+ td->tx_queued - td->tx_done < tx_queued_limit &&
q->queued < q->ndesc / 2) {
int ret;
@@ -196,7 +200,8 @@ mt76_testmode_tx_stop(struct mt76_phy *phy)
mt76_worker_enable(&dev->tx_worker);
- wait_event_timeout(dev->tx_wait, td->tx_done == td->tx_queued, 10 * HZ);
+ wait_event_timeout(dev->tx_wait, td->tx_done == td->tx_queued,
+ MT76_TM_TIMEOUT * HZ);
dev_kfree_skb(td->tx_skb);
td->tx_skb = NULL;
diff --git a/drivers/net/wireless/mediatek/mt76/testmode.h b/drivers/net/wireless/mediatek/mt76/testmode.h
index 90c4b2af5b01..b0fc8f77db68 100644
--- a/drivers/net/wireless/mediatek/mt76/testmode.h
+++ b/drivers/net/wireless/mediatek/mt76/testmode.h
@@ -5,6 +5,8 @@
#ifndef __MT76_TESTMODE_H
#define __MT76_TESTMODE_H
+#define MT76_TM_TIMEOUT 10
+
/**
* enum mt76_testmode_attr - testmode attributes inside NL80211_ATTR_TESTDATA
*