Skip to content
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

nrf_wifi: Add as a standlone library #1414

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ add_subdirectory_ifdef(CONFIG_GZLL gzll)
add_subdirectory_ifdef(CONFIG_NRF_DM nrf_dm)
add_subdirectory_ifdef(CONFIG_NRF_FUEL_GAUGE nrf_fuel_gauge)
add_subdirectory_ifdef(CONFIG_SW_CODEC_LC3_T2_SOFTWARE lc3)
add_subdirectory_ifdef(CONFIG_NRF_WIFI nrf_wifi)
1 change: 1 addition & 0 deletions Kconfig.nrfxlib
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ rsource "gzll/Kconfig"
rsource "nrf_dm/Kconfig"
rsource "lc3/Kconfig"
rsource "nrf_fuel_gauge/Kconfig"
rsource "nrf_wifi/Kconfig"

endmenu
175 changes: 175 additions & 0 deletions nrf_wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: BSD-3-Clause
#

# Enable debug info by default
# Set the CPU architecture to armv8-m.main (Cortex-M33), default is armv4t
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -mcpu=cortex-m33 -mthumb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -mcpu=cortex-m33 -mthumb")

add_library(nrf-wifi STATIC)

set(NRF_WIFI_DIR ${CMAKE_CURRENT_SOURCE_DIR})

target_include_directories(
nrf-wifi
PUBLIC
${NRF_WIFI_DIR}/utils/inc
${NRF_WIFI_DIR}/os_if/inc
${NRF_WIFI_DIR}/bus_if/bus/qspi/inc
${NRF_WIFI_DIR}/bus_if/bal/inc
${NRF_WIFI_DIR}/fw_if/umac_if/inc
${NRF_WIFI_DIR}/fw_load/mips/fw/inc
${NRF_WIFI_DIR}/hw_if/hal/inc
${NRF_WIFI_DIR}/hw_if/hal/inc/fw
${NRF_WIFI_DIR}/fw_if/umac_if/inc/fw
)

target_include_directories_ifdef(CONFIG_NRF70_RADIO_TEST
nrf-wifi
PUBLIC
${NRF_WIFI_DIR}/fw_if/umac_if/inc/radio_test
)

target_include_directories_ifndef(CONFIG_NRF70_RADIO_TEST
nrf-wifi
PUBLIC
${NRF_WIFI_DIR}/fw_if/umac_if/inc/default
)

target_sources(
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/os_if/src/osal.c
${NRF_WIFI_DIR}/utils/src/list.c
${NRF_WIFI_DIR}/utils/src/queue.c
${NRF_WIFI_DIR}/utils/src/util.c
${NRF_WIFI_DIR}/hw_if/hal/src/hal_api.c
${NRF_WIFI_DIR}/hw_if/hal/src/hal_fw_patch_loader.c
${NRF_WIFI_DIR}/hw_if/hal/src/hal_interrupt.c
${NRF_WIFI_DIR}/hw_if/hal/src/hal_mem.c
${NRF_WIFI_DIR}/hw_if/hal/src/hal_reg.c
${NRF_WIFI_DIR}/hw_if/hal/src/hpqm.c
${NRF_WIFI_DIR}/hw_if/hal/src/pal.c
${NRF_WIFI_DIR}/bus_if/bal/src/bal.c
${NRF_WIFI_DIR}/bus_if/bus/qspi/src/qspi.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/cmd.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/event.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_api_common.c
)

target_sources_ifndef(CONFIG_NRF70_RADIO_TEST
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/rx.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_vif.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/default/fmac_api.c
)

target_sources_ifdef(CONFIG_NRF70_RADIO_TEST
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/radio_test/fmac_api.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
)

target_sources_ifdef(CONFIG_NRF700X_DATA_TX
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/tx.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
)

target_sources_ifdef(CONFIG_NRF700X_STA_MODE
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
)

target_sources_ifdef(CONFIG_NRF700X_AP_MODE
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_ap.c
)

# Without WPA supplicant we only support scan
target_sources_ifdef(CONFIG_NRF700X_STA_MODE
nrf-wifi
PRIVATE
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
)

target_compile_definitions_ifdef(CONFIG_NRF_WIFI_LOW_POWER
nrf-wifi
PRIVATE
-DCONFIG_NRF_WIFI_LOW_POWER
)

target_compile_definitions_ifdef(CONFIG_NRF70_RADIO_TEST
nrf-wifi
PRIVATE
-DCONFIG_NRF700X_RADIO_TEST
)

target_compile_definitions_ifdef(CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
nrf-wifi
PRIVATE
-DCONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
)

target_compile_definitions(
nrf-wifi
PRIVATE
-DCONFIG_NRF700X_LOG_VERBOSE=${CONFIG_NRF700X_LOG_VERBOSE}
-DCONFIG_NRF700X_SCAN_ONLY=y
-DCONFIG_WIFI_NRF700X_LOG_LEVEL=${CONFIG_WIFI_NRF700X_SHIM_LOG_LEVEL}
-DCONFIG_NRF700X_MAX_TX_TOKENS=10
-DCONFIG_NRF700X_MAX_TX_AGGREGATION=12
-DCONFIG_NRF700X_RX_NUM_BUFS=63
-DCONFIG_NRF700X_RX_MAX_DATA_SIZE=1600
-DCONFIG_NRF700X_ANT_GAIN_2G=0
-DCONFIG_NRF700X_ANT_GAIN_5G_BAND1=0
-DCONFIG_NRF700X_ANT_GAIN_5G_BAND2=0
-DCONFIG_NRF700X_ANT_GAIN_5G_BAND3=0
-DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_DSSS=0
-DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_DSSS=0
-DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT=0
-DCONFIG_NRF700X_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE=0
-DCONFIG_NRF700X_REG_DOMAIN=\"${CONFIG_NRF70_REG_DOMAIN}\"
-DCONFIG_NRF700X_TX_MAX_DATA_SIZE=1600
-DCONFIG_NRF_WIFI_IFACE_MTU=1500
-DCONFIG_NRF700X_MAX_TX_PENDING_QLEN=48
-DCONFIG_NRF700X_RPU_PS_IDLE_TIMEOUT_MS=10
-DCONFIG_NRF700X_PCB_LOSS_2G=0
-DCONFIG_NRF700X_PCB_LOSS_5G_BAND1=0
-DCONFIG_NRF700X_PCB_LOSS_5G_BAND2=0
-DCONFIG_NRF700X_PCB_LOSS_5G_BAND3=0
-DCONFIG_NRF_WIFI_AP_DEAD_DETECT_TIMEOUT=20
)
18 changes: 18 additions & 0 deletions nrf_wifi/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: BSD-3-Clause
#
menu "Nordic nRF70 Wi-Fi configuration"

config NRF_WIFI
bool "Enable nRF70 OS agnostic library"
help
Enable the nRF70 OS agnostic library.

config NRF70_RADIO_TEST
bool "Enable nRF70 radio test"
help
Enable the nRF70 radio test.

endmenu
12 changes: 7 additions & 5 deletions nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ struct nrf_wifi_fmac_callbk_fns {
signed short signal);
#endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */

#ifndef CONFIG_NRF700X_RADIO_TEST
/** Callback function to be called when a get regulatory response is received. */
void (*event_get_reg)(void *if_priv,
struct nrf_wifi_reg *get_reg,
unsigned int event_len);
#endif /* CONFIG_NRF700X_RADIO_TEST */

#if defined(CONFIG_NRF700X_STA_MODE) || defined(__DOXYGEN__)
/** Callback function to be called when an interface association state changes. */
enum nrf_wifi_status (*if_carr_state_chg_callbk_fn)(void *os_vif_ctx,
Expand Down Expand Up @@ -248,11 +255,6 @@ struct nrf_wifi_fmac_callbk_fns {
struct nrf_wifi_umac_event_twt_sleep *twt_sleep_event_info,
unsigned int event_len);

/** Callback function to be called when a get regulatory response is received. */
void (*event_get_reg)(void *if_priv,
struct nrf_wifi_reg *get_reg,
unsigned int event_len);

/** Callback function to be called when a get power save information
* response is received.
*/
Expand Down
2 changes: 2 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ enum nrf_wifi_status umac_cmd_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
#endif /* CONFIG_NRF700X_TCP_IP_CHECKSUM_OFFLOAD */
umac_cmd_data->discon_timeout = CONFIG_NRF_WIFI_AP_DEAD_DETECT_TIMEOUT;

umac_cmd_data->mgmt_buff_offload = 1;

nrf_wifi_osal_log_dbg(fmac_dev_ctx->fpriv->opriv, "RPU LPM type: %s",
umac_cmd_data->sys_params.sleep_enable == 2 ? "HW" :
umac_cmd_data->sys_params.sleep_enable == 1 ? "SW" : "DISABLED");
Expand Down
10 changes: 4 additions & 6 deletions nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx

switch (umac_hdr->cmd_evnt) {
case NRF_WIFI_UMAC_EVENT_GET_REG:
#ifdef CONFIG_NRF700X_STA_MODE
#ifndef CONFIG_NRF700X_RADIO_TEST
if (callbk_fns->event_get_reg)
callbk_fns->event_get_reg(vif_ctx->os_vif_ctx,
event_data,
Expand All @@ -211,8 +211,7 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
"%s: No callback registered for event %d",
__func__,
umac_hdr->cmd_evnt);
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_RADIO_TEST
#else
get_reg_event = (struct nrf_wifi_reg *)event_data;

nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
Expand All @@ -223,7 +222,7 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
#endif /* CONFIG_NRF700X_RADIO_TEST */
break;
case NRF_WIFI_UMAC_EVENT_REG_CHANGE:
#ifdef CONFIG_NRF700X_STA_MODE
#ifndef CONFIG_NRF700X_RADIO_TEST
if (callbk_fns->reg_change_callbk_fn)
callbk_fns->reg_change_callbk_fn(vif_ctx->os_vif_ctx,
event_data,
Expand All @@ -233,8 +232,7 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
"%s: No callback registered for event %d",
__func__,
umac_hdr->cmd_evnt);
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_RADIO_TEST
#else
reg_change_event = (struct nrf_wifi_event_regulatory_change *)event_data;

fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_zalloc(fmac_dev_ctx->fpriv->opriv,
Expand Down
2 changes: 1 addition & 1 deletion nrf_wifi/fw_if/umac_if/src/fmac_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ enum nrf_wifi_status nrf_wifi_fmac_set_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de

if (!fmac_dev_ctx->reg_set_status) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Failed to set regulatory information",
"%s: Failed to set regulatory information: timedout",
__func__);
status = NRF_WIFI_STATUS_FAIL;
goto out;
Expand Down
7 changes: 7 additions & 0 deletions nrf_wifi/hw_if/hal/inc/fw/pack_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
#include <zephyr/toolchain.h>
#elif __KERNEL__
#include <linux/compiler_attributes.h>
#else
#ifndef __packed
#define __packed __attribute__((packed))
#endif
#ifndef __aligned
#define __aligned(x) __attribute__((aligned(x)))
#endif
#endif

#define __NRF_WIFI_PKD __packed
Expand Down
5 changes: 5 additions & 0 deletions nrf_wifi/hw_if/hal/src/hal_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ static enum nrf_wifi_status hal_rpu_process_wdog(struct nrf_wifi_hal_dev_ctx *ha
unsigned long flags = 0;
#endif

/* NCS 2.7.0 doesn't have proper recovery mechanism for RPU, so
* ignore the watchdog interrupt.
*/
return 0;

nrf_wifi_osal_log_dbg(hal_dev_ctx->hpriv->opriv,
"Processing watchdog interrupt");

Expand Down
11 changes: 11 additions & 0 deletions nrf_wifi/os_if/inc/osal_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1609,4 +1609,15 @@ int nrf_wifi_osal_mem_cmp(struct nrf_wifi_osal_priv *opriv,
const void *addr1,
const void *addr2,
size_t count);

/**
* nrf_wifi_osal_rand8_get() - Get a random 8 bit number.
* @opriv: Pointer to the OSAL context returned by the @nrf_wifi_osal_init API.
*
* Generates an 8 bit random number.
*
* Return:
* returns an 8 bit random number.
*/
unsigned char nrf_wifi_osal_rand8_get(struct nrf_wifi_osal_priv *opriv);
#endif /* __OSAL_API_H__ */
1 change: 1 addition & 0 deletions nrf_wifi/os_if/inc/osal_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ struct nrf_wifi_osal_ops {
char *assert_msg);

unsigned int (*strlen)(const void *str);
unsigned char (*rand8_get)(void);
};


Expand Down
4 changes: 4 additions & 0 deletions nrf_wifi/os_if/inc/osal_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/stdarg.h>
#else
#include <stddef.h>
#include <stdbool.h>
#include <stdarg.h>
#endif

/**
Expand Down
5 changes: 5 additions & 0 deletions nrf_wifi/os_if/src/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,3 +922,8 @@ unsigned int nrf_wifi_osal_strlen(struct nrf_wifi_osal_priv *opriv,
{
return opriv->ops->strlen(str);
}

unsigned char nrf_wifi_osal_rand8_get(struct nrf_wifi_osal_priv *opriv)
{
return opriv->ops->rand8_get();
}
Loading