blob: ed5376ae45f7805c8e2e3b2c7f80670cf626d400 [file] [log] [blame]
developerfe7be7f2022-12-13 21:40:24 +08001From 07b444485d3b25b459d5e2a9a9b84ccb0613a1db 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
developereb6a0182022-12-12 18:53:32 +08004Subject: [PATCH 3006/3011] mt76: mt7915: wed: enable red per-band token drop
developerbf24a8a2022-11-30 14:52:20 +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---
13 mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++----------
14 mt7915/mcu.h | 1 +
developer335cbee2022-11-17 14:55:34 +080015 mt7915/mt7915.h | 3 ++-
16 3 files changed, 46 insertions(+), 11 deletions(-)
developera833e5a2022-09-07 18:00:50 +080017
18diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerfe7be7f2022-12-13 21:40:24 +080019index 3b16a7fb..2cfd5f4a 100644
developera833e5a2022-09-07 18:00:50 +080020--- a/mt7915/mcu.c
21+++ b/mt7915/mcu.c
developereb6a0182022-12-12 18:53:32 +080022@@ -2359,8 +2359,13 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +080023 mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
24 MCU_WA_PARAM_WED_VERSION,
25 wed->rev_id, 0);
developera833e5a2022-09-07 18:00:50 +080026+
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;
developereb6a0182022-12-12 18:53:32 +080036@@ -2370,12 +2375,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +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)
developerfe7be7f2022-12-13 21:40:24 +080050@@ -4507,6 +4507,35 @@ int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a
developera833e5a2022-09-07 18:00:50 +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 {
developerfe7be7f2022-12-13 21:40:24 +080086@@ -4517,17 +4546,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developera833e5a2022-09-07 18:00:50 +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
developerfe7be7f2022-12-13 21:40:24 +0800113index b30cc820..9f882042 100644
developera833e5a2022-09-07 18:00:50 +0800114--- a/mt7915/mcu.h
115+++ b/mt7915/mcu.h
developereb6a0182022-12-12 18:53:32 +0800116@@ -289,6 +289,7 @@ enum {
developera833e5a2022-09-07 18:00:50 +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
developerfe7be7f2022-12-13 21:40:24 +0800125index 8ea75fb9..def78c67 100644
developera833e5a2022-09-07 18:00:50 +0800126--- a/mt7915/mt7915.h
127+++ b/mt7915/mt7915.h
developerfe7be7f2022-12-13 21:40:24 +0800128@@ -775,13 +775,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800129 #endif
developer335cbee2022-11-17 14:55:34 +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);
developera833e5a2022-09-07 18:00:50 +0800132+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer335cbee2022-11-17 14:55:34 +0800133+
developer887da632022-10-28 09:35:38 +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);
developer335cbee2022-11-17 14:55:34 +0800136
developera833e5a2022-09-07 18:00:50 +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--
developereb6a0182022-12-12 18:53:32 +08001452.25.1
developera833e5a2022-09-07 18:00:50 +0800146