blob: 16d9e8f63b85fdf5c04aa8eac0113af7d158e8ea [file] [log] [blame]
developer9bc8ec12022-11-18 16:01:14 +08001From 8a932d446bb0da8b7aa4cc7ea8ed541e002cf015 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
developer9bc8ec12022-11-18 16:01:14 +08004Subject: [PATCH] mt76: mt7915: enable red per-band token drop for HW Path
developer20126ad2022-09-12 14:42:56 +08005
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 +
developer9bc8ec12022-11-18 16:01:14 +080014 mt7915/mt7915.h | 3 ++-
15 3 files changed, 46 insertions(+), 11 deletions(-)
developer20126ad2022-09-12 14:42:56 +080016
17diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer9bc8ec12022-11-18 16:01:14 +080018index 16349c58..2ef353b2 100644
developer20126ad2022-09-12 14:42:56 +080019--- a/mt7915/mcu.c
20+++ b/mt7915/mcu.c
developer2cbf2fb2022-11-16 12:20:48 +080021@@ -2320,8 +2320,13 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developer20126ad2022-09-12 14:42:56 +080022 mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
23 MCU_WA_PARAM_WED_VERSION,
24 wed->rev_id, 0);
25+
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;
developer2cbf2fb2022-11-16 12:20:48 +080035@@ -2331,12 +2336,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developer20126ad2022-09-12 14:42:56 +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)
developer2cbf2fb2022-11-16 12:20:48 +080049@@ -4162,6 +4162,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 +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 {
developer2cbf2fb2022-11-16 12:20:48 +080085@@ -4172,17 +4201,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developer20126ad2022-09-12 14:42:56 +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
developer9bc8ec12022-11-18 16:01:14 +0800112index 4ae8d532..14a0972b 100644
developer20126ad2022-09-12 14:42:56 +0800113--- a/mt7915/mcu.h
114+++ b/mt7915/mcu.h
developer2cbf2fb2022-11-16 12:20:48 +0800115@@ -271,6 +271,7 @@ enum {
developer20126ad2022-09-12 14:42:56 +0800116 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
developer9bc8ec12022-11-18 16:01:14 +0800124index 46670de4..d8765041 100644
developer20126ad2022-09-12 14:42:56 +0800125--- a/mt7915/mt7915.h
126+++ b/mt7915/mt7915.h
developer9bc8ec12022-11-18 16:01:14 +0800127@@ -773,13 +773,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developer20126ad2022-09-12 14:42:56 +0800128 #endif
developer9bc8ec12022-11-18 16:01:14 +0800129 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
130 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
developer20126ad2022-09-12 14:42:56 +0800131+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer9bc8ec12022-11-18 16:01:14 +0800132+
developerb81e95d2022-11-08 10:16:29 +0800133 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
134 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
developer9bc8ec12022-11-18 16:01:14 +0800135
developer20126ad2022-09-12 14:42:56 +0800136 #ifdef MTK_DEBUG
137 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
138 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
139-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
140 void mt7915_dump_tmac_info(u8 *tmac_info);
141 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
142 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
143--
developerb81e95d2022-11-08 10:16:29 +08001442.18.0
developer20126ad2022-09-12 14:42:56 +0800145