developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 1 | From ac7abe57fec7283da9c50d4f513c1b6171e0e912 Mon Sep 17 00:00:00 2001 |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 2 | From: Bo Jiao <Bo.Jiao@mediatek.com> |
| 3 | Date: Mon, 4 Jul 2022 19:24:34 +0800 |
developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1113/1119] mt76: mt7915: drop packets when TWT stations use |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 7 | .../net/wireless/mediatek/mt76/mt7915/mac.c | 21 ++++++++++++++++--- |
| 8 | .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++ |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 9 | 2 files changed, 20 insertions(+), 3 deletions(-) |
| 10 | |
| 11 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 12 | index 5e5df23d..55b38d16 100644 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 13 | --- a/mt7915/mac.c |
| 14 | +++ b/mt7915/mac.c |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 15 | @@ -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] | 16 | 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; |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 20 | struct mt76_connac_fw_txp *txp; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 21 | struct mt76_txwi_cache *t; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 22 | int id, i, nbuf = tx_info->nbuf - 1; |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 23 | @@ -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] | 24 | 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)) { |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 32 | @@ -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] | 33 | mgmt->u.action.category == 0xff) |
| 34 | return -1; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 35 | |
| 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); |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 53 | 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) |
developer | beb7437 | 2022-05-06 16:53:33 +0800 | [diff] [blame] | 56 | struct mt76_dev *mdev = &dev->mt76; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 57 | struct mt76_txwi_cache *txwi; |
| 58 | struct ieee80211_sta *sta = NULL; |
developer | 68e1eb2 | 2022-05-09 17:02:12 +0800 | [diff] [blame] | 59 | + struct mt7915_sta *msta = NULL; |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 60 | LIST_HEAD(free_list); |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 61 | void *end = data + len; |
developer | beb7437 | 2022-05-06 16:53:33 +0800 | [diff] [blame] | 62 | bool v3, wake = false; |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 63 | @@ -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] | 64 | * 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 | |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 71 | @@ -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] | 72 | 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 | } |
| 82 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | b7c4675 | 2022-07-04 19:51:38 +0800 | [diff] [blame] | 83 | index 7c7d6bd3..5f11b3fb 100644 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 84 | --- a/mt7915/mt7915.h |
| 85 | +++ b/mt7915/mt7915.h |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 86 | @@ -136,6 +136,8 @@ struct mt7915_sta { |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 87 | 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 | -- |
developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 96 | 2.25.1 |
developer | 7bfba5a | 2022-05-03 10:24:17 +0800 | [diff] [blame] | 97 | |