blob: c7e2e095a8c7e045c419061d6a5b058170ae0336 [file] [log] [blame]
developerd59e4772022-07-14 13:48:49 +08001From ac7abe57fec7283da9c50d4f513c1b6171e0e912 Mon Sep 17 00:00:00 2001
developerb7c46752022-07-04 19:51:38 +08002From: Bo Jiao <Bo.Jiao@mediatek.com>
3Date: Mon, 4 Jul 2022 19:24:34 +0800
developerd59e4772022-07-14 13:48:49 +08004Subject: [PATCH 1113/1119] mt76: mt7915: drop packets when TWT stations use
developer7bfba5a2022-05-03 10:24:17 +08005
6---
developerd59e4772022-07-14 13:48:49 +08007 .../net/wireless/mediatek/mt76/mt7915/mac.c | 21 ++++++++++++++++---
8 .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++
developer7bfba5a2022-05-03 10:24:17 +08009 2 files changed, 20 insertions(+), 3 deletions(-)
10
11diff --git a/mt7915/mac.c b/mt7915/mac.c
developerd59e4772022-07-14 13:48:49 +080012index 5e5df23d..55b38d16 100644
developer7bfba5a2022-05-03 10:24:17 +080013--- a/mt7915/mac.c
14+++ b/mt7915/mac.c
developerb7c46752022-07-04 19:51:38 +080015@@ -725,6 +725,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer7bfba5a2022-05-03 10:24:17 +080016 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
17 struct ieee80211_key_conf *key = info->control.hw_key;
18 struct ieee80211_vif *vif = info->control.vif;
19+ struct mt7915_sta *msta = NULL;
developerf64861f2022-06-22 11:44:53 +080020 struct mt76_connac_fw_txp *txp;
developer7bfba5a2022-05-03 10:24:17 +080021 struct mt76_txwi_cache *t;
developer7bfba5a2022-05-03 10:24:17 +080022 int id, i, nbuf = tx_info->nbuf - 1;
developerb7c46752022-07-04 19:51:38 +080023@@ -738,8 +739,6 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer7bfba5a2022-05-03 10:24:17 +080024 wcid = &dev->mt76.global_wcid;
25
26 if (sta) {
27- struct mt7915_sta *msta;
28-
29 msta = (struct mt7915_sta *)sta->drv_priv;
30
31 if (time_after(jiffies, msta->jiffies + HZ / 4)) {
developerb7c46752022-07-04 19:51:38 +080032@@ -755,10 +754,22 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer4c6b6002022-05-30 16:36:44 +080033 mgmt->u.action.category == 0xff)
34 return -1;
developer7bfba5a2022-05-03 10:24:17 +080035
36+ spin_lock_bh(&mdev->token_lock);
37+ if (msta && msta->twt.flowid_mask && msta->token_count > 128) {
38+ spin_unlock_bh(&mdev->token_lock);
39+ return -1;
40+ }
41+ spin_unlock_bh(&mdev->token_lock);
42+
43 id = mt76_token_consume(mdev, &t);
44 if (id < 0)
45 return id;
46
47+ spin_lock_bh(&mdev->token_lock);
48+ if (msta)
49+ msta->token_count++;
50+ spin_unlock_bh(&mdev->token_lock);
51+
52 pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
developerb7c46752022-07-04 19:51:38 +080053 mt7915_mac_write_txwi(mdev, txwi_ptr, tx_info->skb, wcid, pid, key,
54 qid, 0);
55@@ -939,6 +950,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developerbeb74372022-05-06 16:53:33 +080056 struct mt76_dev *mdev = &dev->mt76;
developer7bfba5a2022-05-03 10:24:17 +080057 struct mt76_txwi_cache *txwi;
58 struct ieee80211_sta *sta = NULL;
developer68e1eb22022-05-09 17:02:12 +080059+ struct mt7915_sta *msta = NULL;
developer7bfba5a2022-05-03 10:24:17 +080060 LIST_HEAD(free_list);
developer7bfba5a2022-05-03 10:24:17 +080061 void *end = data + len;
developerbeb74372022-05-06 16:53:33 +080062 bool v3, wake = false;
developerb7c46752022-07-04 19:51:38 +080063@@ -962,7 +974,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer7bfba5a2022-05-03 10:24:17 +080064 * 1'b0: msdu_id with the same 'wcid pair' as above.
65 */
66 if (info & MT_TX_FREE_PAIR) {
67- struct mt7915_sta *msta;
68 struct mt76_wcid *wcid;
69 u16 idx;
70
developerb7c46752022-07-04 19:51:38 +080071@@ -995,6 +1006,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer7bfba5a2022-05-03 10:24:17 +080072 txwi = mt76_token_release(mdev, msdu, &wake);
73 if (!txwi)
74 continue;
75+ spin_lock(&mdev->token_lock);
76+ if (msta)
77+ msta->token_count--;
78+ spin_unlock(&mdev->token_lock);
79
80 mt7915_txwi_free(dev, txwi, sta, &free_list);
81 }
82diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerb7c46752022-07-04 19:51:38 +080083index 7c7d6bd3..5f11b3fb 100644
developer7bfba5a2022-05-03 10:24:17 +080084--- a/mt7915/mt7915.h
85+++ b/mt7915/mt7915.h
developerf64861f2022-06-22 11:44:53 +080086@@ -136,6 +136,8 @@ struct mt7915_sta {
developer7bfba5a2022-05-03 10:24:17 +080087 u8 flowid_mask;
88 struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
89 } twt;
90+
91+ int token_count;
92 };
93
94 struct mt7915_vif_cap {
95--
developerd59e4772022-07-14 13:48:49 +0800962.25.1
developer7bfba5a2022-05-03 10:24:17 +080097