Skip to content

Commit a6dfdb9

Browse files
sachinthegreenkartben
authored andcommitted
drivers: nrf_wifi: Use mode specific APIs
Update the nrf70 Wi-Fi driver to use the mode specific APIs (as a precursor to enable combining modes as required). Signed-off-by: Sachin D Kulkarni <Sachin.Kulkarni@nordicsemi.no>
1 parent 922d207 commit a6dfdb9

File tree

14 files changed

+201
-181
lines changed

14 files changed

+201
-181
lines changed

drivers/wifi/nrf_wifi/Kconfig.nrfwifi

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,16 @@ choice NRF70_OPER_MODES
4545
help
4646
Select the operating mode of the nRF70 driver
4747

48-
config NRF70_SYSTEM_MODE
49-
bool "nRF70 system mode"
50-
depends on WIFI_NRF7002 || WIFI_NRF7001
51-
select WIFI_NM_WPA_SUPPLICANT
52-
help
53-
Select this option to enable system mode of the nRF70 driver
54-
5548
config NRF70_SCAN_ONLY
5649
bool "nRF70 scan only mode"
5750
help
5851
Select this option to enable scan only mode of the nRF70 driver
5952

53+
config NRF70_SYSTEM_MODE
54+
bool "System mode of the nRF70 driver"
55+
help
56+
Select this option to enable system mode of the nRF70 driver
57+
6058
config NRF70_RADIO_TEST
6159
bool "Radio test mode of the nRF70 driver"
6260

@@ -65,13 +63,6 @@ config NRF70_OFFLOADED_RAW_TX
6563

6664
endchoice
6765

68-
config NRF70_SYSTEM_WITH_RAW_MODES
69-
bool "nRF70 system mode with raw modes"
70-
depends on NRF70_SYSTEM_MODE
71-
default y if (NRF70_RAW_DATA_TX || NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX)
72-
help
73-
Select this option to enable system mode of the nRF70 driver with raw modes.
74-
7566
config NET_L2_ETHERNET
7667
default y if (!NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX)
7768

@@ -85,17 +76,27 @@ if NRF70_SYSTEM_MODE
8576
config NRF70_STA_MODE
8677
bool "nRF70 STA mode"
8778
default y
79+
depends on WIFI_NRF7002 || WIFI_NRF7001
80+
select WIFI_NM_WPA_SUPPLICANT
81+
select NRF70_DATA_TX
8882
help
8983
Select this option to enable STA mode of the nRF70 driver.
90-
9184
config NRF70_AP_MODE
9285
bool "Access point mode"
86+
depends on WIFI_NRF7002 || WIFI_NRF7001
87+
select NRF70_DATA_TX
9388
depends on WIFI_NM_WPA_SUPPLICANT_AP
9489
default y if WIFI_NM_WPA_SUPPLICANT_AP
9590

9691
config NRF70_P2P_MODE
9792
bool "P2P support in driver"
98-
endif # NRF70_SYSTEM_MODE
93+
94+
config NRF70_SYSTEM_WITH_RAW_MODES
95+
bool
96+
default y if (NRF70_RAW_DATA_TX || NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX)
97+
depends on WIFI_NRF7002 || WIFI_NRF7001
98+
help
99+
Select this option to enable system mode of the nRF70 driver with raw modes.
99100

100101
config NRF70_RAW_DATA_TX
101102
bool "RAW TX data path in the driver"
@@ -112,8 +113,8 @@ config NRF70_PROMISC_DATA_RX
112113
select NET_PROMISCUOUS_MODE
113114

114115
config NRF70_DATA_TX
115-
bool "TX data path in the driver"
116-
default y if NRF70_SYSTEM_MODE
116+
bool
117+
endif # NRF70_SYSTEM_MODE
117118

118119
config NRF_WIFI_IF_AUTO_START
119120
bool "Wi-Fi interface auto start on boot"

drivers/wifi/nrf_wifi/inc/fmac_main.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
#ifdef CONFIG_NRF70_STA_MODE
2828
#include <drivers/driver_zephyr.h>
2929
#endif /* CONFIG_NRF70_STA_MODE */
30+
#include <system/fmac_api.h>
31+
#else
32+
#include <radio_test/fmac_api.h>
3033
#endif /* !CONFIG_NRF70_RADIO_TEST */
3134

32-
#include <fmac_api.h>
3335
#include <host_rpu_umac_if.h>
3436

3537
#define NRF70_DRIVER_VERSION "1."KERNEL_VERSION_STRING

drivers/wifi/nrf_wifi/inc/net_if.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <zephyr/net/net_pkt.h>
1616
#include <zephyr/net/net_if.h>
1717
#include <zephyr/net/ethernet.h>
18-
#include <fmac_structs.h>
1918
#include <zephyr/net/wifi_mgmt.h>
19+
#include <system/fmac_structs.h>
2020

2121
#define UNICAST_MASK GENMASK(7, 1)
2222
#define LOCAL_BIT BIT(1)

drivers/wifi/nrf_wifi/off_raw_tx/inc/off_raw_tx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @brief File containing internal structures for the offloaded raw TX feature in the driver.
99
*/
1010

11-
#include "fmac_structs_common.h"
11+
#include "offload_raw_tx/fmac_structs.h"
1212
#include "osal_api.h"
1313

1414
struct nrf_wifi_ctx_zep {

drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <zephyr/logging/log.h>
1515
#include <zephyr/drivers/wifi/nrf_wifi/off_raw_tx/off_raw_tx_api.h>
1616
#include <off_raw_tx.h>
17-
#include <fmac_api.h>
17+
#include <offload_raw_tx/fmac_api.h>
1818

1919
#define DT_DRV_COMPAT nordic_wlan
2020
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
@@ -146,7 +146,7 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code)
146146

147147
key = k_spin_lock(&off_raw_tx_drv_priv.lock);
148148

149-
off_raw_tx_drv_priv.fmac_priv = nrf_wifi_fmac_off_raw_tx_init();
149+
off_raw_tx_drv_priv.fmac_priv = nrf_wifi_off_raw_tx_fmac_init();
150150

151151
if (off_raw_tx_drv_priv.fmac_priv == NULL) {
152152
LOG_ERR("%s: Failed to initialize nRF70 driver",
@@ -158,8 +158,8 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code)
158158

159159
rpu_ctx_zep->drv_priv_zep = &off_raw_tx_drv_priv;
160160

161-
rpu_ctx = nrf_wifi_fmac_dev_add(off_raw_tx_drv_priv.fmac_priv,
162-
rpu_ctx_zep);
161+
rpu_ctx = nrf_wifi_off_raw_tx_fmac_dev_add(off_raw_tx_drv_priv.fmac_priv,
162+
rpu_ctx_zep);
163163
if (!rpu_ctx) {
164164
LOG_ERR("%s: Failed to add nRF70 device", __func__);
165165
rpu_ctx_zep = NULL;
@@ -197,7 +197,7 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code)
197197

198198
configure_board_dep_params(&board_params);
199199

200-
status = nrf_wifi_fmac_off_raw_tx_dev_init(rpu_ctx_zep->rpu_ctx,
200+
status = nrf_wifi_off_raw_tx_fmac_dev_init(rpu_ctx_zep->rpu_ctx,
201201
#ifdef CONFIG_NRF_WIFI_LOW_POWER
202202
HW_SLEEP_ENABLE,
203203
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
@@ -257,7 +257,7 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code)
257257
return 0;
258258
err:
259259
if (rpu_ctx) {
260-
nrf_wifi_fmac_off_raw_tx_dev_rem(rpu_ctx);
260+
nrf_wifi_fmac_dev_rem(rpu_ctx);
261261
rpu_ctx_zep->rpu_ctx = NULL;
262262
}
263263

@@ -278,7 +278,7 @@ void nrf70_off_raw_tx_deinit(void)
278278
return;
279279
}
280280

281-
nrf_wifi_fmac_off_raw_tx_deinit(off_raw_tx_drv_priv.fmac_priv);
281+
nrf_wifi_fmac_deinit(off_raw_tx_drv_priv.fmac_priv);
282282

283283
k_spin_unlock(&off_raw_tx_drv_priv.lock, key);
284284
}
@@ -361,7 +361,7 @@ int nrf70_off_raw_tx_conf_update(struct nrf_wifi_off_raw_tx_conf *conf)
361361
goto out;
362362
}
363363

364-
status = nrf_wifi_fmac_off_raw_tx_conf(fmac_dev_ctx,
364+
status = nrf_wifi_off_raw_tx_fmac_conf(fmac_dev_ctx,
365365
off_ctrl_params,
366366
off_tx_params);
367367
if (status != NRF_WIFI_STATUS_SUCCESS) {
@@ -398,7 +398,7 @@ int nrf70_off_raw_tx_start(struct nrf_wifi_off_raw_tx_conf *conf)
398398
goto out;
399399
}
400400

401-
status = nrf_wifi_fmac_off_raw_tx_start(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx);
401+
status = nrf_wifi_off_raw_tx_fmac_start(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx);
402402
if (status != NRF_WIFI_STATUS_SUCCESS) {
403403
LOG_ERR("%s: nRF70 offloaded raw TX start failed",
404404
__func__);
@@ -425,7 +425,7 @@ int nrf70_off_raw_tx_stop(void)
425425
goto out;
426426
}
427427

428-
status = nrf_wifi_fmac_off_raw_tx_stop(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx);
428+
status = nrf_wifi_off_raw_tx_fmac_stop(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx);
429429
if (status != NRF_WIFI_STATUS_SUCCESS) {
430430
LOG_ERR("%s: nRF70 offloaded raw TX stop failed",
431431
__func__);
@@ -454,10 +454,10 @@ int nrf70_off_raw_tx_stats(struct nrf_wifi_off_raw_tx_stats *off_raw_tx_stats)
454454
{
455455
int ret = -1;
456456
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
457-
struct rpu_op_stats stats;
457+
struct rpu_off_raw_tx_op_stats stats;
458458
k_spinlock_key_t key;
459459

460-
memset(&stats, 0, sizeof(struct rpu_op_stats));
460+
memset(&stats, 0, sizeof(stats));
461461

462462
key = k_spin_lock(&off_raw_tx_drv_priv.lock);
463463

@@ -466,14 +466,16 @@ int nrf70_off_raw_tx_stats(struct nrf_wifi_off_raw_tx_stats *off_raw_tx_stats)
466466
goto out;
467467
}
468468

469-
status = nrf_wifi_fmac_stats_get(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx, 0, &stats);
469+
status = nrf_wifi_off_raw_tx_fmac_stats_get(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx,
470+
0,
471+
&stats);
470472
if (status != NRF_WIFI_STATUS_SUCCESS) {
471473
LOG_ERR("%s: nRF70 offloaded raw TX stats failed",
472474
__func__);
473475
goto out;
474476
}
475477

476-
off_raw_tx_stats->off_raw_tx_pkt_sent = stats.fw.offloaded_raw_tx.offload_raw_tx_cnt;
478+
off_raw_tx_stats->off_raw_tx_pkt_sent = stats.fw.offload_raw_tx_cnt;
477479

478480
ret = 0;
479481
out:

drivers/wifi/nrf_wifi/src/fmac_main.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424

2525
#include <util.h>
26-
#include <fmac_api.h>
27-
#include "fmac_util.h"
26+
#include "common/fmac_util.h"
2827
#include <fmac_main.h>
2928

3029
#ifndef CONFIG_NRF70_RADIO_TEST
@@ -37,8 +36,11 @@
3736
#include <wifi_mgmt.h>
3837
#include <wifi_mgmt_scan.h>
3938
#endif /* CONFIG_NRF70_STA_MODE */
40-
#include <zephyr/net/conn_mgr_connectivity.h>
4139

40+
#include <system/fmac_api.h>
41+
#include <zephyr/net/conn_mgr_connectivity.h>
42+
#else
43+
#include <radio_test/fmac_api.h>
4244
#endif /* !CONFIG_NRF70_RADIO_TEST */
4345

4446
#define DT_DRV_COMPAT nordic_wlan
@@ -582,7 +584,11 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv
582584

583585
rpu_ctx_zep->drv_priv_zep = drv_priv_zep;
584586

585-
rpu_ctx = nrf_wifi_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep);
587+
#ifdef CONFIG_NRF70_RADIO_TEST
588+
rpu_ctx = nrf_wifi_rt_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep);
589+
#else
590+
rpu_ctx = nrf_wifi_sys_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep);
591+
#endif /* CONFIG_NRF70_RADIO_TEST */
586592

587593
if (!rpu_ctx) {
588594
LOG_ERR("%s: nrf_wifi_fmac_dev_add failed", __func__);
@@ -618,7 +624,7 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv
618624
configure_board_dep_params(&board_params);
619625

620626
#ifdef CONFIG_NRF70_RADIO_TEST
621-
status = nrf_wifi_fmac_dev_init_rt(rpu_ctx_zep->rpu_ctx,
627+
status = nrf_wifi_rt_fmac_dev_init(rpu_ctx_zep->rpu_ctx,
622628
#ifdef CONFIG_NRF_WIFI_LOW_POWER
623629
sleep_type,
624630
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
@@ -630,7 +636,7 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv
630636
&board_params,
631637
STRINGIFY(CONFIG_NRF70_REG_DOMAIN));
632638
#else
633-
status = nrf_wifi_fmac_dev_init(rpu_ctx_zep->rpu_ctx,
639+
status = nrf_wifi_sys_fmac_dev_init(rpu_ctx_zep->rpu_ctx,
634640
#ifdef CONFIG_NRF_WIFI_LOW_POWER
635641
sleep_type,
636642
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
@@ -645,18 +651,14 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv
645651

646652

647653
if (status != NRF_WIFI_STATUS_SUCCESS) {
648-
LOG_ERR("%s: nrf_wifi_fmac_dev_init failed", __func__);
654+
LOG_ERR("%s: nrf_wifi_sys_fmac_dev_init failed", __func__);
649655
goto err;
650656
}
651657

652658
return status;
653659
err:
654660
if (rpu_ctx) {
655-
#ifdef CONFIG_NRF70_RADIO_TEST
656-
nrf_wifi_fmac_dev_rem_rt(rpu_ctx);
657-
#else
658661
nrf_wifi_fmac_dev_rem(rpu_ctx);
659-
#endif /* CONFIG_NRF70_RADIO_TEST */
660662
rpu_ctx_zep->rpu_ctx = NULL;
661663
}
662664
return status;
@@ -668,13 +670,13 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_rem_zep(struct nrf_wifi_drv_priv_zep *drv
668670

669671
rpu_ctx_zep = &drv_priv_zep->rpu_ctx_zep;
670672
#ifdef CONFIG_NRF70_RADIO_TEST
671-
nrf_wifi_fmac_dev_deinit_rt(rpu_ctx_zep->rpu_ctx);
672-
nrf_wifi_fmac_dev_rem_rt(rpu_ctx_zep->rpu_ctx);
673+
nrf_wifi_rt_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx);
673674
#else
674-
nrf_wifi_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx);
675-
nrf_wifi_fmac_dev_rem(rpu_ctx_zep->rpu_ctx);
675+
nrf_wifi_sys_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx);
676676
#endif /* CONFIG_NRF70_RADIO_TEST */
677677

678+
nrf_wifi_fmac_dev_rem(rpu_ctx_zep->rpu_ctx);
679+
678680
k_free(rpu_ctx_zep->extended_capa);
679681
rpu_ctx_zep->extended_capa = NULL;
680682
k_free(rpu_ctx_zep->extended_capa_mask);
@@ -760,9 +762,9 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
760762
*/
761763
nrf_wifi_osal_init(&nrf_wifi_os_zep_ops);
762764

763-
rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init(&data_config,
764-
rx_buf_pools,
765-
&callbk_fns);
765+
rpu_drv_priv_zep.fmac_priv = nrf_wifi_sys_fmac_init(&data_config,
766+
rx_buf_pools,
767+
&callbk_fns);
766768
#else /* !CONFIG_NRF70_RADIO_TEST */
767769
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
768770

@@ -771,7 +773,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
771773
*/
772774
nrf_wifi_osal_init(&nrf_wifi_os_zep_ops);
773775

774-
rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init_rt();
776+
rpu_drv_priv_zep.fmac_priv = nrf_wifi_rt_fmac_init();
775777
#endif /* CONFIG_NRF70_RADIO_TEST */
776778

777779
if (rpu_drv_priv_zep.fmac_priv == NULL) {
@@ -811,7 +813,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
811813
return 0;
812814
#ifdef CONFIG_NRF70_RADIO_TEST
813815
fmac_deinit:
814-
nrf_wifi_fmac_deinit_rt(rpu_drv_priv_zep.fmac_priv);
816+
nrf_wifi_fmac_deinit(rpu_drv_priv_zep.fmac_priv);
815817
nrf_wifi_osal_deinit();
816818
#endif /* CONFIG_NRF70_RADIO_TEST */
817819
err:

0 commit comments

Comments
 (0)