blob: 9f92153b568608c4e4d40e7c4c056587858a407f [file] [log] [blame]
developer70180b02023-11-14 17:01:47 +08001From e7c6d49d0b5582ba7cb37d9d844a341b18c5a393 Mon Sep 17 00:00:00 2001
developer6caa5e22022-06-16 13:33:13 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Thu, 21 Apr 2022 15:43:19 +0800
developer70180b02023-11-14 17:01:47 +08004Subject: [PATCH 1009/1042] wifi: mt76: testmode: additional supports
developer6caa5e22022-06-16 13:33:13 +08005
6Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
developerbb6ddff2023-03-08 17:22:32 +08007Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developer6caa5e22022-06-16 13:33:13 +08008---
developerf7a3ca32022-09-01 14:44:55 +08009 dma.c | 3 +-
10 mac80211.c | 12 +
developerbd9fa1e2023-10-16 11:04:00 +080011 mt76.h | 110 +++-
developerf7a3ca32022-09-01 14:44:55 +080012 mt76_connac_mcu.c | 4 +
13 mt76_connac_mcu.h | 2 +
developerc9333e12023-04-06 18:07:42 +080014 mt7915/eeprom.c | 2 +-
developerf7a3ca32022-09-01 14:44:55 +080015 mt7915/init.c | 2 +-
developerbd9fa1e2023-10-16 11:04:00 +080016 mt7915/mac.c | 40 +-
developerf7a3ca32022-09-01 14:44:55 +080017 mt7915/main.c | 2 +-
developer692ed9b2023-06-19 12:03:50 +080018 mt7915/mcu.c | 22 +-
developer1475cf22023-05-05 13:45:43 +080019 mt7915/mcu.h | 29 +-
developerf7a3ca32022-09-01 14:44:55 +080020 mt7915/mmio.c | 2 +
developerbd9fa1e2023-10-16 11:04:00 +080021 mt7915/mt7915.h | 17 +-
developerf7a3ca32022-09-01 14:44:55 +080022 mt7915/regs.h | 3 +
developer70180b02023-11-14 17:01:47 +080023 mt7915/testmode.c | 1244 ++++++++++++++++++++++++++++++++++++++++++---
developerbd9fa1e2023-10-16 11:04:00 +080024 mt7915/testmode.h | 278 ++++++++++
25 testmode.c | 287 +++++++++--
26 testmode.h | 79 +++
27 tools/fields.c | 90 +++-
developerf7a3ca32022-09-01 14:44:55 +080028 tx.c | 3 +-
developer70180b02023-11-14 17:01:47 +080029 20 files changed, 2063 insertions(+), 168 deletions(-)
developer6caa5e22022-06-16 13:33:13 +080030
31diff --git a/dma.c b/dma.c
developerbd9fa1e2023-10-16 11:04:00 +080032index 24b44e7..8049830 100644
developer6caa5e22022-06-16 13:33:13 +080033--- a/dma.c
34+++ b/dma.c
developerbd9fa1e2023-10-16 11:04:00 +080035@@ -576,8 +576,7 @@ free:
developer6caa5e22022-06-16 13:33:13 +080036 if (mt76_is_testmode_skb(dev, skb, &hw)) {
37 struct mt76_phy *phy = hw->priv;
38
39- if (tx_info.skb == phy->test.tx_skb)
40- phy->test.tx_done--;
41+ phy->test.tx_done--;
42 }
43 #endif
44
45diff --git a/mac80211.c b/mac80211.c
developerbd9fa1e2023-10-16 11:04:00 +080046index 430ed1c..fccf26d 100644
developer6caa5e22022-06-16 13:33:13 +080047--- a/mac80211.c
48+++ b/mac80211.c
developer8effbd32023-04-17 15:57:28 +080049@@ -55,6 +55,13 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
developer6caa5e22022-06-16 13:33:13 +080050 CHAN5G(60, 5300),
51 CHAN5G(64, 5320),
52
53+ CHAN5G(68, 5340),
54+ CHAN5G(80, 5400),
55+ CHAN5G(84, 5420),
56+ CHAN5G(88, 5440),
57+ CHAN5G(92, 5460),
58+ CHAN5G(96, 5480),
59+
60 CHAN5G(100, 5500),
61 CHAN5G(104, 5520),
62 CHAN5G(108, 5540),
developer47efbdb2023-06-29 20:33:22 +080063@@ -76,6 +83,11 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
developer6caa5e22022-06-16 13:33:13 +080064 CHAN5G(169, 5845),
65 CHAN5G(173, 5865),
developer47efbdb2023-06-29 20:33:22 +080066 CHAN5G(177, 5885),
developer6caa5e22022-06-16 13:33:13 +080067+
68+ CHAN5G(184, 4920),
69+ CHAN5G(188, 4940),
70+ CHAN5G(192, 4960),
71+ CHAN5G(196, 4980),
72 };
73
74 static const struct ieee80211_channel mt76_channels_6ghz[] = {
75diff --git a/mt76.h b/mt76.h
developerbd9fa1e2023-10-16 11:04:00 +080076index d66f4d0..597488d 100644
developer6caa5e22022-06-16 13:33:13 +080077--- a/mt76.h
78+++ b/mt76.h
developerbd9fa1e2023-10-16 11:04:00 +080079@@ -670,6 +670,21 @@ struct mt76_testmode_ops {
developer6caa5e22022-06-16 13:33:13 +080080 int (*set_params)(struct mt76_phy *phy, struct nlattr **tb,
81 enum mt76_testmode_state new_state);
82 int (*dump_stats)(struct mt76_phy *phy, struct sk_buff *msg);
83+ int (*set_eeprom)(struct mt76_phy *phy, u32 offset, u8 *val, u8 action);
84+};
85+
86+struct mt76_testmode_entry_data {
87+ struct sk_buff *tx_skb;
88+
89+ u16 tx_mpdu_len;
90+ u8 tx_rate_idx;
91+ u8 tx_rate_nss;
92+ u8 tx_rate_ldpc;
93+
94+ u8 addr[3][ETH_ALEN];
95+ u8 aid;
96+ u8 ru_alloc;
97+ u8 ru_idx;
98 };
99
100 #define MT_TM_FW_RX_COUNT BIT(0)
developerbd9fa1e2023-10-16 11:04:00 +0800101@@ -678,16 +693,13 @@ struct mt76_testmode_data {
developer6caa5e22022-06-16 13:33:13 +0800102 enum mt76_testmode_state state;
103
104 u32 param_set[DIV_ROUND_UP(NUM_MT76_TM_ATTRS, 32)];
105- struct sk_buff *tx_skb;
developerbd9fa1e2023-10-16 11:04:00 +0800106+
107+ u8 sku_en;
developer6caa5e22022-06-16 13:33:13 +0800108
109 u32 tx_count;
110- u16 tx_mpdu_len;
111
112 u8 tx_rate_mode;
113- u8 tx_rate_idx;
114- u8 tx_rate_nss;
115 u8 tx_rate_sgi;
116- u8 tx_rate_ldpc;
117 u8 tx_rate_stbc;
118 u8 tx_ltf;
119
developerbd9fa1e2023-10-16 11:04:00 +0800120@@ -703,10 +715,37 @@ struct mt76_testmode_data {
developer6caa5e22022-06-16 13:33:13 +0800121 u8 tx_power[4];
122 u8 tx_power_control;
123
124- u8 addr[3][ETH_ALEN];
125+ struct list_head tm_entry_list;
126+ struct mt76_wcid *cur_entry;
127+ u8 entry_num;
128+ union {
129+ struct mt76_testmode_entry_data ed;
130+ struct {
131+ /* must be the same as mt76_testmode_entry_data */
132+ struct sk_buff *tx_skb;
133+
134+ u16 tx_mpdu_len;
135+ u8 tx_rate_idx;
136+ u8 tx_rate_nss;
137+ u8 tx_rate_ldpc;
138+
139+ u8 addr[3][ETH_ALEN];
140+ u8 aid;
141+ u8 ru_alloc;
142+ u8 ru_idx;
143+ };
144+ };
145
146 u8 flag;
147
148+ struct {
149+ u8 type;
150+ u8 enable;
151+ } cfg;
152+
153+ u8 txbf_act;
154+ u16 txbf_param[8];
155+
156 u32 tx_pending;
157 u32 tx_queued;
158 u16 tx_queued_limit;
developerbd9fa1e2023-10-16 11:04:00 +0800159@@ -1276,6 +1315,59 @@ static inline bool mt76_testmode_enabled(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +0800160 #endif
161 }
162
163+#ifdef CONFIG_NL80211_TESTMODE
164+static inline struct mt76_wcid *
165+mt76_testmode_first_entry(struct mt76_phy *phy)
166+{
167+ if (list_empty(&phy->test.tm_entry_list) && !phy->test.aid)
168+ return &phy->dev->global_wcid;
169+
170+ return list_first_entry(&phy->test.tm_entry_list,
171+ typeof(struct mt76_wcid),
172+ list);
173+}
174+
175+static inline struct mt76_testmode_entry_data *
176+mt76_testmode_entry_data(struct mt76_phy *phy, struct mt76_wcid *wcid)
177+{
178+ if (!wcid)
179+ return NULL;
180+ if (wcid == &phy->dev->global_wcid)
181+ return &phy->test.ed;
182+
183+ return (struct mt76_testmode_entry_data *)((u8 *)wcid +
184+ phy->hw->sta_data_size);
185+}
186+
187+#define mt76_tm_for_each_entry(phy, wcid, ed) \
188+ for (wcid = mt76_testmode_first_entry(phy), \
189+ ed = mt76_testmode_entry_data(phy, wcid); \
190+ ((phy->test.aid && \
191+ !list_entry_is_head(wcid, &phy->test.tm_entry_list, list)) || \
192+ (!phy->test.aid && wcid == &phy->dev->global_wcid)) && ed; \
193+ wcid = list_next_entry(wcid, list), \
194+ ed = mt76_testmode_entry_data(phy, wcid))
195+#endif
196+
197+static inline bool __mt76_is_testmode_skb(struct mt76_phy *phy,
198+ struct sk_buff *skb)
199+{
200+#ifdef CONFIG_NL80211_TESTMODE
201+ struct mt76_testmode_entry_data *ed = &phy->test.ed;
202+ struct mt76_wcid *wcid;
203+
204+ if (skb == ed->tx_skb)
205+ return true;
206+
207+ mt76_tm_for_each_entry(phy, wcid, ed)
208+ if (skb == ed->tx_skb)
209+ return true;
210+ return false;
211+#else
212+ return false;
213+#endif
214+}
215+
216 static inline bool mt76_is_testmode_skb(struct mt76_dev *dev,
217 struct sk_buff *skb,
218 struct ieee80211_hw **hw)
developerbd9fa1e2023-10-16 11:04:00 +0800219@@ -1286,7 +1378,8 @@ static inline bool mt76_is_testmode_skb(struct mt76_dev *dev,
developerf7a3ca32022-09-01 14:44:55 +0800220 for (i = 0; i < ARRAY_SIZE(dev->phys); i++) {
221 struct mt76_phy *phy = dev->phys[i];
222
223- if (phy && skb == phy->test.tx_skb) {
224+ if (phy && mt76_testmode_enabled(phy) &&
225+ __mt76_is_testmode_skb(phy, skb)) {
226 *hw = dev->phys[i]->hw;
227 return true;
228 }
developerbd9fa1e2023-10-16 11:04:00 +0800229@@ -1388,7 +1481,8 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer6caa5e22022-06-16 13:33:13 +0800230 int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
231 struct netlink_callback *cb, void *data, int len);
232 int mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state);
233-int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len);
234+int mt76_testmode_init_skb(struct mt76_phy *phy, u32 len,
235+ struct sk_buff **tx_skb, u8 (*addr)[ETH_ALEN]);
236
237 static inline void mt76_testmode_reset(struct mt76_phy *phy, bool disable)
238 {
239diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
developerbd9fa1e2023-10-16 11:04:00 +0800240index f06a81d..60e159c 100644
developer6caa5e22022-06-16 13:33:13 +0800241--- a/mt76_connac_mcu.c
242+++ b/mt76_connac_mcu.c
developerbd9fa1e2023-10-16 11:04:00 +0800243@@ -396,6 +396,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
developer6caa5e22022-06-16 13:33:13 +0800244 switch (vif->type) {
245 case NL80211_IFTYPE_MESH_POINT:
246 case NL80211_IFTYPE_AP:
247+ case NL80211_IFTYPE_MONITOR:
developer7af0f762023-05-22 15:16:16 +0800248 if (vif->p2p && !is_mt7921(dev))
developer6caa5e22022-06-16 13:33:13 +0800249 conn_type = CONNECTION_P2P_GC;
250 else
developerbd9fa1e2023-10-16 11:04:00 +0800251@@ -577,6 +578,9 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
developer6caa5e22022-06-16 13:33:13 +0800252 rx->rca2 = 1;
253 rx->rv = 1;
254
255+ if (vif->type == NL80211_IFTYPE_MONITOR)
256+ rx->rca1 = 0;
257+
258 if (!is_connac_v1(dev))
259 return;
260
261diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerbd9fa1e2023-10-16 11:04:00 +0800262index cb68141..7a7dbf4 100644
developer6caa5e22022-06-16 13:33:13 +0800263--- a/mt76_connac_mcu.h
264+++ b/mt76_connac_mcu.h
developerbd9fa1e2023-10-16 11:04:00 +0800265@@ -1002,6 +1002,7 @@ enum {
developer6caa5e22022-06-16 13:33:13 +0800266 MCU_EXT_EVENT_FW_LOG_2_HOST = 0x13,
267 MCU_EXT_EVENT_THERMAL_PROTECT = 0x22,
268 MCU_EXT_EVENT_ASSERT_DUMP = 0x23,
269+ MCU_EXT_EVENT_BF_STATUS_READ = 0x35,
270 MCU_EXT_EVENT_RDD_REPORT = 0x3a,
271 MCU_EXT_EVENT_CSA_NOTIFY = 0x4f,
developer47efbdb2023-06-29 20:33:22 +0800272 MCU_EXT_EVENT_WA_TX_STAT = 0x74,
developerbd9fa1e2023-10-16 11:04:00 +0800273@@ -1211,6 +1212,7 @@ enum {
developer6caa5e22022-06-16 13:33:13 +0800274 MCU_EXT_CMD_PHY_STAT_INFO = 0xad,
275 /* for vendor csi and air monitor */
276 MCU_EXT_CMD_SMESH_CTRL = 0xae,
277+ MCU_EXT_CMD_RX_STAT_USER_CTRL = 0xb3,
278 MCU_EXT_CMD_CERT_CFG = 0xb7,
279 MCU_EXT_CMD_CSI_CTRL = 0xc2,
280 };
developerc9333e12023-04-06 18:07:42 +0800281diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
developerbd9fa1e2023-10-16 11:04:00 +0800282index 76be730..f5ab331 100644
developerc9333e12023-04-06 18:07:42 +0800283--- a/mt7915/eeprom.c
284+++ b/mt7915/eeprom.c
developer7af0f762023-05-22 15:16:16 +0800285@@ -131,7 +131,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
developerc9333e12023-04-06 18:07:42 +0800286 /* read eeprom data from efuse */
287 block_num = DIV_ROUND_UP(eeprom_size, eeprom_blk_size);
288 for (i = 0; i < block_num; i++) {
289- ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size);
290+ ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size, NULL);
291 if (ret < 0)
292 return ret;
293 }
developer6caa5e22022-06-16 13:33:13 +0800294diff --git a/mt7915/init.c b/mt7915/init.c
developerbd9fa1e2023-10-16 11:04:00 +0800295index 607d881..d908a58 100644
developer6caa5e22022-06-16 13:33:13 +0800296--- a/mt7915/init.c
297+++ b/mt7915/init.c
developerbd9fa1e2023-10-16 11:04:00 +0800298@@ -725,7 +725,7 @@ static void mt7915_init_work(struct work_struct *work)
developer6caa5e22022-06-16 13:33:13 +0800299 struct mt7915_dev *dev = container_of(work, struct mt7915_dev,
300 init_work);
301
302- mt7915_mcu_set_eeprom(dev);
303+ mt7915_mcu_set_eeprom(dev, dev->flash_mode);
304 mt7915_mac_init(dev);
developerc8796032023-08-09 10:28:15 +0800305 mt7915_txbf_init(dev);
306 }
developer6caa5e22022-06-16 13:33:13 +0800307diff --git a/mt7915/mac.c b/mt7915/mac.c
developerbd9fa1e2023-10-16 11:04:00 +0800308index f1c78ec..06a5fb1 100644
developer6caa5e22022-06-16 13:33:13 +0800309--- a/mt7915/mac.c
310+++ b/mt7915/mac.c
developerbd9fa1e2023-10-16 11:04:00 +0800311@@ -579,6 +579,7 @@ mt7915_mac_fill_rx_vector(struct mt7915_dev *dev, struct sk_buff *skb)
312 wb_rssi = le32_to_cpu(rxv[9]);
313
314 phy->test.last_rcpi[i] = rcpi & 0xff;
315+ phy->test.last_rssi[i] = to_rssi(GENMASK(7, 0), rcpi);
316 phy->test.last_ib_rssi[i] = ib_rssi & 0xff;
317 phy->test.last_wb_rssi[i] = wb_rssi & 0xff;
318 }
319@@ -604,16 +605,38 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
developer6caa5e22022-06-16 13:33:13 +0800320 {
321 #ifdef CONFIG_NL80211_TESTMODE
322 struct mt76_testmode_data *td = &phy->mt76->test;
323+ struct mt76_testmode_entry_data *ed;
324+ struct mt76_wcid *wcid;
325 const struct ieee80211_rate *r;
326- u8 bw, mode, nss = td->tx_rate_nss;
327- u8 rate_idx = td->tx_rate_idx;
328+ u8 bw, mode, nss, rate_idx, ldpc;
329 u16 rateval = 0;
330 u32 val;
331 bool cck = false;
332 int band;
333
334- if (skb != phy->mt76->test.tx_skb)
335+ txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID);
336+ txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
337+ phy->test.spe_idx));
338+
339+ if (td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU) {
340+ txwi[1] |= cpu_to_le32(BIT(18));
341+ txwi[2] = 0;
342+ txwi[3] &= ~cpu_to_le32(MT_TXD3_NO_ACK);
343+ le32p_replace_bits(&txwi[3], 0x1f, MT_TXD3_REM_TX_COUNT);
344+
developerf7a3ca32022-09-01 14:44:55 +0800345 return;
developer6caa5e22022-06-16 13:33:13 +0800346+ }
347+
348+ mt76_tm_for_each_entry(phy->mt76, wcid, ed)
349+ if (ed->tx_skb == skb)
350+ break;
351+
352+ if (!ed)
developerf7a3ca32022-09-01 14:44:55 +0800353+ return;
354+
developer6caa5e22022-06-16 13:33:13 +0800355+ nss = ed->tx_rate_nss;
356+ rate_idx = ed->tx_rate_idx;
357+ ldpc = ed->tx_rate_ldpc;
developerf7a3ca32022-09-01 14:44:55 +0800358
developer6caa5e22022-06-16 13:33:13 +0800359 switch (td->tx_rate_mode) {
360 case MT76_TM_TX_MODE_HT:
developerbd9fa1e2023-10-16 11:04:00 +0800361@@ -644,7 +667,7 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
developer3f784572023-01-31 15:21:28 +0800362 rate_idx += 4;
363
364 r = &phy->mt76->hw->wiphy->bands[band]->bitrates[rate_idx];
365- val = cck ? r->hw_value_short : r->hw_value;
366+ val = r->hw_value;
367
368 mode = val >> 8;
369 rate_idx = val & 0xff;
developerbd9fa1e2023-10-16 11:04:00 +0800370@@ -703,13 +726,14 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
developer6caa5e22022-06-16 13:33:13 +0800371 if (mode >= MT_PHY_TYPE_HE_SU)
372 val |= FIELD_PREP(MT_TXD6_HELTF, td->tx_ltf);
373
374- if (td->tx_rate_ldpc || (bw > 0 && mode >= MT_PHY_TYPE_HE_SU))
375+ if (ldpc || (bw > 0 && mode >= MT_PHY_TYPE_HE_SU))
376 val |= MT_TXD6_LDPC;
377
developerf7a3ca32022-09-01 14:44:55 +0800378 txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID);
developer6caa5e22022-06-16 13:33:13 +0800379+ if (phy->test.bf_en)
380+ val |= MT_TXD6_TX_IBF | MT_TXD6_TX_EBF;
381+
382 txwi[6] |= cpu_to_le32(val);
383- txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
384- phy->test.spe_idx));
385 #endif
386 }
387
developerbd9fa1e2023-10-16 11:04:00 +0800388@@ -1415,7 +1439,7 @@ mt7915_mac_restart(struct mt7915_dev *dev)
developer047bc182022-11-16 12:20:48 +0800389 goto out;
390
391 /* set the necessary init items */
392- ret = mt7915_mcu_set_eeprom(dev);
393+ ret = mt7915_mcu_set_eeprom(dev, dev->flash_mode);
394 if (ret)
395 goto out;
396
developer6caa5e22022-06-16 13:33:13 +0800397diff --git a/mt7915/main.c b/mt7915/main.c
developer70180b02023-11-14 17:01:47 +0800398index 0b6622e..44a1b21 100644
developer6caa5e22022-06-16 13:33:13 +0800399--- a/mt7915/main.c
400+++ b/mt7915/main.c
developerc5ce7502022-12-19 11:33:22 +0800401@@ -238,7 +238,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
developer6caa5e22022-06-16 13:33:13 +0800402 mvif->phy = phy;
developer17bb0a82022-12-13 15:52:04 +0800403 mvif->mt76.band_idx = phy->mt76->band_idx;
developer6caa5e22022-06-16 13:33:13 +0800404
405- mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP;
406+ mvif->mt76.wmm_idx = (vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_MONITOR);
407 if (ext_phy)
408 mvif->mt76.wmm_idx += 2;
409
410diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerbd9fa1e2023-10-16 11:04:00 +0800411index 7b3c70e..0d1e09c 100644
developer6caa5e22022-06-16 13:33:13 +0800412--- a/mt7915/mcu.c
413+++ b/mt7915/mcu.c
developerbd9fa1e2023-10-16 11:04:00 +0800414@@ -391,6 +391,11 @@ mt7915_mcu_rx_ext_event(struct mt7915_dev *dev, struct sk_buff *skb)
developer6caa5e22022-06-16 13:33:13 +0800415 case MCU_EXT_EVENT_BCC_NOTIFY:
416 mt7915_mcu_rx_bcc_notify(dev, skb);
417 break;
418+#ifdef CONFIG_NL80211_TESTMODE
419+ case MCU_EXT_EVENT_BF_STATUS_READ:
420+ mt7915_tm_txbf_status_read(dev, skb);
421+ break;
422+#endif
423 default:
424 break;
425 }
developerbd9fa1e2023-10-16 11:04:00 +0800426@@ -422,6 +427,7 @@ void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb)
developer47efbdb2023-06-29 20:33:22 +0800427 rxd->ext_eid == MCU_EXT_EVENT_ASSERT_DUMP ||
428 rxd->ext_eid == MCU_EXT_EVENT_PS_SYNC ||
429 rxd->ext_eid == MCU_EXT_EVENT_BCC_NOTIFY ||
430+ rxd->ext_eid == MCU_EXT_EVENT_BF_STATUS_READ ||
431 !rxd->seq) &&
432 !(rxd->eid == MCU_CMD_EXT_CID &&
433 rxd->ext_eid == MCU_EXT_EVENT_WA_TX_STAT))
developerbd9fa1e2023-10-16 11:04:00 +0800434@@ -2764,7 +2770,8 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
developer692ed9b2023-06-19 12:03:50 +0800435 }
436 #endif
437
438- if (mt76_connac_spe_idx(phy->mt76->antenna_mask))
439+ if (mt76_connac_spe_idx(phy->mt76->antenna_mask) &&
440+ !mt76_testmode_enabled(phy->mt76))
441 req.tx_path_num = fls(phy->mt76->antenna_mask);
442
developerbddc9db2023-09-11 13:34:36 +0800443 if (phy->mt76->hw->conf.flags & IEEE80211_CONF_MONITOR)
444@@ -2832,21 +2839,21 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
developer6caa5e22022-06-16 13:33:13 +0800445 return 0;
446 }
447
448-int mt7915_mcu_set_eeprom(struct mt7915_dev *dev)
449+int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode)
450 {
451 struct mt7915_mcu_eeprom req = {
452 .buffer_mode = EE_MODE_EFUSE,
453 .format = EE_FORMAT_WHOLE,
454 };
455
456- if (dev->flash_mode)
457+ if (flash_mode)
458 return mt7915_mcu_set_eeprom_flash(dev);
459
460 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_BUFFER_MODE),
developerc9333e12023-04-06 18:07:42 +0800461 &req, sizeof(req), true);
462 }
463
464-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
465+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
466 {
467 struct mt7915_mcu_eeprom_info req = {
468 .addr = cpu_to_le32(round_down(offset,
developerbddc9db2023-09-11 13:34:36 +0800469@@ -2855,7 +2862,7 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
developerc9333e12023-04-06 18:07:42 +0800470 struct mt7915_mcu_eeprom_info *res;
471 struct sk_buff *skb;
472 int ret;
473- u8 *buf;
474+ u8 *buf = read_buf;
475
476 ret = mt76_mcu_send_and_get_msg(&dev->mt76,
477 MCU_EXT_QUERY(EFUSE_ACCESS),
developerbddc9db2023-09-11 13:34:36 +0800478@@ -2864,8 +2871,11 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
developerc9333e12023-04-06 18:07:42 +0800479 return ret;
480
481 res = (struct mt7915_mcu_eeprom_info *)skb->data;
482- buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
483+
484+ if (!buf)
485+ buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
486 memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
487+
488 dev_kfree_skb(skb);
489
490 return 0;
developer6caa5e22022-06-16 13:33:13 +0800491diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developerbd9fa1e2023-10-16 11:04:00 +0800492index c15b4b7..9982735 100644
developer6caa5e22022-06-16 13:33:13 +0800493--- a/mt7915/mcu.h
494+++ b/mt7915/mcu.h
developer7c3a5082022-06-24 13:40:42 +0800495@@ -8,10 +8,15 @@
developer6caa5e22022-06-16 13:33:13 +0800496
497 enum {
498 MCU_ATE_SET_TRX = 0x1,
499+ MCU_ATE_SET_TSSI = 0x5,
500+ MCU_ATE_SET_DPD = 0x6,
501+ MCU_ATE_SET_RATE_POWER_OFFSET = 0x7,
502+ MCU_ATE_SET_THERMAL_COMP = 0x8,
503 MCU_ATE_SET_FREQ_OFFSET = 0xa,
504 MCU_ATE_SET_PHY_COUNT = 0x11,
505 MCU_ATE_SET_SLOT_TIME = 0x13,
506 MCU_ATE_CLEAN_TXQUEUE = 0x1c,
507+ MCU_ATE_SET_MU_RX_AID = 0x1e,
508 };
509
developer7c3a5082022-06-24 13:40:42 +0800510 struct mt7915_mcu_thermal_ctrl {
developer1475cf22023-05-05 13:45:43 +0800511@@ -527,6 +532,12 @@ enum {
developer6caa5e22022-06-16 13:33:13 +0800512
513 enum {
514 MT_BF_SOUNDING_ON = 1,
515+ MT_BF_DATA_PACKET_APPLY = 2,
516+ MT_BF_PFMU_TAG_READ = 5,
517+ MT_BF_PFMU_TAG_WRITE = 6,
518+ MT_BF_PHASE_CAL = 14,
519+ MT_BF_IBF_PHASE_COMP = 15,
520+ MT_BF_PROFILE_WRITE_ALL = 17,
521 MT_BF_TYPE_UPDATE = 20,
522 MT_BF_MODULE_UPDATE = 25
523 };
developer1475cf22023-05-05 13:45:43 +0800524@@ -775,10 +786,20 @@ struct mt7915_muru {
developer6caa5e22022-06-16 13:33:13 +0800525 #define MURU_OFDMA_SCH_TYPE_UL BIT(1)
526
developer7c3a5082022-06-24 13:40:42 +0800527 /* Common Config */
developer6caa5e22022-06-16 13:33:13 +0800528-#define MURU_COMM_PPDU_FMT BIT(0)
529-#define MURU_COMM_SCH_TYPE BIT(1)
530-#define MURU_COMM_SET (MURU_COMM_PPDU_FMT | MURU_COMM_SCH_TYPE)
developer6caa5e22022-06-16 13:33:13 +0800531-/* DL&UL User config*/
developer6caa5e22022-06-16 13:33:13 +0800532+/* #define MURU_COMM_PPDU_FMT BIT(0) */
533+/* #define MURU_COMM_SCH_TYPE BIT(1) */
534+/* #define MURU_COMM_SET (MURU_COMM_PPDU_FMT | MURU_COMM_SCH_TYPE) */
developer7c3a5082022-06-24 13:40:42 +0800535+#define MURU_COMM_PPDU_FMT BIT(0)
536+#define MURU_COMM_SCH_TYPE BIT(1)
537+#define MURU_COMM_BAND BIT(2)
538+#define MURU_COMM_WMM BIT(3)
539+#define MURU_COMM_SPE_IDX BIT(4)
540+#define MURU_COMM_PROC_TYPE BIT(5)
developer1475cf22023-05-05 13:45:43 +0800541+#define MURU_COMM_SET (MURU_COMM_PPDU_FMT | MURU_COMM_SCH_TYPE)
542+#define MURU_COMM_SET_TM (MURU_COMM_PPDU_FMT | MURU_COMM_BAND | \
543+ MURU_COMM_WMM | MURU_COMM_SPE_IDX)
developer6caa5e22022-06-16 13:33:13 +0800544+
545+/* DL&UL User config */
546 #define MURU_USER_CNT BIT(4)
547
548 enum {
549diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developerbd9fa1e2023-10-16 11:04:00 +0800550index 10c2c7d..87a5c5c 100644
developer6caa5e22022-06-16 13:33:13 +0800551--- a/mt7915/mmio.c
552+++ b/mt7915/mmio.c
developer60a3d662023-02-07 15:24:34 +0800553@@ -134,6 +134,7 @@ static const u32 mt7915_offs[] = {
developer6caa5e22022-06-16 13:33:13 +0800554 [ARB_DRNGR0] = 0x194,
555 [ARB_SCR] = 0x080,
556 [RMAC_MIB_AIRTIME14] = 0x3b8,
557+ [AGG_AALCR0] = 0x048,
558 [AGG_AWSCR0] = 0x05c,
559 [AGG_PCR0] = 0x06c,
560 [AGG_ACR0] = 0x084,
developer60a3d662023-02-07 15:24:34 +0800561@@ -209,6 +210,7 @@ static const u32 mt7916_offs[] = {
developer6caa5e22022-06-16 13:33:13 +0800562 [ARB_DRNGR0] = 0x1e0,
563 [ARB_SCR] = 0x000,
564 [RMAC_MIB_AIRTIME14] = 0x0398,
565+ [AGG_AALCR0] = 0x028,
566 [AGG_AWSCR0] = 0x030,
567 [AGG_PCR0] = 0x040,
568 [AGG_ACR0] = 0x054,
569diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerbd9fa1e2023-10-16 11:04:00 +0800570index ab3c8f7..b91af94 100644
developer6caa5e22022-06-16 13:33:13 +0800571--- a/mt7915/mt7915.h
572+++ b/mt7915/mt7915.h
developerbd9fa1e2023-10-16 11:04:00 +0800573@@ -267,11 +267,15 @@ struct mt7915_phy {
574
575 s32 last_freq_offset;
576 u8 last_rcpi[4];
577+ s8 last_rssi[4];
578 s8 last_ib_rssi[4];
579 s8 last_wb_rssi[4];
developer6caa5e22022-06-16 13:33:13 +0800580 u8 last_snr;
581
582 u8 spe_idx;
583+
584+ bool bf_en;
585+ bool bf_ever_en;
586 } test;
587 #endif
588
developerbd9fa1e2023-10-16 11:04:00 +0800589@@ -371,6 +375,14 @@ struct mt7915_dev {
developer6caa5e22022-06-16 13:33:13 +0800590 void __iomem *dcm;
591 void __iomem *sku;
592
593+#ifdef CONFIG_NL80211_TESTMODE
594+ struct {
595+ void *txbf_phase_cal;
596+ void *txbf_pfmu_data;
597+ void *txbf_pfmu_tag;
598+ } test;
599+#endif
600+
601 #ifdef MTK_DEBUG
602 u16 wlan_idx;
603 struct {
developerbd9fa1e2023-10-16 11:04:00 +0800604@@ -542,8 +554,8 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
developer6caa5e22022-06-16 13:33:13 +0800605 struct ieee80211_vif *vif,
606 struct ieee80211_sta *sta,
607 void *data, u32 field);
608-int mt7915_mcu_set_eeprom(struct mt7915_dev *dev);
developerc9333e12023-04-06 18:07:42 +0800609-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
developer6caa5e22022-06-16 13:33:13 +0800610+int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode);
developerc9333e12023-04-06 18:07:42 +0800611+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf);
developer6caa5e22022-06-16 13:33:13 +0800612 int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
613 int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
developerc9333e12023-04-06 18:07:42 +0800614 bool hdr_trans);
developerbd9fa1e2023-10-16 11:04:00 +0800615@@ -582,6 +594,7 @@ int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
developer6caa5e22022-06-16 13:33:13 +0800616 int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
617 void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
618 void mt7915_mcu_exit(struct mt7915_dev *dev);
619+int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb);
620
621 static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
622 {
623diff --git a/mt7915/regs.h b/mt7915/regs.h
developerbd9fa1e2023-10-16 11:04:00 +0800624index 2a9e50b..6783797 100644
developer6caa5e22022-06-16 13:33:13 +0800625--- a/mt7915/regs.h
626+++ b/mt7915/regs.h
developer3609d782022-11-29 18:07:22 +0800627@@ -62,6 +62,7 @@ enum offs_rev {
developer6caa5e22022-06-16 13:33:13 +0800628 ARB_DRNGR0,
629 ARB_SCR,
630 RMAC_MIB_AIRTIME14,
631+ AGG_AALCR0,
632 AGG_AWSCR0,
633 AGG_PCR0,
634 AGG_ACR0,
developerbd9fa1e2023-10-16 11:04:00 +0800635@@ -486,6 +487,8 @@ enum offs_rev {
developer6caa5e22022-06-16 13:33:13 +0800636 #define MT_WF_AGG_BASE(_band) ((_band) ? 0x820f2000 : 0x820e2000)
637 #define MT_WF_AGG(_band, ofs) (MT_WF_AGG_BASE(_band) + (ofs))
638
639+#define MT_AGG_AALCR0(_band, _n) MT_WF_AGG(_band, (__OFFS(AGG_AALCR0) + \
developer692ed9b2023-06-19 12:03:50 +0800640+ (_n) * 4))
developer6caa5e22022-06-16 13:33:13 +0800641 #define MT_AGG_AWSCR0(_band, _n) MT_WF_AGG(_band, (__OFFS(AGG_AWSCR0) + \
642 (_n) * 4))
643 #define MT_AGG_PCR0(_band, _n) MT_WF_AGG(_band, (__OFFS(AGG_PCR0) + \
644diff --git a/mt7915/testmode.c b/mt7915/testmode.c
developer70180b02023-11-14 17:01:47 +0800645index 4693919..32dc85c 100644
developer6caa5e22022-06-16 13:33:13 +0800646--- a/mt7915/testmode.c
647+++ b/mt7915/testmode.c
developerbd9fa1e2023-10-16 11:04:00 +0800648@@ -9,6 +9,10 @@
developer6caa5e22022-06-16 13:33:13 +0800649 enum {
650 TM_CHANGED_TXPOWER,
651 TM_CHANGED_FREQ_OFFSET,
developerbd9fa1e2023-10-16 11:04:00 +0800652+ TM_CHANGED_SKU_EN,
developer6caa5e22022-06-16 13:33:13 +0800653+ TM_CHANGED_AID,
654+ TM_CHANGED_CFG,
655+ TM_CHANGED_TXBF_ACT,
656
657 /* must be last */
658 NUM_TM_CHANGED
developerbd9fa1e2023-10-16 11:04:00 +0800659@@ -17,6 +21,10 @@ enum {
developer6caa5e22022-06-16 13:33:13 +0800660 static const u8 tm_change_map[] = {
661 [TM_CHANGED_TXPOWER] = MT76_TM_ATTR_TX_POWER,
662 [TM_CHANGED_FREQ_OFFSET] = MT76_TM_ATTR_FREQ_OFFSET,
developerbd9fa1e2023-10-16 11:04:00 +0800663+ [TM_CHANGED_SKU_EN] = MT76_TM_ATTR_SKU_EN,
developer6caa5e22022-06-16 13:33:13 +0800664+ [TM_CHANGED_AID] = MT76_TM_ATTR_AID,
665+ [TM_CHANGED_CFG] = MT76_TM_ATTR_CFG,
666+ [TM_CHANGED_TXBF_ACT] = MT76_TM_ATTR_TXBF_ACT,
667 };
668
669 struct reg_band {
developerbd9fa1e2023-10-16 11:04:00 +0800670@@ -33,6 +41,57 @@ struct reg_band {
developer6caa5e22022-06-16 13:33:13 +0800671 #define TM_REG_MAX_ID 20
672 static struct reg_band reg_backup_list[TM_REG_MAX_ID];
673
674+static void mt7915_tm_update_entry(struct mt7915_phy *phy);
675+
676+static u8 mt7915_tm_chan_bw(enum nl80211_chan_width width)
677+{
678+ static const u8 width_to_bw[] = {
679+ [NL80211_CHAN_WIDTH_40] = TM_CBW_40MHZ,
680+ [NL80211_CHAN_WIDTH_80] = TM_CBW_80MHZ,
681+ [NL80211_CHAN_WIDTH_80P80] = TM_CBW_8080MHZ,
682+ [NL80211_CHAN_WIDTH_160] = TM_CBW_160MHZ,
683+ [NL80211_CHAN_WIDTH_5] = TM_CBW_5MHZ,
684+ [NL80211_CHAN_WIDTH_10] = TM_CBW_10MHZ,
685+ [NL80211_CHAN_WIDTH_20] = TM_CBW_20MHZ,
686+ [NL80211_CHAN_WIDTH_20_NOHT] = TM_CBW_20MHZ,
687+ };
688+
689+ if (width >= ARRAY_SIZE(width_to_bw))
690+ return 0;
691+
692+ return width_to_bw[width];
693+}
694+
developer692ed9b2023-06-19 12:03:50 +0800695+static int
696+mt7915_tm_check_antenna(struct mt7915_phy *phy)
697+{
698+ struct mt76_testmode_data *td = &phy->mt76->test;
699+ struct mt7915_dev *dev = phy->dev;
700+ u8 band_idx = phy->mt76->band_idx;
701+ u32 chainmask = phy->mt76->chainmask;
702+
703+ chainmask = chainmask >> (dev->chainshift * band_idx);
704+ if (td->tx_antenna_mask & ~chainmask) {
705+ dev_err(dev->mt76.dev,
706+ "tx antenna mask %d exceeds hardware limitation (chainmask %d)\n",
707+ td->tx_antenna_mask, chainmask);
708+ return -EINVAL;
709+ }
710+
711+ return 0;
712+}
713+
developer6caa5e22022-06-16 13:33:13 +0800714+static void
715+mt7915_tm_update_channel(struct mt7915_phy *phy)
716+{
717+ mutex_unlock(&phy->dev->mt76.mutex);
718+ mt7915_set_channel(phy);
719+ mutex_lock(&phy->dev->mt76.mutex);
720+
721+ mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(SET_RX_PATH));
722+
723+ mt7915_tm_update_entry(phy);
724+}
725
726 static int
727 mt7915_tm_set_tx_power(struct mt7915_phy *phy)
developerbd9fa1e2023-10-16 11:04:00 +0800728@@ -119,18 +178,28 @@ mt7915_tm_set_trx(struct mt7915_phy *phy, int type, bool en)
developer6caa5e22022-06-16 13:33:13 +0800729 }
730
731 static int
732-mt7915_tm_clean_hwq(struct mt7915_phy *phy, u8 wcid)
733+mt7915_tm_clean_hwq(struct mt7915_phy *phy)
734 {
735+ struct mt76_testmode_entry_data *ed;
736+ struct mt76_wcid *wcid;
737 struct mt7915_dev *dev = phy->dev;
738 struct mt7915_tm_cmd req = {
739 .testmode_en = 1,
740 .param_idx = MCU_ATE_CLEAN_TXQUEUE,
741- .param.clean.wcid = wcid,
developer17bb0a82022-12-13 15:52:04 +0800742 .param.clean.band = phy->mt76->band_idx,
developer6caa5e22022-06-16 13:33:13 +0800743 };
744
745- return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
746- sizeof(req), false);
747+ mt76_tm_for_each_entry(phy->mt76, wcid, ed) {
748+ int ret;
749+
750+ req.param.clean.wcid = wcid->idx;
751+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL),
752+ &req, sizeof(req), false);
753+ if (ret)
754+ return ret;
755+ }
756+
757+ return 0;
758 }
759
760 static int
developerbd9fa1e2023-10-16 11:04:00 +0800761@@ -141,7 +210,7 @@ mt7915_tm_set_phy_count(struct mt7915_phy *phy, u8 control)
developer17bb0a82022-12-13 15:52:04 +0800762 .testmode_en = 1,
763 .param_idx = MCU_ATE_SET_PHY_COUNT,
764 .param.cfg.enable = control,
765- .param.cfg.band = phy != &dev->phy,
766+ .param.cfg.band = phy->mt76->band_idx,
767 };
768
769 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
developerbd9fa1e2023-10-16 11:04:00 +0800770@@ -182,12 +251,739 @@ mt7915_tm_set_tam_arb(struct mt7915_phy *phy, bool enable, bool mu)
developer6caa5e22022-06-16 13:33:13 +0800771 return mt7915_mcu_set_muru_ctrl(dev, MURU_SET_ARB_OP_MODE, op_mode);
772 }
773
774+static int
775+mt7915_tm_set_cfg(struct mt7915_phy *phy)
776+{
777+ static const u8 cfg_cmd[] = {
778+ [MT76_TM_CFG_TSSI] = MCU_ATE_SET_TSSI,
779+ [MT76_TM_CFG_DPD] = MCU_ATE_SET_DPD,
780+ [MT76_TM_CFG_RATE_POWER_OFFSET] = MCU_ATE_SET_RATE_POWER_OFFSET,
781+ [MT76_TM_CFG_THERMAL_COMP] = MCU_ATE_SET_THERMAL_COMP,
782+ };
783+ struct mt76_testmode_data *td = &phy->mt76->test;
784+ struct mt7915_dev *dev = phy->dev;
785+ struct mt7915_tm_cmd req = {
786+ .testmode_en = !(phy->mt76->test.state == MT76_TM_STATE_OFF),
787+ .param_idx = cfg_cmd[td->cfg.type],
788+ .param.cfg.enable = td->cfg.enable,
developer17bb0a82022-12-13 15:52:04 +0800789+ .param.cfg.band = phy->mt76->band_idx,
developer6caa5e22022-06-16 13:33:13 +0800790+ };
791+
792+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
793+ sizeof(req), false);
794+}
795+
796+static int
797+mt7915_tm_add_txbf(struct mt7915_phy *phy, struct ieee80211_vif *vif,
798+ struct ieee80211_sta *sta, u8 pfmu_idx, u8 nr,
799+ u8 nc, bool ebf)
800+{
801+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
802+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
803+ struct mt7915_dev *dev = phy->dev;
804+ struct sk_buff *skb;
805+ struct sta_rec_bf *bf;
806+ struct tlv *tlv;
807+ u8 ndp_rate;
808+
809+ if (nr == 1)
810+ ndp_rate = 8;
811+ else if (nr == 2)
812+ ndp_rate = 16;
813+ else
814+ ndp_rate = 24;
815+
816+ skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
817+ &msta->wcid);
818+ if (IS_ERR(skb))
819+ return PTR_ERR(skb);
820+
821+ tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BF, sizeof(*bf));
822+ bf = (struct sta_rec_bf *)tlv;
823+
824+ bf->pfmu = cpu_to_le16(pfmu_idx);
825+ bf->sounding_phy = 1;
826+ bf->bf_cap = ebf;
827+ bf->ncol = nc;
828+ bf->nrow = nr;
829+ bf->ndp_rate = ndp_rate;
830+ bf->ibf_timeout = 0xff;
831+ bf->tx_mode = MT_PHY_TYPE_HT;
832+
833+ if (ebf) {
834+ bf->mem[0].row = 0;
835+ bf->mem[1].row = 1;
836+ bf->mem[2].row = 2;
837+ bf->mem[3].row = 3;
838+ } else {
839+ bf->mem[0].row = 4;
840+ bf->mem[1].row = 5;
841+ bf->mem[2].row = 6;
842+ bf->mem[3].row = 7;
843+ }
844+
845+ return mt76_mcu_skb_send_msg(&dev->mt76, skb,
846+ MCU_EXT_CMD(STA_REC_UPDATE), true);
847+}
848+
849+static int
850+mt7915_tm_entry_add(struct mt7915_phy *phy, u8 aid)
851+{
852+ struct mt76_testmode_data *td = &phy->mt76->test;
853+ struct mt76_testmode_entry_data *ed;
854+ struct ieee80211_sband_iftype_data *sdata;
855+ struct ieee80211_supported_band *sband;
856+ struct ieee80211_sta *sta;
857+ struct mt7915_sta *msta;
858+ int tid, ret;
859+
860+ if (td->entry_num >= MT76_TM_MAX_ENTRY_NUM)
861+ return -EINVAL;
862+
863+ sta = kzalloc(sizeof(*sta) + phy->mt76->hw->sta_data_size +
864+ sizeof(*ed), GFP_KERNEL);
865+ if (!sta)
866+ return -ENOMEM;
867+
868+ msta = (struct mt7915_sta *)sta->drv_priv;
869+ ed = mt76_testmode_entry_data(phy->mt76, &msta->wcid);
870+ memcpy(ed, &td->ed, sizeof(*ed));
871+
872+ if (phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ) {
873+ sband = &phy->mt76->sband_5g.sband;
874+ sdata = phy->iftype[NL80211_BAND_5GHZ];
875+ } else if (phy->mt76->chandef.chan->band == NL80211_BAND_6GHZ) {
876+ sband = &phy->mt76->sband_6g.sband;
877+ sdata = phy->iftype[NL80211_BAND_6GHZ];
878+ } else {
879+ sband = &phy->mt76->sband_2g.sband;
880+ sdata = phy->iftype[NL80211_BAND_2GHZ];
881+ }
882+
883+ memcpy(sta->addr, ed->addr[0], ETH_ALEN);
884+ if (phy->test.bf_en) {
885+ u8 addr[ETH_ALEN] = {0x00, 0x11, 0x11, 0x11, 0x11, 0x11};
886+
887+ memcpy(sta->addr, addr, ETH_ALEN);
888+ }
889+
890+ if (td->tx_rate_mode >= MT76_TM_TX_MODE_HT)
developer17bb0a82022-12-13 15:52:04 +0800891+ memcpy(&sta->deflink.ht_cap, &sband->ht_cap, sizeof(sta->deflink.ht_cap));
developer6caa5e22022-06-16 13:33:13 +0800892+ if (td->tx_rate_mode >= MT76_TM_TX_MODE_VHT)
developer17bb0a82022-12-13 15:52:04 +0800893+ memcpy(&sta->deflink.vht_cap, &sband->vht_cap, sizeof(sta->deflink.vht_cap));
developer6caa5e22022-06-16 13:33:13 +0800894+ if (td->tx_rate_mode >= MT76_TM_TX_MODE_HE_SU)
developer17bb0a82022-12-13 15:52:04 +0800895+ memcpy(&sta->deflink.he_cap, &sdata[NL80211_IFTYPE_STATION].he_cap,
896+ sizeof(sta->deflink.he_cap));
developer6caa5e22022-06-16 13:33:13 +0800897+ sta->aid = aid;
898+ sta->wme = 1;
899+
900+ ret = mt7915_mac_sta_add(&phy->dev->mt76, phy->monitor_vif, sta);
901+ if (ret) {
902+ kfree(sta);
903+ return ret;
904+ }
905+
906+ /* prevent from starting tx ba session */
907+ for (tid = 0; tid < 8; tid++)
developer47efbdb2023-06-29 20:33:22 +0800908+ set_bit(tid, &msta->wcid.ampdu_state);
developer6caa5e22022-06-16 13:33:13 +0800909+
910+ list_add_tail(&msta->wcid.list, &td->tm_entry_list);
911+ td->entry_num++;
912+
913+ return 0;
914+}
915+
916+static void
917+mt7915_tm_entry_remove(struct mt7915_phy *phy, u8 aid)
918+{
919+ struct mt76_testmode_data *td = &phy->mt76->test;
920+ struct mt76_wcid *wcid, *tmp;
921+
922+ if (list_empty(&td->tm_entry_list))
923+ return;
924+
925+ list_for_each_entry_safe(wcid, tmp, &td->tm_entry_list, list) {
926+ struct mt76_testmode_entry_data *ed;
927+ struct mt7915_dev *dev = phy->dev;
928+ struct ieee80211_sta *sta;
929+
930+ ed = mt76_testmode_entry_data(phy->mt76, wcid);
931+ if (aid && ed->aid != aid)
932+ continue;
933+
934+ sta = wcid_to_sta(wcid);
935+ mt7915_mac_sta_remove(&dev->mt76, phy->monitor_vif, sta);
936+ mt76_wcid_mask_clear(dev->mt76.wcid_mask, wcid->idx);
937+
938+ list_del_init(&wcid->list);
939+ kfree(sta);
940+ phy->mt76->test.entry_num--;
941+ }
942+}
943+
944+static int
945+mt7915_tm_set_entry(struct mt7915_phy *phy)
946+{
947+ struct mt76_testmode_data *td = &phy->mt76->test;
948+ struct mt76_testmode_entry_data *ed;
949+ struct mt76_wcid *wcid;
950+
951+ if (!td->aid) {
952+ if (td->state > MT76_TM_STATE_IDLE)
953+ mt76_testmode_set_state(phy->mt76, MT76_TM_STATE_IDLE);
954+ mt7915_tm_entry_remove(phy, td->aid);
955+ return 0;
956+ }
957+
958+ mt76_tm_for_each_entry(phy->mt76, wcid, ed) {
959+ if (ed->aid == td->aid) {
960+ struct sk_buff *skb;
961+
962+ local_bh_disable();
963+ skb = ed->tx_skb;
964+ memcpy(ed, &td->ed, sizeof(*ed));
965+ ed->tx_skb = skb;
966+ local_bh_enable();
967+
968+ return 0;
969+ }
970+ }
971+
972+ return mt7915_tm_entry_add(phy, td->aid);
973+}
974+
975+static void
976+mt7915_tm_update_entry(struct mt7915_phy *phy)
977+{
978+ struct mt76_testmode_data *td = &phy->mt76->test;
979+ struct mt76_testmode_entry_data *ed, tmp;
980+ struct mt76_wcid *wcid, *last;
981+
982+ if (!td->aid || phy->test.bf_en)
983+ return;
984+
985+ memcpy(&tmp, &td->ed, sizeof(tmp));
986+ last = list_last_entry(&td->tm_entry_list,
987+ struct mt76_wcid, list);
988+
989+ mt76_tm_for_each_entry(phy->mt76, wcid, ed) {
990+ memcpy(&td->ed, ed, sizeof(td->ed));
991+ mt7915_tm_entry_remove(phy, td->aid);
992+ mt7915_tm_entry_add(phy, td->aid);
993+ if (wcid == last)
994+ break;
995+ }
996+
997+ memcpy(&td->ed, &tmp, sizeof(td->ed));
998+}
999+
1000+static int
1001+mt7915_tm_txbf_init(struct mt7915_phy *phy, u16 *val)
1002+{
1003+ struct mt76_testmode_data *td = &phy->mt76->test;
1004+ struct mt7915_dev *dev = phy->dev;
1005+ bool enable = val[0];
1006+ void *phase_cal, *pfmu_data, *pfmu_tag;
1007+ u8 addr[ETH_ALEN] = {0x00, 0x22, 0x22, 0x22, 0x22, 0x22};
1008+
1009+ if (!enable) {
1010+ phy->test.bf_en = 0;
1011+ return 0;
1012+ }
1013+
1014+ if (!dev->test.txbf_phase_cal) {
1015+ phase_cal = devm_kzalloc(dev->mt76.dev,
1016+ sizeof(struct mt7915_tm_txbf_phase) *
1017+ MAX_PHASE_GROUP_NUM,
1018+ GFP_KERNEL);
1019+ if (!phase_cal)
1020+ return -ENOMEM;
1021+
1022+ dev->test.txbf_phase_cal = phase_cal;
1023+ }
1024+
1025+ if (!dev->test.txbf_pfmu_data) {
1026+ pfmu_data = devm_kzalloc(dev->mt76.dev, 512, GFP_KERNEL);
1027+ if (!pfmu_data)
1028+ return -ENOMEM;
1029+
1030+ dev->test.txbf_pfmu_data = pfmu_data;
1031+ }
1032+
1033+ if (!dev->test.txbf_pfmu_tag) {
1034+ pfmu_tag = devm_kzalloc(dev->mt76.dev,
1035+ sizeof(struct mt7915_tm_pfmu_tag), GFP_KERNEL);
1036+ if (!pfmu_tag)
1037+ return -ENOMEM;
1038+
1039+ dev->test.txbf_pfmu_tag = pfmu_tag;
1040+ }
1041+
1042+ memcpy(phy->monitor_vif->addr, addr, ETH_ALEN);
1043+ mt7915_mcu_add_dev_info(phy, phy->monitor_vif, true);
1044+
1045+ td->tx_rate_mode = MT76_TM_TX_MODE_HT;
1046+ td->tx_mpdu_len = 1024;
1047+ td->tx_rate_sgi = 0;
1048+ td->tx_ipg = 100;
1049+ phy->test.bf_en = 1;
1050+
1051+ return mt7915_tm_set_trx(phy, TM_MAC_TX, true);
1052+}
1053+
1054+static int
1055+mt7915_tm_txbf_phase_comp(struct mt7915_phy *phy, u16 *val)
1056+{
1057+ struct mt7915_dev *dev = phy->dev;
1058+ struct {
1059+ u8 category;
1060+ u8 wlan_idx_lo;
1061+ u8 bw;
1062+ u8 jp_band;
1063+ u8 dbdc_idx;
1064+ bool read_from_e2p;
1065+ bool disable;
1066+ u8 wlan_idx_hi;
1067+ u8 buf[40];
1068+ } __packed req = {
1069+ .category = MT_BF_IBF_PHASE_COMP,
1070+ .bw = val[0],
1071+ .jp_band = (val[2] == 1) ? 1 : 0,
developer17bb0a82022-12-13 15:52:04 +08001072+ .dbdc_idx = phy->mt76->band_idx,
developer6caa5e22022-06-16 13:33:13 +08001073+ .read_from_e2p = val[3],
1074+ .disable = val[4],
1075+ };
1076+ struct mt7915_tm_txbf_phase *phase =
1077+ (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal;
1078+
1079+ wait_event_timeout(dev->mt76.tx_wait, phase[val[2]].status != 0, HZ);
1080+ memcpy(req.buf, &phase[val[2]].phase, sizeof(req.buf));
1081+
1082+ pr_info("ibf cal process: phase comp info\n");
1083+ print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
1084+ &req, sizeof(req), 0);
1085+
1086+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req,
1087+ sizeof(req), true);
1088+}
1089+
1090+static int
1091+mt7915_tm_txbf_profile_tag_read(struct mt7915_phy *phy, u8 pfmu_idx)
1092+{
1093+ struct mt7915_dev *dev = phy->dev;
1094+ struct {
1095+ u8 format_id;
1096+ u8 pfmu_idx;
1097+ bool bfer;
1098+ u8 dbdc_idx;
1099+ } __packed req = {
1100+ .format_id = MT_BF_PFMU_TAG_READ,
1101+ .pfmu_idx = pfmu_idx,
1102+ .bfer = 1,
1103+ .dbdc_idx = phy != &dev->phy,
1104+ };
1105+ struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag;
1106+
1107+ tag->t1.pfmu_idx = 0;
1108+
1109+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req,
1110+ sizeof(req), true);
1111+}
1112+
1113+static int
1114+mt7915_tm_txbf_profile_tag_write(struct mt7915_phy *phy, u8 pfmu_idx,
1115+ struct mt7915_tm_pfmu_tag *tag)
1116+{
1117+ struct mt7915_dev *dev = phy->dev;
1118+ struct {
1119+ u8 format_id;
1120+ u8 pfmu_idx;
1121+ bool bfer;
1122+ u8 dbdc_idx;
1123+ u8 buf[64];
1124+ } __packed req = {
1125+ .format_id = MT_BF_PFMU_TAG_WRITE,
1126+ .pfmu_idx = pfmu_idx,
1127+ .bfer = 1,
1128+ .dbdc_idx = phy != &dev->phy,
1129+ };
1130+
1131+ memcpy(req.buf, tag, sizeof(*tag));
1132+ wait_event_timeout(dev->mt76.tx_wait, tag->t1.pfmu_idx != 0, HZ);
1133+
1134+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req,
1135+ sizeof(req), false);
1136+}
1137+
1138+static int
1139+mt7915_tm_txbf_apply_tx(struct mt7915_phy *phy, u16 wlan_idx, bool ebf,
1140+ bool ibf, bool phase_cal)
1141+{
1142+#define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
1143+#define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
1144+ struct mt7915_dev *dev = phy->dev;
1145+ struct {
1146+ u8 category;
1147+ u8 wlan_idx_lo;
1148+ bool ebf;
1149+ bool ibf;
1150+ bool mu_txbf;
1151+ bool phase_cal;
1152+ u8 wlan_idx_hi;
1153+ u8 _rsv;
1154+ } __packed req = {
1155+ .category = MT_BF_DATA_PACKET_APPLY,
1156+ .wlan_idx_lo = to_wcid_lo(wlan_idx),
1157+ .ebf = ebf,
1158+ .ibf = ibf,
1159+ .phase_cal = phase_cal,
1160+ .wlan_idx_hi = to_wcid_hi(wlan_idx),
1161+ };
1162+
1163+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req,
1164+ sizeof(req), false);
1165+}
1166+
1167+static int mt7915_tm_txbf_set_rate(struct mt7915_phy *phy,
1168+ struct mt76_wcid *wcid)
1169+{
1170+ struct mt7915_dev *dev = phy->dev;
1171+ struct mt76_testmode_entry_data *ed = mt76_testmode_entry_data(phy->mt76, wcid);
1172+ struct ieee80211_sta *sta = wcid_to_sta(wcid);
1173+ struct sta_phy rate = {};
1174+
1175+ if (!sta)
1176+ return 0;
1177+
1178+ rate.type = MT_PHY_TYPE_HT;
1179+ rate.bw = mt7915_tm_chan_bw(phy->mt76->chandef.width);
1180+ rate.nss = ed->tx_rate_nss;
1181+ rate.mcs = ed->tx_rate_idx;
1182+ rate.ldpc = (rate.bw || ed->tx_rate_ldpc) * GENMASK(2, 0);
1183+
1184+ return mt7915_mcu_set_fixed_rate_ctrl(dev, phy->monitor_vif, sta,
1185+ &rate, RATE_PARAM_FIXED);
1186+}
1187+
1188+static int
1189+mt7915_tm_txbf_set_tx(struct mt7915_phy *phy, u16 *val)
1190+{
1191+ bool bf_on = val[0], update = val[3];
1192+ /* u16 wlan_idx = val[2]; */
1193+ struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag;
1194+ struct mt76_testmode_data *td = &phy->mt76->test;
1195+ struct mt76_wcid *wcid;
1196+
1197+ if (bf_on) {
1198+ mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false);
1199+ mt7915_tm_txbf_profile_tag_read(phy, 2);
1200+ tag->t1.invalid_prof = false;
1201+ mt7915_tm_txbf_profile_tag_write(phy, 2, tag);
1202+
1203+ phy->test.bf_ever_en = true;
1204+
1205+ if (update)
1206+ mt7915_tm_txbf_apply_tx(phy, 1, 0, 1, 1);
1207+ } else {
1208+ if (!phy->test.bf_ever_en) {
1209+ if (update)
1210+ mt7915_tm_txbf_apply_tx(phy, 1, 0, 0, 0);
1211+ } else {
1212+ phy->test.bf_ever_en = false;
1213+
1214+ mt7915_tm_txbf_profile_tag_read(phy, 2);
1215+ tag->t1.invalid_prof = true;
1216+ mt7915_tm_txbf_profile_tag_write(phy, 2, tag);
1217+ }
1218+ }
1219+
1220+ wcid = list_first_entry(&td->tm_entry_list, struct mt76_wcid, list);
1221+ mt7915_tm_txbf_set_rate(phy, wcid);
1222+
1223+ return 0;
1224+}
1225+
1226+static int
1227+mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf)
1228+{
1229+ static const u8 mode_to_lm[] = {
1230+ [MT76_TM_TX_MODE_CCK] = 0,
1231+ [MT76_TM_TX_MODE_OFDM] = 0,
1232+ [MT76_TM_TX_MODE_HT] = 1,
1233+ [MT76_TM_TX_MODE_VHT] = 2,
1234+ [MT76_TM_TX_MODE_HE_SU] = 3,
1235+ [MT76_TM_TX_MODE_HE_EXT_SU] = 3,
1236+ [MT76_TM_TX_MODE_HE_TB] = 3,
1237+ [MT76_TM_TX_MODE_HE_MU] = 3,
1238+ };
1239+ struct mt76_testmode_data *td = &phy->mt76->test;
1240+ struct mt76_wcid *wcid;
1241+ struct ieee80211_vif *vif = phy->monitor_vif;
1242+ struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag;
1243+ u8 pfmu_idx = val[0], nc = val[2], nr;
1244+ int ret;
1245+
1246+ if (td->tx_antenna_mask == 3)
1247+ nr = 1;
1248+ else if (td->tx_antenna_mask == 7)
1249+ nr = 2;
1250+ else
1251+ nr = 3;
1252+
1253+ memset(tag, 0, sizeof(*tag));
1254+ tag->t1.pfmu_idx = pfmu_idx;
1255+ tag->t1.ebf = ebf;
1256+ tag->t1.nr = nr;
1257+ tag->t1.nc = nc;
1258+ tag->t1.invalid_prof = true;
1259+
1260+ tag->t1.snr_sts4 = 0xc0;
1261+ tag->t1.snr_sts5 = 0xff;
1262+ tag->t1.snr_sts6 = 0xff;
1263+ tag->t1.snr_sts7 = 0xff;
1264+
1265+ if (ebf) {
1266+ tag->t1.row_id1 = 0;
1267+ tag->t1.row_id2 = 1;
1268+ tag->t1.row_id3 = 2;
1269+ tag->t1.row_id4 = 3;
1270+ tag->t1.lm = mode_to_lm[MT76_TM_TX_MODE_HT];
1271+ } else {
1272+ tag->t1.row_id1 = 4;
1273+ tag->t1.row_id2 = 5;
1274+ tag->t1.row_id3 = 6;
1275+ tag->t1.row_id4 = 7;
1276+ tag->t1.lm = mode_to_lm[MT76_TM_TX_MODE_OFDM];
1277+
1278+ tag->t2.ibf_timeout = 0xff;
1279+ tag->t2.ibf_nr = nr;
1280+ }
1281+
1282+ ret = mt7915_tm_txbf_profile_tag_write(phy, pfmu_idx, tag);
1283+ if (ret)
1284+ return ret;
1285+
1286+ wcid = list_first_entry(&td->tm_entry_list, struct mt76_wcid, list);
1287+ ret = mt7915_tm_add_txbf(phy, vif, wcid_to_sta(wcid), pfmu_idx, nr, nc, ebf);
1288+ if (ret)
1289+ return ret;
1290+
1291+ if (!ebf)
1292+ return mt7915_tm_txbf_apply_tx(phy, 1, false, true, true);
1293+
1294+ return 0;
1295+}
1296+
1297+static int
1298+mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val)
1299+{
1300+#define GROUP_L 0
1301+#define GROUP_M 1
1302+#define GROUP_H 2
1303+ struct mt7915_dev *dev = phy->dev;
1304+ struct {
1305+ u8 category;
1306+ u8 group_l_m_n;
1307+ u8 group;
1308+ bool sx2;
1309+ u8 cal_type;
1310+ u8 lna_gain_level;
1311+ u8 _rsv[2];
1312+ } __packed req = {
1313+ .category = MT_BF_PHASE_CAL,
1314+ .group = val[0],
1315+ .group_l_m_n = val[1],
1316+ .sx2 = val[2],
1317+ .cal_type = val[3],
1318+ .lna_gain_level = 0, /* for test purpose */
1319+ };
1320+ struct mt7915_tm_txbf_phase *phase =
1321+ (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal;
1322+
1323+ phase[req.group].status = 0;
1324+
1325+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req,
1326+ sizeof(req), true);
1327+}
1328+
1329+int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb)
1330+{
1331+#define BF_PFMU_TAG 16
1332+#define BF_CAL_PHASE 21
1333+ u8 format_id;
1334+
developer7c3a5082022-06-24 13:40:42 +08001335+ skb_pull(skb, sizeof(struct mt76_connac2_mcu_rxd));
developer6caa5e22022-06-16 13:33:13 +08001336+ format_id = *(u8 *)skb->data;
1337+
1338+ if (format_id == BF_PFMU_TAG) {
1339+ struct mt7915_tm_pfmu_tag *tag = dev->test.txbf_pfmu_tag;
1340+
1341+ skb_pull(skb, 8);
1342+ memcpy(tag, skb->data, sizeof(struct mt7915_tm_pfmu_tag));
1343+ } else if (format_id == BF_CAL_PHASE) {
1344+ struct mt7915_tm_ibf_cal_info *cal;
1345+ struct mt7915_tm_txbf_phase *phase =
1346+ (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal;
1347+
1348+ cal = (struct mt7915_tm_ibf_cal_info *)skb->data;
1349+ switch (cal->cal_type) {
1350+ case IBF_PHASE_CAL_NORMAL:
1351+ case IBF_PHASE_CAL_NORMAL_INSTRUMENT:
1352+ if (cal->group_l_m_n != GROUP_M)
1353+ break;
1354+ phase = &phase[cal->group];
1355+ memcpy(&phase->phase, cal->buf + 16, sizeof(phase->phase));
1356+ phase->status = cal->status;
1357+ break;
1358+ case IBF_PHASE_CAL_VERIFY:
1359+ case IBF_PHASE_CAL_VERIFY_INSTRUMENT:
1360+ break;
1361+ default:
1362+ break;
1363+ }
1364+ }
1365+
1366+ wake_up(&dev->mt76.tx_wait);
1367+
1368+ return 0;
1369+}
1370+
1371+static int
1372+mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val)
1373+{
1374+ struct mt76_testmode_data *td = &phy->mt76->test;
developerf0fd7052023-08-14 20:23:42 +08001375+ u8 nss = hweight8(td->tx_antenna_mask);
developer6caa5e22022-06-16 13:33:13 +08001376+ u16 pfmu_idx = val[0];
1377+ u16 subc_id = val[1];
1378+ u16 angle11 = val[2];
1379+ u16 angle21 = val[3];
1380+ u16 angle31 = val[4];
1381+ u16 angle41 = val[5];
1382+ s16 phi11 = 0, phi21 = 0, phi31 = 0;
1383+ struct mt7915_tm_pfmu_data *pfmu_data;
1384+
1385+ if (subc_id > 63)
1386+ return -EINVAL;
1387+
developerf0fd7052023-08-14 20:23:42 +08001388+ if (nss == 2) {
developer6caa5e22022-06-16 13:33:13 +08001389+ phi11 = (s16)(angle21 - angle11);
developerf0fd7052023-08-14 20:23:42 +08001390+ } else if (nss == 3) {
developer6caa5e22022-06-16 13:33:13 +08001391+ phi11 = (s16)(angle31 - angle11);
1392+ phi21 = (s16)(angle31 - angle21);
1393+ } else {
1394+ phi11 = (s16)(angle41 - angle11);
1395+ phi21 = (s16)(angle41 - angle21);
1396+ phi31 = (s16)(angle41 - angle31);
1397+ }
1398+
1399+ pfmu_data = (struct mt7915_tm_pfmu_data *)phy->dev->test.txbf_pfmu_data;
1400+ pfmu_data = &pfmu_data[subc_id];
1401+
1402+ if (subc_id < 32)
1403+ pfmu_data->subc_idx = cpu_to_le16(subc_id + 224);
1404+ else
1405+ pfmu_data->subc_idx = cpu_to_le16(subc_id - 32);
1406+ pfmu_data->phi11 = cpu_to_le16(phi11);
1407+ pfmu_data->phi21 = cpu_to_le16(phi21);
1408+ pfmu_data->phi31 = cpu_to_le16(phi31);
1409+
1410+ if (subc_id == 63) {
1411+ struct mt7915_dev *dev = phy->dev;
1412+ struct {
1413+ u8 format_id;
1414+ u8 pfmu_idx;
1415+ u8 dbdc_idx;
1416+ u8 _rsv;
1417+ u8 buf[512];
1418+ } __packed req = {
1419+ .format_id = MT_BF_PROFILE_WRITE_ALL,
1420+ .pfmu_idx = pfmu_idx,
1421+ .dbdc_idx = phy != &dev->phy,
1422+ };
1423+
1424+ memcpy(req.buf, dev->test.txbf_pfmu_data, 512);
1425+
1426+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION),
1427+ &req, sizeof(req), true);
1428+ }
1429+
1430+ return 0;
1431+}
1432+
1433+static int
1434+mt7915_tm_txbf_e2p_update(struct mt7915_phy *phy)
1435+{
1436+ struct mt7915_tm_txbf_phase *phase, *p;
1437+ struct mt7915_dev *dev = phy->dev;
1438+ u8 *eeprom = dev->mt76.eeprom.data;
1439+ u16 offset;
1440+ bool is_7976;
1441+ int i;
1442+
1443+ is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76);
1444+ offset = is_7976 ? 0x60a : 0x651;
1445+
1446+ phase = (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal;
1447+ for (i = 0; i < MAX_PHASE_GROUP_NUM; i++) {
1448+ p = &phase[i];
1449+
1450+ if (!p->status)
1451+ continue;
1452+
1453+ /* copy phase cal data to eeprom */
1454+ memcpy(eeprom + offset + i * sizeof(p->phase), &p->phase,
1455+ sizeof(p->phase));
1456+ }
1457+
1458+ return 0;
1459+}
1460+
1461+static int
1462+mt7915_tm_set_txbf(struct mt7915_phy *phy)
1463+{
1464+ struct mt76_testmode_data *td = &phy->mt76->test;
1465+ u16 *val = td->txbf_param;
1466+
1467+ pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u\n",
1468+ td->txbf_act, val[0], val[1], val[2], val[3], val[4]);
1469+
1470+ switch (td->txbf_act) {
1471+ case MT76_TM_TXBF_ACT_INIT:
1472+ return mt7915_tm_txbf_init(phy, val);
1473+ case MT76_TM_TXBF_ACT_UPDATE_CH:
1474+ mt7915_tm_update_channel(phy);
1475+ break;
1476+ case MT76_TM_TXBF_ACT_PHASE_COMP:
1477+ return mt7915_tm_txbf_phase_comp(phy, val);
1478+ case MT76_TM_TXBF_ACT_TX_PREP:
1479+ return mt7915_tm_txbf_set_tx(phy, val);
1480+ case MT76_TM_TXBF_ACT_IBF_PROF_UPDATE:
1481+ return mt7915_tm_txbf_profile_update(phy, val, false);
1482+ case MT76_TM_TXBF_ACT_EBF_PROF_UPDATE:
1483+ return mt7915_tm_txbf_profile_update(phy, val, true);
1484+ case MT76_TM_TXBF_ACT_PHASE_CAL:
1485+ return mt7915_tm_txbf_phase_cal(phy, val);
1486+ case MT76_TM_TXBF_ACT_PROF_UPDATE_ALL:
1487+ return mt7915_tm_txbf_profile_update_all(phy, val);
1488+ case MT76_TM_TXBF_ACT_E2P_UPDATE:
1489+ return mt7915_tm_txbf_e2p_update(phy);
1490+ default:
1491+ break;
1492+ };
1493+
1494+ return 0;
1495+}
1496+
1497 static int
developer7c3a5082022-06-24 13:40:42 +08001498 mt7915_tm_set_wmm_qid(struct mt7915_phy *phy, u8 qid, u8 aifs, u8 cw_min,
developer6caa5e22022-06-16 13:33:13 +08001499- u16 cw_max, u16 txop)
1500+ u16 cw_max, u16 txop, u8 tx_cmd)
1501 {
developer7c3a5082022-06-24 13:40:42 +08001502 struct mt7915_vif *mvif = (struct mt7915_vif *)phy->monitor_vif->drv_priv;
developer6caa5e22022-06-16 13:33:13 +08001503- struct mt7915_mcu_tx req = { .total = 1 };
1504+ struct mt7915_mcu_tx req = {
1505+ .valid = true,
1506+ .mode = tx_cmd,
1507+ .total = 1,
1508+ };
1509 struct edca *e = &req.edca[0];
1510
developer7c3a5082022-06-24 13:40:42 +08001511 e->queue = qid + mvif->mt76.wmm_idx * MT76_CONNAC_MAX_WMM_SETS;
developerbd9fa1e2023-10-16 11:04:00 +08001512@@ -263,7 +1059,8 @@ done:
developer6caa5e22022-06-16 13:33:13 +08001513
developer7c3a5082022-06-24 13:40:42 +08001514 return mt7915_tm_set_wmm_qid(phy,
developer6caa5e22022-06-16 13:33:13 +08001515 mt76_connac_lmac_mapping(IEEE80211_AC_BE),
1516- aifsn, cw, cw, 0);
1517+ aifsn, cw, cw, 0,
1518+ mode == MT76_TM_TX_MODE_HE_MU);
1519 }
1520
1521 static int
developerbd9fa1e2023-10-16 11:04:00 +08001522@@ -339,7 +1136,7 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time)
developer6caa5e22022-06-16 13:33:13 +08001523 bitrate = cfg80211_calculate_bitrate(&rate);
1524 tx_len = bitrate * tx_time / 10 / 8;
1525
1526- ret = mt76_testmode_alloc_skb(phy->mt76, tx_len);
1527+ ret = mt76_testmode_init_skb(phy->mt76, tx_len, &td->tx_skb, td->addr);
1528 if (ret)
1529 return ret;
1530
developer70180b02023-11-14 17:01:47 +08001531@@ -447,7 +1244,9 @@ mt7915_tm_init(struct mt7915_phy *phy, bool en)
1532 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
1533 return;
1534
1535- mt7915_mcu_set_sku_en(phy, !en);
1536+ phy->sku_limit_en = !en;
1537+ phy->sku_path_en = !en;
1538+ mt7915_mcu_set_sku_en(phy);
1539
1540 mt7915_tm_mode_ctrl(dev, en);
1541 mt7915_tm_reg_backup_restore(phy);
1542@@ -458,64 +1257,227 @@ mt7915_tm_init(struct mt7915_phy *phy, bool en)
developer6caa5e22022-06-16 13:33:13 +08001543
1544 phy->mt76->test.flag |= MT_TM_FW_RX_COUNT;
1545
1546- if (!en)
1547+ if (!en) {
1548 mt7915_tm_set_tam_arb(phy, en, 0);
1549+
1550+ phy->mt76->test.aid = 0;
1551+ phy->mt76->test.tx_mpdu_len = 0;
1552+ phy->test.bf_en = 0;
1553+ mt7915_tm_set_entry(phy);
1554+ }
1555+}
1556+
1557+static bool
1558+mt7915_tm_check_skb(struct mt7915_phy *phy)
1559+{
1560+ struct mt76_testmode_entry_data *ed;
1561+ struct mt76_wcid *wcid;
1562+
1563+ mt76_tm_for_each_entry(phy->mt76, wcid, ed) {
1564+ struct ieee80211_tx_info *info;
1565+
1566+ if (!ed->tx_skb)
1567+ return false;
1568+
1569+ info = IEEE80211_SKB_CB(ed->tx_skb);
1570+ info->control.vif = phy->monitor_vif;
1571+ }
1572+
1573+ return true;
1574+}
1575+
1576+static int
1577+mt7915_tm_set_ba(struct mt7915_phy *phy)
1578+{
1579+ struct mt7915_dev *dev = phy->dev;
1580+ struct mt76_testmode_data *td = &phy->mt76->test;
1581+ struct mt76_wcid *wcid;
1582+ struct ieee80211_vif *vif = phy->monitor_vif;
1583+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1584+ struct ieee80211_ampdu_params params = { .buf_size = 256 };
1585+
1586+ list_for_each_entry(wcid, &td->tm_entry_list, list) {
1587+ int tid, ret;
1588+
1589+ params.sta = wcid_to_sta(wcid);
1590+ for (tid = 0; tid < 8; tid++) {
1591+ params.tid = tid;
1592+ ret = mt7915_mcu_add_tx_ba(phy->dev, &params, true);
1593+ if (ret)
1594+ return ret;
1595+ }
1596+ }
1597+
1598+ mt76_wr(dev, MT_AGG_AALCR0(mvif->mt76.band_idx, mvif->mt76.wmm_idx),
1599+ 0x01010101);
1600+
1601+ return 0;
1602+}
1603+
1604+static int
1605+mt7915_tm_set_muru_cfg(struct mt7915_phy *phy, struct mt7915_tm_muru *muru)
1606+{
1607+/* #define MURU_SET_MANUAL_CFG 100 */
1608+ struct mt7915_dev *dev = phy->dev;
1609+ struct {
1610+ __le32 cmd;
1611+ struct mt7915_tm_muru muru;
1612+ } __packed req = {
1613+ .cmd = cpu_to_le32(MURU_SET_MANUAL_CFG),
1614+ };
1615+
1616+ memcpy(&req.muru, muru, sizeof(struct mt7915_tm_muru));
1617+
1618+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &req,
1619+ sizeof(req), false);
1620+}
1621+
1622+static int
1623+mt7915_tm_set_muru_dl(struct mt7915_phy *phy)
1624+{
1625+ struct mt76_testmode_data *td = &phy->mt76->test;
1626+ struct mt76_testmode_entry_data *ed;
1627+ struct mt76_wcid *wcid;
1628+ struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
1629+ struct ieee80211_vif *vif = phy->monitor_vif;
1630+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1631+ struct mt7915_tm_muru muru = {};
1632+ struct mt7915_tm_muru_comm *comm = &muru.comm;
1633+ struct mt7915_tm_muru_dl *dl = &muru.dl;
1634+ int i;
1635+
1636+ comm->ppdu_format = MURU_PPDU_HE_MU;
1637+ comm->band = mvif->mt76.band_idx;
1638+ comm->wmm_idx = mvif->mt76.wmm_idx;
1639+ comm->spe_idx = phy->test.spe_idx;
1640+
1641+ dl->bw = mt7915_tm_chan_bw(chandef->width);
developer692ed9b2023-06-19 12:03:50 +08001642+ dl->gi = td->tx_rate_sgi;
developer6caa5e22022-06-16 13:33:13 +08001643+ dl->ltf = td->tx_ltf;
1644+ dl->tx_mode = MT_PHY_TYPE_HE_MU;
1645+
1646+ for (i = 0; i < sizeof(dl->ru); i++)
1647+ dl->ru[i] = 0x71;
1648+
1649+ mt76_tm_for_each_entry(phy->mt76, wcid, ed) {
1650+ struct mt7915_tm_muru_dl_usr *dl_usr = &dl->usr[dl->user_num];
1651+
1652+ dl_usr->wlan_idx = cpu_to_le16(wcid->idx);
1653+ dl_usr->ru_alloc_seg = ed->aid < 8 ? 0 : 1;
1654+ dl_usr->ru_idx = ed->ru_idx;
1655+ dl_usr->mcs = ed->tx_rate_idx;
1656+ dl_usr->nss = ed->tx_rate_nss - 1;
1657+ dl_usr->ldpc = ed->tx_rate_ldpc;
1658+ dl->ru[dl->user_num] = ed->ru_alloc;
1659+
1660+ dl->user_num++;
1661+ }
1662+
developer1475cf22023-05-05 13:45:43 +08001663+ muru.cfg_comm = cpu_to_le32(MURU_COMM_SET_TM);
developer6caa5e22022-06-16 13:33:13 +08001664+ muru.cfg_dl = cpu_to_le32(MURU_DL_SET);
1665+
1666+ return mt7915_tm_set_muru_cfg(phy, &muru);
1667+}
1668+
1669+static int
1670+mt7915_tm_set_muru_pkt_cnt(struct mt7915_phy *phy, bool enable, u32 tx_count)
1671+{
1672+#define MURU_SET_TX_PKT_CNT 105
1673+#define MURU_SET_TX_EN 106
1674+ struct mt7915_dev *dev = phy->dev;
1675+ struct {
1676+ __le32 cmd;
1677+ u8 band;
1678+ u8 enable;
1679+ u8 _rsv[2];
1680+ __le32 tx_count;
1681+ } __packed req = {
developer17bb0a82022-12-13 15:52:04 +08001682+ .band = phy->mt76->band_idx,
developer6caa5e22022-06-16 13:33:13 +08001683+ .enable = enable,
1684+ .tx_count = enable ? cpu_to_le32(tx_count) : 0,
1685+ };
1686+ int ret;
1687+
1688+ req.cmd = enable ? cpu_to_le32(MURU_SET_TX_PKT_CNT) :
1689+ cpu_to_le32(MURU_SET_TX_EN);
1690+
1691+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &req,
1692+ sizeof(req), false);
1693+ if (ret)
1694+ return ret;
1695+
1696+ req.cmd = enable ? cpu_to_le32(MURU_SET_TX_EN) :
1697+ cpu_to_le32(MURU_SET_TX_PKT_CNT);
1698+
1699+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &req,
1700+ sizeof(req), false);
1701 }
1702
1703 static void
1704-mt7915_tm_update_channel(struct mt7915_phy *phy)
1705+mt7915_tm_tx_frames_mu(struct mt7915_phy *phy, bool enable)
1706 {
1707- mutex_unlock(&phy->dev->mt76.mutex);
1708- mt7915_set_channel(phy);
1709- mutex_lock(&phy->dev->mt76.mutex);
1710+ struct mt76_testmode_data *td = &phy->mt76->test;
1711
1712- mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(SET_RX_PATH));
1713+ if (enable) {
1714+ struct mt7915_dev *dev = phy->dev;
1715+
1716+ mt7915_tm_set_ba(phy);
1717+ mt7915_tm_set_muru_dl(phy);
1718+ mt76_rr(dev, MT_MIB_DR8(phy != &dev->phy));
1719+ } else {
1720+ /* set to zero for counting real tx free num */
1721+ td->tx_done = 0;
1722+ }
1723+
1724+ mt7915_tm_set_muru_pkt_cnt(phy, enable, td->tx_count);
1725+ usleep_range(100000, 200000);
1726 }
1727
1728 static void
developer072c5612022-07-15 18:30:03 +08001729 mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
1730 {
developer6caa5e22022-06-16 13:33:13 +08001731 struct mt76_testmode_data *td = &phy->mt76->test;
1732- struct mt7915_dev *dev = phy->dev;
1733- struct ieee80211_tx_info *info;
1734- u8 duty_cycle = td->tx_duty_cycle;
1735- u32 tx_time = td->tx_time;
1736- u32 ipg = td->tx_ipg;
1737
1738 mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false);
1739- mt7915_tm_clean_hwq(phy, dev->mt76.global_wcid.idx);
1740+ mt7915_tm_set_trx(phy, TM_MAC_TX, false);
1741
1742 if (en) {
1743- mt7915_tm_update_channel(phy);
1744+ u32 tx_time = td->tx_time, ipg = td->tx_ipg;
1745+ u8 duty_cycle = td->tx_duty_cycle;
1746+
1747+ if (!phy->test.bf_en)
1748+ mt7915_tm_update_channel(phy);
1749
developer072c5612022-07-15 18:30:03 +08001750 if (td->tx_spe_idx)
developer6caa5e22022-06-16 13:33:13 +08001751 phy->test.spe_idx = td->tx_spe_idx;
developer072c5612022-07-15 18:30:03 +08001752 else
1753 phy->test.spe_idx = mt76_connac_spe_idx(td->tx_antenna_mask);
developer6caa5e22022-06-16 13:33:13 +08001754- }
1755
1756- mt7915_tm_set_tam_arb(phy, en,
1757- td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU);
1758+ /* if all three params are set, duty_cycle will be ignored */
1759+ if (duty_cycle && tx_time && !ipg) {
1760+ ipg = tx_time * 100 / duty_cycle - tx_time;
1761+ } else if (duty_cycle && !tx_time && ipg) {
1762+ if (duty_cycle < 100)
1763+ tx_time = duty_cycle * ipg / (100 - duty_cycle);
1764+ }
1765
1766- /* if all three params are set, duty_cycle will be ignored */
1767- if (duty_cycle && tx_time && !ipg) {
1768- ipg = tx_time * 100 / duty_cycle - tx_time;
1769- } else if (duty_cycle && !tx_time && ipg) {
1770- if (duty_cycle < 100)
1771- tx_time = duty_cycle * ipg / (100 - duty_cycle);
1772- }
1773+ mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode);
1774+ mt7915_tm_set_tx_len(phy, tx_time);
1775
1776- mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode);
1777- mt7915_tm_set_tx_len(phy, tx_time);
1778+ if (ipg)
1779+ td->tx_queued_limit = MT76_TM_TIMEOUT * 1000000 / ipg / 2;
1780
1781- if (ipg)
1782- td->tx_queued_limit = MT76_TM_TIMEOUT * 1000000 / ipg / 2;
1783+ if (!mt7915_tm_check_skb(phy))
1784+ return;
1785+ } else {
1786+ mt7915_tm_clean_hwq(phy);
1787+ }
1788
1789- if (!en || !td->tx_skb)
1790- return;
1791+ mt7915_tm_set_tam_arb(phy, en,
1792+ td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU);
1793
1794- info = IEEE80211_SKB_CB(td->tx_skb);
1795- info->control.vif = phy->monitor_vif;
1796+ if (td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
1797+ mt7915_tm_tx_frames_mu(phy, en);
1798
1799 mt7915_tm_set_trx(phy, TM_MAC_TX, en);
1800 }
developer70180b02023-11-14 17:01:47 +08001801@@ -544,10 +1506,6 @@ mt7915_tm_get_rx_stats(struct mt7915_phy *phy, bool clear)
developer6caa5e22022-06-16 13:33:13 +08001802 return ret;
1803
1804 rs_band = (struct mt7915_tm_rx_stat_band *)skb->data;
1805- /* pr_info("mdrdy_cnt = %d\n", le32_to_cpu(rs_band->mdrdy_cnt)); */
1806- /* pr_info("fcs_err = %d\n", le16_to_cpu(rs_band->fcs_err)); */
1807- /* pr_info("len_mismatch = %d\n", le16_to_cpu(rs_band->len_mismatch)); */
1808- /* pr_info("fcs_ok = %d\n", le16_to_cpu(rs_band->fcs_succ)); */
1809
1810 if (!clear) {
developerf7a3ca32022-09-01 14:44:55 +08001811 enum mt76_rxq_id q = req.band ? MT_RXQ_BAND1 : MT_RXQ_MAIN;
developer70180b02023-11-14 17:01:47 +08001812@@ -562,13 +1520,61 @@ mt7915_tm_get_rx_stats(struct mt7915_phy *phy, bool clear)
developer6caa5e22022-06-16 13:33:13 +08001813 return 0;
1814 }
1815
1816+static int
1817+mt7915_tm_set_rx_user_idx(struct mt7915_phy *phy, u8 aid)
1818+{
1819+ struct mt7915_dev *dev = phy->dev;
1820+ struct mt76_wcid *wcid = NULL;
1821+ struct mt76_testmode_entry_data *ed;
1822+ struct {
1823+ u8 band;
1824+ u8 _rsv;
1825+ __le16 wlan_idx;
1826+ } __packed req = {
developer17bb0a82022-12-13 15:52:04 +08001827+ .band = phy->mt76->band_idx,
developer6caa5e22022-06-16 13:33:13 +08001828+ };
1829+
1830+ mt76_tm_for_each_entry(phy->mt76, wcid, ed)
1831+ if (ed->aid == aid)
1832+ break;
1833+
1834+ if (!wcid)
1835+ return -EINVAL;
1836+
1837+ req.wlan_idx = cpu_to_le16(wcid->idx);
1838+
1839+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_STAT_USER_CTRL),
1840+ &req, sizeof(req), false);
1841+}
1842+
1843+static int
1844+mt7915_tm_set_muru_aid(struct mt7915_phy *phy, u16 aid)
1845+{
1846+ struct mt7915_dev *dev = phy->dev;
1847+ struct mt7915_tm_cmd req = {
1848+ .testmode_en = 1,
1849+ .param_idx = MCU_ATE_SET_MU_RX_AID,
developer17bb0a82022-12-13 15:52:04 +08001850+ .param.rx_aid.band = cpu_to_le32(phy->mt76->band_idx),
developer6caa5e22022-06-16 13:33:13 +08001851+ .param.rx_aid.aid = cpu_to_le16(aid),
1852+ };
1853+
1854+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
1855+ sizeof(req), false);
1856+}
1857+
1858 static void
1859 mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en)
1860 {
1861+ struct mt76_testmode_data *td = &phy->mt76->test;
1862+
1863+ mt7915_tm_set_trx(phy, TM_MAC_TX, false);
1864 mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false);
1865
1866 if (en) {
1867- mt7915_tm_update_channel(phy);
1868+ if (!phy->test.bf_en)
1869+ mt7915_tm_update_channel(phy);
1870+ if (td->aid)
1871+ mt7915_tm_set_rx_user_idx(phy, td->aid);
1872
1873 /* read-clear */
1874 mt7915_tm_get_rx_stats(phy, true);
developer70180b02023-11-14 17:01:47 +08001875@@ -576,9 +1582,12 @@ mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en)
developer6caa5e22022-06-16 13:33:13 +08001876 /* clear fw count */
1877 mt7915_tm_set_phy_count(phy, 0);
1878 mt7915_tm_set_phy_count(phy, 1);
1879-
1880- mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en);
1881 }
1882+
1883+ if (td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
1884+ mt7915_tm_set_muru_aid(phy, en ? td->aid : 0xf800);
1885+
1886+ mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en);
1887 }
1888
1889 static int
developer70180b02023-11-14 17:01:47 +08001890@@ -617,34 +1626,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
developer6caa5e22022-06-16 13:33:13 +08001891 tx_cont->tx_ant = td->tx_antenna_mask;
developer17bb0a82022-12-13 15:52:04 +08001892 tx_cont->band = band;
developer3609d782022-11-29 18:07:22 +08001893
developer6caa5e22022-06-16 13:33:13 +08001894- switch (chandef->width) {
1895- case NL80211_CHAN_WIDTH_40:
1896- tx_cont->bw = CMD_CBW_40MHZ;
1897- break;
1898- case NL80211_CHAN_WIDTH_80:
1899- tx_cont->bw = CMD_CBW_80MHZ;
1900- break;
1901- case NL80211_CHAN_WIDTH_80P80:
1902- tx_cont->bw = CMD_CBW_8080MHZ;
1903- break;
1904- case NL80211_CHAN_WIDTH_160:
1905- tx_cont->bw = CMD_CBW_160MHZ;
1906- break;
1907- case NL80211_CHAN_WIDTH_5:
1908- tx_cont->bw = CMD_CBW_5MHZ;
1909- break;
1910- case NL80211_CHAN_WIDTH_10:
1911- tx_cont->bw = CMD_CBW_10MHZ;
1912- break;
1913- case NL80211_CHAN_WIDTH_20:
1914- tx_cont->bw = CMD_CBW_20MHZ;
1915- break;
1916- case NL80211_CHAN_WIDTH_20_NOHT:
1917- tx_cont->bw = CMD_CBW_20MHZ;
1918- break;
1919- default:
1920- return -EINVAL;
1921- }
1922+ tx_cont->bw = mt7915_tm_chan_bw(chandef->width);
1923
1924 if (!en) {
developer17bb0a82022-12-13 15:52:04 +08001925 req.op.rf.param.func_data = cpu_to_le32(band);
developer70180b02023-11-14 17:01:47 +08001926@@ -728,6 +1710,18 @@ mt7915_tm_update_params(struct mt7915_phy *phy, u32 changed)
developer6caa5e22022-06-16 13:33:13 +08001927 mt7915_tm_set_freq_offset(phy, en, en ? td->freq_offset : 0);
1928 if (changed & BIT(TM_CHANGED_TXPOWER))
1929 mt7915_tm_set_tx_power(phy);
developerbd9fa1e2023-10-16 11:04:00 +08001930+ if (changed & BIT(TM_CHANGED_SKU_EN)) {
developer70180b02023-11-14 17:01:47 +08001931+ phy->sku_limit_en = td->sku_en;
1932+ phy->sku_path_en = td->sku_en;
1933+ mt7915_mcu_set_sku_en(phy);
developerbd9fa1e2023-10-16 11:04:00 +08001934+ mt7915_mcu_set_txpower_sku(phy);
1935+ }
developer6caa5e22022-06-16 13:33:13 +08001936+ if (changed & BIT(TM_CHANGED_AID))
1937+ mt7915_tm_set_entry(phy);
1938+ if (changed & BIT(TM_CHANGED_CFG))
1939+ mt7915_tm_set_cfg(phy);
1940+ if (changed & BIT(TM_CHANGED_TXBF_ACT))
1941+ mt7915_tm_set_txbf(phy);
1942 }
1943
1944 static int
developer70180b02023-11-14 17:01:47 +08001945@@ -737,6 +1731,11 @@ mt7915_tm_set_state(struct mt76_phy *mphy, enum mt76_testmode_state state)
developerbb6ddff2023-03-08 17:22:32 +08001946 struct mt7915_phy *phy = mphy->priv;
1947 enum mt76_testmode_state prev_state = td->state;
1948
1949+ if (!phy->monitor_vif) {
1950+ dev_err(phy->dev->mt76.dev, "Please make sure monitor interface is up\n");
1951+ return -ENOTCONN;
1952+ }
1953+
1954 mphy->test.state = state;
1955
1956 if (prev_state == MT76_TM_STATE_TX_FRAMES ||
developer70180b02023-11-14 17:01:47 +08001957@@ -757,7 +1756,7 @@ mt7915_tm_set_state(struct mt76_phy *mphy, enum mt76_testmode_state state)
developer692ed9b2023-06-19 12:03:50 +08001958 (state == MT76_TM_STATE_OFF &&
1959 prev_state == MT76_TM_STATE_IDLE)) {
1960 u32 changed = 0;
1961- int i;
1962+ int i, ret;
1963
1964 for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
1965 u16 cur = tm_change_map[i];
developer70180b02023-11-14 17:01:47 +08001966@@ -766,6 +1765,10 @@ mt7915_tm_set_state(struct mt76_phy *mphy, enum mt76_testmode_state state)
developer692ed9b2023-06-19 12:03:50 +08001967 changed |= BIT(i);
1968 }
1969
1970+ ret = mt7915_tm_check_antenna(phy);
1971+ if (ret)
1972+ return ret;
1973+
1974 mt7915_tm_update_params(phy, changed);
1975 }
1976
developer70180b02023-11-14 17:01:47 +08001977@@ -778,10 +1781,8 @@ mt7915_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
developer692ed9b2023-06-19 12:03:50 +08001978 {
1979 struct mt76_testmode_data *td = &mphy->test;
1980 struct mt7915_phy *phy = mphy->priv;
1981- struct mt7915_dev *dev = phy->dev;
1982- u32 chainmask = mphy->chainmask, changed = 0;
1983- bool ext_phy = phy != &dev->phy;
1984- int i;
1985+ u32 changed = 0;
1986+ int i, ret;
1987
1988 BUILD_BUG_ON(NUM_TM_CHANGED >= 32);
1989
developer70180b02023-11-14 17:01:47 +08001990@@ -789,9 +1790,9 @@ mt7915_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
developer692ed9b2023-06-19 12:03:50 +08001991 td->state == MT76_TM_STATE_OFF)
1992 return 0;
1993
1994- chainmask = ext_phy ? chainmask >> dev->chainshift : chainmask;
1995- if (td->tx_antenna_mask > chainmask)
1996- return -EINVAL;
1997+ ret = mt7915_tm_check_antenna(phy);
1998+ if (ret)
1999+ return ret;
2000
2001 for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
2002 if (tb[tm_change_map[i]])
developer70180b02023-11-14 17:01:47 +08002003@@ -807,6 +1808,7 @@ static int
developer6caa5e22022-06-16 13:33:13 +08002004 mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
2005 {
2006 struct mt7915_phy *phy = mphy->priv;
2007+ struct mt7915_dev *dev = phy->dev;
2008 void *rx, *rssi;
2009 int i;
2010
developer70180b02023-11-14 17:01:47 +08002011@@ -827,6 +1829,16 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
developerbd9fa1e2023-10-16 11:04:00 +08002012
2013 nla_nest_end(msg, rssi);
2014
2015+ rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_RSSI);
2016+ if (!rssi)
2017+ return -ENOMEM;
2018+
2019+ for (i = 0; i < ARRAY_SIZE(phy->test.last_rssi); i++)
2020+ if (nla_put_s8(msg, i, phy->test.last_rssi[i]))
2021+ return -ENOMEM;
2022+
2023+ nla_nest_end(msg, rssi);
2024+
2025 rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_IB_RSSI);
2026 if (!rssi)
2027 return -ENOMEM;
developer70180b02023-11-14 17:01:47 +08002028@@ -852,11 +1864,75 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
developer6caa5e22022-06-16 13:33:13 +08002029
2030 nla_nest_end(msg, rx);
2031
2032+ if (mphy->test.tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
2033+ mphy->test.tx_done += mt76_rr(dev, MT_MIB_DR8(phy != &dev->phy));
2034+
2035 return mt7915_tm_get_rx_stats(phy, false);
2036 }
2037
2038+static int
2039+mt7915_tm_write_back_to_efuse(struct mt7915_dev *dev)
2040+{
2041+ struct mt7915_mcu_eeprom_info req = {};
developerc9333e12023-04-06 18:07:42 +08002042+ u8 read_buf[MT76_TM_EEPROM_BLOCK_SIZE], *eeprom = dev->mt76.eeprom.data;
developer6caa5e22022-06-16 13:33:13 +08002043+ int i, ret = -EINVAL;
2044+
2045+ /* prevent from damaging chip id in efuse */
2046+ if (mt76_chip(&dev->mt76) != get_unaligned_le16(eeprom))
2047+ goto out;
2048+
2049+ for (i = 0; i < mt7915_eeprom_size(dev); i += MT76_TM_EEPROM_BLOCK_SIZE) {
2050+ req.addr = cpu_to_le32(i);
developerc9333e12023-04-06 18:07:42 +08002051+ memcpy(req.data, eeprom + i, MT76_TM_EEPROM_BLOCK_SIZE);
2052+
2053+ ret = mt7915_mcu_get_eeprom(dev, i, read_buf);
2054+ if (ret < 0)
2055+ return ret;
2056+
2057+ if (!memcmp(req.data, read_buf, MT76_TM_EEPROM_BLOCK_SIZE))
2058+ continue;
developer6caa5e22022-06-16 13:33:13 +08002059+
2060+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_ACCESS),
2061+ &req, sizeof(req), true);
2062+ if (ret)
2063+ return ret;
2064+ }
2065+
2066+out:
2067+ return ret;
2068+}
2069+
2070+static int
2071+mt7915_tm_set_eeprom(struct mt76_phy *mphy, u32 offset, u8 *val, u8 action)
2072+{
2073+ struct mt7915_phy *phy = mphy->priv;
2074+ struct mt7915_dev *dev = phy->dev;
2075+ u8 *eeprom = dev->mt76.eeprom.data;
2076+ int ret = 0;
2077+
2078+ if (offset >= mt7915_eeprom_size(dev))
2079+ return -EINVAL;
2080+
2081+ switch (action) {
2082+ case MT76_TM_EEPROM_ACTION_UPDATE_DATA:
2083+ memcpy(eeprom + offset, val, MT76_TM_EEPROM_BLOCK_SIZE);
2084+ break;
2085+ case MT76_TM_EEPROM_ACTION_UPDATE_BUFFER_MODE:
2086+ ret = mt7915_mcu_set_eeprom(dev, true);
2087+ break;
2088+ case MT76_TM_EEPROM_ACTION_WRITE_TO_EFUSE:
2089+ ret = mt7915_tm_write_back_to_efuse(dev);
2090+ break;
2091+ default:
2092+ break;
2093+ }
2094+
2095+ return ret;
2096+}
2097+
2098 const struct mt76_testmode_ops mt7915_testmode_ops = {
2099 .set_state = mt7915_tm_set_state,
2100 .set_params = mt7915_tm_set_params,
2101 .dump_stats = mt7915_tm_dump_stats,
2102+ .set_eeprom = mt7915_tm_set_eeprom,
2103 };
2104diff --git a/mt7915/testmode.h b/mt7915/testmode.h
developerbd9fa1e2023-10-16 11:04:00 +08002105index a1c54c8..eb0e043 100644
developer6caa5e22022-06-16 13:33:13 +08002106--- a/mt7915/testmode.h
2107+++ b/mt7915/testmode.h
2108@@ -4,6 +4,8 @@
2109 #ifndef __MT7915_TESTMODE_H
2110 #define __MT7915_TESTMODE_H
2111
2112+#include "mcu.h"
2113+
2114 struct mt7915_tm_trx {
2115 u8 type;
2116 u8 enable;
2117@@ -39,6 +41,11 @@ struct mt7915_tm_cfg {
2118 u8 _rsv[2];
2119 };
2120
2121+struct mt7915_tm_mu_rx_aid {
2122+ __le32 band;
2123+ __le16 aid;
2124+};
2125+
2126 struct mt7915_tm_cmd {
2127 u8 testmode_en;
2128 u8 param_idx;
2129@@ -50,6 +57,7 @@ struct mt7915_tm_cmd {
2130 struct mt7915_tm_slot_time slot;
2131 struct mt7915_tm_clean_txq clean;
2132 struct mt7915_tm_cfg cfg;
2133+ struct mt7915_tm_mu_rx_aid rx_aid;
2134 u8 test[72];
2135 } param;
2136 } __packed;
2137@@ -109,6 +117,16 @@ enum {
2138 TAM_ARB_OP_MODE_FORCE_SU = 5,
2139 };
2140
2141+enum {
2142+ TM_CBW_20MHZ,
2143+ TM_CBW_40MHZ,
2144+ TM_CBW_80MHZ,
2145+ TM_CBW_10MHZ,
2146+ TM_CBW_5MHZ,
2147+ TM_CBW_160MHZ,
2148+ TM_CBW_8080MHZ,
2149+};
2150+
2151 struct mt7915_tm_rx_stat_band {
2152 u8 category;
2153
2154@@ -130,4 +148,264 @@ struct mt7915_tm_rx_stat_band {
2155 __le16 mdrdy_cnt_ofdm;
2156 };
2157
2158+struct mt7915_tm_muru_comm {
2159+ u8 ppdu_format;
2160+ u8 sch_type;
2161+ u8 band;
2162+ u8 wmm_idx;
2163+ u8 spe_idx;
2164+ u8 proc_type;
2165+};
2166+
2167+struct mt7915_tm_muru_dl_usr {
2168+ __le16 wlan_idx;
2169+ u8 ru_alloc_seg;
2170+ u8 ru_idx;
2171+ u8 ldpc;
2172+ u8 nss;
2173+ u8 mcs;
2174+ u8 mu_group_idx;
2175+ u8 vht_groud_id;
2176+ u8 vht_up;
2177+ u8 he_start_stream;
2178+ u8 he_mu_spatial;
2179+ u8 ack_policy;
2180+ __le16 tx_power_alpha;
2181+};
2182+
2183+struct mt7915_tm_muru_dl {
2184+ u8 user_num;
2185+ u8 tx_mode;
2186+ u8 bw;
2187+ u8 gi;
2188+ u8 ltf;
2189+ /* sigB */
2190+ u8 mcs;
2191+ u8 dcm;
2192+ u8 cmprs;
2193+
2194+ u8 tx_power;
2195+ u8 ru[8];
2196+ u8 c26[2];
2197+ u8 ack_policy;
2198+
2199+ struct mt7915_tm_muru_dl_usr usr[16];
2200+};
2201+
2202+struct mt7915_tm_muru_ul_usr {
2203+ __le16 wlan_idx;
2204+ u8 ru_alloc;
2205+ u8 ru_idx;
2206+ u8 ldpc;
2207+ u8 nss;
2208+ u8 mcs;
2209+ u8 target_rssi;
2210+ __le32 trig_pkt_size;
2211+};
2212+
2213+struct mt7915_tm_muru_ul {
2214+ u8 user_num;
2215+
2216+ /* UL TX */
2217+ u8 trig_type;
2218+ __le16 trig_cnt;
2219+ __le16 trig_intv;
2220+ u8 bw;
2221+ u8 gi_ltf;
2222+ __le16 ul_len;
2223+ u8 pad;
2224+ u8 trig_ta[ETH_ALEN];
2225+ u8 ru[8];
2226+ u8 c26[2];
2227+
2228+ struct mt7915_tm_muru_ul_usr usr[16];
2229+ /* HE TB RX Debug */
2230+ __le32 rx_hetb_nonsf_en_bitmap;
2231+ __le32 rx_hetb_cfg[2];
2232+
2233+ /* DL TX */
2234+ u8 ba_type;
2235+};
2236+
2237+struct mt7915_tm_muru {
2238+ __le32 cfg_comm;
2239+ __le32 cfg_dl;
2240+ __le32 cfg_ul;
2241+
2242+ struct mt7915_tm_muru_comm comm;
2243+ struct mt7915_tm_muru_dl dl;
2244+ struct mt7915_tm_muru_ul ul;
2245+};
2246+
2247+#define MURU_PPDU_HE_MU BIT(3)
2248+
2249+/* Common Config */
2250+/* #define MURU_COMM_PPDU_FMT BIT(0) */
2251+/* #define MURU_COMM_SCH_TYPE BIT(1) */
developer692ed9b2023-06-19 12:03:50 +08002252+/* #define MURU_COMM_BAND BIT(2) */
2253+/* #define MURU_COMM_WMM BIT(3) */
developer6caa5e22022-06-16 13:33:13 +08002254+/* #define MURU_COMM_SPE_IDX BIT(4) */
2255+/* #define MURU_COMM_PROC_TYPE BIT(5) */
2256+/* #define MURU_COMM_SET (MURU_COMM_PPDU_FMT | MURU_COMM_BAND | \ */
developer692ed9b2023-06-19 12:03:50 +08002257+/* MURU_COMM_WMM | MURU_COMM_SPE_IDX) */
developer6caa5e22022-06-16 13:33:13 +08002258+/* DL Config */
2259+#define MURU_DL_BW BIT(0)
2260+#define MURU_DL_GI BIT(1)
2261+#define MURU_DL_TX_MODE BIT(2)
2262+#define MURU_DL_TONE_PLAN BIT(3)
2263+#define MURU_DL_USER_CNT BIT(4)
2264+#define MURU_DL_LTF BIT(5)
2265+#define MURU_DL_SIGB_MCS BIT(6)
2266+#define MURU_DL_SIGB_DCM BIT(7)
2267+#define MURU_DL_SIGB_CMPRS BIT(8)
2268+#define MURU_DL_ACK_POLICY BIT(9)
2269+#define MURU_DL_TXPOWER BIT(10)
2270+/* DL Per User Config */
2271+#define MURU_DL_USER_WLAN_ID BIT(16)
2272+#define MURU_DL_USER_COD BIT(17)
2273+#define MURU_DL_USER_MCS BIT(18)
2274+#define MURU_DL_USER_NSS BIT(19)
2275+#define MURU_DL_USER_RU_ALLOC BIT(20)
2276+#define MURU_DL_USER_MUMIMO_GRP BIT(21)
2277+#define MURU_DL_USER_MUMIMO_VHT BIT(22)
2278+#define MURU_DL_USER_ACK_POLICY BIT(23)
2279+#define MURU_DL_USER_MUMIMO_HE BIT(24)
2280+#define MURU_DL_USER_PWR_ALPHA BIT(25)
2281+#define MURU_DL_SET (GENMASK(7, 0) | GENMASK(20, 16) | BIT(25))
2282+
2283+#define MAX_PHASE_GROUP_NUM 9
2284+
2285+struct mt7915_tm_txbf_phase {
2286+ u8 status;
2287+ struct {
2288+ u8 r0_uh;
2289+ u8 r0_h;
2290+ u8 r0_m;
2291+ u8 r0_l;
2292+ u8 r0_ul;
2293+ u8 r1_uh;
2294+ u8 r1_h;
2295+ u8 r1_m;
2296+ u8 r1_l;
2297+ u8 r1_ul;
2298+ u8 r2_uh;
2299+ u8 r2_h;
2300+ u8 r2_m;
2301+ u8 r2_l;
2302+ u8 r2_ul;
2303+ u8 r3_uh;
2304+ u8 r3_h;
2305+ u8 r3_m;
2306+ u8 r3_l;
2307+ u8 r3_ul;
2308+ u8 r2_uh_sx2;
2309+ u8 r2_h_sx2;
2310+ u8 r2_m_sx2;
2311+ u8 r2_l_sx2;
2312+ u8 r2_ul_sx2;
2313+ u8 r3_uh_sx2;
2314+ u8 r3_h_sx2;
2315+ u8 r3_m_sx2;
2316+ u8 r3_l_sx2;
2317+ u8 r3_ul_sx2;
2318+ u8 m_t0_h;
2319+ u8 m_t1_h;
2320+ u8 m_t2_h;
2321+ u8 m_t2_h_sx2;
2322+ u8 r0_reserved;
2323+ u8 r1_reserved;
2324+ u8 r2_reserved;
2325+ u8 r3_reserved;
2326+ u8 r2_sx2_reserved;
2327+ u8 r3_sx2_reserved;
2328+ } phase;
2329+};
2330+
2331+struct mt7915_tm_pfmu_tag1 {
2332+ __le32 pfmu_idx:10;
2333+ __le32 ebf:1;
2334+ __le32 data_bw:2;
2335+ __le32 lm:2;
2336+ __le32 is_mu:1;
2337+ __le32 nr:3, nc:3;
2338+ __le32 codebook:2;
2339+ __le32 ngroup:2;
2340+ __le32 _rsv:2;
2341+ __le32 invalid_prof:1;
2342+ __le32 rmsd:3;
2343+
2344+ __le32 col_id1:6, row_id1:10;
2345+ __le32 col_id2:6, row_id2:10;
2346+ __le32 col_id3:6, row_id3:10;
2347+ __le32 col_id4:6, row_id4:10;
2348+
2349+ __le32 ru_start_id:7;
2350+ __le32 _rsv1:1;
2351+ __le32 ru_end_id:7;
2352+ __le32 _rsv2:1;
2353+ __le32 mob_cal_en:1;
2354+ __le32 _rsv3:15;
2355+
2356+ __le32 snr_sts0:8, snr_sts1:8, snr_sts2:8, snr_sts3:8;
2357+ __le32 snr_sts4:8, snr_sts5:8, snr_sts6:8, snr_sts7:8;
2358+
2359+ __le32 _rsv4;
2360+} __packed;
2361+
2362+struct mt7915_tm_pfmu_tag2 {
2363+ __le32 smart_ant:24;
2364+ __le32 se_idx:5;
2365+ __le32 _rsv:3;
2366+
2367+ __le32 _rsv1:8;
2368+ __le32 rmsd_thres:3;
2369+ __le32 _rsv2:5;
2370+ __le32 ibf_timeout:8;
2371+ __le32 _rsv3:8;
2372+
2373+ __le32 _rsv4:16;
2374+ __le32 ibf_data_bw:2;
2375+ __le32 ibf_nc:3;
2376+ __le32 ibf_nr:3;
2377+ __le32 ibf_ru:8;
2378+
2379+ __le32 mob_delta_t:8;
2380+ __le32 mob_lq_result:7;
2381+ __le32 _rsv5:1;
2382+ __le32 _rsv6:16;
2383+
2384+ __le32 _rsv7;
2385+} __packed;
2386+
2387+struct mt7915_tm_pfmu_tag {
2388+ struct mt7915_tm_pfmu_tag1 t1;
2389+ struct mt7915_tm_pfmu_tag2 t2;
2390+};
2391+
2392+struct mt7915_tm_pfmu_data {
2393+ __le16 subc_idx;
2394+ __le16 phi11;
2395+ __le16 phi21;
2396+ __le16 phi31;
2397+};
2398+
2399+struct mt7915_tm_ibf_cal_info {
2400+ u8 format_id;
2401+ u8 group_l_m_n;
2402+ u8 group;
2403+ bool sx2;
2404+ u8 status;
2405+ u8 cal_type;
2406+ u8 _rsv[2];
2407+ u8 buf[1000];
2408+} __packed;
2409+
2410+enum {
2411+ IBF_PHASE_CAL_UNSPEC,
2412+ IBF_PHASE_CAL_NORMAL,
2413+ IBF_PHASE_CAL_VERIFY,
2414+ IBF_PHASE_CAL_NORMAL_INSTRUMENT,
2415+ IBF_PHASE_CAL_VERIFY_INSTRUMENT,
2416+};
2417+
2418 #endif
2419diff --git a/testmode.c b/testmode.c
developerbd9fa1e2023-10-16 11:04:00 +08002420index 1b37392..b39fef4 100644
developer6caa5e22022-06-16 13:33:13 +08002421--- a/testmode.c
2422+++ b/testmode.c
developerbd9fa1e2023-10-16 11:04:00 +08002423@@ -8,6 +8,7 @@ const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
2424 [MT76_TM_ATTR_RESET] = { .type = NLA_FLAG },
2425 [MT76_TM_ATTR_STATE] = { .type = NLA_U8 },
2426 [MT76_TM_ATTR_TX_COUNT] = { .type = NLA_U32 },
2427+ [MT76_TM_ATTR_SKU_EN] = { .type = NLA_U8 },
2428 [MT76_TM_ATTR_TX_LENGTH] = { .type = NLA_U32 },
2429 [MT76_TM_ATTR_TX_RATE_MODE] = { .type = NLA_U8 },
2430 [MT76_TM_ATTR_TX_RATE_NSS] = { .type = NLA_U8 },
2431@@ -28,28 +29,16 @@ const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
developer6caa5e22022-06-16 13:33:13 +08002432 };
2433 EXPORT_SYMBOL_GPL(mt76_tm_policy);
2434
2435-void mt76_testmode_tx_pending(struct mt76_phy *phy)
2436+static void
2437+mt76_testmode_queue_tx(struct mt76_phy *phy, struct mt76_wcid *wcid,
developerf79ad452022-07-12 11:37:54 +08002438+ struct sk_buff *skb, struct mt76_queue *q, int qid,
2439+ u16 limit)
developer6caa5e22022-06-16 13:33:13 +08002440 {
2441 struct mt76_testmode_data *td = &phy->test;
2442 struct mt76_dev *dev = phy->dev;
2443- struct mt76_wcid *wcid = &dev->global_wcid;
2444- struct sk_buff *skb = td->tx_skb;
2445- struct mt76_queue *q;
2446- u16 tx_queued_limit;
2447- int qid;
2448-
2449- if (!skb || !td->tx_pending)
2450- return;
2451+ u16 count = limit;
2452
2453- qid = skb_get_queue_mapping(skb);
2454- q = phy->q_tx[qid];
2455-
2456- tx_queued_limit = td->tx_queued_limit ? td->tx_queued_limit : 1000;
2457-
2458- spin_lock_bh(&q->lock);
2459-
2460- while (td->tx_pending > 0 &&
2461- td->tx_queued - td->tx_done < tx_queued_limit &&
2462+ while (td->tx_pending > 0 && count &&
2463 q->queued < q->ndesc / 2) {
2464 int ret;
2465
developerbd9fa1e2023-10-16 11:04:00 +08002466@@ -58,13 +47,68 @@ void mt76_testmode_tx_pending(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002467 if (ret < 0)
2468 break;
2469
developer15c355d2023-03-21 17:28:34 +08002470- td->tx_pending--;
developer6caa5e22022-06-16 13:33:13 +08002471+ count--;
developer15c355d2023-03-21 17:28:34 +08002472+
2473+ /* tx_count == UINT_MAX for continuous tx */
2474+ if (td->tx_count != UINT_MAX)
2475+ td->tx_pending--;
developer6caa5e22022-06-16 13:33:13 +08002476 td->tx_queued++;
2477+
2478+ if (td->tx_rate_mode != MT76_TM_TX_MODE_HE_MU)
developer692ed9b2023-06-19 12:03:50 +08002479+ if (td->tx_queued - td->tx_done >= limit)
2480+ break;
developer6caa5e22022-06-16 13:33:13 +08002481 }
2482
2483 dev->queue_ops->kick(dev, q);
2484+}
2485+
2486+void mt76_testmode_tx_pending(struct mt76_phy *phy)
2487+{
2488+ struct mt76_testmode_data *td = &phy->test;
2489+ struct mt76_testmode_entry_data *ed;
2490+ struct mt76_queue *q;
2491+ int qid;
2492+ u16 tx_queued_limit;
2493+ u32 remain;
2494+ bool is_mu;
2495+
2496+ if (!td->tx_pending)
2497+ return;
2498+
2499+ /* tx_queued_limit = td->tx_queued_limit ?: 100; */
2500+ tx_queued_limit = 100;
2501+
2502+ if (!td->aid) {
2503+ qid = skb_get_queue_mapping(td->tx_skb);
2504+ q = phy->q_tx[qid];
2505+ spin_lock_bh(&q->lock);
2506+ mt76_testmode_queue_tx(phy, &phy->dev->global_wcid,
developer692ed9b2023-06-19 12:03:50 +08002507+ td->tx_skb, q, qid, tx_queued_limit);
developer6caa5e22022-06-16 13:33:13 +08002508+ spin_unlock_bh(&q->lock);
2509+
2510+ return;
2511+ }
2512+
2513+ is_mu = td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU;
2514+ ed = mt76_testmode_entry_data(phy, td->cur_entry);
2515+ qid = skb_get_queue_mapping(ed->tx_skb);
2516+ q = phy->q_tx[qid];
2517+
2518+ spin_lock_bh(&q->lock);
2519+
2520+ remain = is_mu ? 1 : (td->tx_pending % td->tx_count) ?: td->tx_count;
2521+ if (remain < tx_queued_limit)
2522+ tx_queued_limit = remain;
2523+
developerf79ad452022-07-12 11:37:54 +08002524+ mt76_testmode_queue_tx(phy, td->cur_entry, ed->tx_skb, q, qid, tx_queued_limit);
developer6caa5e22022-06-16 13:33:13 +08002525+
developer692ed9b2023-06-19 12:03:50 +08002526+ if ((td->tx_count != UINT_MAX && td->tx_pending % td->tx_count == 0) || is_mu)
developer6caa5e22022-06-16 13:33:13 +08002527+ td->cur_entry = list_next_entry(td->cur_entry, list);
2528
2529 spin_unlock_bh(&q->lock);
2530+
2531+ if (is_mu && td->tx_pending)
2532+ mt76_worker_schedule(&phy->dev->tx_worker);
2533 }
2534
2535 static u32
developerbd9fa1e2023-10-16 11:04:00 +08002536@@ -90,15 +134,31 @@ mt76_testmode_max_mpdu_len(struct mt76_phy *phy, u8 tx_rate_mode)
developer6caa5e22022-06-16 13:33:13 +08002537 }
2538
2539 static void
2540-mt76_testmode_free_skb(struct mt76_phy *phy)
2541+mt76_testmode_free_skb(struct sk_buff **tx_skb)
2542+{
2543+ if (!(*tx_skb))
2544+ return;
2545+
2546+ dev_kfree_skb(*tx_skb);
2547+ *tx_skb = NULL;
2548+}
2549+
2550+static void
2551+mt76_testmode_free_skb_all(struct mt76_phy *phy)
2552 {
2553 struct mt76_testmode_data *td = &phy->test;
2554+ struct mt76_testmode_entry_data *ed = &td->ed;
2555+ struct mt76_wcid *wcid;
2556+
2557+ mt76_testmode_free_skb(&ed->tx_skb);
2558
2559- dev_kfree_skb(td->tx_skb);
2560- td->tx_skb = NULL;
2561+ mt76_tm_for_each_entry(phy, wcid, ed)
2562+ mt76_testmode_free_skb(&ed->tx_skb);
2563 }
2564
2565-int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
2566+static int
2567+mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len,
2568+ struct sk_buff **tx_skb, u8 (*addr)[ETH_ALEN])
2569 {
2570 #define MT_TXP_MAX_LEN 4095
2571 u16 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
developerbd9fa1e2023-10-16 11:04:00 +08002572@@ -119,7 +179,8 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
developer6caa5e22022-06-16 13:33:13 +08002573 nfrags = len / MT_TXP_MAX_LEN;
2574 head_len = nfrags ? MT_TXP_MAX_LEN : len;
2575
2576- if (len > IEEE80211_MAX_FRAME_LEN)
2577+ if (len > IEEE80211_MAX_FRAME_LEN ||
2578+ td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
2579 fc |= IEEE80211_STYPE_QOS_DATA;
2580
2581 head = alloc_skb(head_len, GFP_KERNEL);
developerbd9fa1e2023-10-16 11:04:00 +08002582@@ -128,9 +189,9 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
developer6caa5e22022-06-16 13:33:13 +08002583
developer072c5612022-07-15 18:30:03 +08002584 hdr = __skb_put_zero(head, sizeof(*hdr));
developer6caa5e22022-06-16 13:33:13 +08002585 hdr->frame_control = cpu_to_le16(fc);
2586- memcpy(hdr->addr1, td->addr[0], ETH_ALEN);
2587- memcpy(hdr->addr2, td->addr[1], ETH_ALEN);
2588- memcpy(hdr->addr3, td->addr[2], ETH_ALEN);
2589+ memcpy(hdr->addr1, addr[0], ETH_ALEN);
2590+ memcpy(hdr->addr2, addr[1], ETH_ALEN);
2591+ memcpy(hdr->addr3, addr[2], ETH_ALEN);
2592 skb_set_queue_mapping(head, IEEE80211_AC_BE);
developer072c5612022-07-15 18:30:03 +08002593 get_random_bytes(__skb_put(head, head_len - sizeof(*hdr)),
2594 head_len - sizeof(*hdr));
developerbd9fa1e2023-10-16 11:04:00 +08002595@@ -154,7 +215,7 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
developer6caa5e22022-06-16 13:33:13 +08002596
2597 frag = alloc_skb(frag_len, GFP_KERNEL);
2598 if (!frag) {
2599- mt76_testmode_free_skb(phy);
2600+ mt76_testmode_free_skb(tx_skb);
2601 dev_kfree_skb(head);
2602 return -ENOMEM;
2603 }
developerbd9fa1e2023-10-16 11:04:00 +08002604@@ -167,15 +228,14 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
developer6caa5e22022-06-16 13:33:13 +08002605 frag_tail = &(*frag_tail)->next;
2606 }
2607
2608- mt76_testmode_free_skb(phy);
2609- td->tx_skb = head;
2610+ mt76_testmode_free_skb(tx_skb);
2611+ *tx_skb = head;
2612
2613 return 0;
2614 }
2615-EXPORT_SYMBOL(mt76_testmode_alloc_skb);
2616
2617-static int
2618-mt76_testmode_tx_init(struct mt76_phy *phy)
2619+int mt76_testmode_init_skb(struct mt76_phy *phy, u32 len,
2620+ struct sk_buff **tx_skb, u8 (*addr)[ETH_ALEN])
2621 {
2622 struct mt76_testmode_data *td = &phy->test;
2623 struct ieee80211_tx_info *info;
developerbd9fa1e2023-10-16 11:04:00 +08002624@@ -183,7 +243,7 @@ mt76_testmode_tx_init(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002625 u8 max_nss = hweight8(phy->antenna_mask);
2626 int ret;
2627
2628- ret = mt76_testmode_alloc_skb(phy, td->tx_mpdu_len);
2629+ ret = mt76_testmode_alloc_skb(phy, len, tx_skb, addr);
2630 if (ret)
2631 return ret;
2632
developerbd9fa1e2023-10-16 11:04:00 +08002633@@ -193,7 +253,7 @@ mt76_testmode_tx_init(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002634 if (td->tx_antenna_mask)
2635 max_nss = min_t(u8, max_nss, hweight8(td->tx_antenna_mask));
2636
2637- info = IEEE80211_SKB_CB(td->tx_skb);
2638+ info = IEEE80211_SKB_CB(*tx_skb);
2639 rate = &info->control.rates[0];
2640 rate->count = 1;
2641 rate->idx = td->tx_rate_idx;
developerbd9fa1e2023-10-16 11:04:00 +08002642@@ -265,6 +325,25 @@ mt76_testmode_tx_init(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002643 out:
2644 return 0;
2645 }
2646+EXPORT_SYMBOL(mt76_testmode_init_skb);
2647+
2648+static int
2649+mt76_testmode_tx_init(struct mt76_phy *phy)
2650+{
2651+ struct mt76_testmode_entry_data *ed;
2652+ struct mt76_wcid *wcid;
2653+
2654+ mt76_tm_for_each_entry(phy, wcid, ed) {
2655+ int ret;
2656+
2657+ ret = mt76_testmode_init_skb(phy, ed->tx_mpdu_len,
2658+ &ed->tx_skb, ed->addr);
2659+ if (ret)
2660+ return ret;
2661+ }
2662+
2663+ return 0;
2664+}
2665
2666 static void
2667 mt76_testmode_tx_start(struct mt76_phy *phy)
developerbd9fa1e2023-10-16 11:04:00 +08002668@@ -275,6 +354,14 @@ mt76_testmode_tx_start(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002669 td->tx_queued = 0;
2670 td->tx_done = 0;
2671 td->tx_pending = td->tx_count;
2672+ if (td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
2673+ td->tx_pending = 1;
2674+ if (td->entry_num) {
2675+ td->tx_pending *= td->entry_num;
2676+ td->cur_entry = list_first_entry(&td->tm_entry_list,
2677+ struct mt76_wcid, list);
2678+ }
2679+
2680 mt76_worker_schedule(&dev->tx_worker);
2681 }
2682
developerbd9fa1e2023-10-16 11:04:00 +08002683@@ -293,7 +380,7 @@ mt76_testmode_tx_stop(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002684 wait_event_timeout(dev->tx_wait, td->tx_done == td->tx_queued,
2685 MT76_TM_TIMEOUT * HZ);
2686
2687- mt76_testmode_free_skb(phy);
2688+ mt76_testmode_free_skb_all(phy);
2689 }
2690
2691 static inline void
developerbd9fa1e2023-10-16 11:04:00 +08002692@@ -324,6 +411,8 @@ mt76_testmode_init_defaults(struct mt76_phy *phy)
developer6caa5e22022-06-16 13:33:13 +08002693 memcpy(td->addr[0], phy->macaddr, ETH_ALEN);
2694 memcpy(td->addr[1], phy->macaddr, ETH_ALEN);
2695 memcpy(td->addr[2], phy->macaddr, ETH_ALEN);
2696+
2697+ INIT_LIST_HEAD(&phy->test.tm_entry_list);
2698 }
2699
2700 static int
developerbd9fa1e2023-10-16 11:04:00 +08002701@@ -333,8 +422,12 @@ __mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state)
developer6caa5e22022-06-16 13:33:13 +08002702 struct mt76_dev *dev = phy->dev;
2703 int err;
2704
2705- if (prev_state == MT76_TM_STATE_TX_FRAMES)
2706+ if (prev_state == MT76_TM_STATE_TX_FRAMES) {
2707+ /* MU needs to clean hwq for free done event */
2708+ if (phy->test.tx_rate_mode == MT76_TM_TX_MODE_HE_MU)
2709+ dev->test_ops->set_state(phy, MT76_TM_STATE_IDLE);
2710 mt76_testmode_tx_stop(phy);
2711+ }
2712
2713 if (state == MT76_TM_STATE_TX_FRAMES) {
2714 err = mt76_testmode_tx_init(phy);
developerbd9fa1e2023-10-16 11:04:00 +08002715@@ -404,6 +497,44 @@ mt76_tm_get_u8(struct nlattr *attr, u8 *dest, u8 min, u8 max)
developer6caa5e22022-06-16 13:33:13 +08002716 return 0;
2717 }
2718
2719+static int
2720+mt76_testmode_set_eeprom(struct mt76_phy *phy, struct nlattr **tb)
2721+{
2722+ struct mt76_dev *dev = phy->dev;
2723+ u8 action, val[MT76_TM_EEPROM_BLOCK_SIZE];
2724+ u32 offset = 0;
2725+ int err = -EINVAL;
2726+
2727+ if (!dev->test_ops->set_eeprom)
2728+ return -EOPNOTSUPP;
2729+
2730+ if (mt76_tm_get_u8(tb[MT76_TM_ATTR_EEPROM_ACTION], &action,
2731+ 0, MT76_TM_EEPROM_ACTION_MAX))
2732+ goto out;
2733+
2734+ if (tb[MT76_TM_ATTR_EEPROM_OFFSET]) {
2735+ struct nlattr *cur;
2736+ int rem, idx = 0;
2737+
2738+ offset = nla_get_u32(tb[MT76_TM_ATTR_EEPROM_OFFSET]);
2739+ if (!!(offset % MT76_TM_EEPROM_BLOCK_SIZE) ||
2740+ !tb[MT76_TM_ATTR_EEPROM_VAL])
2741+ goto out;
2742+
2743+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_EEPROM_VAL], rem) {
2744+ if (nla_len(cur) != 1 || idx >= ARRAY_SIZE(val))
2745+ goto out;
2746+
2747+ val[idx++] = nla_get_u8(cur);
2748+ }
2749+ }
2750+
2751+ err = dev->test_ops->set_eeprom(phy, offset, val, action);
2752+
2753+out:
2754+ return err;
2755+}
2756+
2757 int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2758 void *data, int len)
2759 {
developerbd9fa1e2023-10-16 11:04:00 +08002760@@ -427,6 +558,11 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer6caa5e22022-06-16 13:33:13 +08002761
2762 mutex_lock(&dev->mutex);
2763
2764+ if (tb[MT76_TM_ATTR_EEPROM_ACTION]) {
2765+ err = mt76_testmode_set_eeprom(phy, tb);
2766+ goto out;
2767+ }
2768+
2769 if (tb[MT76_TM_ATTR_RESET]) {
2770 mt76_testmode_set_state(phy, MT76_TM_STATE_OFF);
2771 memset(td, 0, sizeof(*td));
developerbd9fa1e2023-10-16 11:04:00 +08002772@@ -434,6 +570,9 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2773
2774 mt76_testmode_init_defaults(phy);
2775
2776+ if (tb[MT76_TM_ATTR_SKU_EN])
2777+ td->sku_en = nla_get_u8(tb[MT76_TM_ATTR_SKU_EN]);
2778+
2779 if (tb[MT76_TM_ATTR_TX_COUNT])
2780 td->tx_count = nla_get_u32(tb[MT76_TM_ATTR_TX_COUNT]);
2781
2782@@ -453,7 +592,10 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer6caa5e22022-06-16 13:33:13 +08002783 mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_DUTY_CYCLE],
2784 &td->tx_duty_cycle, 0, 99) ||
2785 mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_POWER_CONTROL],
2786- &td->tx_power_control, 0, 1))
2787+ &td->tx_power_control, 0, 1) ||
2788+ mt76_tm_get_u8(tb[MT76_TM_ATTR_AID], &td->aid, 0, 16) ||
2789+ mt76_tm_get_u8(tb[MT76_TM_ATTR_RU_ALLOC], &td->ru_alloc, 0, 0xff) ||
2790+ mt76_tm_get_u8(tb[MT76_TM_ATTR_RU_IDX], &td->ru_idx, 0, 68))
2791 goto out;
2792
2793 if (tb[MT76_TM_ATTR_TX_LENGTH]) {
developerbd9fa1e2023-10-16 11:04:00 +08002794@@ -485,8 +627,7 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer6caa5e22022-06-16 13:33:13 +08002795
2796 if (tb[MT76_TM_ATTR_TX_POWER]) {
2797 struct nlattr *cur;
2798- int idx = 0;
2799- int rem;
2800+ int rem, idx = 0;
2801
2802 nla_for_each_nested(cur, tb[MT76_TM_ATTR_TX_POWER], rem) {
2803 if (nla_len(cur) != 1 ||
developerbd9fa1e2023-10-16 11:04:00 +08002804@@ -506,11 +647,45 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer6caa5e22022-06-16 13:33:13 +08002805 if (nla_len(cur) != ETH_ALEN || idx >= 3)
2806 goto out;
2807
2808- memcpy(td->addr[idx], nla_data(cur), ETH_ALEN);
2809+ memcpy(td->addr[idx++], nla_data(cur), ETH_ALEN);
2810+ }
2811+ }
2812+
2813+ if (tb[MT76_TM_ATTR_CFG]) {
2814+ struct nlattr *cur;
2815+ int rem, idx = 0;
2816+
2817+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_CFG], rem) {
2818+ if (nla_len(cur) != 1 || idx >= 2)
2819+ goto out;
2820+
2821+ if (idx == 0)
2822+ td->cfg.type = nla_get_u8(cur);
2823+ else
2824+ td->cfg.enable = nla_get_u8(cur);
2825 idx++;
2826 }
2827 }
2828
2829+ if (tb[MT76_TM_ATTR_TXBF_ACT]) {
2830+ struct nlattr *cur;
2831+ int rem, idx = 0;
2832+
2833+ if (!tb[MT76_TM_ATTR_TXBF_PARAM] ||
2834+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TXBF_ACT], &td->txbf_act,
developer692ed9b2023-06-19 12:03:50 +08002835+ 0, MT76_TM_TXBF_ACT_MAX))
developer6caa5e22022-06-16 13:33:13 +08002836+ goto out;
2837+
2838+ memset(td->txbf_param, 0, sizeof(td->txbf_param));
2839+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_TXBF_PARAM], rem) {
2840+ if (nla_len(cur) != 2 ||
2841+ idx >= ARRAY_SIZE(td->txbf_param))
2842+ goto out;
2843+
2844+ td->txbf_param[idx++] = nla_get_u16(cur);
2845+ }
2846+ }
2847+
2848 if (dev->test_ops->set_params) {
2849 err = dev->test_ops->set_params(phy, tb, state);
2850 if (err)
developerbd9fa1e2023-10-16 11:04:00 +08002851@@ -575,6 +750,7 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
developer6caa5e22022-06-16 13:33:13 +08002852 struct mt76_phy *phy = hw->priv;
2853 struct mt76_dev *dev = phy->dev;
2854 struct mt76_testmode_data *td = &phy->test;
2855+ struct mt76_testmode_entry_data *ed = &td->ed;
2856 struct nlattr *tb[NUM_MT76_TM_ATTRS] = {};
2857 int err = 0;
2858 void *a;
developerbd9fa1e2023-10-16 11:04:00 +08002859@@ -607,6 +783,19 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
developer6caa5e22022-06-16 13:33:13 +08002860 goto out;
2861 }
2862
2863+ if (tb[MT76_TM_ATTR_AID]) {
2864+ struct mt76_wcid *wcid;
2865+ u8 aid;
2866+
2867+ err = mt76_tm_get_u8(tb[MT76_TM_ATTR_AID], &aid, 1, 16);
2868+ if (err)
2869+ goto out;
2870+
2871+ mt76_tm_for_each_entry(phy, wcid, ed)
2872+ if (ed->aid == aid)
2873+ ed = mt76_testmode_entry_data(phy, wcid);
2874+ }
2875+
2876 mt76_testmode_init_defaults(phy);
2877
2878 err = -EMSGSIZE;
developerbd9fa1e2023-10-16 11:04:00 +08002879@@ -619,12 +808,9 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
developer6caa5e22022-06-16 13:33:13 +08002880 goto out;
2881
2882 if (nla_put_u32(msg, MT76_TM_ATTR_TX_COUNT, td->tx_count) ||
2883- nla_put_u32(msg, MT76_TM_ATTR_TX_LENGTH, td->tx_mpdu_len) ||
developerbd9fa1e2023-10-16 11:04:00 +08002884+ nla_put_u8(msg, MT76_TM_ATTR_SKU_EN, td->sku_en) ||
developer6caa5e22022-06-16 13:33:13 +08002885 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_MODE, td->tx_rate_mode) ||
2886- nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_NSS, td->tx_rate_nss) ||
2887- nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_IDX, td->tx_rate_idx) ||
2888 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_SGI, td->tx_rate_sgi) ||
2889- nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_LDPC, td->tx_rate_ldpc) ||
2890 nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_STBC, td->tx_rate_stbc) ||
2891 (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_LTF) &&
2892 nla_put_u8(msg, MT76_TM_ATTR_TX_LTF, td->tx_ltf)) ||
developerbd9fa1e2023-10-16 11:04:00 +08002893@@ -641,7 +827,16 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
developer692ed9b2023-06-19 12:03:50 +08002894 (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER_CONTROL) &&
2895 nla_put_u8(msg, MT76_TM_ATTR_TX_POWER_CONTROL, td->tx_power_control)) ||
2896 (mt76_testmode_param_present(td, MT76_TM_ATTR_FREQ_OFFSET) &&
2897- nla_put_u8(msg, MT76_TM_ATTR_FREQ_OFFSET, td->freq_offset)))
2898+ nla_put_u32(msg, MT76_TM_ATTR_FREQ_OFFSET, td->freq_offset)))
2899+ goto out;
2900+
developer6caa5e22022-06-16 13:33:13 +08002901+ if (nla_put_u32(msg, MT76_TM_ATTR_TX_LENGTH, ed->tx_mpdu_len) ||
2902+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_NSS, ed->tx_rate_nss) ||
2903+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_IDX, ed->tx_rate_idx) ||
2904+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_LDPC, ed->tx_rate_ldpc) ||
2905+ nla_put_u8(msg, MT76_TM_ATTR_AID, ed->aid) ||
2906+ nla_put_u8(msg, MT76_TM_ATTR_RU_ALLOC, ed->ru_alloc) ||
2907+ nla_put_u8(msg, MT76_TM_ATTR_RU_IDX, ed->ru_idx))
developer692ed9b2023-06-19 12:03:50 +08002908 goto out;
2909
developer6caa5e22022-06-16 13:33:13 +08002910 if (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER)) {
developer6caa5e22022-06-16 13:33:13 +08002911diff --git a/testmode.h b/testmode.h
developerbd9fa1e2023-10-16 11:04:00 +08002912index 8961326..7a68625 100644
developer6caa5e22022-06-16 13:33:13 +08002913--- a/testmode.h
2914+++ b/testmode.h
2915@@ -6,6 +6,8 @@
2916 #define __MT76_TESTMODE_H
2917
2918 #define MT76_TM_TIMEOUT 10
2919+#define MT76_TM_MAX_ENTRY_NUM 16
2920+#define MT76_TM_EEPROM_BLOCK_SIZE 16
2921
2922 /**
2923 * enum mt76_testmode_attr - testmode attributes inside NL80211_ATTR_TESTDATA
developerbd9fa1e2023-10-16 11:04:00 +08002924@@ -18,6 +20,7 @@
2925 * @MT76_TM_ATTR_MTD_PART: mtd partition used for eeprom data (string)
2926 * @MT76_TM_ATTR_MTD_OFFSET: offset of eeprom data within the partition (u32)
2927 *
2928+ * @MT76_TM_ATTR_SKU_EN: config txpower sku is enabled or disabled in testmode (u8)
2929 * @MT76_TM_ATTR_TX_COUNT: configured number of frames to send when setting
2930 * state to MT76_TM_STATE_TX_FRAMES (u32)
2931 * @MT76_TM_ATTR_TX_PENDING: pending frames during MT76_TM_STATE_TX_FRAMES (u32)
2932@@ -47,6 +50,15 @@
developer6caa5e22022-06-16 13:33:13 +08002933 * @MT76_TM_ATTR_DRV_DATA: driver specific netlink attrs (nested)
2934 *
2935 * @MT76_TM_ATTR_MAC_ADDRS: array of nested MAC addresses (nested)
2936+ *
2937+ * @MT76_TM_ATTR_EEPROM_ACTION: eeprom setting actions
developer692ed9b2023-06-19 12:03:50 +08002938+ * (u8, see &enum mt76_testmode_eeprom_action)
developer6caa5e22022-06-16 13:33:13 +08002939+ * @MT76_TM_ATTR_EEPROM_OFFSET: offset of eeprom data block for writing (u32)
2940+ * @MT76_TM_ATTR_EEPROM_VAL: values for writing into a 16-byte data block
developer692ed9b2023-06-19 12:03:50 +08002941+ * (nested, u8 attrs)
developer6caa5e22022-06-16 13:33:13 +08002942+ *
2943+ * @MT76_TM_ATTR_CFG: config testmode rf feature (nested, see &mt76_testmode_cfg)
2944+ *
2945 */
2946 enum mt76_testmode_attr {
2947 MT76_TM_ATTR_UNSPEC,
developerbd9fa1e2023-10-16 11:04:00 +08002948@@ -57,6 +69,7 @@ enum mt76_testmode_attr {
2949 MT76_TM_ATTR_MTD_PART,
2950 MT76_TM_ATTR_MTD_OFFSET,
2951
2952+ MT76_TM_ATTR_SKU_EN,
2953 MT76_TM_ATTR_TX_COUNT,
2954 MT76_TM_ATTR_TX_LENGTH,
2955 MT76_TM_ATTR_TX_RATE_MODE,
2956@@ -84,6 +97,17 @@ enum mt76_testmode_attr {
developer6caa5e22022-06-16 13:33:13 +08002957 MT76_TM_ATTR_DRV_DATA,
2958
2959 MT76_TM_ATTR_MAC_ADDRS,
2960+ MT76_TM_ATTR_AID,
2961+ MT76_TM_ATTR_RU_ALLOC,
2962+ MT76_TM_ATTR_RU_IDX,
2963+
2964+ MT76_TM_ATTR_EEPROM_ACTION,
2965+ MT76_TM_ATTR_EEPROM_OFFSET,
2966+ MT76_TM_ATTR_EEPROM_VAL,
2967+
2968+ MT76_TM_ATTR_CFG,
2969+ MT76_TM_ATTR_TXBF_ACT,
2970+ MT76_TM_ATTR_TXBF_PARAM,
2971
2972 /* keep last */
2973 NUM_MT76_TM_ATTRS,
developerbd9fa1e2023-10-16 11:04:00 +08002974@@ -128,6 +152,7 @@ enum mt76_testmode_stats_attr {
2975 *
2976 * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32)
2977 * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8)
2978+ * @MT76_TM_RX_ATTR_RSSI: received signal strength indicator (array, s8)
2979 * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (array, s8)
2980 * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (array, s8)
2981 * @MT76_TM_RX_ATTR_SNR: signal-to-noise ratio (u8)
2982@@ -137,6 +162,7 @@ enum mt76_testmode_rx_attr {
2983
2984 MT76_TM_RX_ATTR_FREQ_OFFSET,
2985 MT76_TM_RX_ATTR_RCPI,
2986+ MT76_TM_RX_ATTR_RSSI,
2987 MT76_TM_RX_ATTR_IB_RSSI,
2988 MT76_TM_RX_ATTR_WB_RSSI,
2989 MT76_TM_RX_ATTR_SNR,
2990@@ -198,4 +224,57 @@ enum mt76_testmode_tx_mode {
developer6caa5e22022-06-16 13:33:13 +08002991
2992 extern const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS];
2993
2994+/**
2995+ * enum mt76_testmode_eeprom_action - eeprom setting actions
2996+ *
2997+ * @MT76_TM_EEPROM_ACTION_UPDATE_DATA: update rf values to specific
developer692ed9b2023-06-19 12:03:50 +08002998+ * eeprom data block
developer6caa5e22022-06-16 13:33:13 +08002999+ * @MT76_TM_EEPROM_ACTION_UPDATE_BUFFER_MODE: send updated eeprom data to fw
3000+ * @MT76_TM_EEPROM_ACTION_WRITE_TO_EFUSE: write eeprom data back to efuse
3001+ */
3002+enum mt76_testmode_eeprom_action {
3003+ MT76_TM_EEPROM_ACTION_UPDATE_DATA,
3004+ MT76_TM_EEPROM_ACTION_UPDATE_BUFFER_MODE,
3005+ MT76_TM_EEPROM_ACTION_WRITE_TO_EFUSE,
3006+
3007+ /* keep last */
3008+ NUM_MT76_TM_EEPROM_ACTION,
3009+ MT76_TM_EEPROM_ACTION_MAX = NUM_MT76_TM_EEPROM_ACTION - 1,
3010+};
3011+
3012+/**
3013+ * enum mt76_testmode_cfg - packet tx phy mode
3014+ *
3015+ * @MT76_TM_EEPROM_ACTION_UPDATE_DATA: update rf values to specific
developer692ed9b2023-06-19 12:03:50 +08003016+ * eeprom data block
developer6caa5e22022-06-16 13:33:13 +08003017+ * @MT76_TM_EEPROM_ACTION_UPDATE_BUFFER_MODE: send updated eeprom data to fw
3018+ * @MT76_TM_EEPROM_ACTION_WRITE_TO_EFUSE: write eeprom data back to efuse
3019+ */
3020+enum mt76_testmode_cfg {
3021+ MT76_TM_CFG_TSSI,
3022+ MT76_TM_CFG_DPD,
3023+ MT76_TM_CFG_RATE_POWER_OFFSET,
3024+ MT76_TM_CFG_THERMAL_COMP,
3025+
3026+ /* keep last */
3027+ NUM_MT76_TM_CFG,
3028+ MT76_TM_CFG_MAX = NUM_MT76_TM_CFG - 1,
3029+};
3030+
3031+enum mt76_testmode_txbf_act {
3032+ MT76_TM_TXBF_ACT_INIT,
3033+ MT76_TM_TXBF_ACT_UPDATE_CH,
3034+ MT76_TM_TXBF_ACT_PHASE_COMP,
3035+ MT76_TM_TXBF_ACT_TX_PREP,
3036+ MT76_TM_TXBF_ACT_IBF_PROF_UPDATE,
3037+ MT76_TM_TXBF_ACT_EBF_PROF_UPDATE,
3038+ MT76_TM_TXBF_ACT_PHASE_CAL,
3039+ MT76_TM_TXBF_ACT_PROF_UPDATE_ALL,
3040+ MT76_TM_TXBF_ACT_E2P_UPDATE,
3041+
3042+ /* keep last */
3043+ NUM_MT76_TM_TXBF_ACT,
3044+ MT76_TM_TXBF_ACT_MAX = NUM_MT76_TM_TXBF_ACT - 1,
3045+};
3046+
3047 #endif
3048diff --git a/tools/fields.c b/tools/fields.c
developerbd9fa1e2023-10-16 11:04:00 +08003049index e3f6908..406ba77 100644
developer6caa5e22022-06-16 13:33:13 +08003050--- a/tools/fields.c
3051+++ b/tools/fields.c
3052@@ -10,6 +10,7 @@ static const char * const testmode_state[] = {
3053 [MT76_TM_STATE_IDLE] = "idle",
3054 [MT76_TM_STATE_TX_FRAMES] = "tx_frames",
3055 [MT76_TM_STATE_RX_FRAMES] = "rx_frames",
3056+ [MT76_TM_STATE_TX_CONT] = "tx_cont",
3057 };
3058
3059 static const char * const testmode_tx_mode[] = {
developerbd9fa1e2023-10-16 11:04:00 +08003060@@ -65,7 +66,7 @@ static bool parse_u8(const struct tm_field *field, int idx,
3061
3062 static void print_u8(const struct tm_field *field, struct nlattr *attr)
3063 {
3064- printf("%d", nla_get_u8(attr));
3065+ printf("%u", nla_get_u8(attr));
3066 }
3067
3068 static void print_s8(const struct tm_field *field, struct nlattr *attr)
developer15c355d2023-03-21 17:28:34 +08003069@@ -86,12 +87,12 @@ static void print_s32(const struct tm_field *field, struct nlattr *attr)
3070
3071 static void print_u32(const struct tm_field *field, struct nlattr *attr)
3072 {
3073- printf("%d", nla_get_u32(attr));
3074+ printf("%u", nla_get_u32(attr));
3075 }
3076
3077 static void print_u64(const struct tm_field *field, struct nlattr *attr)
3078 {
3079- printf("%lld", (unsigned long long)nla_get_u64(attr));
3080+ printf("%llu", (unsigned long long)nla_get_u64(attr));
3081 }
3082
3083 static bool parse_flag(const struct tm_field *field, int idx,
developer6caa5e22022-06-16 13:33:13 +08003084@@ -201,6 +202,63 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
3085 printf("%srx_per=%.02f%%\n", prefix, 100 * failed / total);
3086 }
3087
3088+static bool parse_mac(const struct tm_field *field, int idx,
3089+ struct nl_msg *msg, const char *val)
3090+{
3091+#define ETH_ALEN 6
3092+ bool ret = true;
3093+ char *str, *cur, *ap;
3094+ void *a;
3095+
3096+ ap = str = strdup(val);
3097+
3098+ a = nla_nest_start(msg, idx);
3099+
3100+ idx = 0;
3101+ while ((cur = strsep(&ap, ",")) != NULL) {
3102+ unsigned char addr[ETH_ALEN];
3103+ char *val, *tmp = cur;
3104+ int i = 0;
3105+
3106+ while ((val = strsep(&tmp, ":")) != NULL) {
3107+ if (i >= ETH_ALEN)
3108+ break;
3109+
3110+ addr[i++] = strtoul(val, NULL, 16);
3111+ }
3112+
3113+ nla_put(msg, idx, ETH_ALEN, addr);
3114+
3115+ idx++;
3116+ }
3117+
3118+ nla_nest_end(msg, a);
3119+
3120+ free(str);
3121+
3122+ return ret;
3123+}
3124+
3125+static void print_mac(const struct tm_field *field, struct nlattr *attr)
3126+{
3127+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
3128+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
3129+ unsigned char addr[3][6];
3130+ struct nlattr *cur;
3131+ int idx = 0;
3132+ int rem;
3133+
3134+ nla_for_each_nested(cur, attr, rem) {
3135+ if (nla_len(cur) != 6)
3136+ continue;
3137+ memcpy(addr[idx++], nla_data(cur), 6);
3138+ }
3139+
3140+ printf("" MACSTR "," MACSTR "," MACSTR "",
3141+ MAC2STR(addr[0]), MAC2STR(addr[1]), MAC2STR(addr[2]));
3142+
3143+ return;
3144+}
3145
3146 #define FIELD_GENERIC(_field, _name, ...) \
3147 [FIELD_NAME(_field)] = { \
developerbd9fa1e2023-10-16 11:04:00 +08003148@@ -250,10 +308,18 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
developer6caa5e22022-06-16 13:33:13 +08003149 ##__VA_ARGS__ \
3150 )
3151
3152+#define FIELD_MAC(_field, _name) \
3153+ [FIELD_NAME(_field)] = { \
3154+ .name = _name, \
3155+ .parse = parse_mac, \
3156+ .print = print_mac \
3157+ }
3158+
3159 #define FIELD_NAME(_field) MT76_TM_RX_ATTR_##_field
3160 static const struct tm_field rx_fields[NUM_MT76_TM_RX_ATTRS] = {
3161 FIELD_RO(s32, FREQ_OFFSET, "freq_offset"),
developerbd9fa1e2023-10-16 11:04:00 +08003162 FIELD_ARRAY_RO(u8, RCPI, "rcpi"),
3163+ FIELD_ARRAY_RO(s8, RSSI, "rssi"),
3164 FIELD_ARRAY_RO(s8, IB_RSSI, "ib_rssi"),
3165 FIELD_ARRAY_RO(s8, WB_RSSI, "wb_rssi"),
3166 FIELD_RO(s8, SNR, "snr"),
3167@@ -261,6 +327,7 @@ static const struct tm_field rx_fields[NUM_MT76_TM_RX_ATTRS] = {
3168 static struct nla_policy rx_policy[NUM_MT76_TM_RX_ATTRS] = {
3169 [MT76_TM_RX_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
3170 [MT76_TM_RX_ATTR_RCPI] = { .type = NLA_NESTED },
3171+ [MT76_TM_RX_ATTR_RSSI] = { .type = NLA_NESTED },
3172 [MT76_TM_RX_ATTR_IB_RSSI] = { .type = NLA_NESTED },
3173 [MT76_TM_RX_ATTR_WB_RSSI] = { .type = NLA_NESTED },
3174 [MT76_TM_RX_ATTR_SNR] = { .type = NLA_U8 },
3175@@ -291,6 +358,7 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
3176 FIELD_ENUM(STATE, "state", testmode_state),
3177 FIELD_RO(string, MTD_PART, "mtd_part"),
3178 FIELD_RO(u32, MTD_OFFSET, "mtd_offset"),
3179+ FIELD(u8, SKU_EN, "sku_en"),
3180 FIELD(u32, TX_COUNT, "tx_count"),
3181 FIELD(u32, TX_LENGTH, "tx_length"),
3182 FIELD_ENUM(TX_RATE_MODE, "tx_rate_mode", testmode_tx_mode),
3183@@ -300,10 +368,18 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
developer6caa5e22022-06-16 13:33:13 +08003184 FIELD(u8, TX_RATE_LDPC, "tx_rate_ldpc"),
3185 FIELD(u8, TX_RATE_STBC, "tx_rate_stbc"),
3186 FIELD(u8, TX_LTF, "tx_ltf"),
3187+ FIELD(u8, TX_DUTY_CYCLE, "tx_duty_cycle"),
3188+ FIELD(u32, TX_IPG, "tx_ipg"),
3189+ FIELD(u32, TX_TIME, "tx_time"),
3190 FIELD(u8, TX_POWER_CONTROL, "tx_power_control"),
3191 FIELD_ARRAY(u8, TX_POWER, "tx_power"),
3192 FIELD(u8, TX_ANTENNA, "tx_antenna"),
3193+ FIELD(u8, TX_SPE_IDX, "tx_spe_idx"),
3194 FIELD(u32, FREQ_OFFSET, "freq_offset"),
3195+ FIELD(u8, AID, "aid"),
3196+ FIELD(u8, RU_ALLOC, "ru_alloc"),
3197+ FIELD(u8, RU_IDX, "ru_idx"),
3198+ FIELD_MAC(MAC_ADDRS, "mac_addrs"),
3199 FIELD_NESTED_RO(STATS, stats, "",
3200 .print_extra = print_extra_stats),
3201 };
developerbd9fa1e2023-10-16 11:04:00 +08003202@@ -313,6 +389,7 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
3203 [MT76_TM_ATTR_STATE] = { .type = NLA_U8 },
3204 [MT76_TM_ATTR_MTD_PART] = { .type = NLA_STRING },
3205 [MT76_TM_ATTR_MTD_OFFSET] = { .type = NLA_U32 },
3206+ [MT76_TM_ATTR_SKU_EN] = { .type = NLA_U8 },
3207 [MT76_TM_ATTR_TX_COUNT] = { .type = NLA_U32 },
3208 [MT76_TM_ATTR_TX_LENGTH] = { .type = NLA_U32 },
3209 [MT76_TM_ATTR_TX_RATE_MODE] = { .type = NLA_U8 },
3210@@ -322,9 +399,16 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
developer6caa5e22022-06-16 13:33:13 +08003211 [MT76_TM_ATTR_TX_RATE_LDPC] = { .type = NLA_U8 },
3212 [MT76_TM_ATTR_TX_RATE_STBC] = { .type = NLA_U8 },
3213 [MT76_TM_ATTR_TX_LTF] = { .type = NLA_U8 },
3214+ [MT76_TM_ATTR_TX_DUTY_CYCLE] = { .type = NLA_U8 },
3215+ [MT76_TM_ATTR_TX_IPG] = { .type = NLA_U32 },
3216+ [MT76_TM_ATTR_TX_TIME] = { .type = NLA_U32 },
3217 [MT76_TM_ATTR_TX_POWER_CONTROL] = { .type = NLA_U8 },
3218 [MT76_TM_ATTR_TX_ANTENNA] = { .type = NLA_U8 },
3219+ [MT76_TM_ATTR_TX_SPE_IDX] = { .type = NLA_U8 },
3220 [MT76_TM_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
3221+ [MT76_TM_ATTR_AID] = { .type = NLA_U8 },
3222+ [MT76_TM_ATTR_RU_ALLOC] = { .type = NLA_U8 },
3223+ [MT76_TM_ATTR_RU_IDX] = { .type = NLA_U8 },
3224 [MT76_TM_ATTR_STATS] = { .type = NLA_NESTED },
3225 };
3226
3227diff --git a/tx.c b/tx.c
developerbd9fa1e2023-10-16 11:04:00 +08003228index 1809b03..f1dd9f6 100644
developer6caa5e22022-06-16 13:33:13 +08003229--- a/tx.c
3230+++ b/tx.c
developer47efbdb2023-06-29 20:33:22 +08003231@@ -259,8 +259,7 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
developer6caa5e22022-06-16 13:33:13 +08003232 if (mt76_is_testmode_skb(dev, skb, &hw)) {
3233 struct mt76_phy *phy = hw->priv;
3234
3235- if (skb == phy->test.tx_skb)
3236- phy->test.tx_done++;
3237+ phy->test.tx_done++;
3238 if (phy->test.tx_queued == phy->test.tx_done)
3239 wake_up(&dev->tx_wait);
3240
3241--
developerbd9fa1e2023-10-16 11:04:00 +080032422.18.0
developer6caa5e22022-06-16 13:33:13 +08003243