[][MAC80211][wed][change wed token to 7K for mt7915]
[Description]
Change wed token to 7K for mt7915 because fw limit token size to 8K
[Release-log]
N/A
Change-Id: I629589cf96e4fd41d61da8c2a459d6c25c3fdb8a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8170786
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/2011-mt76-wifi-mt7915-wed-setting-wed-hw-tx-token-to-8192.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/2011-mt76-wifi-mt7915-wed-setting-wed-hw-tx-token-to-8192.patch
deleted file mode 100644
index 13d1f48..0000000
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/2011-mt76-wifi-mt7915-wed-setting-wed-hw-tx-token-to-8192.patch
+++ /dev/null
@@ -1,122 +0,0 @@
-From 467bdd35a3ec4603761f1a7e2281a78a3776a0bb Mon Sep 17 00:00:00 2001
-From: "sujuan.chen" <sujuan.chen@mediatek.com>
-Date: Mon, 11 Sep 2023 17:57:32 +0800
-Subject: [PATCH 2011/2011] mt76: wifi: mt7915: wed: setting wed hw tx token to
- 8192
-
-Signed-off-by: sujuan.chen <sujuan.chen@mediatek.com>
----
- mt7915/mmio.c | 8 ++++----
- mt7915/mt7915.h | 4 ++--
- tx.c | 26 ++++++++------------------
- 3 files changed, 14 insertions(+), 24 deletions(-)
-
-diff --git a/mt7915/mmio.c b/mt7915/mmio.c
-index aa5c5dd..b677947 100644
---- a/mt7915/mmio.c
-+++ b/mt7915/mmio.c
-@@ -593,7 +593,7 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
- dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
-
- spin_lock_bh(&dev->mt76.token_lock);
-- dev->mt76.token_size = wed->wlan.token_start;
-+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
- spin_unlock_bh(&dev->mt76.token_lock);
-
- return !wait_event_timeout(dev->mt76.tx_wait,
-@@ -607,7 +607,7 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
- dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
-
- spin_lock_bh(&dev->mt76.token_lock);
-- dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
-+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
- spin_unlock_bh(&dev->mt76.token_lock);
- }
-
-@@ -841,7 +841,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
- wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
- wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
- wed->wlan.txfree_tbit = is_mt798x(&dev->mt76) ? 2 : 1;
-- wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf;
-+ wed->wlan.token_start = 0;
- wed->wlan.wcid_512 = !is_mt7915(&dev->mt76);
-
- wed->wlan.rx_nbuf = 65536;
-@@ -874,7 +874,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
-
- *irq = wed->irq;
- dev->mt76.dma_dev = wed->dev;
-- dev->mt76.token_size = wed->wlan.token_start;
-+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
-
- ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
- if (ret)
-diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index d47abcf..5f3b84e 100644
---- a/mt7915/mt7915.h
-+++ b/mt7915/mt7915.h
-@@ -62,8 +62,8 @@
- #define MT7916_EEPROM_SIZE 4096
-
- #define MT7915_EEPROM_BLOCK_SIZE 16
--#define MT7915_HW_TOKEN_SIZE 7168
--#define MT7915_TOKEN_SIZE 8192
-+#define MT7915_HW_TOKEN_SIZE 8192
-+#define MT7915_TOKEN_SIZE 9216
- #define MT7915_RX_TOKEN_SIZE 4096
-
- #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
-diff --git a/tx.c b/tx.c
-index e290aef..96f9009 100644
---- a/tx.c
-+++ b/tx.c
-@@ -818,20 +818,18 @@ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);
-
- int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
- {
-- int token;
-+ int token, start = 0;
-+
-+ if (mtk_wed_device_active(&dev->mmio.wed))
-+ start = dev->mmio.wed.wlan.nbuf;
-
- spin_lock_bh(&dev->token_lock);
-
-- token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
-- if (token >= 0)
-+ token = idr_alloc(&dev->token, *ptxwi, start, start + dev->token_size,
-+ GFP_ATOMIC);
-+ if (token >= start)
- dev->token_count++;
-
--#ifdef CONFIG_NET_MEDIATEK_SOC_WED
-- if (mtk_wed_device_active(&dev->mmio.wed) &&
-- token >= dev->mmio.wed.wlan.token_start)
-- dev->wed_token_count++;
--#endif
--
- if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
- __mt76_set_tx_blocked(dev, true);
-
-@@ -867,17 +865,9 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
- spin_lock_bh(&dev->token_lock);
-
- txwi = idr_remove(&dev->token, token);
-- if (txwi) {
-+ if (txwi)
- dev->token_count--;
-
--#ifdef CONFIG_NET_MEDIATEK_SOC_WED
-- if (mtk_wed_device_active(&dev->mmio.wed) &&
-- token >= dev->mmio.wed.wlan.token_start &&
-- --dev->wed_token_count == 0)
-- wake_up(&dev->tx_wait);
--#endif
-- }
--
- if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR &&
- dev->phy.q_tx[0]->blocked)
- *wake = true;
---
-2.18.0
-
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/2011-wifi-mt76-mt7915-wed-change-wed-token-init-size-to-a.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/2011-wifi-mt76-mt7915-wed-change-wed-token-init-size-to-a.patch
new file mode 100644
index 0000000..49870b2
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/2011-wifi-mt76-mt7915-wed-change-wed-token-init-size-to-a.patch
@@ -0,0 +1,192 @@
+From 98e230f53b3e81ec9fc216054ebcf567c5e73406 Mon Sep 17 00:00:00 2001
+From: "sujuan.chen" <sujuan.chen@mediatek.com>
+Date: Mon, 11 Sep 2023 17:57:32 +0800
+Subject: [PATCH 20/25] wifi: mt76: mt7915: wed: change wed token init size to
+ adapt wed version
+
+Signed-off-by: sujuan.chen <sujuan.chen@mediatek.com>
+---
+ mt7915/mac.c | 10 ++++++++--
+ mt7915/mcu.c | 7 +++++--
+ mt7915/mmio.c | 13 ++++++++-----
+ mt7915/mt7915.h | 4 +++-
+ tx.c | 26 ++++++++------------------
+ 5 files changed, 32 insertions(+), 28 deletions(-)
+
+diff --git a/mt7915/mac.c b/mt7915/mac.c
+index 59cc1fd7..a473fc61 100644
+--- a/mt7915/mac.c
++++ b/mt7915/mac.c
+@@ -932,7 +932,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
+ v3 = (FIELD_GET(MT_TX_FREE_VER, txd) == 0x4);
+
+ for (cur_info = tx_info; count < total; cur_info++) {
+- u32 msdu, info;
++ u32 msdu, info, max_token_size = MT7915_TOKEN_SIZE;
+ u8 i;
+
+ if (WARN_ON_ONCE((void *)cur_info >= end))
+@@ -988,6 +988,12 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
+ wcid->stats.tx_failed += tx_failed;
+ }
+
++ if (mtk_wed_device_active(&mdev->mmio.wed))
++ max_token_size = (is_mt7915(&dev->mt76) ?
++ MT7915_WED_TOKEN_SIZE_V0 :
++ MT7915_WED_TOKEN_SIZE) +
++ MT7915_WED_SW_TOKEN_SIZE;
++
+ if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3))
+ continue;
+
+@@ -1001,7 +1007,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
+ }
+
+ /* Todo: check if msdu is sw token */
+- if (msdu > MT7915_TOKEN_SIZE)
++ if (msdu > max_token_size)
+ dev_err(mdev->dev, "Receive invalid token id(%d)\n",
+ msdu);
+
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index ebacfd27..b42f7be9 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -2318,6 +2318,9 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
+ static int mt7915_red_set_watermark(struct mt7915_dev *dev)
+ {
+ #define RED_GLOBAL_TOKEN_WATERMARK 2
++ u16 token_size = is_mt7915(&dev->mt76) ?
++ MT7915_WED_TOKEN_SIZE_V0 :
++ MT7915_WED_TOKEN_SIZE;
+ struct {
+ __le32 args[3];
+ u8 cmd;
+@@ -2331,8 +2334,8 @@ static int mt7915_red_set_watermark(struct mt7915_dev *dev)
+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
+ .len = cpu_to_le16(sizeof(req) - sizeof(req.args)),
+- .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256),
+- .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536),
++ .high_mark = cpu_to_le16(token_size - 256),
++ .low_mark = cpu_to_le16(token_size - 256 - 1536),
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
+diff --git a/mt7915/mmio.c b/mt7915/mmio.c
+index aa5c5dd6..2ad7ba4a 100644
+--- a/mt7915/mmio.c
++++ b/mt7915/mmio.c
+@@ -593,7 +593,7 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
+ dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
+
+ spin_lock_bh(&dev->mt76.token_lock);
+- dev->mt76.token_size = wed->wlan.token_start;
++ dev->mt76.token_size = MT7915_WED_SW_TOKEN_SIZE;
+ spin_unlock_bh(&dev->mt76.token_lock);
+
+ return !wait_event_timeout(dev->mt76.tx_wait,
+@@ -607,7 +607,7 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
+ dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
+
+ spin_lock_bh(&dev->mt76.token_lock);
+- dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
++ dev->mt76.token_size = MT7915_WED_SW_TOKEN_SIZE;
+ spin_unlock_bh(&dev->mt76.token_lock);
+ }
+
+@@ -837,11 +837,14 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
+ wed->wlan.wpdma_rx_glo = res->start + MT_WPDMA_GLO_CFG;
+ wed->wlan.wpdma_rx = res->start + MT_RXQ_WED_DATA_RING_BASE;
+ }
+- wed->wlan.nbuf = MT7915_HW_TOKEN_SIZE;
++
++ wed->wlan.nbuf = is_mt7915(&dev->mt76) ?
++ MT7915_WED_TOKEN_SIZE_V0 :
++ MT7915_WED_TOKEN_SIZE;
+ wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
+ wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
+ wed->wlan.txfree_tbit = is_mt798x(&dev->mt76) ? 2 : 1;
+- wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf;
++ wed->wlan.token_start = 0;
+ wed->wlan.wcid_512 = !is_mt7915(&dev->mt76);
+
+ wed->wlan.rx_nbuf = 65536;
+@@ -874,7 +877,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
+
+ *irq = wed->irq;
+ dev->mt76.dma_dev = wed->dev;
+- dev->mt76.token_size = wed->wlan.token_start;
++ dev->mt76.token_size = MT7915_WED_SW_TOKEN_SIZE;
+
+ ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
+ if (ret)
+diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
+index 6156850b..6a175374 100644
+--- a/mt7915/mt7915.h
++++ b/mt7915/mt7915.h
+@@ -62,7 +62,9 @@
+ #define MT7916_EEPROM_SIZE 4096
+
+ #define MT7915_EEPROM_BLOCK_SIZE 16
+-#define MT7915_HW_TOKEN_SIZE 7168
++#define MT7915_WED_TOKEN_SIZE 8192
++#define MT7915_WED_TOKEN_SIZE_V0 7168
++#define MT7915_WED_SW_TOKEN_SIZE 1024
+ #define MT7915_TOKEN_SIZE 8192
+ #define MT7915_RX_TOKEN_SIZE 4096
+
+diff --git a/tx.c b/tx.c
+index e290aef3..96f9009b 100644
+--- a/tx.c
++++ b/tx.c
+@@ -818,20 +818,18 @@ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);
+
+ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
+ {
+- int token;
++ int token, start = 0;
++
++ if (mtk_wed_device_active(&dev->mmio.wed))
++ start = dev->mmio.wed.wlan.nbuf;
+
+ spin_lock_bh(&dev->token_lock);
+
+- token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
+- if (token >= 0)
++ token = idr_alloc(&dev->token, *ptxwi, start, start + dev->token_size,
++ GFP_ATOMIC);
++ if (token >= start)
+ dev->token_count++;
+
+-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
+- if (mtk_wed_device_active(&dev->mmio.wed) &&
+- token >= dev->mmio.wed.wlan.token_start)
+- dev->wed_token_count++;
+-#endif
+-
+ if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
+ __mt76_set_tx_blocked(dev, true);
+
+@@ -867,17 +865,9 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
+ spin_lock_bh(&dev->token_lock);
+
+ txwi = idr_remove(&dev->token, token);
+- if (txwi) {
++ if (txwi)
+ dev->token_count--;
+
+-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
+- if (mtk_wed_device_active(&dev->mmio.wed) &&
+- token >= dev->mmio.wed.wlan.token_start &&
+- --dev->wed_token_count == 0)
+- wake_up(&dev->tx_wait);
+-#endif
+- }
+-
+ if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR &&
+ dev->phy.q_tx[0]->blocked)
+ *wake = true;
+--
+2.18.0
+