Skip to contentSkip to conversation

wifi: mt76: mt7925: extend MCU support for testmode

PATCH New [email protected] 2 participants 3 messages May 5, 2025 – May 10, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wifi: mt76: mt7925: extend MCU support for testmode

From: Michael Lo <[email protected]>

Add MCU command and its handling needed for testmode support on MT7925. This enables low-level chip testing features such as continuous TX/RX..

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  7 +++
 .../net/wireless/mediatek/mt76/mt7925/mcu.c   |  8 ++++
 .../net/wireless/mediatek/mt76/mt7925/mcu.h   | 48 ++++++++++++++++---
 3 files changed, 56 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +7 -0
index 478cd1886736..f93f58eb9bcf 100644
@@ -1183,6 +1183,11 @@ enum {
 #define MCU_UNI_CMD(_t)				(__MCU_CMD_FIELD_UNI |			\
 						 FIELD_PREP(__MCU_CMD_FIELD_ID,		\
 							    MCU_UNI_CMD_##_t))
+
+#define MCU_UNI_QUERY(_t)			(__MCU_CMD_FIELD_UNI | __MCU_CMD_FIELD_QUERY | \
+						 FIELD_PREP(__MCU_CMD_FIELD_ID,		\
+							    MCU_UNI_CMD_##_t))
+
 #define MCU_CE_CMD(_t)				(__MCU_CMD_FIELD_CE |			\
 						 FIELD_PREP(__MCU_CMD_FIELD_ID,		\
 							   MCU_CE_CMD_##_t))
@@ -1288,11 +1293,13 @@ enum {
 	MCU_UNI_CMD_EFUSE_CTRL = 0x2d,
 	MCU_UNI_CMD_RA = 0x2f,
 	MCU_UNI_CMD_MURU = 0x31,
+	MCU_UNI_CMD_TESTMODE_RX_STAT = 0x32,
 	MCU_UNI_CMD_BF = 0x33,
 	MCU_UNI_CMD_CHANNEL_SWITCH = 0x34,
 	MCU_UNI_CMD_THERMAL = 0x35,
 	MCU_UNI_CMD_VOW = 0x37,
 	MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40,
+	MCU_UNI_CMD_TESTMODE_CTRL = 0x46,
 	MCU_UNI_CMD_RRO = 0x57,
 	MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58,
 	MCU_UNI_CMD_PER_STA_INFO = 0x6d,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +8 -0
index 286f602623c0..df38009e0036 100644
@@ -3342,6 +3342,14 @@ int mt7925_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,
 		if (cmd == MCU_UNI_CMD(HIF_CTRL))
 			uni_txd->option &= ~MCU_CMD_ACK;
 
+		if (mcu_cmd == MCU_UNI_CMD_TESTMODE_CTRL ||
+		    mcu_cmd == MCU_UNI_CMD_TESTMODE_RX_STAT) {
+			if (cmd & __MCU_CMD_FIELD_QUERY)
+				uni_txd->option = 0x2;
+			else
+				uni_txd->option = 0x6;
+		}
+
 		goto exit;
 	}
 
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +41 -7

60 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 wifi: mt76: mt7925: add test mode support

From: Michael Lo <[email protected]>

The test mode interface allows controlled execution of chip-level operations such as continuous transmission, reception tests, and register access, which are essential during bring-up, diagnostics , and factory testing.

---
 .../wireless/mediatek/mt76/mt7925/Makefile    |   1 +
 .../net/wireless/mediatek/mt76/mt7925/main.c  |   2 +
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   5 +
 .../wireless/mediatek/mt76/mt7925/testmode.c  | 204 ++++++++++++++++++
 4 files changed, 212 insertions(+)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/testmode.c
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -0
index d321e4ed732f..ade5e647c941 100644
@@ -5,5 +5,6 @@ obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
 mt7925-common-y := mac.o mcu.o main.o init.o debugfs.o
+mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -0
index 83f93f9e002c..17fc5f05cb7b 100644
@@ -2244,6 +2244,8 @@ const struct ieee80211_ops mt7925_ops = {
 	.sta_statistics = mt792x_sta_statistics,
 	.sched_scan_start = mt7925_start_sched_scan,
 	.sched_scan_stop = mt7925_stop_sched_scan,
+	CFG80211_TESTMODE_CMD(mt7925_testmode_cmd)
+	CFG80211_TESTMODE_DUMP(mt7925_testmode_dump)
 #ifdef CONFIG_PM
 	.suspend = mt7925_suspend,
 	.resume = mt7925_resume,
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +5 -0
index 4e50f2597ccd..c507dcae07d4 100644
@@ -366,4 +366,9 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
 				     struct ieee80211_sta *sta,
 				     int link_id);
 
+int mt7925_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			void *data, int len);
+int mt7925_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
+			 struct netlink_callback *cb, void *data, int len);
+
 #endif
drivers/net/wireless/mediatek/mt76/mt7925/testmode.c new file +204 -0

204 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] wifi: mt76: mt7925: add test mode support

kernel test robot noticed the following build warnings:

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.15-rc5 next-20250509] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/wifi-mt76-mt7925-add-test-mode-support/20250506-115641
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20250505233618.1951021-2-sean.wang%40kernel.org
patch subject: [PATCH 2/2] wifi: mt76: mt7925: add test mode support
config: loongarch-allyesconfig (https://download.01.org/0day-ci/archive/20250510/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250510/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/net/wireless/mediatek/mt76/mt7925/testmode.c: In function 'mt7925_tm_query':

>> drivers/net/wireless/mediatek/mt76/mt7925/testmode.c:92:38: warning: variable 'evt' set but not used [-Wunused-but-set-variable]
      92 |         struct uni_cmd_testmode_evt *evt;
         |                                      ^~~

vim +/evt +92 drivers/net/wireless/mediatek/mt76/mt7925/testmode.c

    85	
    86	static int
    87	mt7925_tm_query(struct mt792x_dev *dev, struct mt7925_tm_cmd *req,
    88			char *evt_resp)
    89	{
    90		struct mt7925_rftest_cmd cmd;
    91		char *pcmd = (char *)&cmd;
  > 92		struct uni_cmd_testmode_evt *evt;
    93		struct sk_buff *skb = NULL;
    94		int ret = 1;
    95	
    96		memset(pcmd, 0, sizeof(*pcmd));
    97		memcpy(pcmd + 4, (char *)&req->c, sizeof(struct uni_cmd_testmode_ctrl));
    98	
    99		if (*((uint16_t *)req->padding) == MCU_UNI_CMD_TESTMODE_CTRL)

100 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_QUERY(TESTMODE_CTRL),
101 &cmd, sizeof(cmd), true, &skb);
102 else if (*((uint16_t *)req->padding) == MCU_UNI_CMD_TESTMODE_RX_STAT)
103 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_QUERY(TESTMODE_RX_STAT),
104 &cmd, sizeof(cmd), true, &skb);
105
106 if (ret)
107 goto out;
108
109 evt = (struct uni_cmd_testmode_evt *)skb->data;
110
111 memcpy((char *)evt_resp, (char *)skb->data + 8, MT7925_EVT_RSP_LEN);
112
113 out:
114 dev_kfree_skb(skb);
115
116 return ret;
117 }
118

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki