blob: 3798866cf5955a445484722726e3a0a458351d76 [file] [log] [blame]
developerf6ebf632023-01-06 19:15:00 +08001From 4a7d3194f24e390b37bd9b1349ee25a4ca5e17aa 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
developerf6ebf632023-01-06 19:15:00 +08004Subject: [PATCH 3006/3014] mt76: mt7915: wed: enable red per-band token drop
developerd75d3632023-01-05 14:31:01 +08005 for HW Path
developera833e5a2022-09-07 18:00:50 +08006
7Limit the number of token used by each band. If a band uses too many token,
8it may hurt the throughput of the other band. The SW path can solve this
9problem by AQL.
10
11Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
12---
developer0ed66722022-12-29 15:09:39 +080013 mt76_connac_mcu.h | 2 +-
14 mt7915/mcu.c | 45 ++++++++++++++++++++++++++++++++++++++-------
15 mt7915/mcu.h | 1 +
16 mt7915/mmio.c | 2 +-
17 mt7915/mt7915.h | 4 +++-
18 5 files changed, 44 insertions(+), 10 deletions(-)
developera833e5a2022-09-07 18:00:50 +080019
developer0ed66722022-12-29 15:09:39 +080020diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerf6ebf632023-01-06 19:15:00 +080021index 98b00747..21ea55d1 100644
developer0ed66722022-12-29 15:09:39 +080022--- a/mt76_connac_mcu.h
23+++ b/mt76_connac_mcu.h
24@@ -1174,13 +1174,13 @@ enum {
25 MCU_EXT_CMD_RXDCOC_CAL = 0x59,
26 MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
27 #ifdef MTK_DEBUG
28- MCU_EXT_CMD_RED_ENABLE = 0x68,
29 MCU_EXT_CMD_RED_SHOW_STA = 0x69,
30 MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A,
31 MCU_EXT_CMD_RED_TX_RPT = 0x6B,
32 #endif
33 MCU_EXT_CMD_TXDPD_CAL = 0x60,
34 MCU_EXT_CMD_CAL_CACHE = 0x67,
35+ MCU_EXT_CMD_RED_ENABLE = 0x68,
36 MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
37 MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
38 MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
developera833e5a2022-09-07 18:00:50 +080039diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerf6ebf632023-01-06 19:15:00 +080040index f494d9f6..116a5cc9 100644
developera833e5a2022-09-07 18:00:50 +080041--- a/mt7915/mcu.c
42+++ b/mt7915/mcu.c
developer28d04742023-01-18 14:02:40 +080043@@ -2377,6 +2377,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developerafd75872022-12-14 21:15:46 +080044 return ret;
developera833e5a2022-09-07 18:00:50 +080045 }
46
47+
48 ret = mt7915_mcu_set_mwds(dev, 1);
49 if (ret)
50 return ret;
developer28d04742023-01-18 14:02:40 +080051@@ -2390,8 +2391,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +080052 if (ret)
53 return ret;
54
developera833e5a2022-09-07 18:00:50 +080055- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
56- MCU_WA_PARAM_RED, 0, 0);
developer0ed66722022-12-29 15:09:39 +080057+ return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed));
developera833e5a2022-09-07 18:00:50 +080058 }
59
60 int mt7915_mcu_init(struct mt7915_dev *dev)
developer28d04742023-01-18 14:02:40 +080061@@ -4534,27 +4534,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 +080062
63 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
64 }
65+#endif
66+
67+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
68+{
69+#define RED_GLOBAL_TOKEN_WATERMARK 2
developera833e5a2022-09-07 18:00:50 +080070+ struct {
71+ __le32 args[3];
72+
73+ u8 cmd;
74+ u8 version;
75+ u8 __rsv1[4];
76+ u16 len;
77+
78+ __le16 high_mark;
79+ __le16 low_mark;
80+ u8 __rsv2[12];
developer0ed66722022-12-29 15:09:39 +080081+ } __packed req = {
developera833e5a2022-09-07 18:00:50 +080082+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
83+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
84+ .len = cpu_to_le16(sizeof(req) - 12),
85+
developer30d39c22022-12-16 10:29:49 +080086+ .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256),
87+ .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536),
developera833e5a2022-09-07 18:00:50 +080088+ };
89+
90+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
91+ sizeof(req), false);
92+}
93
94 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
95 {
developer0ed66722022-12-29 15:09:39 +080096 #define RED_DISABLE 0
97-#define RED_BY_HOST_ENABLE 1
98 #define RED_BY_WA_ENABLE 2
99 int ret;
developera833e5a2022-09-07 18:00:50 +0800100 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
101 __le32 req = cpu_to_le32(red_type);
102
103+ if (enabled) {
104+ ret = mt7915_red_set_watermark(dev);
105+ if (ret < 0)
106+ return ret;
107+ }
108+
109 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
110 sizeof(req), false);
111 if (ret < 0)
112 return ret;
113
114- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
115- MCU_WA_PARAM_RED, enabled, 0, true);
116+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
117+ MCU_WA_PARAM_RED, enabled, 0);
118
119- return 0;
120 }
121-#endif
122
123 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
124 {
125diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developerf6ebf632023-01-06 19:15:00 +0800126index f2f88cc4..572cc16a 100644
developera833e5a2022-09-07 18:00:50 +0800127--- a/mt7915/mcu.h
128+++ b/mt7915/mcu.h
developerafd75872022-12-14 21:15:46 +0800129@@ -285,6 +285,7 @@ enum {
130 MCU_WA_PARAM_CPU_UTIL = 0x0b,
131 MCU_WA_PARAM_RED = 0x0e,
developera833e5a2022-09-07 18:00:50 +0800132 MCU_WA_PARAM_WED_VERSION = 0x32,
133+ MCU_WA_PARAM_RED_SETTING = 0x40,
developerafd75872022-12-14 21:15:46 +0800134 #ifdef MTK_DEBUG
135 MCU_WA_PARAM_RED_SHOW_STA = 0xf,
136 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
developer30d39c22022-12-16 10:29:49 +0800137diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developerf6ebf632023-01-06 19:15:00 +0800138index e0761e89..b29fe7a4 100644
developer30d39c22022-12-16 10:29:49 +0800139--- a/mt7915/mmio.c
140+++ b/mt7915/mmio.c
141@@ -759,7 +759,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
142 wed->wlan.wpdma_rx_glo = res->start + MT_WPDMA_GLO_CFG;
143 wed->wlan.wpdma_rx = res->start + MT_RXQ_WED_DATA_RING_BASE;
144 }
145- wed->wlan.nbuf = 4096;
146+ wed->wlan.nbuf = MT7915_HW_TOKEN_SIZE;
147 wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
148 wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
149 wed->wlan.txfree_tbit = is_mt7986(&dev->mt76) ? 2 : 1;
developera833e5a2022-09-07 18:00:50 +0800150diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerf6ebf632023-01-06 19:15:00 +0800151index 89c13dbe..2335f78f 100644
developera833e5a2022-09-07 18:00:50 +0800152--- a/mt7915/mt7915.h
153+++ b/mt7915/mt7915.h
developer30d39c22022-12-16 10:29:49 +0800154@@ -56,6 +56,7 @@
155
156 #define MT7915_EEPROM_BLOCK_SIZE 16
157 #define MT7915_TOKEN_SIZE 8192
developer49a5cc72022-12-20 13:57:30 +0800158+#define MT7915_HW_TOKEN_SIZE 7168
developer30d39c22022-12-16 10:29:49 +0800159
160 #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
161 #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
162@@ -771,13 +772,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800163 #endif
developer335cbee2022-11-17 14:55:34 +0800164 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
165 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
developera833e5a2022-09-07 18:00:50 +0800166+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer335cbee2022-11-17 14:55:34 +0800167+
developer887da632022-10-28 09:35:38 +0800168 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
169 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
developer335cbee2022-11-17 14:55:34 +0800170
developera833e5a2022-09-07 18:00:50 +0800171 #ifdef MTK_DEBUG
172 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
173 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
174-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
175 void mt7915_dump_tmac_info(u8 *tmac_info);
176 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
177 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
178--
developer0ed66722022-12-29 15:09:39 +08001792.18.0
developera833e5a2022-09-07 18:00:50 +0800180