[][MAC80211][MT76][reduce TWT SP sent to FW for cert]
[Description]
Remove token limitation of TWT stations and reduce TWT SP sent to FW.
[Release-log]
N/A
Change-Id: I71e6457b99a29af46a55d83e6a21bc2e264e2ae4
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6344723
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch
deleted file mode 100644
index c7e2e09..0000000
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From ac7abe57fec7283da9c50d4f513c1b6171e0e912 Mon Sep 17 00:00:00 2001
-From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Mon, 4 Jul 2022 19:24:34 +0800
-Subject: [PATCH 1113/1119] mt76: mt7915: drop packets when TWT stations use
-
----
- .../net/wireless/mediatek/mt76/mt7915/mac.c | 21 ++++++++++++++++---
- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++
- 2 files changed, 20 insertions(+), 3 deletions(-)
-
-diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 5e5df23d..55b38d16 100644
---- a/mt7915/mac.c
-+++ b/mt7915/mac.c
-@@ -725,6 +725,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
- struct ieee80211_key_conf *key = info->control.hw_key;
- struct ieee80211_vif *vif = info->control.vif;
-+ struct mt7915_sta *msta = NULL;
- struct mt76_connac_fw_txp *txp;
- struct mt76_txwi_cache *t;
- int id, i, nbuf = tx_info->nbuf - 1;
-@@ -738,8 +739,6 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- wcid = &dev->mt76.global_wcid;
-
- if (sta) {
-- struct mt7915_sta *msta;
--
- msta = (struct mt7915_sta *)sta->drv_priv;
-
- if (time_after(jiffies, msta->jiffies + HZ / 4)) {
-@@ -755,10 +754,22 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- mgmt->u.action.category == 0xff)
- return -1;
-
-+ spin_lock_bh(&mdev->token_lock);
-+ if (msta && msta->twt.flowid_mask && msta->token_count > 128) {
-+ spin_unlock_bh(&mdev->token_lock);
-+ return -1;
-+ }
-+ spin_unlock_bh(&mdev->token_lock);
-+
- id = mt76_token_consume(mdev, &t);
- if (id < 0)
- return id;
-
-+ spin_lock_bh(&mdev->token_lock);
-+ if (msta)
-+ msta->token_count++;
-+ spin_unlock_bh(&mdev->token_lock);
-+
- pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
- mt7915_mac_write_txwi(mdev, txwi_ptr, tx_info->skb, wcid, pid, key,
- qid, 0);
-@@ -939,6 +950,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- struct mt76_dev *mdev = &dev->mt76;
- struct mt76_txwi_cache *txwi;
- struct ieee80211_sta *sta = NULL;
-+ struct mt7915_sta *msta = NULL;
- LIST_HEAD(free_list);
- void *end = data + len;
- bool v3, wake = false;
-@@ -962,7 +974,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- * 1'b0: msdu_id with the same 'wcid pair' as above.
- */
- if (info & MT_TX_FREE_PAIR) {
-- struct mt7915_sta *msta;
- struct mt76_wcid *wcid;
- u16 idx;
-
-@@ -995,6 +1006,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- txwi = mt76_token_release(mdev, msdu, &wake);
- if (!txwi)
- continue;
-+ spin_lock(&mdev->token_lock);
-+ if (msta)
-+ msta->token_count--;
-+ spin_unlock(&mdev->token_lock);
-
- mt7915_txwi_free(dev, txwi, sta, &free_list);
- }
-diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 7c7d6bd3..5f11b3fb 100644
---- a/mt7915/mt7915.h
-+++ b/mt7915/mt7915.h
-@@ -136,6 +136,8 @@ struct mt7915_sta {
- u8 flowid_mask;
- struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
- } twt;
-+
-+ int token_count;
- };
-
- struct mt7915_vif_cap {
---
-2.25.1
-
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch
new file mode 100644
index 0000000..4d28ad7
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch
@@ -0,0 +1,28 @@
+From af6a70a816d5a98d22b5bb1012e21cc2ecb4d5db Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Thu, 4 Aug 2022 14:08:11 +0800
+Subject: [PATCH] mt76: mt7915: reduce TWT SP sent to FW for cert
+
+Set TWT SP duration to 88 percent to prevent HW sends PPDU over TWT SP.
+
+Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
+---
+ mt7915/mcu.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index d7e717f4..2bd67f7c 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -3538,7 +3538,7 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
+ .own_mac_idx = mvif->mt76.omac_idx,
+ .flowid = flow->id,
+ .peer_id = cpu_to_le16(flow->wcid),
+- .duration = flow->duration,
++ .duration = (flow->duration * 7) >> 3,
+ .bss_idx = mvif->mt76.idx,
+ .start_tsf = cpu_to_le64(flow->tsf),
+ .mantissa = flow->mantissa,
+--
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1119-mt76-mt7915-initialize-wcid.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1119-mt76-mt7915-initialize-wcid.patch
index ed572cc..d26e59c 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1119-mt76-mt7915-initialize-wcid.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1119-mt76-mt7915-initialize-wcid.patch
@@ -1,26 +1,26 @@
-From ce1b7634efbf75007f431dd770ebd70e47771029 Mon Sep 17 00:00:00 2001
+From 1c4ec7f43f20ebbbe0c30100e6798ace079c3714 Mon Sep 17 00:00:00 2001
From: Sujuan Chen <sujuan.chen@mediatek.com>
Date: Tue, 12 Jul 2022 13:56:07 +0800
-Subject: [PATCH 1119/1119] mt76 mt7915 initialize wcid
+Subject: [PATCH] mt76 mt7915 initialize wcid
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +-
+ mt7915/mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 55b38d16..0310ca74 100644
+index 5e5df23d..9674015d 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
-@@ -974,7 +974,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- * 1'b0: msdu_id with the same 'wcid pair' as above.
+@@ -963,7 +963,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
*/
if (info & MT_TX_FREE_PAIR) {
+ struct mt7915_sta *msta;
- struct mt76_wcid *wcid;
+ struct mt76_wcid *wcid = NULL;
u16 idx;
idx = FIELD_GET(MT_TX_FREE_WLAN_ID, info);
--
-2.25.1
+2.18.0