blob: 254e6f03529fba13cc00dfa7968520acf45ef218 [file] [log] [blame]
developer2458e702022-12-13 15:52:04 +08001From 10e8cbecc7872f0ad0d18ef37713362da3f9600d Mon Sep 17 00:00:00 2001
developer20126ad2022-09-12 14:42:56 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 2 Sep 2022 14:40:40 +0800
developer2458e702022-12-13 15:52:04 +08004Subject: [PATCH 3006/3011] mt76: mt7915: wed: enable red per-band token drop
developerbcc85ca2022-12-05 11:29:56 +08005 for HW Path
developer20126ad2022-09-12 14:42:56 +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---
13 mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++----------
14 mt7915/mcu.h | 1 +
developer9bc8ec12022-11-18 16:01:14 +080015 mt7915/mt7915.h | 3 ++-
16 3 files changed, 46 insertions(+), 11 deletions(-)
developer20126ad2022-09-12 14:42:56 +080017
18diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer2458e702022-12-13 15:52:04 +080019index 0ad110ff..fcb15fb5 100644
developer20126ad2022-09-12 14:42:56 +080020--- a/mt7915/mcu.c
21+++ b/mt7915/mcu.c
developer2458e702022-12-13 15:52:04 +080022@@ -2359,8 +2359,13 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developer20126ad2022-09-12 14:42:56 +080023 mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
24 MCU_WA_PARAM_WED_VERSION,
25 wed->rev_id, 0);
26+
27+ mt7915_mcu_set_red(dev, true);
28+ } else {
29+ mt7915_mcu_set_red(dev, false);
30 }
31
32+
33 ret = mt7915_mcu_set_mwds(dev, 1);
34 if (ret)
35 return ret;
developer2458e702022-12-13 15:52:04 +080036@@ -2370,12 +2375,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developer20126ad2022-09-12 14:42:56 +080037 if (ret)
38 return ret;
39
40- ret = mt7915_mcu_init_rx_airtime(dev);
41- if (ret)
42- return ret;
43-
44- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
45- MCU_WA_PARAM_RED, 0, 0);
46+ return mt7915_mcu_init_rx_airtime(dev);
47 }
48
49 int mt7915_mcu_init(struct mt7915_dev *dev)
developer2458e702022-12-13 15:52:04 +080050@@ -4445,6 +4445,35 @@ int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a
developer20126ad2022-09-12 14:42:56 +080051
52 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
53 }
54+#endif
55+
56+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
57+{
58+#define RED_GLOBAL_TOKEN_WATERMARK 2
59+#define TOTAL_HW_TOKEN_SIZE 8192
60+ struct {
61+ __le32 args[3];
62+
63+ u8 cmd;
64+ u8 version;
65+ u8 __rsv1[4];
66+ u16 len;
67+
68+ __le16 high_mark;
69+ __le16 low_mark;
70+ u8 __rsv2[12];
71+ } req = {
72+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
73+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
74+ .len = cpu_to_le16(sizeof(req) - 12),
75+
76+ .high_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256),
77+ .low_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256 - 1536),
78+ };
79+
80+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
81+ sizeof(req), false);
82+}
83
84 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
85 {
developer2458e702022-12-13 15:52:04 +080086@@ -4455,17 +4484,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developer20126ad2022-09-12 14:42:56 +080087 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
88 __le32 req = cpu_to_le32(red_type);
89
90+ if (enabled) {
91+ ret = mt7915_red_set_watermark(dev);
92+ if (ret < 0)
93+ return ret;
94+ }
95+
96 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
97 sizeof(req), false);
98 if (ret < 0)
99 return ret;
100
101- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
102- MCU_WA_PARAM_RED, enabled, 0, true);
103+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
104+ MCU_WA_PARAM_RED, enabled, 0);
105
106- return 0;
107 }
108-#endif
109
110 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
111 {
112diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer2458e702022-12-13 15:52:04 +0800113index cf1d7d7a..49728514 100644
developer20126ad2022-09-12 14:42:56 +0800114--- a/mt7915/mcu.h
115+++ b/mt7915/mcu.h
developer2458e702022-12-13 15:52:04 +0800116@@ -289,6 +289,7 @@ enum {
developer20126ad2022-09-12 14:42:56 +0800117 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
118 #endif
119 MCU_WA_PARAM_WED_VERSION = 0x32,
120+ MCU_WA_PARAM_RED_SETTING = 0x40,
121 };
122
123 enum mcu_mmps_mode {
124diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer2458e702022-12-13 15:52:04 +0800125index c39be358..2c0aee1e 100644
developer20126ad2022-09-12 14:42:56 +0800126--- a/mt7915/mt7915.h
127+++ b/mt7915/mt7915.h
developer2458e702022-12-13 15:52:04 +0800128@@ -773,13 +773,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developer20126ad2022-09-12 14:42:56 +0800129 #endif
developer9bc8ec12022-11-18 16:01:14 +0800130 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
131 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
developer20126ad2022-09-12 14:42:56 +0800132+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer9bc8ec12022-11-18 16:01:14 +0800133+
developerb81e95d2022-11-08 10:16:29 +0800134 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
135 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
developer9bc8ec12022-11-18 16:01:14 +0800136
developer20126ad2022-09-12 14:42:56 +0800137 #ifdef MTK_DEBUG
138 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
139 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
140-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
141 void mt7915_dump_tmac_info(u8 *tmac_info);
142 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
143 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
144--
developer2458e702022-12-13 15:52:04 +08001452.25.1
developer20126ad2022-09-12 14:42:56 +0800146