Search code examples
wifilinux-device-driverproc

Testing WiFi Linux driver for certification using procfs question


I am working with NXP based (w8987o) wireless module. The module didn't need much of software integration to be done to start working under Linux Kernel version 5.15.67. The Kernel seems to be having the driver under drivers/net/wireless/marvell/mwifiex/. I did the following to find the exact driver running in the system:

readlink /sys/class/net/mlan0/device/driver
../../../../../../../../bus/sdio/drivers/mwifiex_sdio 
 
lsmod | grep mwifiex
mwifiex_sdio           36864  0 
mwifiex               266240  1 mwifiex_sdio
cfg80211              671744  1 mwifiex

Wifi seems to be working fine so far. Now we are preparing to do the testing for the certification purposes and the vendor seems to be suggesting to do the certification using the following and similar (sample) script:

echo "rf_test_mode=1" >> /proc/mwlan/adapter0/config                # enable RF test mode
echo "tx_antenna=1" >> /proc/mwlan/adapter0/config                  # 1x1
echo "rx_antenna=1" >> /proc/mwlan/adapter0/config                  # 1x1
echo "band=0" >> /proc/mwlan/adapter0/config                        # 2.4 GHz band
echo "bw=0" >> /proc/mwlan/adapter0/config                          # 20 MHz
echo "channel=11" >> /proc/mwlan/adapter0/config                    # Ch11 => 2462 MHz
echo "tx_power=16 2 0" >> /proc/mwlan/adapter0/config               # 16 dBm MCS PathA
echo "tx_continuous=0" >> /proc/mwlan/adapter0/config               # stop ongoing transmissions 
echo "tx_continuous=1 0 0xAAA 0 3 3" >> /proc/mwlan/adapter0/config # packet mode, 0xAAA payload, CS mode disabled, both subchannels active, MCS3
cat /proc/mwlan/adapter0/config

Now, when I looked into the drivers/net/wireless/marvell/ source code, I cannot see any of the above proc interfaces are provided/exposed/created by the drivers/net/wireless/marvell/ code. Apparently, the test case suggestion came from the integration of the same Wireless chip-set in another i.MX 8M based system where (seems to me) the driver most possibly was exporting these proc interfaces to the user. Now, my question is how do I achieve the similar testing functionality without changing the existing WiFi driver (marvell)? I am thinking there must be some IOCTLs which I may be able to use to overcome the proc dependency but I cannot find where the IOCTL commands are located. I spotted a file called driver/net/wireless/marvell/mwiflex/sta_ioctl.c - but it doesn't tell me what are the commands to use from the user space, nor how to open the driver device file. I have also mounted the debugfs and can get some information about the driver as follows:

mount -t debugfs none /sys/kernel/debug
# cat /sys/kernel/debug/mwifiex/mlan0/info 
[ 5013.941246] mwifiex_sdio mmc0:0001:1: info: MWIFIEX VERSION: mwifiex 1.0 (16.68.10.p33) 
driver_name = "mwifiex"[ 5013.974665] mwifiex_sdio mmc0:0001:1: info: MWIFIEX VERSION: mwifiex 1.0 (16.68.10.p33) 

driver_version = mwifiex 1.0 (16.68.10.p33) 
verext = w8987o-V0, RF878X, FP68_LINUX, 16.68.10.p33
interface_name="mlan0"
bss_mode="STATION"
media_state="Connected"
mac_address="xx:xx:xx:xx:xx:xx"
multicast_count="3"
essid="ABCXYZ"
bssid="xx:xx:xx:xx:xx:xx"
channel="x"
country_code = ""
region_code="0xYY"
multicast_address[0]="xx:xx:xx:xx:xx:xx"
num_tx_bytes = 248
num_rx_bytes = 11665
num_tx_pkts = 2
num_rx_pkts = 99
num_tx_pkts_dropped = 0
num_rx_pkts_dropped = 2
num_tx_pkts_err = 0
num_rx_pkts_err = 0
carrier on
tx queue 0:started 1:started 2:started 3:started

But this is not helping me to design a test around this as the above debugfs seems to be information to the user not vice versa. I have also enabled the following configuration in the kernel to get additional debug support from the kernel:

# cat /proc/config.gz | gunzip | grep CONFIG_CFG80211_DEBUGFS
CONFIG_CFG80211_DEBUGFS=y
# cat /proc/config.gz | gunzip | grep CFG80211_DEBUGFS
CONFIG_CFG80211_DEBUGFS=y
# cat /proc/config.gz | gunzip | grep CFG80211_WEXT
CONFIG_CFG80211_WEXT=y

But so far I have not figured out how to be able to change the parameters in the WiFi config to do some testing. Please suggest if there is anything which might help me in this without going the route of trying to replace the existing driver with a vendor provided (if they - haven't checked yet) custom driver. That will be a long shot for me. Please advise.


Solution

  • I have done analysing this test script, existing WiFi driver source code go through and the possibility of accommodating this test mechanism in the present form of the driver. I can confirm that the /proc/mwlan/ is missing in the existing marvell/mwifiex driver. I did a lot of digging in the driver source code for the following:

    • Hidden proc entries which are not enabled in the linux config. I did actually enable quite few possible config entries to try understand this. But unfortunately, none of these configs (CONFIG_CFG80211_DEBUGFS, CONFIG_CFG80211_DEBUGFS, CONFIG_CFG80211_WEXT) would provide us a viable alternate mechanism to achieve what this test scripts (rf_test_2_4_ghz.sh, rf_test_5_ghz.sh) try to achieve.

    • IOCTL - ideally the driver should provide the same functionalities via ioctl call. So I browsed the source for possible IOCTL commands with which then we can write test applications to achieve the same. However, there is no ioctl interface that I found can help us write an application which can help the test.

    • Enabling the debugfs interface and see if that can give us a via route to achieve this but the debugfs interface is limited only few debug information and not more than that.

    The I looked into the available NXP forums and online public documents to see if they provide any driver which provides these proc interfaces and looks like the below is the closest I can find:

    https://github.com/nxp-imx/mwifiex

    In the above source code, if we look into the following source file it will be clear that these proc interfaces are custom created for the nxp-imx testing:

    moal_proc.c → func: woal_config_write() → this function implement all the proc nodes as can be found in the test scripts (rf_test_mode, tx_antenna, rx_antenna, band, bw, channel, tx_power, tx_continuous, tx_continuous).