blob: 6facdc353f311b5372cfce9de757b7eb00556a7a [file] [log] [blame]
developer064da3c2023-06-13 15:57:26 +08001From 826ab7312fa42110844329a333df76dec614e48f Mon Sep 17 00:00:00 2001
developer1bc2ce22023-03-25 00:47:41 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Wed, 1 Mar 2023 11:59:16 +0800
developer064da3c2023-06-13 15:57:26 +08004Subject: [PATCH] wifi: mt76: testmode: add basic testmode support
developer1bc2ce22023-03-25 00:47:41 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7---
8 eeprom.c | 6 +-
9 mac80211.c | 3 +-
developerde9ecce2023-05-22 11:17:16 +080010 mt76.h | 33 +++
developer1bc2ce22023-03-25 00:47:41 +080011 mt76_connac_mcu.h | 2 +
12 mt7996/Makefile | 2 +
13 mt7996/eeprom.c | 35 ++-
14 mt7996/eeprom.h | 1 +
15 mt7996/init.c | 7 +
developer064da3c2023-06-13 15:57:26 +080016 mt7996/main.c | 16 ++
17 mt7996/mcu.c | 42 ++-
developer1bc2ce22023-03-25 00:47:41 +080018 mt7996/mcu.h | 27 ++
19 mt7996/mt7996.h | 22 ++
developer064da3c2023-06-13 15:57:26 +080020 mt7996/testmode.c | 658 ++++++++++++++++++++++++++++++++++++++++++++++
21 mt7996/testmode.h | 295 +++++++++++++++++++++
22 testmode.c | 73 +++--
developer1bc2ce22023-03-25 00:47:41 +080023 testmode.h | 60 +++++
24 tools/fields.c | 92 +++++++
developer064da3c2023-06-13 15:57:26 +080025 17 files changed, 1344 insertions(+), 30 deletions(-)
developer1bc2ce22023-03-25 00:47:41 +080026 create mode 100644 mt7996/testmode.c
27 create mode 100644 mt7996/testmode.h
28
29diff --git a/eeprom.c b/eeprom.c
developer064da3c2023-06-13 15:57:26 +080030index ea54b7a..263e508 100644
developer1bc2ce22023-03-25 00:47:41 +080031--- a/eeprom.c
32+++ b/eeprom.c
33@@ -89,8 +89,10 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
34 }
35
36 #ifdef CONFIG_NL80211_TESTMODE
37- dev->test_mtd.name = devm_kstrdup(dev->dev, part, GFP_KERNEL);
38- dev->test_mtd.offset = offset;
39+ if (len == dev->eeprom.size) {
40+ dev->test_mtd.name = devm_kstrdup(dev->dev, part, GFP_KERNEL);
41+ dev->test_mtd.offset = offset;
42+ }
43 #endif
44
45 out_put_node:
46diff --git a/mac80211.c b/mac80211.c
developer064da3c2023-06-13 15:57:26 +080047index 467afef..d1cdaee 100644
developer1bc2ce22023-03-25 00:47:41 +080048--- a/mac80211.c
49+++ b/mac80211.c
50@@ -826,7 +826,8 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb)
51 }
52
53 #ifdef CONFIG_NL80211_TESTMODE
54- if (phy->test.state == MT76_TM_STATE_RX_FRAMES) {
55+ if (!(phy->test.flag & MT_TM_FW_RX_COUNT) &&
56+ phy->test.state == MT76_TM_STATE_RX_FRAMES) {
57 phy->test.rx_stats.packets[q]++;
58 if (status->flag & RX_FLAG_FAILED_FCS_CRC)
59 phy->test.rx_stats.fcs_error[q]++;
60diff --git a/mt76.h b/mt76.h
developer064da3c2023-06-13 15:57:26 +080061index 6b07b8f..31d5dc3 100644
developer1bc2ce22023-03-25 00:47:41 +080062--- a/mt76.h
63+++ b/mt76.h
64@@ -652,8 +652,12 @@ struct mt76_testmode_ops {
65 int (*set_params)(struct mt76_phy *phy, struct nlattr **tb,
66 enum mt76_testmode_state new_state);
67 int (*dump_stats)(struct mt76_phy *phy, struct sk_buff *msg);
68+ void (*reset_rx_stats)(struct mt76_phy *phy);
69+ void (*tx_stop)(struct mt76_phy *phy);
70 };
71
72+#define MT_TM_FW_RX_COUNT BIT(0)
73+
74 struct mt76_testmode_data {
75 enum mt76_testmode_state state;
76
77@@ -669,6 +673,7 @@ struct mt76_testmode_data {
78 u8 tx_rate_sgi;
79 u8 tx_rate_ldpc;
80 u8 tx_rate_stbc;
81+ u16 tx_preamble_puncture;
82 u8 tx_ltf;
83
84 u8 tx_antenna_mask;
85@@ -678,6 +683,9 @@ struct mt76_testmode_data {
86 u32 tx_time;
87 u32 tx_ipg;
88
89+ bool ibf;
90+ bool ebf;
91+
92 u32 freq_offset;
93
94 u8 tx_power[4];
developerde9ecce2023-05-22 11:17:16 +080095@@ -692,7 +700,16 @@ struct mt76_testmode_data {
developer1bc2ce22023-03-25 00:47:41 +080096 struct {
97 u64 packets[__MT_RXQ_MAX];
98 u64 fcs_error[__MT_RXQ_MAX];
99+ u64 len_mismatch;
100 } rx_stats;
101+ u8 flag;
developerde9ecce2023-05-22 11:17:16 +0800102+
103+ struct {
104+ u8 type;
105+ u8 enable;
106+ } cfg;
107+
developer1bc2ce22023-03-25 00:47:41 +0800108+ u8 aid;
109 };
110
111 struct mt76_vif {
developerde9ecce2023-05-22 11:17:16 +0800112@@ -1258,6 +1275,22 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
113 int mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state);
114 int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len);
115
116+static inline void
117+mt76_testmode_param_set(struct mt76_testmode_data *td, u16 idx)
118+{
119+#ifdef CONFIG_NL80211_TESTMODE
120+ td->param_set[idx / 32] |= BIT(idx % 32);
121+#endif
122+}
123+
124+static inline bool
125+mt76_testmode_param_present(struct mt76_testmode_data *td, u16 idx)
126+{
127+#ifdef CONFIG_NL80211_TESTMODE
128+ return td->param_set[idx / 32] & BIT(idx % 32);
129+#endif
130+}
131+
132 static inline void mt76_testmode_reset(struct mt76_phy *phy, bool disable)
133 {
134 #ifdef CONFIG_NL80211_TESTMODE
developer1bc2ce22023-03-25 00:47:41 +0800135diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer064da3c2023-06-13 15:57:26 +0800136index 30c9a5d..724a48a 100644
developer1bc2ce22023-03-25 00:47:41 +0800137--- a/mt76_connac_mcu.h
138+++ b/mt76_connac_mcu.h
139@@ -1218,10 +1218,12 @@ enum {
140 MCU_UNI_CMD_EFUSE_CTRL = 0x2d,
141 MCU_UNI_CMD_RA = 0x2f,
142 MCU_UNI_CMD_MURU = 0x31,
143+ MCU_UNI_CMD_TESTMODE_RX_STAT = 0x32,
144 MCU_UNI_CMD_BF = 0x33,
145 MCU_UNI_CMD_CHANNEL_SWITCH = 0x34,
146 MCU_UNI_CMD_THERMAL = 0x35,
147 MCU_UNI_CMD_VOW = 0x37,
148+ MCU_UNI_CMD_TESTMODE_CTRL = 0x46,
149 MCU_UNI_CMD_RRO = 0x57,
150 MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58,
developerde9ecce2023-05-22 11:17:16 +0800151 MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
developer1bc2ce22023-03-25 00:47:41 +0800152diff --git a/mt7996/Makefile b/mt7996/Makefile
developer064da3c2023-06-13 15:57:26 +0800153index 07c8b55..bed9efd 100644
developer1bc2ce22023-03-25 00:47:41 +0800154--- a/mt7996/Makefile
155+++ b/mt7996/Makefile
developerde9ecce2023-05-22 11:17:16 +0800156@@ -6,3 +6,5 @@ mt7996e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \
developer1bc2ce22023-03-25 00:47:41 +0800157 debugfs.o mmio.o
developerde9ecce2023-05-22 11:17:16 +0800158
159 mt7996e-$(CONFIG_DEV_COREDUMP) += coredump.o
developer1bc2ce22023-03-25 00:47:41 +0800160+
161+mt7996e-$(CONFIG_NL80211_TESTMODE) += testmode.o
162diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
developer064da3c2023-06-13 15:57:26 +0800163index 544b6c6..f5e9546 100644
developer1bc2ce22023-03-25 00:47:41 +0800164--- a/mt7996/eeprom.c
165+++ b/mt7996/eeprom.c
166@@ -6,6 +6,11 @@
167 #include <linux/firmware.h>
168 #include "mt7996.h"
169 #include "eeprom.h"
170+#include <linux/moduleparam.h>
171+
172+static bool testmode_enable;
173+module_param(testmode_enable, bool, 0644);
174+MODULE_PARM_DESC(testmode_enable, "Enable testmode");
175
176 static int mt7996_check_eeprom(struct mt7996_dev *dev)
177 {
178@@ -23,7 +28,10 @@ static int mt7996_check_eeprom(struct mt7996_dev *dev)
179 static char *mt7996_eeprom_name(struct mt7996_dev *dev)
180 {
181 /* reserve for future variants */
182- return MT7996_EEPROM_DEFAULT;
183+ if (dev->testmode_enable)
184+ return MT7996_EEPROM_DEFAULT_TM;
185+ else
186+ return MT7996_EEPROM_DEFAULT;
187 }
188
189 static int
190@@ -52,21 +60,36 @@ out:
191 return ret;
192 }
193
194-static int mt7996_eeprom_load(struct mt7996_dev *dev)
195+int mt7996_eeprom_check_fw_mode(struct mt7996_dev *dev)
196 {
197+ u8 *eeprom;
198 int ret;
199
200+ /* load eeprom in flash or bin file mode to determine fw mode */
201 ret = mt76_eeprom_init(&dev->mt76, MT7996_EEPROM_SIZE);
202 if (ret < 0)
203 return ret;
204
205 if (ret) {
206 dev->flash_mode = true;
207- } else {
208- u8 free_block_num;
209- u32 block_num, i;
210- u32 eeprom_blk_size = MT7996_EEPROM_BLOCK_SIZE;
211+ eeprom = dev->mt76.eeprom.data;
212+ /* testmode enable priority: eeprom field > module parameter */
213+ dev->testmode_enable = !mt7996_check_eeprom(dev) ? eeprom[MT_EE_TESTMODE_EN] :
214+ testmode_enable;
215+ }
216+
217+ return ret;
218+}
219+
220+static int mt7996_eeprom_load(struct mt7996_dev *dev)
221+{
222+ int ret;
223+ u8 free_block_num;
224+ u32 block_num, i;
225+ u32 eeprom_blk_size = MT7996_EEPROM_BLOCK_SIZE;
226
227+ /* flash or bin file mode eeprom is loaded before mcu init */
228+ if (!dev->flash_mode) {
229 ret = mt7996_mcu_get_eeprom_free_block(dev, &free_block_num);
230 if (ret < 0)
231 return ret;
232diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h
developer064da3c2023-06-13 15:57:26 +0800233index 0c74977..0f8f0cd 100644
developer1bc2ce22023-03-25 00:47:41 +0800234--- a/mt7996/eeprom.h
235+++ b/mt7996/eeprom.h
236@@ -14,6 +14,7 @@ enum mt7996_eeprom_field {
237 MT_EE_MAC_ADDR = 0x004,
238 MT_EE_MAC_ADDR2 = 0x00a,
239 MT_EE_WIFI_CONF = 0x190,
240+ MT_EE_TESTMODE_EN = 0x1af,
241 MT_EE_MAC_ADDR3 = 0x2c0,
242 MT_EE_RATE_DELTA_2G = 0x1400,
243 MT_EE_RATE_DELTA_5G = 0x147d,
244diff --git a/mt7996/init.c b/mt7996/init.c
developer064da3c2023-06-13 15:57:26 +0800245index 0319e7f..fecd0d3 100644
developer1bc2ce22023-03-25 00:47:41 +0800246--- a/mt7996/init.c
247+++ b/mt7996/init.c
developer064da3c2023-06-13 15:57:26 +0800248@@ -641,6 +641,10 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
developer1bc2ce22023-03-25 00:47:41 +0800249
250 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
251
252+ ret = mt7996_eeprom_check_fw_mode(dev);
253+ if (ret < 0)
254+ return ret;
255+
256 ret = mt7996_mcu_init(dev);
257 if (ret)
258 return ret;
developer064da3c2023-06-13 15:57:26 +0800259@@ -1056,6 +1060,9 @@ int mt7996_register_device(struct mt7996_dev *dev)
developer1bc2ce22023-03-25 00:47:41 +0800260
261 mt7996_init_wiphy(hw);
262
263+#ifdef CONFIG_NL80211_TESTMODE
264+ dev->mt76.test_ops = &mt7996_testmode_ops;
265+#endif
266 /* init led callbacks */
267 if (IS_ENABLED(CONFIG_MT76_LEDS)) {
268 dev->mphy.leds.cdev.brightness_set = mt7996_led_set_brightness;
269diff --git a/mt7996/main.c b/mt7996/main.c
developer064da3c2023-06-13 15:57:26 +0800270index 8e38ebc..6c38993 100644
developer1bc2ce22023-03-25 00:47:41 +0800271--- a/mt7996/main.c
272+++ b/mt7996/main.c
developer064da3c2023-06-13 15:57:26 +0800273@@ -23,6 +23,18 @@ static bool mt7996_dev_running(struct mt7996_dev *dev)
developer1bc2ce22023-03-25 00:47:41 +0800274 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);
275 }
276
277+static void mt7996_testmode_disable_all(struct mt7996_dev *dev)
278+{
279+ struct mt7996_phy *phy;
280+ int i;
281+
282+ for (i = 0; i < __MT_MAX_BAND; i++) {
283+ phy = __mt7996_phy(dev, i);
developer064da3c2023-06-13 15:57:26 +0800284+ if (phy)
285+ mt76_testmode_set_state(phy->mt76, MT76_TM_STATE_OFF);
developer1bc2ce22023-03-25 00:47:41 +0800286+ }
287+}
288+
289 int mt7996_run(struct ieee80211_hw *hw)
290 {
291 struct mt7996_dev *dev = mt7996_hw_dev(hw);
developer064da3c2023-06-13 15:57:26 +0800292@@ -37,6 +49,8 @@ int mt7996_run(struct ieee80211_hw *hw)
developer1bc2ce22023-03-25 00:47:41 +0800293 goto out;
294 }
295
296+ mt7996_testmode_disable_all(dev);
297+
298 mt7996_mac_enable_nf(dev, phy->mt76->band_idx);
299
300 ret = mt7996_mcu_set_rts_thresh(phy, 0x92b);
developer064da3c2023-06-13 15:57:26 +0800301@@ -1389,6 +1403,8 @@ const struct ieee80211_ops mt7996_ops = {
developer1bc2ce22023-03-25 00:47:41 +0800302 .sta_set_decap_offload = mt7996_sta_set_decap_offload,
303 .add_twt_setup = mt7996_mac_add_twt_setup,
304 .twt_teardown_request = mt7996_twt_teardown_request,
305+ CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
306+ CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
307 #ifdef CONFIG_MAC80211_DEBUGFS
308 .sta_add_debugfs = mt7996_sta_add_debugfs,
309 #endif
310diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer064da3c2023-06-13 15:57:26 +0800311index 665457a..0d2053c 100644
developer1bc2ce22023-03-25 00:47:41 +0800312--- a/mt7996/mcu.c
313+++ b/mt7996/mcu.c
developer064da3c2023-06-13 15:57:26 +0800314@@ -2515,8 +2515,12 @@ static int mt7996_load_ram(struct mt7996_dev *dev)
315 {
316 int ret;
developer1bc2ce22023-03-25 00:47:41 +0800317
developer064da3c2023-06-13 15:57:26 +0800318- ret = __mt7996_load_ram(dev, "WM", MT7996_FIRMWARE_WM,
319- MT7996_RAM_TYPE_WM);
developer1bc2ce22023-03-25 00:47:41 +0800320+ if (dev->testmode_enable)
developer064da3c2023-06-13 15:57:26 +0800321+ ret = __mt7996_load_ram(dev, "WM_TM", MT7996_FIRMWARE_WM_TM,
322+ MT7996_RAM_TYPE_WM_TM);
developer1bc2ce22023-03-25 00:47:41 +0800323+ else
developer064da3c2023-06-13 15:57:26 +0800324+ ret = __mt7996_load_ram(dev, "WM", MT7996_FIRMWARE_WM,
325+ MT7996_RAM_TYPE_WM);
326 if (ret)
327 return ret;
328
329@@ -4066,3 +4070,37 @@ int mt7996_mcu_set_rro(struct mt7996_dev *dev, u16 tag, u8 val)
developer1bc2ce22023-03-25 00:47:41 +0800330 return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(RRO), &req,
331 sizeof(req), true);
332 }
333+
334+int mt7996_mcu_set_tx_power_ctrl(struct mt7996_phy *phy, u8 power_ctrl_id, u8 data)
335+{
336+ struct mt7996_dev *dev = phy->dev;
337+ struct tx_power_ctrl req = {
338+ .tag = cpu_to_le16(power_ctrl_id),
339+ .len = cpu_to_le16(sizeof(req) - 4),
340+ .power_ctrl_id = power_ctrl_id,
341+ .band_idx = phy->mt76->band_idx,
342+ };
343+
344+ switch (power_ctrl_id) {
345+ case UNI_TXPOWER_SKU_POWER_LIMIT_CTRL:
346+ req.sku_enable = !!data;
347+ break;
348+ case UNI_TXPOWER_PERCENTAGE_CTRL:
349+ req.percentage_ctrl_enable = !!data;
350+ break;
351+ case UNI_TXPOWER_PERCENTAGE_DROP_CTRL:
352+ req.power_drop_level = data;
353+ break;
354+ case UNI_TXPOWER_BACKOFF_POWER_LIMIT_CTRL:
355+ req.bf_backoff_enable = !!data;
356+ break;
357+ case UNI_TXPOWER_ATE_MODE_CTRL:
358+ req.ate_mode_enable = !!data;
359+ break;
360+ default:
361+ req.sku_enable = !!data;
362+ }
363+
364+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TXPOWER),
365+ &req, sizeof(req), false);
366+}
367diff --git a/mt7996/mcu.h b/mt7996/mcu.h
developer064da3c2023-06-13 15:57:26 +0800368index f235175..4ba06d9 100644
developer1bc2ce22023-03-25 00:47:41 +0800369--- a/mt7996/mcu.h
370+++ b/mt7996/mcu.h
developer064da3c2023-06-13 15:57:26 +0800371@@ -703,6 +703,33 @@ enum {
developer1bc2ce22023-03-25 00:47:41 +0800372 UNI_CMD_THERMAL_PROTECT_DUTY_CONFIG,
373 };
374
375+struct tx_power_ctrl {
376+ u8 _rsv[4];
377+
378+ __le16 tag;
379+ __le16 len;
380+
381+ u8 power_ctrl_id;
382+ union {
383+ bool sku_enable;
384+ bool ate_mode_enable;
385+ bool percentage_ctrl_enable;
386+ bool bf_backoff_enable;
387+ u8 power_drop_level;
388+ };
389+ u8 band_idx;
390+ u8 rsv[1];
391+} __packed;
392+
393+enum {
394+ UNI_TXPOWER_SKU_POWER_LIMIT_CTRL = 0,
395+ UNI_TXPOWER_PERCENTAGE_CTRL = 1,
396+ UNI_TXPOWER_PERCENTAGE_DROP_CTRL = 2,
397+ UNI_TXPOWER_BACKOFF_POWER_LIMIT_CTRL = 3,
398+ UNI_TXPOWER_POWER_LIMIT_TABLE_CTRL = 4,
399+ UNI_TXPOWER_ATE_MODE_CTRL = 6,
400+};
401+
402 enum {
403 UNI_CMD_ACCESS_REG_BASIC = 0x0,
404 UNI_CMD_ACCESS_RF_REG_BASIC,
405diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer064da3c2023-06-13 15:57:26 +0800406index 071031b..f7d6580 100644
developer1bc2ce22023-03-25 00:47:41 +0800407--- a/mt7996/mt7996.h
408+++ b/mt7996/mt7996.h
developer064da3c2023-06-13 15:57:26 +0800409@@ -31,9 +31,11 @@
developer1bc2ce22023-03-25 00:47:41 +0800410 #define MT7996_FIRMWARE_WA "mediatek/mt7996/mt7996_wa.bin"
411 #define MT7996_FIRMWARE_WM "mediatek/mt7996/mt7996_wm.bin"
412 #define MT7996_FIRMWARE_DSP "mediatek/mt7996/mt7996_dsp.bin"
413+#define MT7996_FIRMWARE_WM_TM "mediatek/mt7996/mt7996_wm_tm.bin"
414 #define MT7996_ROM_PATCH "mediatek/mt7996/mt7996_rom_patch.bin"
415
416 #define MT7996_EEPROM_DEFAULT "mediatek/mt7996/mt7996_eeprom.bin"
417+#define MT7996_EEPROM_DEFAULT_TM "mediatek/mt7996/mt7996_eeprom_tm.bin"
418 #define MT7996_EEPROM_SIZE 7680
419 #define MT7996_EEPROM_BLOCK_SIZE 16
developer064da3c2023-06-13 15:57:26 +0800420 #define MT7996_TOKEN_SIZE 16384
421@@ -63,6 +65,7 @@ struct mt7996_dfs_pattern;
developer1bc2ce22023-03-25 00:47:41 +0800422
423 enum mt7996_ram_type {
developer064da3c2023-06-13 15:57:26 +0800424 MT7996_RAM_TYPE_WM,
developer1bc2ce22023-03-25 00:47:41 +0800425+ MT7996_RAM_TYPE_WM_TM = MT7996_RAM_TYPE_WM,
426 MT7996_RAM_TYPE_WA,
427 MT7996_RAM_TYPE_DSP,
428 };
developer064da3c2023-06-13 15:57:26 +0800429@@ -244,6 +247,20 @@ struct mt7996_phy {
developer1bc2ce22023-03-25 00:47:41 +0800430
431 struct mib_stats mib;
432 struct mt76_channel_state state_ts;
433+
434+#ifdef CONFIG_NL80211_TESTMODE
435+ struct {
436+ u32 *reg_backup;
437+
438+ s32 last_freq_offset;
439+ u8 last_rcpi[4];
440+ s8 last_ib_rssi[4];
441+ s8 last_wb_rssi[4];
442+ u8 last_snr;
443+
444+ u8 spe_idx;
445+ } test;
446+#endif
447 };
448
449 struct mt7996_dev {
developer064da3c2023-06-13 15:57:26 +0800450@@ -303,6 +320,8 @@ struct mt7996_dev {
developer1bc2ce22023-03-25 00:47:41 +0800451 bool flash_mode:1;
452 bool has_eht:1;
453
454+ bool testmode_enable;
455+
456 bool ibf;
457 u8 fw_debug_wm;
458 u8 fw_debug_wa;
developer064da3c2023-06-13 15:57:26 +0800459@@ -408,6 +427,7 @@ mt7996_phy3(struct mt7996_dev *dev)
developer1bc2ce22023-03-25 00:47:41 +0800460 extern const struct ieee80211_ops mt7996_ops;
461 extern struct pci_driver mt7996_pci_driver;
462 extern struct pci_driver mt7996_hif_driver;
463+extern const struct mt76_testmode_ops mt7996_testmode_ops;
464
465 struct mt7996_dev *mt7996_mmio_probe(struct device *pdev,
466 void __iomem *mem_base, u32 device_id);
developer064da3c2023-06-13 15:57:26 +0800467@@ -417,6 +437,7 @@ u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif);
developer1bc2ce22023-03-25 00:47:41 +0800468 int mt7996_register_device(struct mt7996_dev *dev);
469 void mt7996_unregister_device(struct mt7996_dev *dev);
470 int mt7996_eeprom_init(struct mt7996_dev *dev);
471+int mt7996_eeprom_check_fw_mode(struct mt7996_dev *dev);
472 int mt7996_eeprom_parse_hw_cap(struct mt7996_dev *dev, struct mt7996_phy *phy);
473 int mt7996_eeprom_get_target_power(struct mt7996_dev *dev,
474 struct ieee80211_channel *chan);
developer064da3c2023-06-13 15:57:26 +0800475@@ -494,6 +515,7 @@ int mt7996_mcu_fw_dbg_ctrl(struct mt7996_dev *dev, u32 module, u8 level);
developerde9ecce2023-05-22 11:17:16 +0800476 int mt7996_mcu_trigger_assert(struct mt7996_dev *dev);
developer1bc2ce22023-03-25 00:47:41 +0800477 void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb);
478 void mt7996_mcu_exit(struct mt7996_dev *dev);
479+int mt7996_mcu_set_tx_power_ctrl(struct mt7996_phy *phy, u8 power_ctrl_id, u8 data);
480
481 static inline u8 mt7996_max_interface_num(struct mt7996_dev *dev)
482 {
483diff --git a/mt7996/testmode.c b/mt7996/testmode.c
484new file mode 100644
developer064da3c2023-06-13 15:57:26 +0800485index 0000000..43eca4e
developer1bc2ce22023-03-25 00:47:41 +0800486--- /dev/null
487+++ b/mt7996/testmode.c
developer064da3c2023-06-13 15:57:26 +0800488@@ -0,0 +1,658 @@
developer1bc2ce22023-03-25 00:47:41 +0800489+// SPDX-License-Identifier: ISC
490+/*
491+ * Copyright (C) 2022 MediaTek Inc.
492+ */
493+
494+#include "mt7996.h"
495+#include "mac.h"
496+#include "mcu.h"
497+#include "testmode.h"
498+
499+enum {
500+ TM_CHANGED_TXPOWER,
501+ TM_CHANGED_FREQ_OFFSET,
502+ TM_CHANGED_TX_LENGTH,
503+ TM_CHANGED_TX_TIME,
developerde9ecce2023-05-22 11:17:16 +0800504+ TM_CHANGED_CFG,
developer1bc2ce22023-03-25 00:47:41 +0800505+
506+ /* must be last */
507+ NUM_TM_CHANGED
508+};
509+
510+static const u8 tm_change_map[] = {
511+ [TM_CHANGED_TXPOWER] = MT76_TM_ATTR_TX_POWER,
512+ [TM_CHANGED_FREQ_OFFSET] = MT76_TM_ATTR_FREQ_OFFSET,
513+ [TM_CHANGED_TX_LENGTH] = MT76_TM_ATTR_TX_LENGTH,
514+ [TM_CHANGED_TX_TIME] = MT76_TM_ATTR_TX_TIME,
developerde9ecce2023-05-22 11:17:16 +0800515+ [TM_CHANGED_CFG] = MT76_TM_ATTR_CFG,
developer1bc2ce22023-03-25 00:47:41 +0800516+};
517+
518+static u8 mt7996_tm_bw_mapping(enum nl80211_chan_width width, enum bw_mapping_method method)
519+{
520+ static const u8 width_to_bw[][NUM_BW_MAP] = {
521+ [NL80211_CHAN_WIDTH_40] = {FW_CDBW_40MHZ, TM_CBW_40MHZ},
522+ [NL80211_CHAN_WIDTH_80] = {FW_CDBW_80MHZ, TM_CBW_80MHZ},
523+ [NL80211_CHAN_WIDTH_80P80] = {FW_CDBW_8080MHZ, TM_CBW_8080MHZ},
524+ [NL80211_CHAN_WIDTH_160] = {FW_CDBW_160MHZ, TM_CBW_160MHZ},
525+ [NL80211_CHAN_WIDTH_5] = {FW_CDBW_5MHZ, TM_CBW_5MHZ},
526+ [NL80211_CHAN_WIDTH_10] = {FW_CDBW_10MHZ, TM_CBW_10MHZ},
527+ [NL80211_CHAN_WIDTH_20] = {FW_CDBW_20MHZ, TM_CBW_20MHZ},
528+ [NL80211_CHAN_WIDTH_20_NOHT] = {FW_CDBW_20MHZ, TM_CBW_20MHZ},
529+ [NL80211_CHAN_WIDTH_320] = {FW_CDBW_320MHZ, TM_CBW_320MHZ},
530+ };
531+
532+ if (width >= ARRAY_SIZE(width_to_bw))
533+ return 0;
534+
535+ return width_to_bw[width][method];
536+}
537+
538+static u8 mt7996_tm_rate_to_phy(u8 tx_rate_mode)
539+{
540+ static const u8 rate_to_phy[] = {
541+ [MT76_TM_TX_MODE_CCK] = MT_PHY_TYPE_CCK,
542+ [MT76_TM_TX_MODE_OFDM] = MT_PHY_TYPE_OFDM,
543+ [MT76_TM_TX_MODE_HT] = MT_PHY_TYPE_HT,
544+ [MT76_TM_TX_MODE_VHT] = MT_PHY_TYPE_VHT,
545+ [MT76_TM_TX_MODE_HE_SU] = MT_PHY_TYPE_HE_SU,
546+ [MT76_TM_TX_MODE_HE_EXT_SU] = MT_PHY_TYPE_HE_EXT_SU,
547+ [MT76_TM_TX_MODE_HE_TB] = MT_PHY_TYPE_HE_TB,
548+ [MT76_TM_TX_MODE_HE_MU] = MT_PHY_TYPE_HE_MU,
549+ [MT76_TM_TX_MODE_EHT_SU] = MT_PHY_TYPE_EHT_SU,
550+ [MT76_TM_TX_MODE_EHT_TRIG] = MT_PHY_TYPE_EHT_TRIG,
551+ [MT76_TM_TX_MODE_EHT_MU] = MT_PHY_TYPE_EHT_MU,
552+ };
553+
554+ if (tx_rate_mode > MT76_TM_TX_MODE_MAX)
555+ return -EINVAL;
556+
557+ return rate_to_phy[tx_rate_mode];
558+}
559+
560+static int
developer064da3c2023-06-13 15:57:26 +0800561+mt7996_tm_check_antenna(struct mt7996_phy *phy)
562+{
563+ struct mt76_testmode_data *td = &phy->mt76->test;
564+ struct mt7996_dev *dev = phy->dev;
565+ u8 band_idx = phy->mt76->band_idx;
566+ u32 chainmask = phy->mt76->chainmask;
567+ u32 aux_rx_mask;
568+
569+ chainmask = chainmask >> dev->chainshift[band_idx];
570+ aux_rx_mask = BIT(fls(chainmask)) * phy->has_aux_rx;
571+ if (td->tx_antenna_mask & ~(chainmask | aux_rx_mask)) {
572+ dev_err(dev->mt76.dev,
573+ "tx antenna mask 0x%x exceeds hw limit (chainmask 0x%x, has aux rx: %s)\n",
574+ td->tx_antenna_mask, chainmask, phy->has_aux_rx ? "yes" : "no");
575+ return -EINVAL;
576+ }
577+
578+ return 0;
579+}
580+
581+static int
developer1bc2ce22023-03-25 00:47:41 +0800582+mt7996_tm_set(struct mt7996_dev *dev, u32 func_idx, u32 data)
583+{
584+ struct mt7996_tm_req req = {
585+ .rf_test = {
586+ .tag = cpu_to_le16(UNI_RF_TEST_CTRL),
587+ .len = cpu_to_le16(sizeof(req.rf_test)),
588+ .action = RF_ACTION_SET,
589+ .op.rf.func_idx = func_idx,
590+ .op.rf.param.func_data = cpu_to_le32(data),
591+ },
592+ };
593+
594+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_CTRL), &req,
595+ sizeof(req), false);
596+}
597+
598+static int
599+mt7996_tm_get(struct mt7996_dev *dev, u32 func_idx, u32 data, u32 *result)
600+{
601+ struct mt7996_tm_req req = {
602+ .rf_test = {
603+ .tag = cpu_to_le16(UNI_RF_TEST_CTRL),
604+ .len = cpu_to_le16(sizeof(req.rf_test)),
605+ .action = RF_ACTION_GET,
606+ .op.rf.func_idx = func_idx,
607+ .op.rf.param.func_data = cpu_to_le32(data),
608+ },
609+ };
610+ struct mt7996_tm_event *event;
611+ struct sk_buff *skb;
612+ int ret;
613+
614+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(TESTMODE_CTRL),
615+ &req, sizeof(req), true, &skb);
616+ if (ret)
617+ return ret;
618+
619+ event = (struct mt7996_tm_event *)skb->data;
620+ *result = event->result.payload_length;
621+
622+ dev_kfree_skb(skb);
623+
624+ return ret;
625+}
626+
627+static void
628+mt7996_tm_set_antenna(struct mt7996_phy *phy, u32 func_idx)
629+{
630+#define SPE_INDEX_MASK BIT(31)
developer064da3c2023-06-13 15:57:26 +0800631+#define TX_ANTENNA_MASK GENMASK(3, 0)
developer1bc2ce22023-03-25 00:47:41 +0800632+#define RX_ANTENNA_MASK GENMASK(20, 16) /* RX antenna mask at most 5 bit */
633+ struct mt7996_dev *dev = phy->dev;
634+ struct mt76_testmode_data *td = &phy->mt76->test;
developerde9ecce2023-05-22 11:17:16 +0800635+ u32 antenna_mask;
developer1bc2ce22023-03-25 00:47:41 +0800636+
developerde9ecce2023-05-22 11:17:16 +0800637+ if (!mt76_testmode_param_present(td, MT76_TM_ATTR_TX_ANTENNA))
developer1bc2ce22023-03-25 00:47:41 +0800638+ return;
639+
640+ if (func_idx == SET_ID(TX_PATH))
641+ antenna_mask = td->tx_spe_idx ? (SPE_INDEX_MASK | td->tx_spe_idx) :
developer064da3c2023-06-13 15:57:26 +0800642+ td->tx_antenna_mask & TX_ANTENNA_MASK;
developer1bc2ce22023-03-25 00:47:41 +0800643+ else if (func_idx == SET_ID(RX_PATH))
644+ antenna_mask = u32_encode_bits(td->tx_antenna_mask, RX_ANTENNA_MASK);
645+ else
646+ return;
647+
648+ mt7996_tm_set(dev, func_idx, antenna_mask);
649+}
650+
651+static void
652+mt7996_tm_set_mac_addr(struct mt7996_dev *dev, u8 *addr, u32 func_idx)
653+{
654+#define REMAIN_PART_TAG BIT(18)
655+ u32 own_mac_first = 0, own_mac_remain = 0;
656+ int len = sizeof(u32);
657+
658+ memcpy(&own_mac_first, addr, len);
659+ mt7996_tm_set(dev, func_idx, own_mac_first);
660+ /* Set the remain part of mac address */
661+ memcpy(&own_mac_remain, addr + len, ETH_ALEN - len);
662+ mt7996_tm_set(dev, func_idx | REMAIN_PART_TAG, own_mac_remain);
663+}
664+
665+static int
666+mt7996_tm_rf_switch_mode(struct mt7996_dev *dev, u32 op_mode)
667+{
668+ struct mt7996_tm_req req = {
669+ .rf_test = {
670+ .tag = cpu_to_le16(UNI_RF_TEST_CTRL),
671+ .len = cpu_to_le16(sizeof(req.rf_test)),
672+ .action = RF_ACTION_SWITCH_TO_RF_TEST,
673+ .op.op_mode = cpu_to_le32(op_mode),
674+ },
675+ };
676+
677+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_CTRL), &req,
678+ sizeof(req), false);
679+}
680+
681+static void
682+mt7996_tm_init(struct mt7996_phy *phy, bool en)
683+{
684+#define POWER_CTRL(type) UNI_TXPOWER_##type##_CTRL
685+ struct mt7996_dev *dev = phy->dev;
686+ u8 rf_test_mode = en ? RF_OPER_RF_TEST : RF_OPER_NORMAL;
687+
688+ if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
689+ return;
690+
691+ mt7996_mcu_set_tx_power_ctrl(phy, POWER_CTRL(ATE_MODE), en);
692+ mt7996_mcu_set_tx_power_ctrl(phy, POWER_CTRL(SKU_POWER_LIMIT), !en);
693+ mt7996_mcu_set_tx_power_ctrl(phy, POWER_CTRL(PERCENTAGE_DROP), 100);
694+ mt7996_mcu_set_tx_power_ctrl(phy, POWER_CTRL(PERCENTAGE), !en);
695+ mt7996_mcu_set_tx_power_ctrl(phy, POWER_CTRL(BACKOFF_POWER_LIMIT), !en);
696+
697+ mt7996_tm_rf_switch_mode(dev, rf_test_mode);
698+
699+ mt7996_mcu_add_bss_info(phy, phy->monitor_vif, en);
700+ mt7996_mcu_add_sta(dev, phy->monitor_vif, NULL, en);
701+
702+ mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx);
703+
704+ /* use firmware counter for RX stats */
705+ phy->mt76->test.flag |= MT_TM_FW_RX_COUNT;
706+}
707+
708+static void
709+mt7996_tm_update_channel(struct mt7996_phy *phy)
710+{
711+#define CHAN_FREQ_BW_80P80_TAG (SET_ID(CHAN_FREQ) | BIT(16))
712+ struct mt7996_dev *dev = phy->dev;
713+ struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
714+ struct ieee80211_channel *chan = chandef->chan;
715+ u8 width = chandef->width;
716+ static const u8 ch_band[] = {
717+ [NL80211_BAND_2GHZ] = 0,
718+ [NL80211_BAND_5GHZ] = 1,
719+ [NL80211_BAND_6GHZ] = 2,
720+ };
721+
722+ if (!chan || !chandef) {
723+ dev_info(dev->mt76.dev, "chandef not found, channel update failed!\n");
724+ return;
725+ }
726+
727+ /* system bw */
728+ mt7996_tm_set(dev, SET_ID(CBW), mt7996_tm_bw_mapping(width, BW_MAP_NL_TO_FW));
729+
730+ if (width == NL80211_CHAN_WIDTH_80P80) {
731+ width = NL80211_CHAN_WIDTH_160;
732+ mt7996_tm_set(dev, CHAN_FREQ_BW_80P80_TAG, chandef->center_freq2 * 1000);
733+ }
734+
735+ /* TODO: define per-packet bw */
736+ /* per-packet bw */
737+ mt7996_tm_set(dev, SET_ID(DBW), mt7996_tm_bw_mapping(width, BW_MAP_NL_TO_FW));
738+
739+ /* control channel selection index */
740+ mt7996_tm_set(dev, SET_ID(PRIMARY_CH), 0);
741+ mt7996_tm_set(dev, SET_ID(BAND), ch_band[chan->band]);
742+
743+ /* trigger switch channel calibration */
744+ mt7996_tm_set(dev, SET_ID(CHAN_FREQ), chandef->center_freq1 * 1000);
745+
746+ // TODO: update power limit table
747+}
748+
749+static void
750+mt7996_tm_tx_stop(struct mt76_phy *mphy)
751+{
752+ struct mt76_testmode_data *td = &mphy->test;
753+ struct mt7996_phy *phy = mphy->priv;
754+ struct mt7996_dev *dev = phy->dev;
755+
756+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(STOP_TEST));
757+ td->tx_pending = 0;
758+}
759+
760+static void
761+mt7996_tm_set_tx_frames(struct mt7996_phy *phy, bool en)
762+{
763+#define FRAME_CONTROL 0x88
764+ struct mt76_testmode_data *td = &phy->mt76->test;
765+ struct mt7996_dev *dev = phy->dev;
766+
767+ //TODO: RU operation, replace mcs, nss, and ldpc
768+ if (en) {
769+ mt7996_tm_set(dev, SET_ID(MAC_HEADER), FRAME_CONTROL);
770+ mt7996_tm_set(dev, SET_ID(SEQ_CTRL), 0);
771+ mt7996_tm_set(dev, SET_ID(TX_COUNT), td->tx_count);
772+ mt7996_tm_set(dev, SET_ID(TX_MODE), mt7996_tm_rate_to_phy(td->tx_rate_mode));
773+ mt7996_tm_set(dev, SET_ID(TX_RATE), td->tx_rate_idx);
developerde9ecce2023-05-22 11:17:16 +0800774+
775+ if (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER))
776+ mt7996_tm_set(dev, SET_ID(POWER), td->tx_power[0]);
777+
778+ if (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_TIME)) {
779+ mt7996_tm_set(dev, SET_ID(TX_LEN), 0);
780+ mt7996_tm_set(dev, SET_ID(TX_TIME), td->tx_time);
781+ } else {
782+ mt7996_tm_set(dev, SET_ID(TX_LEN), td->tx_mpdu_len);
783+ mt7996_tm_set(dev, SET_ID(TX_TIME), 0);
784+ }
785+
developer1bc2ce22023-03-25 00:47:41 +0800786+ mt7996_tm_set_antenna(phy, SET_ID(TX_PATH));
developer064da3c2023-06-13 15:57:26 +0800787+ mt7996_tm_set_antenna(phy, SET_ID(RX_PATH));
developer1bc2ce22023-03-25 00:47:41 +0800788+ mt7996_tm_set(dev, SET_ID(STBC), td->tx_rate_stbc);
789+ mt7996_tm_set(dev, SET_ID(ENCODE_MODE), td->tx_rate_ldpc);
790+ mt7996_tm_set(dev, SET_ID(IBF_ENABLE), td->ibf);
791+ mt7996_tm_set(dev, SET_ID(EBF_ENABLE), td->ebf);
792+ mt7996_tm_set(dev, SET_ID(IPG), td->tx_ipg);
793+ mt7996_tm_set(dev, SET_ID(GI), td->tx_rate_sgi);
794+ mt7996_tm_set(dev, SET_ID(NSS), td->tx_rate_nss);
795+ mt7996_tm_set(dev, SET_ID(AID_OFFSET), 0);
796+ mt7996_tm_set(dev, SET_ID(PUNCTURE), td->tx_preamble_puncture);
797+
798+ mt7996_tm_set(dev, SET_ID(MAX_PE), 2);
799+ mt7996_tm_set(dev, SET_ID(HW_TX_MODE), 0);
800+ mt7996_tm_update_channel(phy);
801+
802+ /* trigger firmware to start TX */
803+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(START_TX));
804+ } else {
805+ mt7996_tm_tx_stop(phy->mt76);
806+ }
807+}
808+
809+static int
810+mt7996_tm_rx_stats_user_ctrl(struct mt7996_phy *phy, u16 user_idx)
811+{
812+ struct mt7996_dev *dev = phy->dev;
813+ struct mt7996_tm_rx_req req = {
814+ .band = phy->mt76->band_idx,
815+ .user_ctrl = {
816+ .tag = cpu_to_le16(UNI_TM_RX_STAT_SET_USER_CTRL),
817+ .len = cpu_to_le16(sizeof(req.user_ctrl)),
818+ .band_idx = phy->mt76->band_idx,
819+ .user_idx = cpu_to_le16(user_idx),
820+ },
821+ };
822+
823+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_RX_STAT), &req,
824+ sizeof(req), false);
825+}
826+
827+static void
828+mt7996_tm_set_rx_frames(struct mt7996_phy *phy, bool en)
829+{
830+#define RX_MU_DISABLE 0xf800
831+ struct mt76_testmode_data *td = &phy->mt76->test;
832+ struct mt7996_dev *dev = phy->dev;
833+ int ret;
834+
835+ if (en) {
836+ ret = mt7996_tm_rx_stats_user_ctrl(phy, td->aid);
837+ if (ret) {
838+ dev_info(dev->mt76.dev, "Set RX stats user control failed!\n");
839+ return;
840+ }
841+
842+ mt7996_tm_update_channel(phy);
843+
844+ if (td->tx_rate_mode >= MT76_TM_TX_MODE_HE_MU) {
845+ if (td->aid)
846+ ret = mt7996_tm_set(dev, SET_ID(RX_MU_AID), td->aid);
847+ else
848+ ret = mt7996_tm_set(dev, SET_ID(RX_MU_AID), RX_MU_DISABLE);
849+ }
850+ mt7996_tm_set(dev, SET_ID(TX_MODE), mt7996_tm_rate_to_phy(td->tx_rate_mode));
851+ mt7996_tm_set(dev, SET_ID(GI), td->tx_rate_sgi);
852+ mt7996_tm_set_antenna(phy, SET_ID(RX_PATH));
853+ mt7996_tm_set(dev, SET_ID(MAX_PE), 2);
854+
855+ mt7996_tm_set_mac_addr(dev, td->addr[1], SET_ID(SA));
856+
857+ /* trigger firmware to start RX */
858+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(START_RX));
859+ } else {
860+ /* trigger firmware to stop RX */
861+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(STOP_TEST));
862+ }
863+}
864+
865+static void
866+mt7996_tm_set_tx_cont(struct mt7996_phy *phy, bool en)
867+{
868+#define CONT_WAVE_MODE_OFDM 3
869+ struct mt76_testmode_data *td = &phy->mt76->test;
870+ struct mt7996_dev *dev = phy->dev;
871+
872+ if (en) {
873+ mt7996_tm_update_channel(phy);
874+ mt7996_tm_set(dev, SET_ID(TX_MODE), mt7996_tm_rate_to_phy(td->tx_rate_mode));
875+ mt7996_tm_set(dev, SET_ID(TX_RATE), td->tx_rate_idx);
876+ /* fix payload is OFDM */
877+ mt7996_tm_set(dev, SET_ID(CONT_WAVE_MODE), CONT_WAVE_MODE_OFDM);
878+ mt7996_tm_set(dev, SET_ID(ANT_MASK), td->tx_antenna_mask);
879+
880+ /* trigger firmware to start CONT TX */
881+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(CONT_WAVE));
882+ } else {
883+ /* trigger firmware to stop CONT TX */
884+ mt7996_tm_set(dev, SET_ID(COMMAND), RF_CMD(STOP_TEST));
885+ }
886+}
887+
888+static void
889+mt7996_tm_update_params(struct mt7996_phy *phy, u32 changed)
890+{
891+ struct mt76_testmode_data *td = &phy->mt76->test;
892+ struct mt7996_dev *dev = phy->dev;
893+ bool en = td->state != MT76_TM_STATE_OFF;
894+
895+ if (changed & BIT(TM_CHANGED_FREQ_OFFSET))
896+ mt7996_tm_set(dev, SET_ID(FREQ_OFFSET), en ? td->freq_offset : 0);
897+ if (changed & BIT(TM_CHANGED_TXPOWER))
898+ mt7996_tm_set(dev, SET_ID(POWER), td->tx_power[0]);
899+ if (changed & BIT(TM_CHANGED_TX_LENGTH)) {
900+ mt7996_tm_set(dev, SET_ID(TX_LEN), td->tx_mpdu_len);
901+ mt7996_tm_set(dev, SET_ID(TX_TIME), 0);
902+ }
903+ if (changed & BIT(TM_CHANGED_TX_TIME)) {
904+ mt7996_tm_set(dev, SET_ID(TX_LEN), 0);
905+ mt7996_tm_set(dev, SET_ID(TX_TIME), td->tx_time);
906+ }
developerde9ecce2023-05-22 11:17:16 +0800907+ if (changed & BIT(TM_CHANGED_CFG)) {
908+ u32 func_idx = td->cfg.enable ? SET_ID(CFG_ON) : SET_ID(CFG_OFF);
909+
910+ mt7996_tm_set(dev, func_idx, td->cfg.type);
911+ }
developer1bc2ce22023-03-25 00:47:41 +0800912+}
913+
914+static int
915+mt7996_tm_set_state(struct mt76_phy *mphy, enum mt76_testmode_state state)
916+{
917+ struct mt76_testmode_data *td = &mphy->test;
918+ struct mt7996_phy *phy = mphy->priv;
919+ enum mt76_testmode_state prev_state = td->state;
920+
921+ mphy->test.state = state;
922+
923+ if (prev_state != MT76_TM_STATE_OFF)
924+ mt7996_tm_set(phy->dev, SET_ID(BAND_IDX), mphy->band_idx);
925+
926+ if (prev_state == MT76_TM_STATE_TX_FRAMES ||
927+ state == MT76_TM_STATE_TX_FRAMES)
928+ mt7996_tm_set_tx_frames(phy, state == MT76_TM_STATE_TX_FRAMES);
929+ else if (prev_state == MT76_TM_STATE_RX_FRAMES ||
930+ state == MT76_TM_STATE_RX_FRAMES)
931+ mt7996_tm_set_rx_frames(phy, state == MT76_TM_STATE_RX_FRAMES);
932+ else if (prev_state == MT76_TM_STATE_TX_CONT ||
933+ state == MT76_TM_STATE_TX_CONT)
934+ mt7996_tm_set_tx_cont(phy, state == MT76_TM_STATE_TX_CONT);
935+ else if (prev_state == MT76_TM_STATE_OFF ||
936+ state == MT76_TM_STATE_OFF)
937+ mt7996_tm_init(phy, !(state == MT76_TM_STATE_OFF));
938+
939+ if ((state == MT76_TM_STATE_IDLE &&
940+ prev_state == MT76_TM_STATE_OFF) ||
941+ (state == MT76_TM_STATE_OFF &&
942+ prev_state == MT76_TM_STATE_IDLE)) {
943+ u32 changed = 0;
developer064da3c2023-06-13 15:57:26 +0800944+ int i, ret;
developer1bc2ce22023-03-25 00:47:41 +0800945+
946+ for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
947+ u16 cur = tm_change_map[i];
948+
developerde9ecce2023-05-22 11:17:16 +0800949+ if (mt76_testmode_param_present(td, cur))
developer1bc2ce22023-03-25 00:47:41 +0800950+ changed |= BIT(i);
951+ }
952+
developer064da3c2023-06-13 15:57:26 +0800953+ ret = mt7996_tm_check_antenna(phy);
954+ if (ret)
955+ return ret;
956+
developer1bc2ce22023-03-25 00:47:41 +0800957+ mt7996_tm_update_params(phy, changed);
958+ }
959+
960+ return 0;
961+}
962+
963+static int
964+mt7996_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
965+ enum mt76_testmode_state new_state)
966+{
967+ struct mt76_testmode_data *td = &mphy->test;
968+ struct mt7996_phy *phy = mphy->priv;
969+ struct mt7996_dev *dev = phy->dev;
developer064da3c2023-06-13 15:57:26 +0800970+ u32 changed = 0;
971+ int i, ret;
developer1bc2ce22023-03-25 00:47:41 +0800972+
973+ BUILD_BUG_ON(NUM_TM_CHANGED >= 32);
974+
975+ if (new_state == MT76_TM_STATE_OFF ||
976+ td->state == MT76_TM_STATE_OFF)
977+ return 0;
978+
developer064da3c2023-06-13 15:57:26 +0800979+ ret = mt7996_tm_check_antenna(phy);
980+ if (ret)
981+ return ret;
developer1bc2ce22023-03-25 00:47:41 +0800982+
983+ for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
984+ if (tb[tm_change_map[i]])
985+ changed |= BIT(i);
986+ }
987+
988+ mt7996_tm_set(dev, SET_ID(BAND_IDX), mphy->band_idx);
989+ mt7996_tm_update_params(phy, changed);
990+
991+ return 0;
992+}
993+
994+static int
995+mt7996_tm_get_rx_stats(struct mt7996_phy *phy)
996+{
997+ struct mt7996_dev *dev = phy->dev;
998+ struct mt7996_tm_rx_req req = {
999+ .band = phy->mt76->band_idx,
1000+ .rx_stat_all = {
1001+ .tag = cpu_to_le16(UNI_TM_RX_STAT_GET_ALL_V2),
1002+ .len = cpu_to_le16(sizeof(req.rx_stat_all)),
1003+ .band_idx = phy->mt76->band_idx,
1004+ },
1005+ };
1006+ struct mt76_testmode_data *td = &phy->mt76->test;
1007+ struct mt7996_tm_rx_event *rx_stats;
1008+ struct mt7996_tm_rx_event_stat_all *rx_stats_all;
1009+ struct sk_buff *skb;
1010+ enum mt76_rxq_id qid;
1011+ int i, ret = 0;
1012+ u32 mac_rx_mdrdy_cnt;
1013+ u16 mac_rx_len_mismatch, fcs_err_count;
1014+
1015+ if (td->state != MT76_TM_STATE_RX_FRAMES)
1016+ return 0;
1017+
1018+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(TESTMODE_RX_STAT),
1019+ &req, sizeof(req), true, &skb);
1020+
1021+ if (ret)
1022+ return ret;
1023+
1024+ rx_stats = (struct mt7996_tm_rx_event *)skb->data;
1025+ rx_stats_all = &rx_stats->rx_stat_all;
1026+
1027+ phy->test.last_freq_offset = le32_to_cpu(rx_stats_all->user_info[0].freq_offset);
1028+ phy->test.last_snr = le32_to_cpu(rx_stats_all->user_info[0].snr);
1029+ for (i = 0; i < ARRAY_SIZE(phy->test.last_rcpi); i++) {
1030+ phy->test.last_rcpi[i] = le16_to_cpu(rx_stats_all->rxv_info[i].rcpi);
1031+ phy->test.last_ib_rssi[i] = rx_stats_all->fagc[i].ib_rssi;
1032+ phy->test.last_wb_rssi[i] = rx_stats_all->fagc[i].wb_rssi;
1033+ }
1034+
1035+ if (phy->mt76->band_idx == 2)
1036+ qid = MT_RXQ_BAND2;
1037+ else if (phy->mt76->band_idx == 1)
1038+ qid = MT_RXQ_BAND1;
1039+ else
1040+ qid = MT_RXQ_MAIN;
1041+
1042+ fcs_err_count = le16_to_cpu(rx_stats_all->band_info.mac_rx_fcs_err_cnt);
1043+ mac_rx_len_mismatch = le16_to_cpu(rx_stats_all->band_info.mac_rx_len_mismatch);
1044+ mac_rx_mdrdy_cnt = le32_to_cpu(rx_stats_all->band_info.mac_rx_mdrdy_cnt);
1045+ td->rx_stats.packets[qid] += mac_rx_mdrdy_cnt;
1046+ td->rx_stats.packets[qid] += fcs_err_count;
1047+ td->rx_stats.fcs_error[qid] += fcs_err_count;
1048+ td->rx_stats.len_mismatch += mac_rx_len_mismatch;
1049+
1050+ dev_kfree_skb(skb);
1051+
1052+ return ret;
1053+}
1054+
1055+static void
developerde9ecce2023-05-22 11:17:16 +08001056+mt7996_tm_reset_trx_stats(struct mt76_phy *mphy)
developer1bc2ce22023-03-25 00:47:41 +08001057+{
1058+ struct mt7996_phy *phy = mphy->priv;
1059+ struct mt7996_dev *dev = phy->dev;
1060+
1061+ memset(&mphy->test.rx_stats, 0, sizeof(mphy->test.rx_stats));
1062+ mt7996_tm_set(dev, SET_ID(TRX_COUNTER_RESET), 0);
1063+}
1064+
1065+static int
1066+mt7996_tm_get_tx_stats(struct mt7996_phy *phy)
1067+{
1068+ struct mt7996_dev *dev = phy->dev;
1069+ struct mt76_testmode_data *td = &phy->mt76->test;
1070+ int ret;
1071+
1072+ if (td->state != MT76_TM_STATE_TX_FRAMES)
1073+ return 0;
1074+
1075+ ret = mt7996_tm_get(dev, GET_ID(TXED_COUNT), 0, &td->tx_done);
1076+ if (ret)
1077+ return ret;
1078+
1079+ td->tx_pending = td->tx_count - td->tx_done;
1080+
1081+ return ret;
1082+}
1083+
1084+static int
1085+mt7996_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
1086+{
1087+ struct mt7996_phy *phy = mphy->priv;
1088+ void *rx, *rssi;
1089+ int i;
1090+
1091+ mt7996_tm_set(phy->dev, SET_ID(BAND_IDX), mphy->band_idx);
1092+ mt7996_tm_get_rx_stats(phy);
1093+ mt7996_tm_get_tx_stats(phy);
1094+
1095+ rx = nla_nest_start(msg, MT76_TM_STATS_ATTR_LAST_RX);
1096+ if (!rx)
1097+ return -ENOMEM;
1098+
1099+ if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, phy->test.last_freq_offset))
1100+ return -ENOMEM;
1101+
1102+ rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_RCPI);
1103+ if (!rssi)
1104+ return -ENOMEM;
1105+
1106+ for (i = 0; i < ARRAY_SIZE(phy->test.last_rcpi); i++)
1107+ if (nla_put_u8(msg, i, phy->test.last_rcpi[i]))
1108+ return -ENOMEM;
1109+
1110+ nla_nest_end(msg, rssi);
1111+
1112+ rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_IB_RSSI);
1113+ if (!rssi)
1114+ return -ENOMEM;
1115+
1116+ for (i = 0; i < ARRAY_SIZE(phy->test.last_ib_rssi); i++)
1117+ if (nla_put_s8(msg, i, phy->test.last_ib_rssi[i]))
1118+ return -ENOMEM;
1119+
1120+ nla_nest_end(msg, rssi);
1121+
1122+ rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_WB_RSSI);
1123+ if (!rssi)
1124+ return -ENOMEM;
1125+
1126+ for (i = 0; i < ARRAY_SIZE(phy->test.last_wb_rssi); i++)
1127+ if (nla_put_s8(msg, i, phy->test.last_wb_rssi[i]))
1128+ return -ENOMEM;
1129+
1130+ nla_nest_end(msg, rssi);
1131+
1132+ if (nla_put_u8(msg, MT76_TM_RX_ATTR_SNR, phy->test.last_snr))
1133+ return -ENOMEM;
1134+
1135+ nla_nest_end(msg, rx);
1136+
1137+ return 0;
1138+}
1139+
1140+const struct mt76_testmode_ops mt7996_testmode_ops = {
1141+ .set_state = mt7996_tm_set_state,
1142+ .set_params = mt7996_tm_set_params,
1143+ .dump_stats = mt7996_tm_dump_stats,
developerde9ecce2023-05-22 11:17:16 +08001144+ .reset_rx_stats = mt7996_tm_reset_trx_stats,
developer1bc2ce22023-03-25 00:47:41 +08001145+ .tx_stop = mt7996_tm_tx_stop,
1146+};
1147diff --git a/mt7996/testmode.h b/mt7996/testmode.h
1148new file mode 100644
developer064da3c2023-06-13 15:57:26 +08001149index 0000000..f00e51f
developer1bc2ce22023-03-25 00:47:41 +08001150--- /dev/null
1151+++ b/mt7996/testmode.h
developerde9ecce2023-05-22 11:17:16 +08001152@@ -0,0 +1,295 @@
developer1bc2ce22023-03-25 00:47:41 +08001153+/* SPDX-License-Identifier: ISC */
1154+/* Copyright (C) 2020 MediaTek Inc. */
1155+
1156+#ifndef __MT7996_TESTMODE_H
1157+#define __MT7996_TESTMODE_H
1158+
1159+enum {
1160+ TM_CBW_20MHZ,
1161+ TM_CBW_40MHZ,
1162+ TM_CBW_80MHZ,
1163+ TM_CBW_10MHZ,
1164+ TM_CBW_5MHZ,
1165+ TM_CBW_160MHZ,
1166+ TM_CBW_8080MHZ,
1167+ TM_CBW_320MHZ = 12,
1168+};
1169+
1170+/* BW defined in FW hal_cal_flow_rom.h */
1171+enum {
1172+ FW_CDBW_20MHZ,
1173+ FW_CDBW_40MHZ,
1174+ FW_CDBW_80MHZ,
1175+ FW_CDBW_160MHZ,
1176+ FW_CDBW_320MHZ,
1177+ FW_CDBW_5MHZ,
1178+ FW_CDBW_10MHZ,
1179+ FW_CDBW_8080MHZ,
1180+};
1181+
1182+enum bw_mapping_method {
1183+ BW_MAP_NL_TO_FW,
1184+ BW_MAP_NL_TO_TM,
1185+
1186+ NUM_BW_MAP,
1187+};
1188+
1189+struct mt7996_tm_rf_test {
1190+ __le16 tag;
1191+ __le16 len;
1192+
1193+ u8 action;
1194+ u8 icap_len;
1195+ u8 _rsv[2];
1196+ union {
1197+ __le32 op_mode;
1198+ __le32 freq;
1199+
1200+ struct {
1201+ __le32 func_idx;
1202+ union {
1203+ __le32 func_data;
1204+ __le32 cal_dump;
1205+
1206+ u8 _pad[80];
1207+ } param;
1208+ } rf;
1209+ } op;
1210+} __packed;
1211+
1212+struct mt7996_tm_req {
1213+ u8 _rsv[4];
1214+
1215+ struct mt7996_tm_rf_test rf_test;
1216+} __packed;
1217+
1218+struct mt7996_tm_rf_test_result {
1219+ __le32 func_idx;
1220+ __le32 payload_length;
1221+ u8 event[0];
1222+};
1223+
1224+struct mt7996_tm_event {
1225+ u8 _rsv[4];
1226+
1227+ __le16 tag;
1228+ __le16 len;
1229+ struct mt7996_tm_rf_test_result result;
1230+} __packed;
1231+
1232+enum {
1233+ RF_ACTION_SWITCH_TO_RF_TEST,
1234+ RF_ACTION_IN_RF_TEST,
1235+ RF_ACTION_SET = 3,
1236+ RF_ACTION_GET,
1237+};
1238+
1239+enum {
1240+ RF_OPER_NORMAL,
1241+ RF_OPER_RF_TEST,
1242+ RF_OPER_ICAP,
1243+ RF_OPER_ICAP_OVERLAP,
1244+ RF_OPER_WIFI_SPECTRUM,
1245+};
1246+
1247+enum {
1248+ UNI_RF_TEST_CTRL,
1249+};
1250+
1251+#define RF_CMD(cmd) RF_TEST_CMD_##cmd
1252+
1253+enum {
1254+ RF_TEST_CMD_STOP_TEST = 0,
1255+ RF_TEST_CMD_START_TX = 1,
1256+ RF_TEST_CMD_START_RX = 2,
1257+ RF_TEST_CMD_CONT_WAVE = 10,
1258+ RF_TEST_CMD_TX_COMMIT = 18,
1259+ RF_TEST_CMD_RX_COMMIT = 19,
1260+};
1261+
1262+#define SET_ID(id) RF_TEST_ID_SET_##id
1263+#define GET_ID(id) RF_TEST_ID_GET_##id
1264+
1265+enum {
1266+ RF_TEST_ID_SET_COMMAND = 1,
1267+ RF_TEST_ID_SET_POWER = 2,
1268+ RF_TEST_ID_SET_TX_RATE = 3,
1269+ RF_TEST_ID_SET_TX_MODE = 4,
1270+ RF_TEST_ID_SET_TX_LEN = 6,
1271+ RF_TEST_ID_SET_TX_COUNT = 7,
1272+ RF_TEST_ID_SET_IPG = 8,
1273+ RF_TEST_ID_SET_GI = 16,
1274+ RF_TEST_ID_SET_STBC = 17,
1275+ RF_TEST_ID_SET_CHAN_FREQ = 18,
1276+ RF_TEST_ID_GET_TXED_COUNT = 32,
1277+ RF_TEST_ID_SET_CONT_WAVE_MODE = 65,
1278+ RF_TEST_ID_SET_DA = 68,
1279+ RF_TEST_ID_SET_SA = 69,
1280+ RF_TEST_ID_SET_CBW = 71,
1281+ RF_TEST_ID_SET_DBW = 72,
1282+ RF_TEST_ID_SET_PRIMARY_CH = 73,
1283+ RF_TEST_ID_SET_ENCODE_MODE = 74,
1284+ RF_TEST_ID_SET_BAND = 90,
1285+ RF_TEST_ID_SET_TRX_COUNTER_RESET = 91,
1286+ RF_TEST_ID_SET_MAC_HEADER = 101,
1287+ RF_TEST_ID_SET_SEQ_CTRL = 102,
developerde9ecce2023-05-22 11:17:16 +08001288+ RF_TEST_ID_SET_PAYLOAD = 103,
developer1bc2ce22023-03-25 00:47:41 +08001289+ RF_TEST_ID_SET_BAND_IDX = 104,
1290+ RF_TEST_ID_SET_RX_PATH = 106,
1291+ RF_TEST_ID_SET_FREQ_OFFSET = 107,
1292+ RF_TEST_ID_GET_FREQ_OFFSET = 108,
1293+ RF_TEST_ID_SET_TX_PATH = 113,
1294+ RF_TEST_ID_SET_NSS = 114,
1295+ RF_TEST_ID_SET_ANT_MASK = 115,
1296+ RF_TEST_ID_SET_IBF_ENABLE = 126,
1297+ RF_TEST_ID_SET_EBF_ENABLE = 127,
1298+ RF_TEST_ID_GET_TX_POWER = 136,
1299+ RF_TEST_ID_SET_RX_MU_AID = 157,
1300+ RF_TEST_ID_SET_HW_TX_MODE = 167,
1301+ RF_TEST_ID_SET_PUNCTURE = 168,
developerde9ecce2023-05-22 11:17:16 +08001302+ RF_TEST_ID_SET_CFG_ON = 176,
1303+ RF_TEST_ID_SET_CFG_OFF = 177,
developer1bc2ce22023-03-25 00:47:41 +08001304+ RF_TEST_ID_SET_BSSID = 189,
1305+ RF_TEST_ID_SET_TX_TIME = 190,
1306+ RF_TEST_ID_SET_MAX_PE = 191,
1307+ RF_TEST_ID_SET_AID_OFFSET = 204,
1308+};
1309+
1310+struct mt7996_tm_rx_stat_user_ctrl {
1311+ __le16 tag;
1312+ __le16 len;
1313+
1314+ u8 band_idx;
1315+ u8 rsv;
1316+ __le16 user_idx;
1317+} __packed;
1318+
1319+struct mt7996_tm_rx_stat_all {
1320+ __le16 tag;
1321+ __le16 len;
1322+
1323+ u8 band_idx;
1324+ u8 rsv[3];
1325+} __packed;
1326+
1327+struct mt7996_tm_rx_req {
1328+ u8 band;
1329+ u8 _rsv[3];
1330+
1331+ union {
1332+ struct mt7996_tm_rx_stat_user_ctrl user_ctrl;
1333+ struct mt7996_tm_rx_stat_all rx_stat_all;
1334+ };
1335+} __packed;
1336+
1337+enum {
1338+ UNI_TM_RX_STAT_SET_USER_CTRL = 7,
1339+ UNI_TM_RX_STAT_GET_ALL_V2 = 9,
1340+};
1341+
1342+struct rx_band_info {
1343+ /* mac part */
1344+ __le16 mac_rx_fcs_err_cnt;
1345+ __le16 mac_rx_len_mismatch;
1346+ __le16 mac_rx_fcs_ok_cnt;
1347+ u8 rsv1[2];
1348+ __le32 mac_rx_mdrdy_cnt;
1349+
1350+ /* phy part */
1351+ __le16 phy_rx_fcs_err_cnt_cck;
1352+ __le16 phy_rx_fcs_err_cnt_ofdm;
1353+ __le16 phy_rx_pd_cck;
1354+ __le16 phy_rx_pd_ofdm;
1355+ __le16 phy_rx_sig_err_cck;
1356+ __le16 phy_rx_sfd_err_cck;
1357+ __le16 phy_rx_sig_err_ofdm;
1358+ __le16 phy_rx_tag_err_ofdm;
1359+ __le16 phy_rx_mdrdy_cnt_cck;
1360+ __le16 phy_rx_mdrdy_cnt_ofdm;
1361+} __packed;
1362+
1363+struct rx_band_info_ext {
1364+ /* mac part */
1365+ __le32 mac_rx_mpdu_cnt;
1366+
1367+ /* phy part */
1368+ u8 rsv[4];
1369+} __packed;
1370+
1371+struct rx_common_info {
1372+ __le16 rx_fifo_full;
1373+ u8 rsv[2];
1374+ __le32 aci_hit_low;
1375+ __le32 aci_hit_high;
1376+} __packed;
1377+
1378+struct rx_common_info_ext {
1379+ __le32 driver_rx_count;
1380+ __le32 sinr;
1381+ __le32 mu_pkt_count;
1382+
1383+ /* mac part */
1384+ u8 _rsv[4];
1385+
1386+ /* phy part */
1387+ u8 sig_mcs;
1388+ u8 rsv[3];
1389+} __packed;
1390+
1391+struct rx_rxv_info {
1392+ __le16 rcpi;
1393+ s16 rssi;
1394+ s16 snr;
1395+ s16 adc_rssi;
1396+} __packed;
1397+
1398+struct rx_rssi_info {
1399+ s8 ib_rssi;
1400+ s8 wb_rssi;
1401+ u8 rsv[2];
1402+} __packed;
1403+
1404+struct rx_user_info {
1405+ s32 freq_offset;
1406+ s32 snr;
1407+ __le32 fcs_err_count;
1408+} __packed;
1409+
1410+struct rx_user_info_ext {
1411+ s8 ne_var_db_all_user;
1412+ u8 rsv[3];
1413+} __packed;
1414+
1415+#define MAX_ANTENNA_NUM 8
1416+#define MAX_USER_NUM 16
1417+
1418+struct mt7996_tm_rx_event_stat_all {
1419+ __le16 tag;
1420+ __le16 len;
1421+
1422+ struct rx_band_info band_info;
1423+ struct rx_band_info_ext band_info_ext;
1424+ struct rx_common_info common_info;
1425+ struct rx_common_info_ext common_info_ext;
1426+
1427+ /* RXV info */
1428+ struct rx_rxv_info rxv_info[MAX_ANTENNA_NUM];
1429+
1430+ /* RSSI info */
1431+ struct rx_rssi_info fagc[MAX_ANTENNA_NUM];
1432+ struct rx_rssi_info inst[MAX_ANTENNA_NUM];
1433+
1434+ /* User info */
1435+ struct rx_user_info user_info[MAX_USER_NUM];
1436+ struct rx_user_info_ext user_info_ext[MAX_USER_NUM];
1437+} __packed;
1438+
1439+struct mt7996_tm_rx_event {
1440+ u8 _rsv[4];
1441+
1442+ union {
1443+ struct mt7996_tm_rx_event_stat_all rx_stat_all;
1444+ };
1445+} __packed;
1446+
1447+#endif
1448diff --git a/testmode.c b/testmode.c
developer064da3c2023-06-13 15:57:26 +08001449index 0d2bae9..fc68c2a 100644
developer1bc2ce22023-03-25 00:47:41 +08001450--- a/testmode.c
1451+++ b/testmode.c
1452@@ -2,6 +2,7 @@
1453 /* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */
1454
1455 #include <linux/random.h>
1456+#include "mt76_connac.h"
1457 #include "mt76.h"
1458
1459 const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
1460@@ -81,6 +82,11 @@ mt76_testmode_max_mpdu_len(struct mt76_phy *phy, u8 tx_rate_mode)
1461 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991)
1462 return IEEE80211_MAX_MPDU_LEN_VHT_7991;
1463 return IEEE80211_MAX_MPDU_LEN_VHT_11454;
1464+ case MT76_TM_TX_MODE_EHT_SU:
1465+ case MT76_TM_TX_MODE_EHT_TRIG:
1466+ case MT76_TM_TX_MODE_EHT_MU:
1467+ /* TODO: check the limit */
1468+ return UINT_MAX;
1469 case MT76_TM_TX_MODE_CCK:
1470 case MT76_TM_TX_MODE_OFDM:
1471 default:
1472@@ -182,6 +188,9 @@ mt76_testmode_tx_init(struct mt76_phy *phy)
1473 u8 max_nss = hweight8(phy->antenna_mask);
1474 int ret;
1475
1476+ if (is_mt7996(phy->dev))
1477+ return 0;
1478+
1479 ret = mt76_testmode_alloc_skb(phy, td->tx_mpdu_len);
1480 if (ret)
1481 return ret;
1482@@ -274,7 +283,9 @@ mt76_testmode_tx_start(struct mt76_phy *phy)
1483 td->tx_queued = 0;
1484 td->tx_done = 0;
1485 td->tx_pending = td->tx_count;
1486- mt76_worker_schedule(&dev->tx_worker);
1487+
1488+ if (!is_mt7996(dev))
1489+ mt76_worker_schedule(&dev->tx_worker);
1490 }
1491
1492 static void
1493@@ -283,6 +294,11 @@ mt76_testmode_tx_stop(struct mt76_phy *phy)
1494 struct mt76_testmode_data *td = &phy->test;
1495 struct mt76_dev *dev = phy->dev;
1496
1497+ if (is_mt7996(dev) && dev->test_ops->tx_stop) {
1498+ dev->test_ops->tx_stop(phy);
1499+ return;
1500+ }
1501+
1502 mt76_worker_disable(&dev->tx_worker);
1503
1504 td->tx_pending = 0;
developerde9ecce2023-05-22 11:17:16 +08001505@@ -295,22 +311,11 @@ mt76_testmode_tx_stop(struct mt76_phy *phy)
1506 mt76_testmode_free_skb(phy);
1507 }
1508
1509-static inline void
1510-mt76_testmode_param_set(struct mt76_testmode_data *td, u16 idx)
1511-{
1512- td->param_set[idx / 32] |= BIT(idx % 32);
1513-}
1514-
1515-static inline bool
1516-mt76_testmode_param_present(struct mt76_testmode_data *td, u16 idx)
1517-{
1518- return td->param_set[idx / 32] & BIT(idx % 32);
1519-}
1520-
1521 static void
developer1bc2ce22023-03-25 00:47:41 +08001522 mt76_testmode_init_defaults(struct mt76_phy *phy)
1523 {
1524 struct mt76_testmode_data *td = &phy->test;
1525+ u8 addr[ETH_ALEN] = {phy->band_idx, 0x11, 0x22, 0xaa, 0xbb, 0xcc};
1526
1527 if (td->tx_mpdu_len > 0)
1528 return;
developerde9ecce2023-05-22 11:17:16 +08001529@@ -318,11 +323,18 @@ mt76_testmode_init_defaults(struct mt76_phy *phy)
developer1bc2ce22023-03-25 00:47:41 +08001530 td->tx_mpdu_len = 1024;
1531 td->tx_count = 1;
1532 td->tx_rate_mode = MT76_TM_TX_MODE_OFDM;
1533+ td->tx_rate_idx = 7;
1534 td->tx_rate_nss = 1;
1535+ /* 0xffff for OFDMA no puncture */
1536+ td->tx_preamble_puncture = ~(td->tx_preamble_puncture & 0);
1537+ td->tx_ipg = 50;
developerde9ecce2023-05-22 11:17:16 +08001538+
1539+ /* rx stat user config */
1540+ td->aid = 1;
developer1bc2ce22023-03-25 00:47:41 +08001541
1542- memcpy(td->addr[0], phy->macaddr, ETH_ALEN);
1543- memcpy(td->addr[1], phy->macaddr, ETH_ALEN);
1544- memcpy(td->addr[2], phy->macaddr, ETH_ALEN);
developer1bc2ce22023-03-25 00:47:41 +08001545+ memcpy(td->addr[0], addr, ETH_ALEN);
1546+ memcpy(td->addr[1], addr, ETH_ALEN);
1547+ memcpy(td->addr[2], addr, ETH_ALEN);
1548 }
1549
1550 static int
developerde9ecce2023-05-22 11:17:16 +08001551@@ -352,7 +364,7 @@ __mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state)
developer1bc2ce22023-03-25 00:47:41 +08001552 if (state == MT76_TM_STATE_TX_FRAMES)
1553 mt76_testmode_tx_start(phy);
1554 else if (state == MT76_TM_STATE_RX_FRAMES) {
1555- memset(&phy->test.rx_stats, 0, sizeof(phy->test.rx_stats));
1556+ dev->test_ops->reset_rx_stats(phy);
1557 }
1558
1559 phy->test.state = state;
developerde9ecce2023-05-22 11:17:16 +08001560@@ -453,7 +465,8 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer1bc2ce22023-03-25 00:47:41 +08001561 mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_DUTY_CYCLE],
1562 &td->tx_duty_cycle, 0, 99) ||
1563 mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_POWER_CONTROL],
1564- &td->tx_power_control, 0, 1))
1565+ &td->tx_power_control, 0, 1) ||
1566+ mt76_tm_get_u8(tb[MT76_TM_ATTR_AID], &td->aid, 0, 16))
1567 goto out;
1568
1569 if (tb[MT76_TM_ATTR_TX_LENGTH]) {
developerde9ecce2023-05-22 11:17:16 +08001570@@ -493,7 +506,9 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer1bc2ce22023-03-25 00:47:41 +08001571 idx >= ARRAY_SIZE(td->tx_power))
1572 goto out;
1573
1574- td->tx_power[idx++] = nla_get_u8(cur);
1575+ err = mt76_tm_get_u8(cur, &td->tx_power[idx++], 0, 63);
1576+ if (err)
1577+ return err;
1578 }
1579 }
1580
developerde9ecce2023-05-22 11:17:16 +08001581@@ -511,6 +526,22 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1582 }
1583 }
1584
1585+ if (tb[MT76_TM_ATTR_CFG]) {
1586+ struct nlattr *cur;
1587+ int rem, idx = 0;
1588+
1589+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_CFG], rem) {
1590+ if (nla_len(cur) != 1 || idx >= 2)
1591+ goto out;
1592+
1593+ if (idx == 0)
1594+ td->cfg.type = nla_get_u8(cur);
1595+ else
1596+ td->cfg.enable = nla_get_u8(cur);
1597+ idx++;
1598+ }
1599+ }
1600+
1601 if (dev->test_ops->set_params) {
1602 err = dev->test_ops->set_params(phy, tb, state);
1603 if (err)
1604@@ -560,6 +591,9 @@ mt76_testmode_dump_stats(struct mt76_phy *phy, struct sk_buff *msg)
developer1bc2ce22023-03-25 00:47:41 +08001605 nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_PACKETS, rx_packets,
1606 MT76_TM_STATS_ATTR_PAD) ||
1607 nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_FCS_ERROR, rx_fcs_error,
1608+ MT76_TM_STATS_ATTR_PAD) ||
1609+ nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_LEN_MISMATCH,
1610+ td->rx_stats.len_mismatch,
1611 MT76_TM_STATS_ATTR_PAD))
1612 return -EMSGSIZE;
1613
developerde9ecce2023-05-22 11:17:16 +08001614@@ -624,6 +658,7 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
developer1bc2ce22023-03-25 00:47:41 +08001615 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_SGI, td->tx_rate_sgi) ||
1616 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_LDPC, td->tx_rate_ldpc) ||
1617 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_STBC, td->tx_rate_stbc) ||
1618+ nla_put_u8(msg, MT76_TM_ATTR_AID, td->aid) ||
1619 (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_LTF) &&
1620 nla_put_u8(msg, MT76_TM_ATTR_TX_LTF, td->tx_ltf)) ||
1621 (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_ANTENNA) &&
1622diff --git a/testmode.h b/testmode.h
developer064da3c2023-06-13 15:57:26 +08001623index a40cd74..8d0b970 100644
developer1bc2ce22023-03-25 00:47:41 +08001624--- a/testmode.h
1625+++ b/testmode.h
1626@@ -39,6 +39,11 @@
1627 *
1628 * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
1629 *
1630+ * @MT76_TM_ATTR_PRECAL: Pre-cal data (u8)
1631+ * @MT76_TM_ATTR_PRECAL_INFO: group size, dpd size, dpd_info, transmit size,
1632+ * eeprom cal indicator (u32),
1633+ * dpd_info = [dpd_per_chan_size, chan_num_2g,
1634+ * chan_num_5g, chan_num_6g]
1635 * @MT76_TM_ATTR_TX_SPE_IDX: tx spatial extension index (u8)
1636 *
1637 * @MT76_TM_ATTR_TX_DUTY_CYCLE: packet tx duty cycle (u8)
1638@@ -48,6 +53,29 @@
1639 * @MT76_TM_ATTR_DRV_DATA: driver specific netlink attrs (nested)
1640 *
1641 * @MT76_TM_ATTR_MAC_ADDRS: array of nested MAC addresses (nested)
1642+ *
1643+ * @MT76_TM_ATTR_EEPROM_ACTION: eeprom setting actions
1644+ * (u8, see &enum mt76_testmode_eeprom_action)
1645+ * @MT76_TM_ATTR_EEPROM_OFFSET: offset of eeprom data block for writing (u32)
1646+ * @MT76_TM_ATTR_EEPROM_VAL: values for writing into a 16-byte data block
1647+ * (nested, u8 attrs)
1648+ *
1649+ * @MT76_TM_ATTR_CFG: config testmode rf feature (nested, see &mt76_testmode_cfg)
1650+ * @MT76_TM_ATTR_TXBF_ACT: txbf setting actions (u8)
1651+ * @MT76_TM_ATTR_TXBF_PARAM: txbf parameters (nested)
1652+ *
1653+ * @MT76_TM_ATTR_OFF_CH_SCAN_CH: config the channel of background chain (ZWDFS) (u8)
1654+ * @MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH: config the center channel of background chain (ZWDFS) (u8)
1655+ * @MT76_TM_ATTR_OFF_CH_SCAN_BW: config the bandwidth of background chain (ZWDFS) (u8)
1656+ * @MT76_TM_ATTR_OFF_CH_SCAN_PATH: config the tx path of background chain (ZWDFS) (u8)
1657+ *
1658+ * @MT76_TM_ATTR_IPI_THRESHOLD: config the IPI index you want to read (u8)
1659+ * @MT76_TM_ATTR_IPI_PERIOD: config the time period for reading
1660+ * the histogram of specific IPI index (u8)
1661+ * @MT76_TM_ATTR_IPI_ANTENNA_INDEX: config the antenna index for reading
1662+ * the histogram of specific IPI index (u8)
1663+ * @MT76_TM_ATTR_IPI_RESET: Reset the IPI counter
1664+ *
1665 */
1666 enum mt76_testmode_attr {
1667 MT76_TM_ATTR_UNSPEC,
1668@@ -76,6 +104,8 @@ enum mt76_testmode_attr {
1669 MT76_TM_ATTR_FREQ_OFFSET,
1670
1671 MT76_TM_ATTR_STATS,
1672+ MT76_TM_ATTR_PRECAL,
1673+ MT76_TM_ATTR_PRECAL_INFO,
1674
1675 MT76_TM_ATTR_TX_SPE_IDX,
1676
1677@@ -86,6 +116,27 @@ enum mt76_testmode_attr {
1678 MT76_TM_ATTR_DRV_DATA,
1679
1680 MT76_TM_ATTR_MAC_ADDRS,
1681+ MT76_TM_ATTR_AID,
1682+ MT76_TM_ATTR_RU_ALLOC,
1683+ MT76_TM_ATTR_RU_IDX,
1684+
1685+ MT76_TM_ATTR_EEPROM_ACTION,
1686+ MT76_TM_ATTR_EEPROM_OFFSET,
1687+ MT76_TM_ATTR_EEPROM_VAL,
1688+
1689+ MT76_TM_ATTR_CFG,
1690+ MT76_TM_ATTR_TXBF_ACT,
1691+ MT76_TM_ATTR_TXBF_PARAM,
1692+
1693+ MT76_TM_ATTR_OFF_CH_SCAN_CH,
1694+ MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH,
1695+ MT76_TM_ATTR_OFF_CH_SCAN_BW,
1696+ MT76_TM_ATTR_OFF_CH_SCAN_PATH,
1697+
1698+ MT76_TM_ATTR_IPI_THRESHOLD,
1699+ MT76_TM_ATTR_IPI_PERIOD,
1700+ MT76_TM_ATTR_IPI_ANTENNA_INDEX,
1701+ MT76_TM_ATTR_IPI_RESET,
1702
1703 /* keep last */
1704 NUM_MT76_TM_ATTRS,
1705@@ -103,6 +154,8 @@ enum mt76_testmode_attr {
1706 * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64)
1707 * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet
1708 * see &enum mt76_testmode_rx_attr
1709+ * @MT76_TM_STATS_ATTR_RX_LEN_MISMATCH: number of rx packets with length
1710+ * mismatch error (u64)
1711 */
1712 enum mt76_testmode_stats_attr {
1713 MT76_TM_STATS_ATTR_UNSPEC,
1714@@ -115,6 +168,7 @@ enum mt76_testmode_stats_attr {
1715 MT76_TM_STATS_ATTR_RX_PACKETS,
1716 MT76_TM_STATS_ATTR_RX_FCS_ERROR,
1717 MT76_TM_STATS_ATTR_LAST_RX,
1718+ MT76_TM_STATS_ATTR_RX_LEN_MISMATCH,
1719
1720 /* keep last */
1721 NUM_MT76_TM_STATS_ATTRS,
1722@@ -179,6 +233,9 @@ enum mt76_testmode_state {
1723 * @MT76_TM_TX_MODE_HE_EXT_SU: 802.11ax extended-range SU
1724 * @MT76_TM_TX_MODE_HE_TB: 802.11ax trigger-based
1725 * @MT76_TM_TX_MODE_HE_MU: 802.11ax multi-user MIMO
1726+ * @MT76_TM_TX_MODE_EHT_SU: 802.11be single-user MIMO
1727+ * @MT76_TM_TX_MODE_EHT_TRIG: 802.11be trigger-based
1728+ * @MT76_TM_TX_MODE_EHT_MU: 802.11be multi-user MIMO
1729 */
1730 enum mt76_testmode_tx_mode {
1731 MT76_TM_TX_MODE_CCK,
1732@@ -189,6 +246,9 @@ enum mt76_testmode_tx_mode {
1733 MT76_TM_TX_MODE_HE_EXT_SU,
1734 MT76_TM_TX_MODE_HE_TB,
1735 MT76_TM_TX_MODE_HE_MU,
1736+ MT76_TM_TX_MODE_EHT_SU,
1737+ MT76_TM_TX_MODE_EHT_TRIG,
1738+ MT76_TM_TX_MODE_EHT_MU,
1739
1740 /* keep last */
1741 NUM_MT76_TM_TX_MODES,
1742diff --git a/tools/fields.c b/tools/fields.c
developer064da3c2023-06-13 15:57:26 +08001743index e3f6908..e5cf7c5 100644
developer1bc2ce22023-03-25 00:47:41 +08001744--- a/tools/fields.c
1745+++ b/tools/fields.c
1746@@ -10,6 +10,7 @@ static const char * const testmode_state[] = {
1747 [MT76_TM_STATE_IDLE] = "idle",
1748 [MT76_TM_STATE_TX_FRAMES] = "tx_frames",
1749 [MT76_TM_STATE_RX_FRAMES] = "rx_frames",
1750+ [MT76_TM_STATE_TX_CONT] = "tx_cont",
1751 };
1752
1753 static const char * const testmode_tx_mode[] = {
1754@@ -21,6 +22,9 @@ static const char * const testmode_tx_mode[] = {
1755 [MT76_TM_TX_MODE_HE_EXT_SU] = "he_ext_su",
1756 [MT76_TM_TX_MODE_HE_TB] = "he_tb",
1757 [MT76_TM_TX_MODE_HE_MU] = "he_mu",
1758+ [MT76_TM_TX_MODE_EHT_SU] = "eht_su",
1759+ [MT76_TM_TX_MODE_EHT_TRIG] = "eht_tb",
1760+ [MT76_TM_TX_MODE_EHT_MU] = "eht_mu",
1761 };
1762
1763 static void print_enum(const struct tm_field *field, struct nlattr *attr)
1764@@ -201,6 +205,62 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
1765 printf("%srx_per=%.02f%%\n", prefix, 100 * failed / total);
1766 }
1767
1768+static bool parse_mac(const struct tm_field *field, int idx,
1769+ struct nl_msg *msg, const char *val)
1770+{
1771+#define ETH_ALEN 6
1772+ bool ret = true;
1773+ char *str, *cur, *ap;
1774+ void *a;
1775+
1776+ str = strdup(val);
1777+ ap = str;
1778+
1779+ a = nla_nest_start(msg, idx);
1780+
1781+ idx = 0;
1782+ while ((cur = strsep(&ap, ",")) != NULL) {
1783+ unsigned char addr[ETH_ALEN];
1784+ char *val, *tmp = cur;
1785+ int i = 0;
1786+
1787+ while ((val = strsep(&tmp, ":")) != NULL) {
1788+ if (i >= ETH_ALEN)
1789+ break;
1790+
1791+ addr[i++] = strtoul(val, NULL, 16);
1792+ }
1793+
1794+ nla_put(msg, idx, ETH_ALEN, addr);
1795+
1796+ idx++;
1797+ }
1798+
1799+ nla_nest_end(msg, a);
1800+
1801+ free(str);
1802+
1803+ return ret;
1804+}
1805+
1806+static void print_mac(const struct tm_field *field, struct nlattr *attr)
1807+{
1808+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
1809+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
1810+ unsigned char addr[3][6];
1811+ struct nlattr *cur;
1812+ int idx = 0;
1813+ int rem;
1814+
1815+ nla_for_each_nested(cur, attr, rem) {
1816+ if (nla_len(cur) != 6)
1817+ continue;
1818+ memcpy(addr[idx++], nla_data(cur), 6);
1819+ }
1820+
1821+ printf("" MACSTR "," MACSTR "," MACSTR "",
1822+ MAC2STR(addr[0]), MAC2STR(addr[1]), MAC2STR(addr[2]));
1823+}
1824
1825 #define FIELD_GENERIC(_field, _name, ...) \
1826 [FIELD_NAME(_field)] = { \
1827@@ -250,6 +310,13 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
1828 ##__VA_ARGS__ \
1829 )
1830
1831+#define FIELD_MAC(_field, _name) \
1832+ [FIELD_NAME(_field)] = { \
1833+ .name = _name, \
1834+ .parse = parse_mac, \
1835+ .print = print_mac \
1836+ }
1837+
1838 #define FIELD_NAME(_field) MT76_TM_RX_ATTR_##_field
1839 static const struct tm_field rx_fields[NUM_MT76_TM_RX_ATTRS] = {
1840 FIELD_RO(s32, FREQ_OFFSET, "freq_offset"),
1841@@ -274,6 +341,7 @@ static const struct tm_field stats_fields[NUM_MT76_TM_STATS_ATTRS] = {
1842 FIELD_RO(u32, TX_DONE, "tx_done"),
1843 FIELD_RO(u64, RX_PACKETS, "rx_packets"),
1844 FIELD_RO(u64, RX_FCS_ERROR, "rx_fcs_error"),
1845+ FIELD_RO(u64, RX_LEN_MISMATCH, "rx_len_mismatch"),
1846 FIELD_NESTED_RO(LAST_RX, rx, "last_"),
1847 };
1848 static struct nla_policy stats_policy[NUM_MT76_TM_STATS_ATTRS] = {
1849@@ -282,6 +350,7 @@ static struct nla_policy stats_policy[NUM_MT76_TM_STATS_ATTRS] = {
1850 [MT76_TM_STATS_ATTR_TX_DONE] = { .type = NLA_U32 },
1851 [MT76_TM_STATS_ATTR_RX_PACKETS] = { .type = NLA_U64 },
1852 [MT76_TM_STATS_ATTR_RX_FCS_ERROR] = { .type = NLA_U64 },
1853+ [MT76_TM_STATS_ATTR_RX_LEN_MISMATCH] = { .type = NLA_U64 },
1854 };
1855 #undef FIELD_NAME
1856
1857@@ -300,12 +369,20 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
1858 FIELD(u8, TX_RATE_LDPC, "tx_rate_ldpc"),
1859 FIELD(u8, TX_RATE_STBC, "tx_rate_stbc"),
1860 FIELD(u8, TX_LTF, "tx_ltf"),
1861+ FIELD(u8, TX_DUTY_CYCLE, "tx_duty_cycle"),
1862+ FIELD(u32, TX_IPG, "tx_ipg"),
1863+ FIELD(u32, TX_TIME, "tx_time"),
1864 FIELD(u8, TX_POWER_CONTROL, "tx_power_control"),
1865 FIELD_ARRAY(u8, TX_POWER, "tx_power"),
1866 FIELD(u8, TX_ANTENNA, "tx_antenna"),
1867 FIELD(u32, FREQ_OFFSET, "freq_offset"),
1868+ FIELD(u8, AID, "aid"),
1869+ FIELD(u8, RU_ALLOC, "ru_alloc"),
1870+ FIELD(u8, RU_IDX, "ru_idx"),
1871+ FIELD_MAC(MAC_ADDRS, "mac_addrs"),
1872 FIELD_NESTED_RO(STATS, stats, "",
1873 .print_extra = print_extra_stats),
1874+
1875 };
1876 #undef FIELD_NAME
1877
1878@@ -322,10 +399,25 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
1879 [MT76_TM_ATTR_TX_RATE_LDPC] = { .type = NLA_U8 },
1880 [MT76_TM_ATTR_TX_RATE_STBC] = { .type = NLA_U8 },
1881 [MT76_TM_ATTR_TX_LTF] = { .type = NLA_U8 },
1882+ [MT76_TM_ATTR_TX_DUTY_CYCLE] = { .type = NLA_U8 },
1883+ [MT76_TM_ATTR_TX_IPG] = { .type = NLA_U32 },
1884+ [MT76_TM_ATTR_TX_TIME] = { .type = NLA_U32 },
1885 [MT76_TM_ATTR_TX_POWER_CONTROL] = { .type = NLA_U8 },
1886 [MT76_TM_ATTR_TX_ANTENNA] = { .type = NLA_U8 },
1887+ [MT76_TM_ATTR_TX_SPE_IDX] = { .type = NLA_U8 },
1888 [MT76_TM_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
1889+ [MT76_TM_ATTR_AID] = { .type = NLA_U8 },
1890+ [MT76_TM_ATTR_RU_ALLOC] = { .type = NLA_U8 },
1891+ [MT76_TM_ATTR_RU_IDX] = { .type = NLA_U8 },
1892 [MT76_TM_ATTR_STATS] = { .type = NLA_NESTED },
1893+ [MT76_TM_ATTR_TXBF_ACT] = { .type = NLA_U8 },
1894+ [MT76_TM_ATTR_OFF_CH_SCAN_CH] = { .type = NLA_U8 },
1895+ [MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH] = { .type = NLA_U8 },
1896+ [MT76_TM_ATTR_OFF_CH_SCAN_BW] = { .type = NLA_U8 },
1897+ [MT76_TM_ATTR_IPI_THRESHOLD] = { .type = NLA_U8 },
1898+ [MT76_TM_ATTR_IPI_PERIOD] = { .type = NLA_U32 },
1899+ [MT76_TM_ATTR_IPI_ANTENNA_INDEX] = { .type = NLA_U8 },
1900+ [MT76_TM_ATTR_IPI_RESET] = { .type = NLA_U8 },
1901 };
1902
1903 const struct tm_field msg_field = {
1904--
developer064da3c2023-06-13 15:57:26 +080019052.18.0
developer1bc2ce22023-03-25 00:47:41 +08001906