Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions drivers/wifi/nrf_wifi/Kconfig.nrfwifi
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ config NRF70_AP_MODE
depends on WIFI_NM_WPA_SUPPLICANT_AP
default y if WIFI_USAGE_MODE_AP || WIFI_USAGE_MODE_STA_AP

config NRF70_ENABLE_DUAL_VIF
bool "Dual virtual Wi-Fi interfaces"
default y if WIFI_NM_MAX_MANAGED_INTERFACES = 2
depends on (WIFI_NRF7002 || WIFI_NRF7001) && NET_L2_ETHERNET
help
Enable support for two virtual Wi-Fi interfaces (VIFs).
When enabled, the driver can operate two VIFs simultaneously,
allowing use cases such as one interface in AP mode and another in STA mode.

config NRF70_P2P_MODE
bool "P2P support in driver"

Expand Down Expand Up @@ -165,6 +174,7 @@ config NRF_WIFI_LOW_POWER

config NRF70_TCP_IP_CHECKSUM_OFFLOAD
bool "TCP/IP checksum offload"
depends on !NRF71_ON_IPC
default y

config NRF70_REG_DOMAIN
Expand Down Expand Up @@ -655,28 +665,27 @@ config WIFI_NRF70_SCAN_TIMEOUT_S
int "Scan timeout in seconds"
default 30

menu "nRF Wi-Fi operation band(s)"
visible if !NRF70_2_4G_ONLY
choice NRF_WIFI_OP_BAND
prompt "nRF Wi-Fi operation bands"
default NRF_WIFI_2G_BAND if NRF70_2_4G_ONLY
default NRF_WIFI_ALL_BAND

config NRF_WIFI_ALL_BAND
bool "Set operation band to all supported bands"

config NRF_WIFI_2G_BAND
bool "Set operation band to 2.4GHz"
default y if NRF70_2_4G_ONLY

config NRF_WIFI_5G_BAND
bool "Set operation band to 5GHz"
depends on !NRF70_2_4G_ONLY

config NRF_WIFI_OP_BAND
int "Options to set operation band"
default 1 if NRF_WIFI_2G_BAND
default 2 if NRF_WIFI_5G_BAND
default 3
help
Set this option to select frequency band
1 - 2.4GHz
2 - 5GHz
3 - All ( 2.4GHz and 5GHz )
endmenu
if NRF71_ON_IPC
config NRF_WIFI_6G_BAND
bool "Set operation band to 6GHz"

config NRF_WIFI_DUAL_BAND
bool "Set operation band to 2.4GHz and 5GHz"
endif # NRF71_ON_IPC
endchoice

config NRF_WIFI_IFACE_MTU
int "MTU for Wi-Fi interface"
Expand Down
14 changes: 13 additions & 1 deletion drivers/wifi/nrf_wifi/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@
#else
#include <radio_test/fmac_api.h>
#endif /* !CONFIG_NRF70_RADIO_TEST */

#ifdef CONFIG_NRF71_ON_IPC
#include <nrf71_wifi_ctrl.h>
#else
#include <host_rpu_umac_if.h>
#endif /* CONFIG_NRF71_ON_IPC */

#define NRF70_DRIVER_VERSION "1."KERNEL_VERSION_STRING

/* Calculate compile-time maximum for vendor stats */
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
#define MAX_VENDOR_STATS ((sizeof(struct rpu_sys_fw_stats) / sizeof(uint32_t)) + 1)
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */

#ifndef CONFIG_NRF70_OFFLOADED_RAW_TX
#ifndef CONFIG_NRF70_RADIO_TEST
struct nrf_wifi_vif_ctx_zep {
Expand All @@ -61,6 +69,10 @@ struct nrf_wifi_vif_ctx_zep {
bool set_if_event_received;
int set_if_status;
#ifdef CONFIG_NET_STATISTICS_ETHERNET
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
struct net_stats_eth_vendor eth_stats_vendor_data[MAX_VENDOR_STATS];
char vendor_key_strings[MAX_VENDOR_STATS][16];
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
struct net_stats_eth eth_stats;
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
#if defined(CONFIG_NRF70_STA_MODE) || defined(CONFIG_NRF70_RAW_DATA_RX)
Expand Down
22 changes: 21 additions & 1 deletion drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,25 @@
}
#endif /* CONFIG_WIFI_FIXED_MAC_ADDRESS_ENABLED */

static enum op_band get_nrf_wifi_op_band(void)
{
if (IS_ENABLED(CONFIG_NRF_WIFI_2G_BAND)) {
return BAND_24G;
}
#ifdef CONFIG_NRF71_ON_IPC
if (IS_ENABLED(CONFIG_NRF_WIFI_5G_BAND)) {
return BAND_5G;
}
if (IS_ENABLED(CONFIG_NRF_WIFI_6G_BAND)) {
return BAND_6G;
}
if (IS_ENABLED(CONFIG_NRF_WIFI_DUAL_BAND)) {
return BAND_DUAL;
}
#endif /* CONFIG_NRF71_ON_IPC */
return BAND_ALL;
}

int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
Expand All @@ -138,6 +157,7 @@
struct nrf_wifi_board_params board_params;
unsigned int fw_ver = 0;
k_spinlock_key_t key;
enum op_band op_band = get_nrf_wifi_op_band();

/* The OSAL layer needs to be initialized before any other initialization
* so that other layers (like FW IF,HW IF etc) have access to OS ops
Expand Down Expand Up @@ -202,13 +222,13 @@
HW_SLEEP_ENABLE,
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
NRF_WIFI_DEF_PHY_CALIB,
CONFIG_NRF_WIFI_OP_BAND,
op_band,
IS_ENABLED(CONFIG_NRF_WIFI_BEAMFORMING),
&ctrl_params,
&ceil_params,
&board_params,
country_code);
if (status != NRF_WIFI_STATUS_SUCCESS) {

Check notice on line 231 in drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c:231 - status = nrf_wifi_off_raw_tx_fmac_dev_init(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_off_raw_tx_fmac_dev_init( + rpu_ctx_zep->rpu_ctx, #ifdef CONFIG_NRF_WIFI_LOW_POWER - HW_SLEEP_ENABLE, + HW_SLEEP_ENABLE, #endif /* CONFIG_NRF_WIFI_LOW_POWER */ - NRF_WIFI_DEF_PHY_CALIB, - op_band, - IS_ENABLED(CONFIG_NRF_WIFI_BEAMFORMING), - &ctrl_params, - &ceil_params, - &board_params, - country_code); + NRF_WIFI_DEF_PHY_CALIB, op_band, IS_ENABLED(CONFIG_NRF_WIFI_BEAMFORMING), + &ctrl_params, &ceil_params, &board_params, country_code);
LOG_ERR("%s: nRF70 firmware initialization failed", __func__);
goto err;
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/wifi/nrf_wifi/src/debug_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*/
#include <stdlib.h>
#include <zephyr/shell/shell.h>
#ifdef NRF71_ON_IPC
#include <nrf71_wifi_ctrl.h>
#else
#include "host_rpu_umac_if.h"
#endif
#include "fmac_main.h"

extern struct nrf_wifi_drv_priv_zep rpu_drv_priv_zep;
Expand Down
84 changes: 68 additions & 16 deletions drivers/wifi/nrf_wifi/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
"Max TX aggregation is 15");
BUILD_ASSERT(CONFIG_NRF70_RX_NUM_BUFS >= 1,
"At least one RX buffer is required");
#ifndef CONFIG_NRF71_ON_IPC
BUILD_ASSERT(RPU_PKTRAM_SIZE - TOTAL_RX_SIZE >= TOTAL_TX_SIZE,
"Packet RAM overflow: not enough memory for TX");

#endif /* CONFIG_NRF71_ON_IPC */
BUILD_ASSERT(CONFIG_NRF70_TX_MAX_DATA_SIZE >= MAX_TX_FRAME_SIZE,
"TX buffer size must be at least as big as the MTU and headroom");

Expand Down Expand Up @@ -503,12 +504,9 @@
}
#endif /* !CONFIG_NRF70_RADIO_TEST */

#ifdef CONFIG_NRF71_ON_IPC
#define MAX_TX_PWR(label) DT_PROP(DT_NODELABEL(wifi), label) * 4
#else
#ifndef CONFIG_NRF71_ON_IPC
/* DTS uses 1dBm as the unit for TX power, while the RPU uses 0.25dBm */
#define MAX_TX_PWR(label) DT_PROP(DT_NODELABEL(nrf70), label) * 4
#endif /* CONFIG_NRF71_ON_IPC */

void configure_tx_pwr_settings(struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params)
Expand Down Expand Up @@ -587,13 +585,34 @@
board_params->pcb_loss_5g_band3 = CONFIG_NRF70_PCB_LOSS_5G_BAND3;
#endif /* CONFIG_NRF70_2_4G_ONLY */
}
#endif /* CONFIG_NRF71_ON_IPC */

static enum op_band get_nrf_wifi_op_band(void)
{
if (IS_ENABLED(CONFIG_NRF_WIFI_2G_BAND)) {
return BAND_24G;
}
#ifdef CONFIG_NRF71_ON_IPC
if (IS_ENABLED(CONFIG_NRF_WIFI_5G_BAND)) {
return BAND_5G;
}

if (IS_ENABLED(CONFIG_NRF_WIFI_6G_BAND)) {
return BAND_6G;
}
if (IS_ENABLED(CONFIG_NRF_WIFI_DUAL_BAND)) {
return BAND_DUAL;
}
#endif /* CONFIG_NRF71_ON_IPC */
return BAND_ALL;
}

enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
void *rpu_ctx = NULL;
enum op_band op_band = CONFIG_NRF_WIFI_OP_BAND;
enum op_band op_band = get_nrf_wifi_op_band();
#ifdef CONFIG_NRF_WIFI_LOW_POWER
int sleep_type = -1;

Expand All @@ -606,7 +625,6 @@
struct nrf_wifi_tx_pwr_ctrl_params tx_pwr_ctrl_params;
struct nrf_wifi_tx_pwr_ceil_params tx_pwr_ceil_params;
struct nrf_wifi_board_params board_params;

unsigned int fw_ver = 0;

#if defined(CONFIG_NRF70_SR_COEX_SLEEP_CTRL_GPIO_CTRL) && \
Expand Down Expand Up @@ -654,10 +672,12 @@
NRF_WIFI_UMAC_VER_MIN(fw_ver),
NRF_WIFI_UMAC_VER_EXTRA(fw_ver));

#ifndef CONFIG_NRF71_ON_IPC
configure_tx_pwr_settings(&tx_pwr_ctrl_params,
&tx_pwr_ceil_params);

configure_board_dep_params(&board_params);
#endif /* CONFIG_NRF71_ON_IPC */

#if defined(CONFIG_NRF70_SR_COEX_SLEEP_CTRL_GPIO_CTRL) && \
defined(CONFIG_NRF70_SYSTEM_MODE)
Expand Down Expand Up @@ -743,8 +763,28 @@
struct nrf_wifi_data_config_params data_config = { 0 };
struct rx_buf_pool_params rx_buf_pools[MAX_NUM_OF_RX_QUEUES];
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = dev->data;
static unsigned char fixed_vif_cnt;

if (fixed_vif_cnt >= MAX_NUM_VIFS) {
LOG_ERR("%s: Max number of VIFs reached", __func__);
return -ENOMEM;
}

/* Setup the linkage between the FMAC and the VIF contexts */
vif_ctx_zep->rpu_ctx_zep = &rpu_drv_priv_zep.rpu_ctx_zep;
#ifndef CONFIG_NRF70_RADIO_TEST
k_work_init_delayable(&vif_ctx_zep->scan_timeout_work,
nrf_wifi_scan_timeout_work);
k_work_init(&vif_ctx_zep->disp_scan_res_work,
nrf_wifi_disp_scan_res_work_handler);

Check notice on line 780 in drivers/wifi/nrf_wifi/src/fmac_main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/fmac_main.c:780 - k_work_init_delayable(&vif_ctx_zep->scan_timeout_work, - nrf_wifi_scan_timeout_work); - k_work_init(&vif_ctx_zep->disp_scan_res_work, - nrf_wifi_disp_scan_res_work_handler); + k_work_init_delayable(&vif_ctx_zep->scan_timeout_work, nrf_wifi_scan_timeout_work); + k_work_init(&vif_ctx_zep->disp_scan_res_work, nrf_wifi_disp_scan_res_work_handler);
vif_ctx_zep->bss_max_idle_period = USHRT_MAX;
#endif /* !CONFIG_NRF70_RADIO_TEST */

if (fixed_vif_cnt++ > 0) {
/* FMAC is already initialized for VIF-0 */
return 0;
}

#ifdef CONFIG_NRF70_DATA_TX
data_config.aggregation = aggregation;
Expand Down Expand Up @@ -823,7 +863,6 @@

rpu_drv_priv_zep.fmac_priv = nrf_wifi_rt_fmac_init();
#endif /* CONFIG_NRF70_RADIO_TEST */

if (rpu_drv_priv_zep.fmac_priv == NULL) {
LOG_ERR("%s: nrf_wifi_fmac_init failed",
__func__);
Expand All @@ -834,9 +873,14 @@
struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL;

sys_fpriv = wifi_fmac_priv(rpu_drv_priv_zep.fmac_priv);
#ifdef CONFIG_NRF71_ON_IPC
/* TODO: Revisit this */
sys_fpriv->max_ampdu_len_per_token = 8192;
#else
sys_fpriv->max_ampdu_len_per_token =
(RPU_PKTRAM_SIZE - (CONFIG_NRF70_RX_NUM_BUFS * CONFIG_NRF70_RX_MAX_DATA_SIZE)) /
CONFIG_NRF70_MAX_TX_TOKENS;
#endif /* CONFIG_NRF71_ON_IPC */
/* Align to 4-byte */
sys_fpriv->max_ampdu_len_per_token &= ~0x3;

Expand All @@ -852,17 +896,10 @@
LOG_ERR("%s: nrf_wifi_fmac_dev_add_zep failed", __func__);
goto fmac_deinit;
}
#else
k_work_init_delayable(&vif_ctx_zep->scan_timeout_work,
nrf_wifi_scan_timeout_work);
k_work_init(&vif_ctx_zep->disp_scan_res_work,
nrf_wifi_disp_scan_res_work_handler);
#endif /* CONFIG_NRF70_RADIO_TEST */

k_mutex_init(&rpu_drv_priv_zep.rpu_ctx_zep.rpu_lock);
#ifndef CONFIG_NRF70_RADIO_TEST
vif_ctx_zep->bss_max_idle_period = USHRT_MAX;
#endif /* !CONFIG_NRF70_RADIO_TEST */

return 0;
#ifdef CONFIG_NRF70_RADIO_TEST
fmac_deinit:
Expand Down Expand Up @@ -979,7 +1016,22 @@
CONFIG_WIFI_INIT_PRIORITY, /* prio */
&wifi_offload_ops, /* api */
CONFIG_NRF_WIFI_IFACE_MTU); /*mtu */
#ifdef CONFIG_NRF70_ENABLE_DUAL_VIF
/* Register second interface */
ETH_NET_DEVICE_DT_INST_DEFINE(1,
nrf_wifi_drv_main_zep, /* init_fn */
NULL, /* pm_action_cb */
&rpu_drv_priv_zep.rpu_ctx_zep.vif_ctx_zep[1], /* data */
#ifdef CONFIG_NRF70_STA_MODE
&wpa_supp_ops, /* cfg */
#else /* CONFIG_NRF70_STA_MODE */
NULL, /* cfg */
#endif /* !CONFIG_NRF70_STA_MODE */
CONFIG_WIFI_INIT_PRIORITY, /* prio */
&wifi_offload_ops, /* api */
CONFIG_NRF_WIFI_IFACE_MTU); /*mtu */
#endif /* NRF70_ENABLE_DUAL_VIF */
#else

Check notice on line 1034 in drivers/wifi/nrf_wifi/src/fmac_main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/fmac_main.c:1034 -ETH_NET_DEVICE_DT_INST_DEFINE(1, - nrf_wifi_drv_main_zep, /* init_fn */ - NULL, /* pm_action_cb */ - &rpu_drv_priv_zep.rpu_ctx_zep.vif_ctx_zep[1], /* data */ -#ifdef CONFIG_NRF70_STA_MODE - &wpa_supp_ops, /* cfg */ -#else /* CONFIG_NRF70_STA_MODE */ - NULL, /* cfg */ -#endif /* !CONFIG_NRF70_STA_MODE */ - CONFIG_WIFI_INIT_PRIORITY, /* prio */ - &wifi_offload_ops, /* api */ - CONFIG_NRF_WIFI_IFACE_MTU); /*mtu */ -#endif /* NRF70_ENABLE_DUAL_VIF */ +ETH_NET_DEVICE_DT_INST_DEFINE(1, nrf_wifi_drv_main_zep, /* init_fn */ + NULL, /* pm_action_cb */ + &rpu_drv_priv_zep.rpu_ctx_zep.vif_ctx_zep[1], /* data */ +#ifdef CONFIG_NRF70_STA_MODE + &wpa_supp_ops, /* cfg */ +#else /* CONFIG_NRF70_STA_MODE */ + NULL, /* cfg */ +#endif /* !CONFIG_NRF70_STA_MODE */ + CONFIG_WIFI_INIT_PRIORITY, /* prio */ + &wifi_offload_ops, /* api */ + CONFIG_NRF_WIFI_IFACE_MTU); /*mtu */ +#endif /* NRF70_ENABLE_DUAL_VIF */
DEVICE_DT_INST_DEFINE(0,
nrf_wifi_drv_main_zep, /* init_fn */
NULL, /* pm_action_cb */
Expand Down
8 changes: 7 additions & 1 deletion drivers/wifi/nrf_wifi/src/fw_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);

#include <fmac_main.h>
#ifndef CONFIG_NRF71_ON_IPC
static const char fw_patch[] = {
#include <nrf70_fw_patch/nrf70.bin.inc>
};
#endif /* CONFIG_NRF71_ON_IPC */

enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;

#ifndef CONFIG_NRF71_ON_IPC
struct nrf_wifi_fmac_fw_info fw_info = { 0 };

status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_patch, sizeof(fw_patch), &fw_info);
if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: nrf_wifi_fmac_fw_parse failed", __func__);
return status;
}
#ifndef CONFIG_NRF71_ON_IPC

/* Load the FW patches to the RPU */
status = nrf_wifi_fmac_fw_load(rpu_ctx, &fw_info);

if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: nrf_wifi_fmac_fw_load failed", __func__);
}
#else
status = NRF_WIFI_STATUS_SUCCESS;
#endif /* !CONFIG_NRF71_ON_IPC */
return status;
}
Loading
Loading