blob: e6dc07ad60875de793cbb0d22d70cff04818ac3f [file] [log] [blame]
developera833e5a2022-09-07 18:00:50 +08001From 17753f183bce83f2b2f03e9f15312f84b67558e9 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 2 Sep 2022 14:40:40 +0800
4Subject: [PATCH] mt76: mt7915: enable red per-band token drop for HW Path
5
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---
12 mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++----------
13 mt7915/mcu.h | 1 +
14 mt7915/mt7915.h | 2 +-
15 3 files changed, 45 insertions(+), 11 deletions(-)
16
17diff --git a/mt7915/mcu.c b/mt7915/mcu.c
18index 1cbdf0cf..c29eb80a 100644
19--- a/mt7915/mcu.c
20+++ b/mt7915/mcu.c
developere0cbe332022-09-10 17:36:02 +080021@@ -2410,8 +2410,13 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
22 mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
23 MCU_WA_PARAM_WED_VERSION,
24 wed->rev_id, 0);
developera833e5a2022-09-07 18:00:50 +080025+
26+ mt7915_mcu_set_red(dev, true);
27+ } else {
28+ mt7915_mcu_set_red(dev, false);
29 }
30
31+
32 ret = mt7915_mcu_set_mwds(dev, 1);
33 if (ret)
34 return ret;
developere0cbe332022-09-10 17:36:02 +080035@@ -2421,12 +2426,7 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +080036 if (ret)
37 return ret;
38
39- ret = mt7915_mcu_init_rx_airtime(dev);
40- if (ret)
41- return ret;
42-
43- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
44- MCU_WA_PARAM_RED, 0, 0);
45+ return mt7915_mcu_init_rx_airtime(dev);
46 }
47
48 int mt7915_mcu_init(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +080049@@ -4230,6 +4230,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 +080050
51 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
52 }
53+#endif
54+
55+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
56+{
57+#define RED_GLOBAL_TOKEN_WATERMARK 2
58+#define TOTAL_HW_TOKEN_SIZE 8192
59+ struct {
60+ __le32 args[3];
61+
62+ u8 cmd;
63+ u8 version;
64+ u8 __rsv1[4];
65+ u16 len;
66+
67+ __le16 high_mark;
68+ __le16 low_mark;
69+ u8 __rsv2[12];
70+ } req = {
71+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
72+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
73+ .len = cpu_to_le16(sizeof(req) - 12),
74+
75+ .high_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256),
76+ .low_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256 - 1536),
77+ };
78+
79+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
80+ sizeof(req), false);
81+}
82
83 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
84 {
developere0cbe332022-09-10 17:36:02 +080085@@ -4240,17 +4269,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developera833e5a2022-09-07 18:00:50 +080086 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
87 __le32 req = cpu_to_le32(red_type);
88
89+ if (enabled) {
90+ ret = mt7915_red_set_watermark(dev);
91+ if (ret < 0)
92+ return ret;
93+ }
94+
95 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
96 sizeof(req), false);
97 if (ret < 0)
98 return ret;
99
100- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
101- MCU_WA_PARAM_RED, enabled, 0, true);
102+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
103+ MCU_WA_PARAM_RED, enabled, 0);
104
105- return 0;
106 }
107-#endif
108
109 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
110 {
111diff --git a/mt7915/mcu.h b/mt7915/mcu.h
112index ce50e606..230ad9db 100644
113--- a/mt7915/mcu.h
114+++ b/mt7915/mcu.h
115@@ -269,6 +269,7 @@ enum {
116 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
117 #endif
118 MCU_WA_PARAM_WED_VERSION = 0x32,
119+ MCU_WA_PARAM_RED_SETTING = 0x40,
120 };
121
122 enum mcu_mmps_mode {
123diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
124index f2081640..f2a1e615 100644
125--- a/mt7915/mt7915.h
126+++ b/mt7915/mt7915.h
developere0cbe332022-09-10 17:36:02 +0800127@@ -749,11 +749,11 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800128 #endif
129 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value,
130 s8 compensation);
131+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
132
133 #ifdef MTK_DEBUG
134 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
135 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
136-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
137 void mt7915_dump_tmac_info(u8 *tmac_info);
138 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
139 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
140--
1412.18.0
142