blob: 6e34978673464b149903b2b8f607020c3a6d4553 [file] [log] [blame]
developer1346ce52022-12-15 21:36:14 +08001From 7a2f7d7f2ae97179af8eb6efbe97c9cef5e47553 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
developerafd75872022-12-14 21:15:46 +08004Subject: [PATCH 3006/3012] mt76: mt7915: wed: enable red per-band token drop
developerbf24a8a2022-11-30 14:52:20 +08005 for HW 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---
developerafd75872022-12-14 21:15:46 +080013 mt7915/mcu.c | 57 ++++++++++++++++++++++++++++++++++++++++---------
developera833e5a2022-09-07 18:00:50 +080014 mt7915/mcu.h | 1 +
developer335cbee2022-11-17 14:55:34 +080015 mt7915/mt7915.h | 3 ++-
developerafd75872022-12-14 21:15:46 +080016 3 files changed, 50 insertions(+), 11 deletions(-)
developera833e5a2022-09-07 18:00:50 +080017
18diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer1346ce52022-12-15 21:36:14 +080019index b2d6412..1164eff 100644
developera833e5a2022-09-07 18:00:50 +080020--- a/mt7915/mcu.c
21+++ b/mt7915/mcu.c
developer1346ce52022-12-15 21:36:14 +080022@@ -2374,8 +2374,17 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developerafd75872022-12-14 21:15:46 +080023 dev->mt76.mmio.wed.rev_id, 0);
24 if (ret)
25 return ret;
developera833e5a2022-09-07 18:00:50 +080026+
developerafd75872022-12-14 21:15:46 +080027+ ret = mt7915_mcu_set_red(dev, true);
28+ if (ret)
29+ return ret;
developera833e5a2022-09-07 18:00:50 +080030+ } else {
31+ mt7915_mcu_set_red(dev, false);
developerafd75872022-12-14 21:15:46 +080032+ if (ret)
33+ return ret;
developera833e5a2022-09-07 18:00:50 +080034 }
35
36+
37 ret = mt7915_mcu_set_mwds(dev, 1);
38 if (ret)
39 return ret;
developer1346ce52022-12-15 21:36:14 +080040@@ -2385,12 +2394,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
developera833e5a2022-09-07 18:00:50 +080041 if (ret)
42 return ret;
43
44- ret = mt7915_mcu_init_rx_airtime(dev);
45- if (ret)
46- return ret;
47-
48- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
49- MCU_WA_PARAM_RED, 0, 0);
50+ return mt7915_mcu_init_rx_airtime(dev);
51 }
52
53 int mt7915_mcu_init(struct mt7915_dev *dev)
developer1346ce52022-12-15 21:36:14 +080054@@ -4533,6 +4537,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 +080055
56 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
57 }
58+#endif
59+
60+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
61+{
62+#define RED_GLOBAL_TOKEN_WATERMARK 2
63+#define TOTAL_HW_TOKEN_SIZE 8192
64+ struct {
65+ __le32 args[3];
66+
67+ u8 cmd;
68+ u8 version;
69+ u8 __rsv1[4];
70+ u16 len;
71+
72+ __le16 high_mark;
73+ __le16 low_mark;
74+ u8 __rsv2[12];
75+ } req = {
76+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
77+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
78+ .len = cpu_to_le16(sizeof(req) - 12),
79+
80+ .high_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256),
81+ .low_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256 - 1536),
82+ };
83+
84+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
85+ sizeof(req), false);
86+}
87
88 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
89 {
developer1346ce52022-12-15 21:36:14 +080090@@ -4543,17 +4576,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
developera833e5a2022-09-07 18:00:50 +080091 u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
92 __le32 req = cpu_to_le32(red_type);
93
94+ if (enabled) {
95+ ret = mt7915_red_set_watermark(dev);
96+ if (ret < 0)
97+ return ret;
98+ }
99+
100 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
101 sizeof(req), false);
102 if (ret < 0)
103 return ret;
104
105- mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
106- MCU_WA_PARAM_RED, enabled, 0, true);
107+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
108+ MCU_WA_PARAM_RED, enabled, 0);
109
110- return 0;
111 }
112-#endif
113
114 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
115 {
116diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer1346ce52022-12-15 21:36:14 +0800117index f2f88cc..572cc16 100644
developera833e5a2022-09-07 18:00:50 +0800118--- a/mt7915/mcu.h
119+++ b/mt7915/mcu.h
developerafd75872022-12-14 21:15:46 +0800120@@ -285,6 +285,7 @@ enum {
121 MCU_WA_PARAM_CPU_UTIL = 0x0b,
122 MCU_WA_PARAM_RED = 0x0e,
developera833e5a2022-09-07 18:00:50 +0800123 MCU_WA_PARAM_WED_VERSION = 0x32,
124+ MCU_WA_PARAM_RED_SETTING = 0x40,
developerafd75872022-12-14 21:15:46 +0800125 #ifdef MTK_DEBUG
126 MCU_WA_PARAM_RED_SHOW_STA = 0xf,
127 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
developera833e5a2022-09-07 18:00:50 +0800128diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer1346ce52022-12-15 21:36:14 +0800129index 73806ae..3683ef0 100644
developera833e5a2022-09-07 18:00:50 +0800130--- a/mt7915/mt7915.h
131+++ b/mt7915/mt7915.h
developer1346ce52022-12-15 21:36:14 +0800132@@ -780,13 +780,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
developera833e5a2022-09-07 18:00:50 +0800133 #endif
developer335cbee2022-11-17 14:55:34 +0800134 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
135 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
developera833e5a2022-09-07 18:00:50 +0800136+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
developer335cbee2022-11-17 14:55:34 +0800137+
developer887da632022-10-28 09:35:38 +0800138 int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
139 int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
developer335cbee2022-11-17 14:55:34 +0800140
developera833e5a2022-09-07 18:00:50 +0800141 #ifdef MTK_DEBUG
142 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
143 int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
144-int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
145 void mt7915_dump_tmac_info(u8 *tmac_info);
146 int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
147 void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
148--
developer9851a292022-12-15 17:33:43 +08001492.18.0
developera833e5a2022-09-07 18:00:50 +0800150