blob: 4f4d70012b5c068c7a380e662abf6a42628b4f32 [file] [log] [blame]
developer20747c12022-09-16 14:09:40 +08001From 10f2c201cbeaae838ffa2489a7ff928d812d6f49 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
developer20747c12022-09-16 14:09:40 +08004Subject: [PATCH 3007/3007] 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>
12---
13 mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++----------
14 mt7915/mcu.h | 1 +
15 mt7915/mt7915.h | 2 +-
16 3 files changed, 45 insertions(+), 11 deletions(-)
17
18diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer20747c12022-09-16 14:09:40 +080019index b0fa6dac..98277d27 100644
developera833e5a2022-09-07 18:00:50 +080020--- a/mt7915/mcu.c
21+++ b/mt7915/mcu.c
developer20747c12022-09-16 14:09:40 +080022@@ -2412,8 +2412,13 @@ int mt7915_run_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;
developer20747c12022-09-16 14:09:40 +080036@@ -2423,12 +2428,7 @@ int mt7915_run_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)
developer20747c12022-09-16 14:09:40 +080050@@ -4232,6 +4232,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 {
developer20747c12022-09-16 14:09:40 +080086@@ -4242,17 +4271,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
developer20747c12022-09-16 14:09:40 +0800113index 1f56db6b..9181e961 100644
developera833e5a2022-09-07 18:00:50 +0800114--- a/mt7915/mcu.h
115+++ b/mt7915/mcu.h
116@@ -269,6 +269,7 @@ enum {
117 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
developer20747c12022-09-16 14:09:40 +0800125index 03486837..30293158 100644
developera833e5a2022-09-07 18:00:50 +0800126--- a/mt7915/mt7915.h
127+++ b/mt7915/mt7915.h
developere0cbe332022-09-10 17:36:02 +0800128@@ -749,11 +749,11 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800129 #endif
130 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value,
131 s8 compensation);
132+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
133
134 #ifdef MTK_DEBUG
135 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
136 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
137-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
138 void mt7915_dump_tmac_info(u8 *tmac_info);
139 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
140 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
141--
developer20747c12022-09-16 14:09:40 +08001422.25.1
developera833e5a2022-09-07 18:00:50 +0800143