developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 1 | From 9bc707077df60aa6423c89b1d17fd8a5f4e2d36b Mon Sep 17 00:00:00 2001 |
| 2 | From: Bo Jiao <Bo.Jiao@mediatek.com> |
| 3 | Date: Mon, 4 Jul 2022 19:24:34 +0800 |
| 4 | Subject: [PATCH] mt76: mt7915: drop packets when TWT stations use |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
developer | 4721e25 | 2022-06-21 16:41:28 +0800 | [diff] [blame] | 7 | mt7915/mac.c | 21 ++++++++++++++++++--- |
| 8 | mt7915/mt7915.h | 2 ++ |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 9 | 2 files changed, 20 insertions(+), 3 deletions(-) |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 10 | mode change 100644 => 100755 mt7915/mac.c |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 11 | |
| 12 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 13 | old mode 100644 |
| 14 | new mode 100755 |
| 15 | index 5e5df23d..55b38d16 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 16 | --- a/mt7915/mac.c |
| 17 | +++ b/mt7915/mac.c |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 18 | @@ -725,6 +725,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 19 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); |
| 20 | struct ieee80211_key_conf *key = info->control.hw_key; |
| 21 | struct ieee80211_vif *vif = info->control.vif; |
| 22 | + struct mt7915_sta *msta = NULL; |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 23 | struct mt76_connac_fw_txp *txp; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 24 | struct mt76_txwi_cache *t; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 25 | int id, i, nbuf = tx_info->nbuf - 1; |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 26 | @@ -738,8 +739,6 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 27 | wcid = &dev->mt76.global_wcid; |
| 28 | |
| 29 | if (sta) { |
| 30 | - struct mt7915_sta *msta; |
| 31 | - |
| 32 | msta = (struct mt7915_sta *)sta->drv_priv; |
| 33 | |
| 34 | if (time_after(jiffies, msta->jiffies + HZ / 4)) { |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 35 | @@ -755,10 +754,22 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 4c6b600 | 2022-05-30 16:36:44 +0800 | [diff] [blame] | 36 | mgmt->u.action.category == 0xff) |
| 37 | return -1; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 38 | |
| 39 | + spin_lock_bh(&mdev->token_lock); |
| 40 | + if (msta && msta->twt.flowid_mask && msta->token_count > 128) { |
| 41 | + spin_unlock_bh(&mdev->token_lock); |
| 42 | + return -1; |
| 43 | + } |
| 44 | + spin_unlock_bh(&mdev->token_lock); |
| 45 | + |
| 46 | id = mt76_token_consume(mdev, &t); |
| 47 | if (id < 0) |
| 48 | return id; |
| 49 | |
| 50 | + spin_lock_bh(&mdev->token_lock); |
| 51 | + if (msta) |
| 52 | + msta->token_count++; |
| 53 | + spin_unlock_bh(&mdev->token_lock); |
| 54 | + |
| 55 | pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 56 | mt7915_mac_write_txwi(mdev, txwi_ptr, tx_info->skb, wcid, pid, key, |
| 57 | qid, 0); |
| 58 | @@ -939,6 +950,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | beb7437 | 2022-05-06 16:53:33 +0800 | [diff] [blame] | 59 | struct mt76_dev *mdev = &dev->mt76; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 60 | struct mt76_txwi_cache *txwi; |
| 61 | struct ieee80211_sta *sta = NULL; |
developer | 68e1eb2 | 2022-05-09 17:02:12 +0800 | [diff] [blame] | 62 | + struct mt7915_sta *msta = NULL; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 63 | LIST_HEAD(free_list); |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 64 | void *end = data + len; |
developer | beb7437 | 2022-05-06 16:53:33 +0800 | [diff] [blame] | 65 | bool v3, wake = false; |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 66 | @@ -962,7 +974,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 67 | * 1'b0: msdu_id with the same 'wcid pair' as above. |
| 68 | */ |
| 69 | if (info & MT_TX_FREE_PAIR) { |
| 70 | - struct mt7915_sta *msta; |
| 71 | struct mt76_wcid *wcid; |
| 72 | u16 idx; |
| 73 | |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 74 | @@ -995,6 +1006,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 75 | txwi = mt76_token_release(mdev, msdu, &wake); |
| 76 | if (!txwi) |
| 77 | continue; |
| 78 | + spin_lock(&mdev->token_lock); |
| 79 | + if (msta) |
| 80 | + msta->token_count--; |
| 81 | + spin_unlock(&mdev->token_lock); |
| 82 | |
| 83 | mt7915_txwi_free(dev, txwi, sta, &free_list); |
| 84 | } |
| 85 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 86 | index 7c7d6bd3..5f11b3fb 100644 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 87 | --- a/mt7915/mt7915.h |
| 88 | +++ b/mt7915/mt7915.h |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 89 | @@ -136,6 +136,8 @@ struct mt7915_sta { |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 90 | u8 flowid_mask; |
| 91 | struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT]; |
| 92 | } twt; |
| 93 | + |
| 94 | + int token_count; |
| 95 | }; |
| 96 | |
| 97 | struct mt7915_vif_cap { |
| 98 | -- |
developer | 4721e25 | 2022-06-21 16:41:28 +0800 | [diff] [blame] | 99 | 2.18.0 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 100 | |