blob: 13d1f489c6cc3287cc164ff06ff0fe6a11207713 [file] [log] [blame]
developere35b8e42023-10-16 11:04:00 +08001From 467bdd35a3ec4603761f1a7e2281a78a3776a0bb Mon Sep 17 00:00:00 2001
2From: "sujuan.chen" <sujuan.chen@mediatek.com>
3Date: Mon, 11 Sep 2023 17:57:32 +0800
4Subject: [PATCH 2011/2011] mt76: wifi: mt7915: wed: setting wed hw tx token to
5 8192
6
7Signed-off-by: sujuan.chen <sujuan.chen@mediatek.com>
8---
9 mt7915/mmio.c | 8 ++++----
10 mt7915/mt7915.h | 4 ++--
11 tx.c | 26 ++++++++------------------
12 3 files changed, 14 insertions(+), 24 deletions(-)
13
14diff --git a/mt7915/mmio.c b/mt7915/mmio.c
15index aa5c5dd..b677947 100644
16--- a/mt7915/mmio.c
17+++ b/mt7915/mmio.c
18@@ -593,7 +593,7 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
19 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
20
21 spin_lock_bh(&dev->mt76.token_lock);
22- dev->mt76.token_size = wed->wlan.token_start;
23+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
24 spin_unlock_bh(&dev->mt76.token_lock);
25
26 return !wait_event_timeout(dev->mt76.tx_wait,
27@@ -607,7 +607,7 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
28 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
29
30 spin_lock_bh(&dev->mt76.token_lock);
31- dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
32+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
33 spin_unlock_bh(&dev->mt76.token_lock);
34 }
35
36@@ -841,7 +841,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
37 wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
38 wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
39 wed->wlan.txfree_tbit = is_mt798x(&dev->mt76) ? 2 : 1;
40- wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf;
41+ wed->wlan.token_start = 0;
42 wed->wlan.wcid_512 = !is_mt7915(&dev->mt76);
43
44 wed->wlan.rx_nbuf = 65536;
45@@ -874,7 +874,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
46
47 *irq = wed->irq;
48 dev->mt76.dma_dev = wed->dev;
49- dev->mt76.token_size = wed->wlan.token_start;
50+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
51
52 ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
53 if (ret)
54diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
55index d47abcf..5f3b84e 100644
56--- a/mt7915/mt7915.h
57+++ b/mt7915/mt7915.h
58@@ -62,8 +62,8 @@
59 #define MT7916_EEPROM_SIZE 4096
60
61 #define MT7915_EEPROM_BLOCK_SIZE 16
62-#define MT7915_HW_TOKEN_SIZE 7168
63-#define MT7915_TOKEN_SIZE 8192
64+#define MT7915_HW_TOKEN_SIZE 8192
65+#define MT7915_TOKEN_SIZE 9216
66 #define MT7915_RX_TOKEN_SIZE 4096
67
68 #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
69diff --git a/tx.c b/tx.c
70index e290aef..96f9009 100644
71--- a/tx.c
72+++ b/tx.c
73@@ -818,20 +818,18 @@ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);
74
75 int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
76 {
77- int token;
78+ int token, start = 0;
79+
80+ if (mtk_wed_device_active(&dev->mmio.wed))
81+ start = dev->mmio.wed.wlan.nbuf;
82
83 spin_lock_bh(&dev->token_lock);
84
85- token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
86- if (token >= 0)
87+ token = idr_alloc(&dev->token, *ptxwi, start, start + dev->token_size,
88+ GFP_ATOMIC);
89+ if (token >= start)
90 dev->token_count++;
91
92-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
93- if (mtk_wed_device_active(&dev->mmio.wed) &&
94- token >= dev->mmio.wed.wlan.token_start)
95- dev->wed_token_count++;
96-#endif
97-
98 if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
99 __mt76_set_tx_blocked(dev, true);
100
101@@ -867,17 +865,9 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
102 spin_lock_bh(&dev->token_lock);
103
104 txwi = idr_remove(&dev->token, token);
105- if (txwi) {
106+ if (txwi)
107 dev->token_count--;
108
109-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
110- if (mtk_wed_device_active(&dev->mmio.wed) &&
111- token >= dev->mmio.wed.wlan.token_start &&
112- --dev->wed_token_count == 0)
113- wake_up(&dev->tx_wait);
114-#endif
115- }
116-
117 if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR &&
118 dev->phy.q_tx[0]->blocked)
119 *wake = true;
120--
1212.18.0
122