Skip to contentSkip to conversation

wifi: nxpwifi: add manufacturing mode support

PATCH In review Viktor Korsnes 2 participants 3 messages Nov 30 – Dec 2

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

PATCH 1/1 wifi: nxpwifi: add manufacturing mode support

Add a mfg_mode module parameter to support booting NXP IW61x devices with manufacturing firmware, mirroring mwifiex's mfg_mode parameter.

Manufacturing firmware must be selected at probe time before the wiphy or debugfs interfaces exist, so a module parameter is used to request the manufacturing firmware image.

When mfg_mode is enabled:
- Load the card's manufacturing firmware (or fail with -EOPNOTSUPP if the card does not define one).
- Skip standard operational firmware and interface initialization (STA init, MAC/BSS setup, SNMP MIB queries, and deep sleep quirks) as well as operational shutdown commands on teardown.
- Reject standard driver-generated host commands in nxpwifi_send_cmd() with -EPERM, allowing only raw manufacturing commands (cmd_no == 0) passed from userspace via NL80211_CMD_TESTMODE.

---
Tested on an i.MX8MM board with an NXP IW611 (SDIO) module using manufacturing firmware nxp/sd_w61x_mfg_v1.bin.se (FW 18.80.8.52, Mfg 2.0.0.63). Verified end-to-end NL80211_CMD_TESTMODE command/reply handling (FW version query, get/set RF channel and bandwidth, RX packet counters) with NXP's labtool via a userspace ioctl-to-nl80211 shim [1].

[1] https://github.com/vkn-rm/labtool-nxpwifi-shim

 drivers/net/wireless/nxp/nxpwifi/cfg80211.c | 42 +++++++++++----------
 drivers/net/wireless/nxp/nxpwifi/cmdevt.c   |  9 +++++
 drivers/net/wireless/nxp/nxpwifi/init.c     | 14 ++++---
 drivers/net/wireless/nxp/nxpwifi/main.c     | 14 +++++--
 drivers/net/wireless/nxp/nxpwifi/main.h     |  1 +
 drivers/net/wireless/nxp/nxpwifi/sdio.c     | 17 +++++++--
 drivers/net/wireless/nxp/nxpwifi/sdio.h     |  3 ++
 7 files changed, 69 insertions(+), 31 deletions(-)
drivers/net/wireless/nxp/nxpwifi/cfg80211.c +23 -19
index c10fddbe2973..18b209dbe791 100644
@@ -2754,21 +2754,23 @@ struct wireless_dev *nxpwifi_add_virtual_intf(struct wiphy *wiphy,
 
 	priv->netdev = dev;
 
-	nxpwifi_set_mac_address(priv, dev, false, NULL);
+	if (!adapter->mfg_mode) {
+		nxpwifi_set_mac_address(priv, dev, false, NULL);
 
-	if (type != NL80211_IFTYPE_MONITOR) {
-		ret = nxpwifi_set_bss_mode(priv);
+		if (type != NL80211_IFTYPE_MONITOR) {
+			ret = nxpwifi_set_bss_mode(priv);
 
-		if (ret) {
-			nxpwifi_dbg(adapter, ERROR,
-				    "%s: err_set_bss_mode\n", __func__);
-			goto err_set_bss_mode;
+			if (ret) {
+				nxpwifi_dbg(adapter, ERROR,
+					    "%s: err_set_bss_mode\n", __func__);
+				goto err_set_bss_mode;
+			}
 		}
-	}
 
-	ret = nxpwifi_sta_init_cmd(priv, false, false);
-	if (ret)
-		goto err_sta_init;
+		ret = nxpwifi_sta_init_cmd(priv, false, false);
+		if (ret)
+			goto err_sta_init;
+	}
 
 	dev_net_set(dev, wiphy_net(wiphy));
 	dev->ieee80211_ptr = &priv->wdev;
@@ -4226,14 +4228,16 @@ int nxpwifi_register_cfg80211(struct nxpwifi_adapter *adapter)
 		}
 	}
 
-	nxpwifi_get_802_11_snmp_mib(priv, FRAG_THRESH_I, &thr);
-	wiphy->frag_threshold = thr;
-	nxpwifi_get_802_11_snmp_mib(priv, RTS_THRESH_I, &thr);
-	wiphy->rts_threshold = thr;
-	nxpwifi_get_802_11_snmp_mib(priv, SHORT_RETRY_LIM_I, &retry);
-	wiphy->retry_short = (u8)retry;
-	nxpwifi_get_802_11_snmp_mib(priv, LONG_RETRY_LIM_I, &retry);
-	wiphy->retry_long = (u8)retry;
+	if (!adapter->mfg_mode) {
+		nxpwifi_get_802_11_snmp_mib(priv, FRAG_THRESH_I, &thr);
+		wiphy->frag_threshold = thr;
+		nxpwifi_get_802_11_snmp_mib(priv, RTS_THRESH_I, &thr);
+		wiphy->rts_threshold = thr;
+		nxpwifi_get_802_11_snmp_mib(priv, SHORT_RETRY_LIM_I, &retry);
+		wiphy->retry_short = (u8)retry;
+		nxpwifi_get_802_11_snmp_mib(priv, LONG_RETRY_LIM_I, &retry);
+		wiphy->retry_long = (u8)retry;
+	}
 
 	adapter->wiphy = wiphy;
 	return ret;
drivers/net/wireless/nxp/nxpwifi/cmdevt.c +9 -0
index 2f96ebe7b47f..c018d2c1412d 100644
@@ -470,6 +470,15 @@ int nxpwifi_send_cmd(struct nxpwifi_private *priv, u16 cmd_no,
 		}
 	}
 
+	/* We don't expect commands in manufacturing mode. They are cooked
+	 * in application and ready to download buffer is passed to the driver
+	 */
+	if (adapter->mfg_mode && cmd_no) {
+		nxpwifi_dbg(adapter, CMD,
+			    "Ignoring commands in manufacturing mode\n");
+		return -EPERM;
+	}
+
 	if (priv->adapter->hs_activated_manually &&
 	    cmd_no != HOST_CMD_802_11_HS_CFG_ENH) {
 		nxpwifi_cancel_hs(priv, NXPWIFI_ASYNC_CMD);
drivers/net/wireless/nxp/nxpwifi/init.c +8 -6
index 6e03aac54694..c7c2f1e3f9b2 100644
@@ -436,13 +436,15 @@ int nxpwifi_init_fw(struct nxpwifi_adapter *adapter)
 			return ret;
 	}
 
-	for (i = 0; i < adapter->priv_num; i++) {
-		ret = nxpwifi_sta_init_cmd(adapter->priv[i],
-					   first_sta, true);
-		if (ret)
-			return ret;
+	if (!adapter->mfg_mode) {
+		for (i = 0; i < adapter->priv_num; i++) {
+			ret = nxpwifi_sta_init_cmd(adapter->priv[i],
+						   first_sta, true);
+			if (ret)
+				return ret;
 
-		first_sta = false;
+			first_sta = false;
+		}
 	}
 	spin_lock_bh(&adapter->cmd_pending_q_lock);
 	WARN_ON(!list_empty(&adapter->cmd_pending_q));
drivers/net/wireless/nxp/nxpwifi/main.c +11 -3
index 73fa00a9bc0d..7370f991b2fe 100644
@@ -18,6 +18,10 @@
 
 static unsigned int debug_mask = NXPWIFI_DEFAULT_DEBUG_MASK;
 
+static bool mfg_mode;
+module_param(mfg_mode, bool, 0444);
+MODULE_PARM_DESC(mfg_mode, "manufacturing mode enable:1, disable:0");
+
 char nxpwifi_driver_version[] = "nxpwifi " VERSION " (%s) ";
 
 const u16 nxpwifi_1d_to_wmm_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
@@ -43,6 +47,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev,
 	/* Save interface specific operations in adapter */
 	memmove(&adapter->if_ops, if_ops, sizeof(struct nxpwifi_if_ops));
 	adapter->debug_mask = debug_mask;
+	adapter->mfg_mode = mfg_mode;
 
 	/* card specific initialization has been deferred until now .. */
 	if (adapter->if_ops.init_if) {
@@ -601,7 +606,8 @@ static int _nxpwifi_fw_dpc(const struct firmware *firmware, void *context)
 	if (ret)
 		goto err_init_fw;
 
-	maybe_quirk_fw_disable_ds(adapter);
+	if (!adapter->mfg_mode)
+		maybe_quirk_fw_disable_ds(adapter);
 
 	if (!adapter->wiphy) {
 		ret = nxpwifi_register_cfg80211(adapter);
@@ -1414,9 +1420,11 @@ void nxpwifi_shutdown_sw(struct nxpwifi_adapter *adapter)
 	reinit_completion(adapter->fw_done);
 
 	priv = nxpwifi_get_priv(adapter, NXPWIFI_BSS_ROLE_ANY);
-	nxpwifi_deauthenticate(priv, NULL);
+	if (!adapter->mfg_mode) {
+		nxpwifi_deauthenticate(priv, NULL);
 
-	nxpwifi_init_shutdown_fw(priv, NXPWIFI_FUNC_SHUTDOWN);
+		nxpwifi_init_shutdown_fw(priv, NXPWIFI_FUNC_SHUTDOWN);
+	}
 
 	nxpwifi_uninit_sw(adapter);
 	adapter->is_up = false;
drivers/net/wireless/nxp/nxpwifi/main.h +1 -0
index bb2b4c77ed91..434833242cfd 100644
@@ -925,6 +925,7 @@ struct nxpwifi_adapter {
 	struct completion *fw_done; /* FW init completion */
 	bool is_up;
 	bool ext_scan;
+	bool mfg_mode;
 	u8 fw_api_ver;
 	u8 fw_hotfix_ver;
 	u8 key_api_major_ver, key_api_minor_ver;
drivers/net/wireless/nxp/nxpwifi/sdio.c +14 -3
index bdc8834fe428..1baa7a26a9ba 100644
@@ -85,6 +85,7 @@ static const struct nxpwifi_sdio_card_reg nxpwifi_reg_iw61x = {
 
 static const struct nxpwifi_sdio_device nxpwifi_sdio_iw61x = {
 	.firmware = IW61X_SDIO_FW_NAME,
+	.mfg_firmware = IW61X_SDIO_MFG_FW_NAME,
 	.reg = &nxpwifi_reg_iw61x,
 	.max_ports = 32,
 	.mp_agg_pkt_limit = 16,
@@ -151,6 +152,7 @@ nxpwifi_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
 
 		card->firmware = data->firmware;
 		card->firmware_sdiouart = data->firmware_sdiouart;
+		card->mfg_firmware = data->mfg_firmware;
 		card->reg = data->reg;
 		card->max_ports = data->max_ports;
 		card->mp_agg_pkt_limit = data->mp_agg_pkt_limit;
@@ -390,7 +392,8 @@ nxpwifi_sdio_remove(struct sdio_func *func)
 		return;
 
 	ret = nxpwifi_sdio_read_fw_status(adapter, &firmware_stat);
-	if (!ret && firmware_stat == FIRMWARE_READY_SDIO) {
+	if (!ret && firmware_stat == FIRMWARE_READY_SDIO &&
+	    !adapter->mfg_mode) {
 		nxpwifi_deauthenticate_all(adapter);
 
 		priv = nxpwifi_get_priv(adapter, NXPWIFI_BSS_ROLE_ANY);
@@ -1672,10 +1675,18 @@ static int nxpwifi_register_dev(struct nxpwifi_adapter *adapter)
 	}
 
 	/*
-	 * Select correct firmware (sdsd or sdiouart) firmware based on the strapping
+	 * Select manufacturing firmware if mfg_mode is enabled, otherwise
+	 * select correct firmware (sdsd or sdiouart) based on the strapping
 	 * option
 	 */
-	if (card->firmware_sdiouart) {
+	if (adapter->mfg_mode) {
+		if (!card->mfg_firmware) {
+			nxpwifi_dbg(adapter, ERROR,
+				    "manufacturing firmware not supported\n");
+			return -EOPNOTSUPP;
+		}
+		firmware = card->mfg_firmware;
+	} else if (card->firmware_sdiouart) {
 		u8 val;
 
 		nxpwifi_read_reg(adapter, card->reg->host_strap_reg, &val);
drivers/net/wireless/nxp/nxpwifi/sdio.h +3 -0
index e9881448fe2f..340c600f4563 100644
@@ -11,6 +11,7 @@
 #include "main.h"
 
 #define IW61X_SDIO_FW_NAME     "nxp/sd_w61x_v1.bin.se"
+#define IW61X_SDIO_MFG_FW_NAME "nxp/sd_w61x_mfg_v1.bin.se"
 #define IW610_SDIO_FW_NAME     "nxp/sd_iw610.bin.se"
 
 #define BLOCK_MODE	1
@@ -225,6 +226,7 @@ struct sdio_mmc_card {
 	struct completion fw_done;
 	const char *firmware;
 	const char *firmware_sdiouart;
+	const char *mfg_firmware;
 	const struct nxpwifi_sdio_card_reg *reg;
 	u8 max_ports;
 	u8 mp_agg_pkt_limit;
@@ -256,6 +258,7 @@ struct sdio_mmc_card {
 struct nxpwifi_sdio_device {
 	const char *firmware;
 	const char *firmware_sdiouart;
+	const char *mfg_firmware;
 	const struct nxpwifi_sdio_card_reg *reg;
 	u8 max_ports;
 	u8 mp_agg_pkt_limit;
Signature · 1 line
2.55.0
#1 lore raw

From: Jeff Chen <[email protected]>

Quoted 2 lines · Viktor Korsnes

Add a mfg_mode module parameter to support booting NXP IW61x devices with manufacturing firmware, mirroring mwifiex's mfg_mode parameter.

Hi Viktor,

NXP's downstream driver (mxmdriver) already supports manufacturing mode with labtool. Why does nxpwifi also need it?

Also, the patch adds a new module_param, which wifibot flags as deprecated_api.

Thanks,
Jeff

#2 lore raw
Quoted 2 lines · On Wed, Dec 2, 2026 at 2:56 AM <[email protected]> wrote:

NXP's downstream driver (mxmdriver) already supports manufacturing mode with labtool. Why does nxpwifi also need it?

Maintaining the out-of-tree driver is a lot of effort. Also, nxpwifi already supports NL80211_CMD_TESTMODE, which cannot be used without skipping normal init and loading the MFG firmware.

Quoted 2 lines

Also, the patch adds a new module_param, which wifibot flags as deprecated_api.

I implemented it similar to mwifiex and ath11k/ath12k. It's probably possible to solve it with a reload without using a module parameter, but using a familiar interface seems like the best solution. Let me know if you want me to rework that part.

Thanks,
Viktor