Skip to content

drivers: wifi: nrf7002: Add support for multiple virtual interfaces #91916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hanan619
Copy link

Description:
The nRF7002 firmware supports two virtual interfaces (VIFs) that can operate in different modes (e.g., AP and STA). However, the existing Zephyr driver only utilizes a single VIF, preventing full multi-interface support.

This PR extends the nRF7002 driver to support multiple VIFs by making the following modifications:

  • VIF Context Handling: The driver already contains an array of vif_ctx_zep, but only the first element was being used. Now, a second Ethernet device is registered using vif_ctx_zep[1], enabling multi-VIF operation.
  • Tracking Interfaces: Introduced vif_ctx_cnt to keep track of active interfaces and manage their state effectively.
  • FMAC Initialization: Ensured that FMAC (Firmware MAC) is initialized only once, avoiding redundant initializations when multiple VIFs are present.

Testing:
Verified that two virtual interfaces can be registered and operate simultaneously.
Tested AP mode on one VIF and STA mode on another VIF concurrently.
Ensured that UMAC command responses are correctly matched to their respective VIFs.
Dependencies:
This PR depends on the corresponding hostap PR, which introduces multiple control channels in WPA supplicant to handle separate interfaces.

hanan619 added 4 commits June 18, 2025 18:43
…VIFs)

Description:
The nRF7002 firmware supports two virtual interfaces (VIFs) that can
operate in different modes (e.g., AP and STA). However, the existing
Zephyr driver only utilizes a single VIF, preventing full
multi-interface support.

This commit extends the nRF7002 driver to support multiple VIFs by
making the following modifications:

* The driver already contains an array of vif_ctx_zep, but only the
first item was being used. Now, a second Ethernet device is registered
using vif_ctx_zep[1], enabling multi-VIF operation.
* Introduced vif_ctx_cnt to keep track of active interfaces and manage
their state effectively.
* Ensured that FMAC (Firmware MAC) is initialized only once, avoiding
redundant initializations when multiple VIFs are present.
* The UMAC control commands previously did not associate responses with
the issuing VIF. A queue is now introduced to track the originating VIF
for each command and correctly route the response event to the
corresponding interface.

Signed-off-by: Hanan Arshad <[email protected]>
This commit links the hostap PR required for the nrf7002 driver.
west.yml is updated

Signed-off-by: Hanan Arshad <[email protected]>
Update WPA supplicant functions to pass the control channel (socket) as a
parameter instead of relying on a global socket. This change aligns with
the PR 80 modifications in hostap repo and ensures that each Virtual
Interface (VIF) uses its dedicated control channel for communication.

Signed-off-by: Hanan Arshad <[email protected]>
This commit adds the second wlan in dts file for nrf70.
Also adjusts the sockets count required for wpa supplicant sockets

Signed-off-by: Hanan Arshad <[email protected]>
@hanan619
Copy link
Author

@krish2718
Duplicate PR of #86618

Copy link

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hostap zephyrproject-rtos/hostap@cf27000 (main) zephyrproject-rtos/hostap#80 zephyrproject-rtos/hostap#80/files

DNM label due to: 1 project with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest-hostap DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Jun 19, 2025
@krish2718
Copy link
Collaborator

@krish2718 Duplicate PR of #86618

Thanks, hopefully the tests will go through now.

Copy link

@@ -21,8 +28,20 @@ static int cmd_wpa_cli(const struct shell *sh,
size_t argc,
const char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is, if there are 2 virtual interfaces, then how to run wpa_cli cmd on the second interface, since you get the iface by net_if_get_first_wifi?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate pr can be created to specify interface index in wpa cli.
This change is added to make the wpa cli compatible with new wpa supplicant changes as ctrl_conn is now associated with wpa_s object

@hanan619 hanan619 requested a review from MaochenWang1 June 20, 2025 08:13
@krish2718
Copy link
Collaborator

krish2718 commented Jun 20, 2025

I did some testing and here's my feedback. BTW, how are you testing this PR? Are you testing on a nRF7002DK? Have you tested a working STA + AP? I see that the right after flashing the second VIF fails to be initialized?

uart:~$ 
[00:00:00.465,606] <err> wifi_nrf: nrf_wifi_if_start_zep: rpu_ctx_zep is NULL
*** Booting Zephyr OS build v4.1.0-6207-gf9f1f564fb93 ***
[00:00:00.484,436] <inf> wifi_supplicant: wpa_supplicant initialized

Earlier feedback is not implemented: #86618 (comment)

  1. Missing fix: krish2718@73b149e#diff-762ac3b8c00bc2d577de9dfcb9ce4d514d08233c991077269227fa889886929b -> Causes 2nd VIF to fail to initailize
  2. Missing memory updates to hostap and socketpair (FYI, Remove socketpair in hostap to save memory #90317 removes the socketpair support, so, might want to drop that change once its merged)

New issues

  1. Fix Max VIF check in nrf_wifi (needs a manifest update as well)
  2. Use the newly introduced: WIFI_USAGE_MODE_STA_AP (left a review comment too)

See attached patch with all fixes. (renamed as .patch isn't allowed in GH)
mvif_working.txt

Build with recovery disabled (as I mentioned earlier, this doesn't work): west build -p -d samples/net/wifi/shell/build_70dk_dual -b nrf7002dk/nrf5340/cpuapp samples/net/wifi/shell/ -- -DCONFIG_LOG_MODE_IMMEDIATE=y -DCONFIG_WIFI_USAGE_MODE_STA_AP=y -DCONFIG_NRF_WIFI_RPU_RECOVERY=n

uart:~$ wifi connect <...>
# Start AP on the same channel as STA
uart:~$ wifi ap enable -i 2 -s MVIF -c 2

uart:~$ wifi status -i 2
Status: successful
==================
State: COMPLETED
Interface Mode: ACCESS POINT
Link Mode: UNKNOWN
SSID: MVIF
BSSID: <SNIP..>
Band: 2.4GHz
Channel: 2
Security:  OPEN
MFP: Disable
Beacon Interval: 100
DTIM: 2
TWT: Not supported
Current PHY TX rate (Mbps) : 0
uart:~$ wifi status -i 1
Status: successful
==================
State: COMPLETED
Interface Mode: STATION
Link Mode: WIFI 6 (802.11ax/HE)
SSID: OpenWrt
BSSID: <SNIP..>
Band: 2.4GHz
Channel: 2
Security:  WPA2-PSK
MFP: Optional
RSSI: -74
Beacon Interval: 100

We are quite close now, if you can submit the above fixes this PR can be merged for upcoming 4.2 (before RC1 on 27th June).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Networking area: Shields Shields (add-on boards) area: Wi-Fi Wi-Fi DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hostap platform: nRF Nordic nRFx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants