Skip to content

Commit b38046b

Browse files
committed
drivers: wifi: nrf7002: Add config to enable dual vif context
Enable dual Virtual Interface (VIF) support for the nRF7002 Wi-Fi driver by introducing a new Kconfig option: CONFIG_NRF70_WIFI_ENABLE_DUAL_VIF. Signed-off-by: Hanan Arshad <hananarshad619@gmail.com>
1 parent ffb5d26 commit b38046b

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

drivers/wifi/nrf_wifi/Kconfig.nrfwifi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ config NRF70_AP_MODE
8888
depends on WIFI_NM_WPA_SUPPLICANT_AP
8989
default y if WIFI_NM_WPA_SUPPLICANT_AP
9090

91-
config NRF70_STA_AP_MODE
92-
bool "Simultaneous STA and AP mode"
93-
depends on WIFI_NRF7002
94-
select NRF70_AP_MODE
95-
select NRF70_STA_MODE
96-
default n
97-
help
98-
Select this option to operate both STA an AP mode simultaneously
99-
91+
config NRF70_WIFI_ENABLE_DUAL_VIF
92+
bool "Enable dual virtual Wi-Fi interfaces"
93+
default y if WIFI_NM_MAX_MANAGED_INTERFACES = 2
94+
default n
95+
depends on WIFI_NRF7002 && NET_L2_ETHERNET
96+
help
97+
Enable support for two virtual Wi-Fi interfaces (VIFs).
98+
When enabled, the driver can operate two VIFs simultaneously,
99+
allowing use cases such as one interface in AP mode and another in STA mode.
100100

101101
config NRF70_P2P_MODE
102102
bool "P2P support in driver"

drivers/wifi/nrf_wifi/inc/fmac_main.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ struct nrf_wifi_ctx_zep {
112112
bool rf_test_run;
113113
unsigned char rf_test;
114114
#else /* CONFIG_NRF70_RADIO_TEST */
115-
unsigned int vif_ctx_cnt; // Variable to keep track for multiple interfaces
116115
struct nrf_wifi_vif_ctx_zep vif_ctx_zep[MAX_NUM_VIFS];
117116
#ifdef CONFIG_NRF70_UTIL
118117
struct rpu_conf_params conf_params;

drivers/wifi/nrf_wifi/src/fmac_main.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ const char *nrf_wifi_get_drv_version(void)
130130
return NRF70_DRIVER_VERSION;
131131
}
132132

133-
/* If the interface is not Wi-Fi then errors are expected, so, fail silently */
134133
struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx_by_idx(int index)
135134
{
136135
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
@@ -140,7 +139,7 @@ struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx_by_idx(int index)
140139
return NULL;
141140
}
142141

143-
for (int i = 0; i < rpu_ctx_zep->vif_ctx_cnt; i++) {
142+
for (int i = 0; i < ARRAY_SIZE(rpu_ctx_zep->vif_ctx_zep); i++) {
144143
if (rpu_ctx_zep->vif_ctx_zep[i].vif_idx == index) {
145144
vif_ctx_zep = &rpu_ctx_zep->vif_ctx_zep[i];
146145
break;
@@ -154,15 +153,15 @@ struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx_by_idx(int index)
154153
struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx(struct net_if *iface)
155154
{
156155
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
157-
struct nrf_wifi_ctx_zep *rpu_ctx_zep = &rpu_drv_priv_zep.rpu_ctx_zep;
156+
struct nrf_wifi_ctx_zep *rpu_ctx = &rpu_drv_priv_zep.rpu_ctx_zep;
158157

159-
if (!iface || !rpu_ctx_zep || !rpu_ctx_zep->rpu_ctx) {
158+
if (!iface || !rpu_ctx || !rpu_ctx->rpu_ctx) {
160159
return NULL;
161160
}
162161

163-
for (int i = 0; i < rpu_ctx_zep->vif_ctx_cnt; i++) {
164-
if (rpu_ctx_zep->vif_ctx_zep[i].zep_net_if_ctx == iface) {
165-
vif_ctx_zep = &rpu_ctx_zep->vif_ctx_zep[i];
162+
for (int i = 0; i < ARRAY_SIZE(rpu_ctx->vif_ctx_zep); i++) {
163+
if (rpu_ctx->vif_ctx_zep[i].zep_net_if_ctx == iface) {
164+
vif_ctx_zep = &rpu_ctx->vif_ctx_zep[i];
166165
break;
167166
}
168167
}
@@ -441,6 +440,7 @@ void nrf_wifi_event_proc_cookie_rsp(void *vif_ctx,
441440
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
442441
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
443442
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
443+
unsigned int vif_ctx_cnt = 0;
444444

445445
vif_ctx_zep = vif_ctx;
446446

@@ -451,6 +451,7 @@ void nrf_wifi_event_proc_cookie_rsp(void *vif_ctx,
451451

452452
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
453453
fmac_dev_ctx = rpu_ctx_zep->rpu_ctx;
454+
vif_ctx_cnt = nrf_wifi_fmac_get_num_vifs(rpu_ctx_zep->rpu_ctx);
454455

455456
LOG_DBG("%s: cookie_rsp_event->cookie = %llx", __func__, cookie_rsp_event->cookie);
456457
LOG_DBG("%s: host_cookie = %llx", __func__, cookie_rsp_event->host_cookie);
@@ -462,8 +463,11 @@ void nrf_wifi_event_proc_cookie_rsp(void *vif_ctx,
462463
cookie_rsp_event->mac_addr[4],
463464
cookie_rsp_event->mac_addr[5]);
464465

465-
for(int i = 0; i < rpu_ctx_zep->vif_ctx_cnt; ++i) {
466-
rpu_ctx_zep->vif_ctx_zep[i].cookie_resp_received = true;
466+
/* Notify all vif */
467+
for(int idx = 0; idx < vif_ctx_cnt; ++idx) {
468+
vif_ctx_zep = nrf_wifi_get_vif_ctx_by_idx(idx);
469+
if(vif_ctx_zep)
470+
vif_ctx_zep->cookie_resp_received = true;
467471
}
468472
/* TODO: When supp_callbk_fns.mgmt_tx_status is implemented, add logic
469473
* here to use the cookie and host_cookie to map requests to responses.
@@ -737,16 +741,14 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
737741
struct rx_buf_pool_params rx_buf_pools[MAX_NUM_OF_RX_QUEUES];
738742
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = dev->data;
739743
struct nrf_wifi_ctx_zep *rpu_ctx_zep = &rpu_drv_priv_zep.rpu_ctx_zep;
744+
unsigned int vif_ctx_cnt = nrf_wifi_fmac_get_num_vifs(rpu_ctx_zep->rpu_ctx);
740745

741-
vif_ctx_zep->rpu_ctx_zep = rpu_ctx_zep;
742-
743-
if(rpu_ctx_zep->vif_ctx_cnt >= MAX_NUM_VIFS){
746+
if(vif_ctx_cnt >= MAX_NUM_VIFS){
744747
LOG_ERR("%s: Max number of VIFs reached", __func__);
745748
return -ENOMEM;
746-
}
749+
}
747750

748-
rpu_ctx_zep->vif_ctx_cnt++;
749-
if (rpu_ctx_zep->vif_ctx_cnt > 1) {
751+
if (vif_ctx_cnt > 1) {
750752
// FMAC is already initialized for VIF-0
751753
return 0;
752754
}
@@ -976,7 +978,7 @@ ETH_NET_DEVICE_DT_INST_DEFINE(0,
976978
CONFIG_WIFI_INIT_PRIORITY, /* prio */
977979
&wifi_offload_ops, /* api */
978980
CONFIG_NRF_WIFI_IFACE_MTU); /*mtu */
979-
#ifdef CONFIG_NRF70_STA_AP_MODE
981+
#ifdef CONFIG_NRF70_WIFI_ENABLE_DUAL_VIF
980982
// Register second interface
981983
ETH_NET_DEVICE_DT_INST_DEFINE(1,
982984
nrf_wifi_drv_main_zep, /* init_fn */

0 commit comments

Comments
 (0)