blob: 16d9e8f63b85fdf5c04aa8eac0113af7d158e8ea [file] [log] [blame]
developer335cbee2022-11-17 14:55:34 +08001From 8a932d446bb0da8b7aa4cc7ea8ed541e002cf015 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
developer335cbee2022-11-17 14:55:34 +08004Subject: [PATCH] mt76: mt7915: enable red per-band token drop for HW Path
developera833e5a2022-09-07 18:00:50 +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 +
developer335cbee2022-11-17 14:55:34 +080014 mt7915/mt7915.h | 3 ++-
15 3 files changed, 46 insertions(+), 11 deletions(-)
developera833e5a2022-09-07 18:00:50 +080016
17diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer335cbee2022-11-17 14:55:34 +080018index 16349c58..2ef353b2 100644
developera833e5a2022-09-07 18:00:50 +080019--- a/mt7915/mcu.c
20+++ b/mt7915/mcu.c
developer356ecec2022-11-14 10:25:04 +080021@@ -2320,8 +2320,13 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +080022 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;
developer356ecec2022-11-14 10:25:04 +080035@@ -2331,12 +2336,7 @@ int mt7915_mcu_init_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)
developer356ecec2022-11-14 10:25:04 +080049@@ -4162,6 +4162,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 {
developer356ecec2022-11-14 10:25:04 +080085@@ -4172,17 +4201,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
developer335cbee2022-11-17 14:55:34 +0800112index 4ae8d532..14a0972b 100644
developera833e5a2022-09-07 18:00:50 +0800113--- a/mt7915/mcu.h
114+++ b/mt7915/mcu.h
developer356ecec2022-11-14 10:25:04 +0800115@@ -271,6 +271,7 @@ enum {
developera833e5a2022-09-07 18:00:50 +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
developer335cbee2022-11-17 14:55:34 +0800124index 46670de4..d8765041 100644
developera833e5a2022-09-07 18:00:50 +0800125--- a/mt7915/mt7915.h
126+++ b/mt7915/mt7915.h
developer335cbee2022-11-17 14:55:34 +0800127@@ -773,13 +773,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800128 #endif
developer335cbee2022-11-17 14:55:34 +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);
developera833e5a2022-09-07 18:00:50 +0800131+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer335cbee2022-11-17 14:55:34 +0800132+
developer887da632022-10-28 09:35:38 +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);
developer335cbee2022-11-17 14:55:34 +0800135
developera833e5a2022-09-07 18:00:50 +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--
developer887da632022-10-28 09:35:38 +08001442.18.0
developera833e5a2022-09-07 18:00:50 +0800145