[rdkb][common][bsp][Refactor and sync wifi from openwrt]
[Description]
3a2eef0b [MAC80211][Release][Update release note for Filogic 880/860 MLO Beta release]
cfbd2411 [MAC80211][Release][Filogic 880/860 MLO Beta release]
6c180e3f [MAC80211][WiFi7][misc][Add Eagle BE14000 efem default bin]
a55f34db [MAC80211][Release][Prepare for Filogic 880/860 release]
5b45ebca [MAC80211][WiFi7][hostapd][Add puncture bitmap to ucode]
95bbea73 [MAC80211][WiFi6][mt76][Add PID to only report data-frame TX rate]
b15ced26 [MAC80211][WiFi6][hostapd][Fix DFS channel selection issue]
d59133cb [MAC80211][WiFi6][mt76][Fix pse info not correct information]
3921b4b2 [MAC80211][WiFi6][mt76][Fix incomplete QoS-map setting to FW]
4e7690c7 [MAC80211][WiFi6/7][app][Change ATECHANNEL mapping cmd]
eb37af90 [MAC80211][WiFi7][app][Add support for per-packet bw & primary selection]
0ea82adf [MAC80211][WiFi6][core][Fix DFS CAC issue after CSA]
[Release-log]
Change-Id: I9bec97ec1b2e1c49ed43a812a07a5b21fcbb70a6
diff --git a/recipes-wifi/linux-mt76/files/patches-3.x/0190-mtk-mt76-mt7996-add-per-band-token-limit.patch b/recipes-wifi/linux-mt76/files/patches-3.x/0190-mtk-mt76-mt7996-add-per-band-token-limit.patch
new file mode 100644
index 0000000..78737b8
--- /dev/null
+++ b/recipes-wifi/linux-mt76/files/patches-3.x/0190-mtk-mt76-mt7996-add-per-band-token-limit.patch
@@ -0,0 +1,200 @@
+From 08bab29bc70a7b21150167f2ae502d8e5538c743 Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Tue, 30 Jul 2024 19:49:39 +0800
+Subject: [PATCH 190/199] mtk: mt76: mt7996: add per-band token limit
+
+Add a threshold for per-band token count.
+The bands use the same token pool so a band cannot transmit if
+the other band occupy too many tokens. With this patch, we can
+prevent a band from interfering with the other band.
+
+Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
+---
+ mt76.h | 6 +++++-
+ mt7996/init.c | 2 ++
+ mt7996/mac.c | 5 ++++-
+ mt7996/mt7996.h | 1 +
+ mt7996/mtk_debugfs.c | 14 ++++++++++++--
+ tx.c | 19 ++++++++++++++++---
+ 6 files changed, 40 insertions(+), 7 deletions(-)
+
+diff --git a/mt76.h b/mt76.h
+index 1858f542..e5e5529d 100644
+--- a/mt76.h
++++ b/mt76.h
+@@ -462,6 +462,7 @@ struct mt76_txwi_cache {
+ dma_addr_t dma_addr;
+
+ unsigned long jiffies;
++ u8 phy_idx;
+
+ struct sk_buff *skb;
+ };
+@@ -960,6 +961,7 @@ struct mt76_phy {
+ } leds;
+ struct mt76_tx_debug tx_dbg_stats;
+ struct mt76_rx_debug rx_dbg_stats;
++ int tokens;
+ };
+
+ struct mt76_dev {
+@@ -1009,6 +1011,7 @@ struct mt76_dev {
+ u16 wed_token_count;
+ u16 token_count;
+ u16 token_size;
++ u16 token_threshold;
+
+ spinlock_t rx_token_lock;
+ struct idr rx_token;
+@@ -1879,7 +1882,8 @@ static inline bool mt76_queue_is_wed_rx(struct mt76_queue *q)
+
+ struct mt76_txwi_cache *
+ mt76_token_release(struct mt76_dev *dev, int token, bool *wake);
+-int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi);
++int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi,
++ u8 phy_idx);
+ void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked);
+ struct mt76_rxwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token);
+ int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr,
+diff --git a/mt7996/init.c b/mt7996/init.c
+index 2f43c0ff..bad4b1b7 100644
+--- a/mt7996/init.c
++++ b/mt7996/init.c
+@@ -1770,6 +1770,8 @@ int mt7996_register_device(struct mt7996_dev *dev)
+ if (ret)
+ return ret;
+
++ dev->mt76.token_threshold = MT7996_PER_BAND_TOKEN_SIZE;
++
+ ret = mt7996_init_dev_debugfs(&dev->phy);
+ if (ret)
+ goto error;
+diff --git a/mt7996/mac.c b/mt7996/mac.c
+index 32f5b859..f9344f28 100644
+--- a/mt7996/mac.c
++++ b/mt7996/mac.c
+@@ -959,7 +959,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
+ t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size);
+ t->skb = tx_info->skb;
+
+- id = mt76_token_consume(mdev, &t);
++ id = mt76_token_consume(mdev, &t, mconf->mt76.band_idx);
+ if (id < 0) {
+ mdev->tx_dbg_stats.tx_drop[MT_TX_DROP_GET_TOKEN_FAIL]++;
+ return id;
+@@ -1683,8 +1683,11 @@ void mt7996_tx_token_put(struct mt7996_dev *dev)
+
+ spin_lock_bh(&dev->mt76.token_lock);
+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
++ struct mt76_phy *phy = mt76_dev_phy(&dev->mt76, txwi->phy_idx);
++
+ mt7996_txwi_free(dev, txwi, NULL, NULL, NULL);
+ dev->mt76.token_count--;
++ phy->tokens--;
+ }
+ spin_unlock_bh(&dev->mt76.token_lock);
+ idr_destroy(&dev->mt76.token);
+diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
+index fa884316..04832b0c 100644
+--- a/mt7996/mt7996.h
++++ b/mt7996/mt7996.h
+@@ -76,6 +76,7 @@
+ #define MT7996_TOKEN_SIZE 16384
+ #define MT7996_HW_TOKEN_SIZE 8192
+ #define MT7996_SW_TOKEN_SIZE 15360
++#define MT7996_PER_BAND_TOKEN_SIZE 5120
+
+ #define MT7996_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
+ #define MT7996_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
+diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
+index fa8de2db..a4703b07 100644
+--- a/mt7996/mtk_debugfs.c
++++ b/mt7996/mtk_debugfs.c
+@@ -2401,7 +2401,7 @@ static int mt7996_sta_info(struct seq_file *s, void *data)
+ static int mt7996_token_read(struct seq_file *s, void *data)
+ {
+ struct mt7996_dev *dev = dev_get_drvdata(s->private);
+- int msdu_id;
++ int msdu_id, i;
+ struct mt76_txwi_cache *txwi;
+
+ seq_printf(s, "Token from host:\n");
+@@ -2410,8 +2410,18 @@ static int mt7996_token_read(struct seq_file *s, void *data)
+ seq_printf(s, "%4d (pending time %u ms)\n", msdu_id,
+ jiffies_to_msecs(jiffies - txwi->jiffies));
+ }
+- spin_unlock_bh(&dev->mt76.token_lock);
+ seq_printf(s, "\n");
++ for (i = 0; i < __MT_MAX_BAND; i++) {
++ struct mt76_phy *phy = mt76_dev_phy(&dev->mt76, i);
++
++ if (!mt7996_band_valid(dev, i))
++ continue;
++
++ seq_printf(s, "Band%u consume: %d, free: %d total: %d\n",
++ i, phy->tokens, dev->mt76.token_threshold - phy->tokens,
++ dev->mt76.token_threshold);
++ }
++ spin_unlock_bh(&dev->mt76.token_lock);
+
+ return 0;
+ }
+diff --git a/tx.c b/tx.c
+index 5e6e433f..c965f0e3 100644
+--- a/tx.c
++++ b/tx.c
+@@ -837,20 +837,29 @@ void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked)
+ }
+ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);
+
+-int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
++int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi,
++ u8 phy_idx)
+ {
+- int token, start = 0;
++ int token = -EINVAL, start = 0;
++ struct mt76_phy *phy = mt76_dev_phy(dev, phy_idx);
+
+ if (mtk_wed_device_active(&dev->mmio.wed))
+ start = dev->mmio.wed.wlan.nbuf;
+
+ spin_lock_bh(&dev->token_lock);
+
++ if (phy->tokens > dev->token_threshold)
++ goto out;
++
+ token = idr_alloc(&dev->token, *ptxwi, start, start + dev->token_size,
+ GFP_ATOMIC);
+- if (token >= start)
++ if (token >= start) {
+ dev->token_count++;
+
++ (*ptxwi)->phy_idx = phy_idx;
++ phy->tokens++;
++ }
++
+ #ifdef CONFIG_NET_MEDIATEK_SOC_WED
+ if (mtk_wed_device_active(&dev->mmio.wed) &&
+ token >= dev->mmio.wed.wlan.token_start)
+@@ -860,6 +869,7 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
+ if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
+ __mt76_set_tx_blocked(dev, true);
+
++out:
+ spin_unlock_bh(&dev->token_lock);
+
+ return token;
+@@ -893,7 +903,10 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
+
+ txwi = idr_remove(&dev->token, token);
+ if (txwi) {
++ struct mt76_phy *phy = mt76_dev_phy(dev, txwi->phy_idx);
++
+ dev->token_count--;
++ phy->tokens--;
+
+ #ifdef CONFIG_NET_MEDIATEK_SOC_WED
+ if (mtk_wed_device_active(&dev->mmio.wed) &&
+--
+2.18.0
+