blob: de7a3a177bbac3bf0c3cc6334fdc00740a637cd4 [file] [log] [blame]
developer0ed66722022-12-29 15:09:39 +08001From 2f0b6e966f10cfcdb3a325238e10966c25c1ea3b Mon Sep 17 00:00:00 2001
developera833e5a2022-09-07 18:00:50 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 2 Sep 2022 14:40:40 +0800
developer0ed66722022-12-29 15:09:39 +08004Subject: [PATCH] mt76: mt7915: wed: enable red per-band token drop for HW Path
developera833e5a2022-09-07 18:00:50 +08005
6Limit the number of token used by each band. If a band uses too many token,
7it may hurt the throughput of the other band. The SW path can solve this
8problem by AQL.
9
10Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
11---
developer0ed66722022-12-29 15:09:39 +080012 mt76_connac_mcu.h | 2 +-
13 mt7915/mcu.c | 45 ++++++++++++++++++++++++++++++++++++++-------
14 mt7915/mcu.h | 1 +
15 mt7915/mmio.c | 2 +-
16 mt7915/mt7915.h | 4 +++-
17 5 files changed, 44 insertions(+), 10 deletions(-)
developera833e5a2022-09-07 18:00:50 +080018
developer0ed66722022-12-29 15:09:39 +080019diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
20index 98b00747..21ea55d1 100644
21--- a/mt76_connac_mcu.h
22+++ b/mt76_connac_mcu.h
23@@ -1174,13 +1174,13 @@ enum {
24 MCU_EXT_CMD_RXDCOC_CAL = 0x59,
25 MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
26 #ifdef MTK_DEBUG
27- MCU_EXT_CMD_RED_ENABLE = 0x68,
28 MCU_EXT_CMD_RED_SHOW_STA = 0x69,
29 MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A,
30 MCU_EXT_CMD_RED_TX_RPT = 0x6B,
31 #endif
32 MCU_EXT_CMD_TXDPD_CAL = 0x60,
33 MCU_EXT_CMD_CAL_CACHE = 0x67,
34+ MCU_EXT_CMD_RED_ENABLE = 0x68,
35 MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
36 MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
37 MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
developera833e5a2022-09-07 18:00:50 +080038diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer0ed66722022-12-29 15:09:39 +080039index f494d9f6..116a5cc9 100644
developera833e5a2022-09-07 18:00:50 +080040--- a/mt7915/mcu.c
41+++ b/mt7915/mcu.c
developer0ed66722022-12-29 15:09:39 +080042@@ -2376,6 +2376,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developerafd75872022-12-14 21:15:46 +080043 return ret;
developera833e5a2022-09-07 18:00:50 +080044 }
45
46+
47 ret = mt7915_mcu_set_mwds(dev, 1);
48 if (ret)
49 return ret;
developer0ed66722022-12-29 15:09:39 +080050@@ -2389,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +080051 if (ret)
52 return ret;
53
developera833e5a2022-09-07 18:00:50 +080054- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
55- MCU_WA_PARAM_RED, 0, 0);
developer0ed66722022-12-29 15:09:39 +080056+ return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed));
developera833e5a2022-09-07 18:00:50 +080057 }
58
59 int mt7915_mcu_init(struct mt7915_dev *dev)
developer0ed66722022-12-29 15:09:39 +080060@@ -4533,27 +4533,58 @@ int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a
developera833e5a2022-09-07 18:00:50 +080061
62 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
63 }
64+#endif
65+
66+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
67+{
68+#define RED_GLOBAL_TOKEN_WATERMARK 2
developera833e5a2022-09-07 18:00:50 +080069+ struct {
70+ __le32 args[3];
71+
72+ u8 cmd;
73+ u8 version;
74+ u8 __rsv1[4];
75+ u16 len;
76+
77+ __le16 high_mark;
78+ __le16 low_mark;
79+ u8 __rsv2[12];
developer0ed66722022-12-29 15:09:39 +080080+ } __packed req = {
developera833e5a2022-09-07 18:00:50 +080081+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
82+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
83+ .len = cpu_to_le16(sizeof(req) - 12),
84+
developer30d39c22022-12-16 10:29:49 +080085+ .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256),
86+ .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536),
developera833e5a2022-09-07 18:00:50 +080087+ };
88+
89+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
90+ sizeof(req), false);
91+}
92
93 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
94 {
developer0ed66722022-12-29 15:09:39 +080095 #define RED_DISABLE 0
96-#define RED_BY_HOST_ENABLE 1
97 #define RED_BY_WA_ENABLE 2
98 int ret;
developera833e5a2022-09-07 18:00:50 +080099 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
100 __le32 req = cpu_to_le32(red_type);
101
102+ if (enabled) {
103+ ret = mt7915_red_set_watermark(dev);
104+ if (ret < 0)
105+ return ret;
106+ }
107+
108 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
109 sizeof(req), false);
110 if (ret < 0)
111 return ret;
112
113- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
114- MCU_WA_PARAM_RED, enabled, 0, true);
115+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
116+ MCU_WA_PARAM_RED, enabled, 0);
117
118- return 0;
119 }
120-#endif
121
122 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
123 {
124diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer0ed66722022-12-29 15:09:39 +0800125index f2f88cc4..572cc16a 100644
developera833e5a2022-09-07 18:00:50 +0800126--- a/mt7915/mcu.h
127+++ b/mt7915/mcu.h
developerafd75872022-12-14 21:15:46 +0800128@@ -285,6 +285,7 @@ enum {
129 MCU_WA_PARAM_CPU_UTIL = 0x0b,
130 MCU_WA_PARAM_RED = 0x0e,
developera833e5a2022-09-07 18:00:50 +0800131 MCU_WA_PARAM_WED_VERSION = 0x32,
132+ MCU_WA_PARAM_RED_SETTING = 0x40,
developerafd75872022-12-14 21:15:46 +0800133 #ifdef MTK_DEBUG
134 MCU_WA_PARAM_RED_SHOW_STA = 0xf,
135 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
developer30d39c22022-12-16 10:29:49 +0800136diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer0ed66722022-12-29 15:09:39 +0800137index e0761e89..b29fe7a4 100644
developer30d39c22022-12-16 10:29:49 +0800138--- a/mt7915/mmio.c
139+++ b/mt7915/mmio.c
140@@ -759,7 +759,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
141 wed->wlan.wpdma_rx_glo = res->start + MT_WPDMA_GLO_CFG;
142 wed->wlan.wpdma_rx = res->start + MT_RXQ_WED_DATA_RING_BASE;
143 }
144- wed->wlan.nbuf = 4096;
145+ wed->wlan.nbuf = MT7915_HW_TOKEN_SIZE;
146 wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
147 wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
148 wed->wlan.txfree_tbit = is_mt7986(&dev->mt76) ? 2 : 1;
developera833e5a2022-09-07 18:00:50 +0800149diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer0ed66722022-12-29 15:09:39 +0800150index 89c13dbe..2335f78f 100644
developera833e5a2022-09-07 18:00:50 +0800151--- a/mt7915/mt7915.h
152+++ b/mt7915/mt7915.h
developer30d39c22022-12-16 10:29:49 +0800153@@ -56,6 +56,7 @@
154
155 #define MT7915_EEPROM_BLOCK_SIZE 16
156 #define MT7915_TOKEN_SIZE 8192
developer49a5cc72022-12-20 13:57:30 +0800157+#define MT7915_HW_TOKEN_SIZE 7168
developer30d39c22022-12-16 10:29:49 +0800158
159 #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
160 #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
161@@ -771,13 +772,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800162 #endif
developer335cbee2022-11-17 14:55:34 +0800163 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
164 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
developera833e5a2022-09-07 18:00:50 +0800165+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer335cbee2022-11-17 14:55:34 +0800166+
developer887da632022-10-28 09:35:38 +0800167 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
168 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
developer335cbee2022-11-17 14:55:34 +0800169
developera833e5a2022-09-07 18:00:50 +0800170 #ifdef MTK_DEBUG
171 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
172 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
173-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
174 void mt7915_dump_tmac_info(u8 *tmac_info);
175 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
176 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
177--
developer0ed66722022-12-29 15:09:39 +08001782.18.0
developera833e5a2022-09-07 18:00:50 +0800179