blob: 57ec82a2fb5dd22cc4f30d08f57682bb3cc9f482 [file] [log] [blame]
developer887da632022-10-28 09:35:38 +08001From 7953cd4cc8b1f91e56ee6cae491a227bafe5f81e 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
developer887da632022-10-28 09:35:38 +08004Subject: [PATCH 3007/3010] mt76: mt7915: enable red per-band token drop for HW
developerf9843e22022-09-13 10:57:15 +08005 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>
developer887da632022-10-28 09:35:38 +080012Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developera833e5a2022-09-07 18:00:50 +080013---
14 mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++----------
15 mt7915/mcu.h | 1 +
16 mt7915/mt7915.h | 2 +-
17 3 files changed, 45 insertions(+), 11 deletions(-)
18
19diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer887da632022-10-28 09:35:38 +080020index eda4f70..b98c8e8 100644
developera833e5a2022-09-07 18:00:50 +080021--- a/mt7915/mcu.c
22+++ b/mt7915/mcu.c
developer20747c12022-09-16 14:09:40 +080023@@ -2412,8 +2412,13 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +080024 mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
25 MCU_WA_PARAM_WED_VERSION,
26 wed->rev_id, 0);
developera833e5a2022-09-07 18:00:50 +080027+
28+ mt7915_mcu_set_red(dev, true);
29+ } else {
30+ mt7915_mcu_set_red(dev, false);
31 }
32
33+
34 ret = mt7915_mcu_set_mwds(dev, 1);
35 if (ret)
36 return ret;
developer20747c12022-09-16 14:09:40 +080037@@ -2423,12 +2428,7 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +080038 if (ret)
39 return ret;
40
41- ret = mt7915_mcu_init_rx_airtime(dev);
42- if (ret)
43- return ret;
44-
45- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
46- MCU_WA_PARAM_RED, 0, 0);
47+ return mt7915_mcu_init_rx_airtime(dev);
48 }
49
50 int mt7915_mcu_init(struct mt7915_dev *dev)
developer81ca9d62022-10-14 11:23:22 +080051@@ -4239,6 +4239,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 +080052
53 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
54 }
55+#endif
56+
57+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
58+{
59+#define RED_GLOBAL_TOKEN_WATERMARK 2
60+#define TOTAL_HW_TOKEN_SIZE 8192
61+ struct {
62+ __le32 args[3];
63+
64+ u8 cmd;
65+ u8 version;
66+ u8 __rsv1[4];
67+ u16 len;
68+
69+ __le16 high_mark;
70+ __le16 low_mark;
71+ u8 __rsv2[12];
72+ } req = {
73+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
74+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
75+ .len = cpu_to_le16(sizeof(req) - 12),
76+
77+ .high_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256),
78+ .low_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256 - 1536),
79+ };
80+
81+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
82+ sizeof(req), false);
83+}
84
85 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
86 {
developer81ca9d62022-10-14 11:23:22 +080087@@ -4249,17 +4278,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developera833e5a2022-09-07 18:00:50 +080088 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
89 __le32 req = cpu_to_le32(red_type);
90
91+ if (enabled) {
92+ ret = mt7915_red_set_watermark(dev);
93+ if (ret < 0)
94+ return ret;
95+ }
96+
97 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
98 sizeof(req), false);
99 if (ret < 0)
100 return ret;
101
102- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
103- MCU_WA_PARAM_RED, enabled, 0, true);
104+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
105+ MCU_WA_PARAM_RED, enabled, 0);
106
107- return 0;
108 }
109-#endif
110
111 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
112 {
113diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer887da632022-10-28 09:35:38 +0800114index cb95add..4071a73 100644
developera833e5a2022-09-07 18:00:50 +0800115--- a/mt7915/mcu.h
116+++ b/mt7915/mcu.h
117@@ -269,6 +269,7 @@ enum {
118 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
119 #endif
120 MCU_WA_PARAM_WED_VERSION = 0x32,
121+ MCU_WA_PARAM_RED_SETTING = 0x40,
122 };
123
124 enum mcu_mmps_mode {
125diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer887da632022-10-28 09:35:38 +0800126index 9977162..e0c0b49 100644
developera833e5a2022-09-07 18:00:50 +0800127--- a/mt7915/mt7915.h
128+++ b/mt7915/mt7915.h
developer887da632022-10-28 09:35:38 +0800129@@ -753,6 +753,7 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800130 #endif
131 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value,
132 s8 compensation);
133+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
134
developer887da632022-10-28 09:35:38 +0800135 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
136 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
137@@ -760,7 +761,6 @@ int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool w
developera833e5a2022-09-07 18:00:50 +0800138 #ifdef MTK_DEBUG
139 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
140 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
141-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
142 void mt7915_dump_tmac_info(u8 *tmac_info);
143 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
144 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
145--
developer887da632022-10-28 09:35:38 +08001462.18.0
developera833e5a2022-09-07 18:00:50 +0800147