Skip to content

Commit c4b08c2

Browse files
sachinthegreennordicjm
authored andcommitted
drivers: wifi: nrf71: Restructure driver sources by operating mode
Reorganize the nRF71 Wi-Fi driver layout to separate system, radio test, and offloaded raw TX modes into dedicated source and header trees. Move fmac_main into system/main, consolidate offloaded raw TX into src/offload_raw_tx/api.c, and add shared rf_params and vtf helpers under src/common. Remove the legacy off_raw_tx subtree, debug shell, and the public nrf71_radio_test.h header in favor of in-tree radio_test APIs. Update dependent samples to use the new include paths. Signed-off-by: Sachin D Kulkarni <Sachin.Kulkarni@nordicsemi.no>
1 parent b5361d0 commit c4b08c2

41 files changed

Lines changed: 1196 additions & 1882 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/wifi/nrf71/CMakeLists.txt

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function(nrf71_wifi_setup_include_and_sources)
4848
${nrf71_bus_dir}/device.c
4949
${nrf71_bus_dir}/ipc_if.c
5050
${nrf71_bus_dir}/ipc_service.c
51+
src/common/rf_params.c
52+
src/common/vtf.c
5153
)
5254

5355
if(CONFIG_NRF71_RADIO_TEST)
@@ -56,6 +58,8 @@ function(nrf71_wifi_setup_include_and_sources)
5658
${nrf71_osal_base}/fw_if/umac_if/src/radio_test/fmac_cmd.c
5759
${nrf71_osal_base}/fw_if/umac_if/src/radio_test/fmac_event.c
5860
${nrf71_osal_base}/hw_if/hal/src/radio_test/hal_api.c
61+
src/radio_test/main.c
62+
src/radio_test/api.c
5963
)
6064

6165
zephyr_library_include_directories(
@@ -82,6 +86,7 @@ function(nrf71_wifi_setup_include_and_sources)
8286
${nrf71_osal_base}/fw_if/umac_if/src/offload_raw_tx/fmac_cmd.c
8387
${nrf71_osal_base}/fw_if/umac_if/src/offload_raw_tx/fmac_event.c
8488
${nrf71_osal_base}/hw_if/hal/src/offload_raw_tx/hal_api.c
89+
src/offload_raw_tx/api.c
8590
)
8691
endif()
8792

@@ -205,54 +210,39 @@ function(nrf71_wifi_setup_include_and_sources)
205210

206211
zephyr_library_compile_definitions(NRF_WIFI_RX_BUFF_PROG_UMAC)
207212

208-
zephyr_library_include_directories_ifdef(CONFIG_NRF71_OFFLOADED_RAW_TX
209-
off_raw_tx/inc
210-
)
211213

212214

213215
# ---- Sources: driver (Zephyr shim, net_if, mgmt, wpa, etc.) ----
214216

215217
# Coexistence transport used by the standalone nRF71 SR coexistence driver
216218
# (drivers/nrf71_sr_coex) to reach the Coexistence Manager over FMAC.
217219
zephyr_library_sources_ifdef(CONFIG_NRF71_SR_COEX_DRIVER
218-
src/coex_transport.c
220+
src/system/coex_transport.c
219221
)
220222

221-
zephyr_library_sources_ifndef(CONFIG_NRF71_OFFLOADED_RAW_TX
222-
src/fmac_main.c
223+
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT
224+
src/system/wifi_mgmt_scan.c
223225
)
224226

225-
if(NOT CONFIG_NRF71_RADIO_TEST AND NOT CONFIG_NRF71_OFFLOADED_RAW_TX)
226-
zephyr_library_sources(src/net_if.c)
227+
if(CONFIG_NRF71_SYSTEM_MODE OR CONFIG_NRF71_SCAN_ONLY)
228+
zephyr_library_sources(
229+
src/system/main.c
230+
src/system/net_if.c
231+
)
227232
endif()
228233

229-
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT
230-
src/wifi_mgmt_scan.c
231-
)
232-
233234
zephyr_library_sources_ifdef(CONFIG_NRF71_SYSTEM_MODE
234-
src/wifi_mgmt.c
235-
)
236-
237-
zephyr_library_sources_ifdef(CONFIG_NRF71_OFFLOADED_RAW_TX
238-
off_raw_tx/src/off_raw_tx_api.c
235+
src/system/wifi_mgmt.c
239236
)
240237

241238
zephyr_library_sources_ifdef(CONFIG_NRF71_STA_MODE
242-
src/wpa_supp_if.c
243-
src/wifi_mgmt.c
239+
src/system/wpa_supp_if.c
240+
src/system/wifi_mgmt.c
244241
)
245242

246243
zephyr_library_sources_ifdef(CONFIG_NRF71_UTIL
247-
src/wifi_util.c
248-
)
249-
250-
if(CONFIG_NRF71_UTIL OR CONFIG_NRF71_DEBUG_SHELL)
251-
zephyr_library_sources(src/shell.c)
252-
endif()
253-
254-
zephyr_library_sources_ifdef(CONFIG_NRF71_DEBUG_SHELL
255-
src/debug_shell.c
244+
src/common/shell.c
245+
src/common/util_shell.c
256246
)
257247
endfunction()
258248

drivers/wifi/nrf71/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ config NRF71_UTIL
212212
bool "Utility shell in nRF71 driver"
213213
depends on SHELL
214214

215-
config NRF71_DEBUG_SHELL
216-
bool "Debug shell in nRF71 driver"
217-
depends on SHELL
218-
219215
config NRF71_PCB_LOSS_2G
220216
int "PCB loss for 2.4 GHz band"
221217
default 0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Header containing RF parameters specific declarations
9+
*/
10+
11+
#ifndef __RF_PARAMS_H__
12+
#define __RF_PARAMS_H__
13+
14+
#include <stdint.h>
15+
16+
#define NUM_RF_PARAM_ADDRS 22
17+
18+
struct rf_hex_param {
19+
const char *hex_str;
20+
uint8_t *bytes;
21+
int bytes_len;
22+
};
23+
24+
/**
25+
* @brief Configure RF parameters in the RPU.
26+
*
27+
* @param dev_ctx Pointer to the FMAC device context.
28+
* @param rf_params_addr Array of RF parameter buffer addresses (NUM_RF_PARAM_ADDRS entries).
29+
*
30+
* @retval NRF_WIFI_STATUS_SUCCESS On success.
31+
* @retval NRF_WIFI_STATUS_FAIL On failure.
32+
*/
33+
enum nrf_wifi_status nrf_wifi_fmac_config_rf_params(void *dev_ctx,
34+
unsigned int *rf_params_addr);
35+
36+
#endif /* __RF_PARAMS_H__ */
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Header containing VTF parameters specific declarations
9+
*/
10+
11+
#ifndef __VTF_H__
12+
#define __VTF_H__
13+
14+
#include <common/fmac_structs_common.h>
15+
16+
/**
17+
* @brief Configure VTF parameters in the RPU.
18+
*
19+
* @param dev_ctx Pointer to the FMAC device context.
20+
* @param voltage Voltage reading used for VTF configuration.
21+
* @param temp Temperature reading used for VTF configuration.
22+
* @param x0 X0 frequency value used for VTF configuration.
23+
* @param vtf_buffer_start_address Output pointer to the allocated VTF parameter buffer.
24+
*
25+
* @retval NRF_WIFI_STATUS_SUCCESS On success.
26+
* @retval NRF_WIFI_STATUS_FAIL On failure.
27+
*/
28+
enum nrf_wifi_status nrf_wifi_fmac_config_vtf_params(struct nrf_wifi_fmac_dev_ctx *dev_ctx,
29+
unsigned int voltage,
30+
unsigned int temp,
31+
unsigned int x0,
32+
unsigned int *vtf_buffer_start_address);
33+
#endif /* __VTF_H__ */
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef __OFF_RAW_TX_API_H__
8+
#define __OFF_RAW_TX_API_H__
9+
10+
/**
11+
* @brief Header containing offloaded raw TX mode specific API declarations
12+
*/
13+
14+
#include <zephyr/kernel.h>
15+
#include <nrf71_wifi_ctrl.h>
16+
#include <common/rf_params.h>
17+
#include <common/vtf.h>
18+
19+
/* Minimum frame size for raw packet transmission */
20+
#define NRF_WIFI_OFF_RAW_TX_FRAME_SIZE_MIN 26
21+
/* Maximum frame size for raw packet transmission */
22+
#define NRF_WIFI_OFF_RAW_TX_FRAME_SIZE_MAX 600
23+
/* Maximum length of country code*/
24+
#define NRF_WIFI_COUNTRY_CODE_LEN 2
25+
26+
struct nrf_wifi_off_raw_tx_drv_ctx {
27+
void *drv_priv;
28+
void *rpu_ctx;
29+
uint8_t mac_addr[6];
30+
unsigned int phy_rf_params_addr[NUM_RF_PARAM_ADDRS];
31+
unsigned int vtf_buffer_start_address;
32+
};
33+
34+
35+
struct nrf_wifi_off_raw_tx_drv_priv {
36+
struct nrf_wifi_fmac_priv *fmac_priv;
37+
struct nrf_wifi_off_raw_tx_drv_ctx drv_ctx;
38+
struct k_spinlock lock;
39+
};
40+
41+
extern struct nrf_wifi_off_raw_tx_drv_priv off_raw_tx_drv_priv;
42+
#endif /* __OFF_RAW_TX_API_H__ */
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Header containing radio test API declarations
9+
*/
10+
11+
#ifndef __RADIO_TEST_API_H__
12+
#define __RADIO_TEST_API_H__
13+
14+
#include <zephyr/kernel.h>
15+
#include <nrf71_wifi_ctrl.h>
16+
#include <common/rf_params.h>
17+
#include <radio_test/fmac_api.h>
18+
#include <common/vtf.h>
19+
20+
struct nrf_wifi_rt_drv_ctx {
21+
void *drv_priv;
22+
void *rpu_ctx;
23+
struct rpu_conf_params conf_params;
24+
bool rf_test_run;
25+
unsigned char rf_test;
26+
struct k_mutex rpu_lock;
27+
unsigned int phy_rf_params_addr[NUM_RF_PARAM_ADDRS];
28+
unsigned int vtf_buffer_start_address;
29+
};
30+
31+
struct nrf_wifi_rt_drv_priv {
32+
struct nrf_wifi_fmac_priv *fmac_priv;
33+
struct nrf_wifi_rt_drv_ctx drv_ctx;
34+
};
35+
36+
37+
enum nrf_wifi_status nrf_wifi_rt_fmac_dev_rem(struct nrf_wifi_rt_drv_priv *drv_priv);
38+
39+
#endif /* __RADIO_TEST_API_H__ */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Header containing radio test main specific declarations
9+
*/
10+
11+
#ifndef __RADIO_TEST_MAIN_H__
12+
#define __RADIO_TEST_MAIN_H__
13+
14+
#include <radio_test/api.h>
15+
16+
extern struct nrf_wifi_rt_drv_priv rt_drv_priv;
17+
18+
#endif /* __RADIO_TEST_MAIN_H__ */
Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,41 @@
55
*/
66

77
/**
8-
* @brief Header containing FMAC interface specific declarations for the
9-
* Zephyr OS layer of the Wi-Fi driver.
8+
* @brief Header containing system mode specific declarations
109
*/
1110

12-
#ifndef __ZEPHYR_FMAC_MAIN_H__
13-
#define __ZEPHYR_FMAC_MAIN_H__
11+
#ifndef __SYSTEM_MAIN_H__
12+
#define __SYSTEM_MAIN_H__
1413

1514
#include <stdio.h>
1615

1716
#include <version.h>
1817

1918
#include <zephyr/kernel.h>
2019
#include <zephyr/net/net_if.h>
21-
#ifdef CONFIG_NRF71_RADIO_TEST
22-
#include <nrf71_radio_test.h>
23-
#else
2420
#include <zephyr/net/wifi_mgmt.h>
2521
#include <zephyr/net/ethernet.h>
22+
2623
#ifdef CONFIG_NETWORKING
27-
#include <net_if.h>
24+
#include <system/net_if.h>
2825
#endif /* CONFIG_NETWORKING */
26+
2927
#ifdef CONFIG_NRF71_STA_MODE
3028
#include <drivers/driver_zephyr.h>
3129
#endif /* CONFIG_NRF71_STA_MODE */
30+
3231
#include <system/fmac_api.h>
33-
#endif /* CONFIG_NRF71_RADIO_TEST */
3432
#include <nrf71_wifi_ctrl.h>
33+
#include <common/rf_params.h>
34+
#include <common/vtf.h>
3535

3636
#define NRF71_DRIVER_VERSION "1."KERNEL_VERSION_STRING
3737

38-
#define NUM_RF_PARAM_ADDRS 22
39-
4038
/* Calculate compile-time maximum for vendor stats */
4139
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
4240
#define MAX_VENDOR_STATS ((sizeof(struct rpu_sys_fw_stats) / sizeof(uint32_t)) + 1)
4341
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
4442

45-
#ifndef CONFIG_NRF71_OFFLOADED_RAW_TX
46-
#ifndef CONFIG_NRF71_RADIO_TEST
4743
struct nrf_wifi_vif_ctx_zep {
4844
const struct device *zep_dev_ctx;
4945
struct net_if *zep_net_if_ctx;
@@ -155,40 +151,17 @@ struct nrf_wifi_ctx_zep {
155151

156152
struct nrf_wifi_drv_priv_zep {
157153
struct nrf_wifi_fmac_priv *fmac_priv;
158-
/* TODO: Replace with a linked list to handle unlimited RPUs */
159154
struct nrf_wifi_ctx_zep rpu_ctx_zep;
160155
};
161156

162157
extern struct nrf_wifi_drv_priv_zep rpu_drv_priv_zep;
163-
#endif /* !CONFIG_NRF71_RADIO_TEST */
164-
165-
void nrf_wifi_scan_timeout_work(struct k_work *work);
166-
167-
void configure_tx_pwr_settings(struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params,
168-
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params);
169-
void configure_board_dep_params(struct nrf_wifi_board_params *board_params);
170-
void set_tx_pwr_ceil_default(struct nrf_wifi_tx_pwr_ceil_params *pwr_ceil_params);
171-
const char *nrf_wifi_get_drv_version(void);
172-
char *nrf_wifi_sprint_ll_addr_buf(const uint8_t *ll, uint8_t ll_len,
173-
char *buf, int buflen);
174-
enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep);
175-
enum nrf_wifi_status nrf_wifi_fmac_dev_rem_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep);
176-
struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx(struct net_if *iface);
158+
177159
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY
178160
void nrf_wifi_rpu_recovery_cb(void *vif_ctx,
179161
void *event_data,
180162
unsigned int event_len);
181163
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
182-
#if defined(CONFIG_NRF71_RAW_DATA_TX) || defined(CONFIG_NRF71_RAW_DATA_RX)
183-
unsigned char get_nrf_wifi_op_band(void);
184-
#endif
185-
#endif /* !CONFIG_NRF71_OFFLOADED_RAW_TX */
186-
enum nrf_wifi_status nrf_wifi_fmac_config_rf_params(void *dev_ctx,
187-
unsigned int *rf_params_addr);
188-
189-
enum nrf_wifi_status nrf_wifi_fmac_config_vtf_params(struct nrf_wifi_fmac_dev_ctx *dev_ctx,
190-
unsigned int voltage,
191-
unsigned int temp,
192-
unsigned int x0,
193-
unsigned int *vtf_buffer_start_address);
194-
#endif /* __ZEPHYR_FMAC_MAIN_H__ */
164+
165+
enum nrf_wifi_status nrf_wifi_sys_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep);
166+
enum nrf_wifi_status nrf_wifi_sys_fmac_dev_rem_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep);
167+
#endif /* __SYSTEM_MAIN_H__ */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <zephyr/device.h>
1717
#include <zephyr/net/wifi_mgmt.h>
1818

19-
#include "osal_api.h"
19+
#include <osal_api.h>
2020

2121
/** Filter setting defines for sniffer mode. */
2222
#define WIFI_MGMT_DATA_CTRL_FILTER_SETTING 0xE

0 commit comments

Comments
 (0)