diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi index 0c5307c4c8c..b0cb997de94 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi @@ -16,3 +16,6 @@ &lfxo { status = "okay"; }; + +/* Get a node label for wi-fi spi to use in shield files */ +wifi_spi: &spi130 {}; diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi b/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi index 33cfebb55d6..6a40af0ee95 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi @@ -98,3 +98,6 @@ pinctrl-1 = <&pwm20_sleep>; pinctrl-names = "default", "sleep"; }; + +/* Get a node label for wi-fi spi to use in shield files */ +wifi_spi: &spi22 {}; diff --git a/drivers/wifi/nrf_wifi/CMakeLists.txt b/drivers/wifi/nrf_wifi/CMakeLists.txt index 0df8d92c017..d44aa7b98c8 100644 --- a/drivers/wifi/nrf_wifi/CMakeLists.txt +++ b/drivers/wifi/nrf_wifi/CMakeLists.txt @@ -41,7 +41,7 @@ zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT src/wifi_mgmt_scan.c ) -zephyr_library_sources_ifdef(CONFIG_NRF70_SYSTEM_MODE_COMMON +zephyr_library_sources_ifdef(CONFIG_NRF70_SYSTEM_MODE src/wifi_mgmt.c ) @@ -62,6 +62,14 @@ zephyr_library_sources_ifdef(CONFIG_NRF70_UTIL src/wifi_util.c ) +if(CONFIG_NRF70_UTIL OR CONFIG_NRF70_DEBUG_SHELL) + zephyr_library_sources(src/shell.c) +endif() + +zephyr_library_sources_ifdef(CONFIG_NRF70_DEBUG_SHELL + src/debug_shell.c +) + zephyr_compile_definitions_ifdef(CONFIG_NRF70_ON_QSPI # These are XIP related anomalies and aren't applicable for nRF7002 and cause # throughput issues. @@ -73,19 +81,21 @@ zephyr_compile_definitions_ifdef(CONFIG_NRF70_ON_QSPI -DNRF53_ERRATA_159_ENABLE_WORKAROUND=0 ) -target_link_libraries(nrf_wifi PRIVATE nrf70-buslib) +zephyr_library_link_libraries(nrf70-buslib nrf-wifi-shim) if (CONFIG_NRF_WIFI_PATCHES_BUILTIN) zephyr_blobs_verify(MODULE nrf_wifi REQUIRED) # RPU FW patch binaries based on the selected configuration if(CONFIG_NRF70_SYSTEM_MODE) - set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin) + if (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES) + set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin) + else() + set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin) + endif() elseif(CONFIG_NRF70_RADIO_TEST) set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin) elseif(CONFIG_NRF70_SCAN_ONLY) set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin) - elseif (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES) - set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin) elseif(CONFIG_NRF70_OFFLOADED_RAW_TX) set(NRF70_PATCH ${FW_BINS_BASE}/offloaded_raw_tx/nrf70.bin) else() diff --git a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi index 126688d9a47..18e478456a1 100644 --- a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi +++ b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi @@ -40,67 +40,57 @@ config NRF70_QSPI_LOW_POWER choice NRF70_OPER_MODES bool "nRF70 operating modes" - default NRF70_SYSTEM_WITH_RAW_MODES if !WIFI_NRF7000 && \ - (NRF70_RAW_DATA_TX || NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX) default NRF70_SYSTEM_MODE if !WIFI_NRF7000 default NRF70_SCAN_ONLY if WIFI_NRF7000 help Select the operating mode of the nRF70 driver -config NRF70_SYSTEM_MODE - bool "nRF70 system mode" - depends on WIFI_NRF7002 || WIFI_NRF7001 - select WIFI_NM_WPA_SUPPLICANT - help - Select this option to enable system mode of the nRF70 driver - config NRF70_SCAN_ONLY bool "nRF70 scan only mode" help Select this option to enable scan only mode of the nRF70 driver +config NRF70_SYSTEM_MODE + bool "System mode of the nRF70 driver" + help + Select this option to enable system mode of the nRF70 driver + config NRF70_RADIO_TEST bool "Radio test mode of the nRF70 driver" config NRF70_OFFLOADED_RAW_TX bool "Offloaded raw TX mode of the nRF70 driver" -config NRF70_SYSTEM_WITH_RAW_MODES - bool "nRF70 system mode with raw modes" - depends on WIFI_NRF7002 || WIFI_NRF7001 - select WIFI_NM_WPA_SUPPLICANT - help - Select this option to enable system mode of the nRF70 driver with raw modes. endchoice -config NRF70_SYSTEM_MODE_COMMON - bool - default y if NRF70_SYSTEM_MODE || NRF70_SYSTEM_WITH_RAW_MODES - config NET_L2_ETHERNET default y if (!NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX) -config HEAP_MEM_POOL_ADD_SIZE_NRF70 - # Use a maximum that works for typical use cases and boards, each sample/app can override - # this value if needed by using CONFIG_HEAP_MEM_POOL_IGNORE_MIN - def_int 25000 if NRF70_SCAN_ONLY - def_int 150000 - -if NRF70_SYSTEM_MODE || NRF70_SYSTEM_WITH_RAW_MODES +if NRF70_SYSTEM_MODE config NRF70_STA_MODE bool "nRF70 STA mode" default y + depends on WIFI_NRF7002 || WIFI_NRF7001 + select WIFI_NM_WPA_SUPPLICANT + select NRF70_DATA_TX help Select this option to enable STA mode of the nRF70 driver. - config NRF70_AP_MODE bool "Access point mode" + depends on WIFI_NRF7002 || WIFI_NRF7001 + select NRF70_DATA_TX depends on WIFI_NM_WPA_SUPPLICANT_AP default y if WIFI_NM_WPA_SUPPLICANT_AP config NRF70_P2P_MODE bool "P2P support in driver" -endif # NRF70_SYSTEM_MODE || NRF70_SYSTEM_WITH_RAW_MODES + +config NRF70_SYSTEM_WITH_RAW_MODES + bool "nRF70 system mode with raw modes" + default y if (NRF70_RAW_DATA_TX || NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX) + depends on WIFI_NRF7002 || WIFI_NRF7001 + help + Select this option to enable system mode of the nRF70 driver with raw modes. config NRF70_RAW_DATA_TX bool "RAW TX data path in the driver" @@ -117,8 +107,8 @@ config NRF70_PROMISC_DATA_RX select NET_PROMISCUOUS_MODE config NRF70_DATA_TX - bool "TX data path in the driver" - default y if NRF70_SYSTEM_MODE || NRF70_SYSTEM_WITH_RAW_MODES + bool +endif # NRF70_SYSTEM_MODE config NRF_WIFI_IF_AUTO_START bool "Wi-Fi interface auto start on boot" @@ -176,18 +166,6 @@ config WIFI_NRF70_LOG_LEVEL # Enable error by default default 1 -config NRF70_ON_QSPI - def_bool DT_HAS_NORDIC_NRF7002_QSPI_ENABLED || \ - DT_HAS_NORDIC_NRF7001_QSPI_ENABLED || \ - DT_HAS_NORDIC_NRF7000_QSPI_ENABLED - select NRFX_QSPI - -config NRF70_ON_SPI - def_bool DT_HAS_NORDIC_NRF7002_SPI_ENABLED || \ - DT_HAS_NORDIC_NRF7001_SPI_ENABLED || \ - DT_HAS_NORDIC_NRF7000_SPI_ENABLED - select SPI - config NRF70_2_4G_ONLY def_bool y if WIFI_NRF7001 @@ -220,6 +198,10 @@ config NRF70_UTIL depends on SHELL bool "Utility shell in nRF70 driver" +config NRF70_DEBUG_SHELL + depends on SHELL + bool "Debug shell in nRF70 driver" + config NRF70_QSPI_LOW_POWER bool "low power mode in QSPI" default y if NRF_WIFI_LOW_POWER @@ -546,8 +528,19 @@ config NRF70_RSSI_STALE_TIMEOUT_MS value as the driver does not store it and requires RPU to provide the information. +config NRF_WIFI_CTRL_HEAP_SIZE + int "Dedicated memory pool for control plane" + default 20000 + +config NRF_WIFI_DATA_HEAP_SIZE + int "Dedicated memory pool for data plane" + default 8000 if NRF70_SCAN_ONLY || NRF70_RADIO_TEST #TODO: Need to optimize this. + default 110000 if !SOC_FAMILY_NORDIC_NRF + default 130000 + if NETWORKING # Finetune defaults for certain system components used by the driver + config SYSTEM_WORKQUEUE_STACK_SIZE default 4096 @@ -828,4 +821,25 @@ config NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN help Enable this configuration to disable priority window for scan in the case of coexistence with Short Range radio. + +if NETWORKING +config NRF_WIFI_ZERO_COPY_TX + bool "Zero copy Transmit path [EXPERIMENTAL]" + select NET_L2_ETHERNET_RESERVE_HEADER + select EXPERIMENTAL + # 54L has lower RAM + default y if SOC_SERIES_NRF54LX + help + Enable this configuration to use zero copy Transmit path. + The driver will use the network buffer directly for transmission + without copying the data to the driver's buffer. This reduces the + driver heap memory usage without much impact on the performance. + + The application should configure the network buffers to ensure that + the whole packet fits in a single buffer, else the driver will fallback + to the normal copy path, but the memory requirements would still match + to the zero copy path and may be sub-optimal for the normal copy path. + +endif # NETWORKING + endif # WIFI_NRF70 diff --git a/drivers/wifi/nrf_wifi/inc/fmac_main.h b/drivers/wifi/nrf_wifi/inc/fmac_main.h index 4c0b0e4daf5..0d37a2f2371 100644 --- a/drivers/wifi/nrf_wifi/inc/fmac_main.h +++ b/drivers/wifi/nrf_wifi/inc/fmac_main.h @@ -27,9 +27,11 @@ #ifdef CONFIG_NRF70_STA_MODE #include #endif /* CONFIG_NRF70_STA_MODE */ +#include +#else +#include #endif /* !CONFIG_NRF70_RADIO_TEST */ -#include #include #define NRF70_DRIVER_VERSION "1."KERNEL_VERSION_STRING diff --git a/drivers/wifi/nrf_wifi/inc/net_if.h b/drivers/wifi/nrf_wifi/inc/net_if.h index 8d97802ba65..315740ac5d9 100644 --- a/drivers/wifi/nrf_wifi/inc/net_if.h +++ b/drivers/wifi/nrf_wifi/inc/net_if.h @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #define UNICAST_MASK GENMASK(7, 1) #define LOCAL_BIT BIT(1) diff --git a/drivers/wifi/nrf_wifi/off_raw_tx/inc/off_raw_tx.h b/drivers/wifi/nrf_wifi/off_raw_tx/inc/off_raw_tx.h index 1cb6e258462..68c31f24e4f 100644 --- a/drivers/wifi/nrf_wifi/off_raw_tx/inc/off_raw_tx.h +++ b/drivers/wifi/nrf_wifi/off_raw_tx/inc/off_raw_tx.h @@ -8,7 +8,7 @@ * @brief File containing internal structures for the offloaded raw TX feature in the driver. */ -#include "fmac_structs_common.h" +#include "offload_raw_tx/fmac_structs.h" #include "osal_api.h" struct nrf_wifi_ctx_zep { diff --git a/drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c b/drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c index b714b902eeb..17825511787 100644 --- a/drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c +++ b/drivers/wifi/nrf_wifi/off_raw_tx/src/off_raw_tx_api.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #define DT_DRV_COMPAT nordic_wlan 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) key = k_spin_lock(&off_raw_tx_drv_priv.lock); - off_raw_tx_drv_priv.fmac_priv = nrf_wifi_fmac_off_raw_tx_init(); + off_raw_tx_drv_priv.fmac_priv = nrf_wifi_off_raw_tx_fmac_init(); if (off_raw_tx_drv_priv.fmac_priv == NULL) { 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) rpu_ctx_zep->drv_priv_zep = &off_raw_tx_drv_priv; - rpu_ctx = nrf_wifi_fmac_dev_add(off_raw_tx_drv_priv.fmac_priv, - rpu_ctx_zep); + rpu_ctx = nrf_wifi_off_raw_tx_fmac_dev_add(off_raw_tx_drv_priv.fmac_priv, + rpu_ctx_zep); if (!rpu_ctx) { LOG_ERR("%s: Failed to add nRF70 device", __func__); rpu_ctx_zep = NULL; @@ -197,7 +197,7 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code) configure_board_dep_params(&board_params); - status = nrf_wifi_fmac_off_raw_tx_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, #endif /* CONFIG_NRF_WIFI_LOW_POWER */ @@ -257,7 +257,7 @@ int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code) return 0; err: if (rpu_ctx) { - nrf_wifi_fmac_off_raw_tx_dev_rem(rpu_ctx); + nrf_wifi_fmac_dev_rem(rpu_ctx); rpu_ctx_zep->rpu_ctx = NULL; } @@ -278,7 +278,7 @@ void nrf70_off_raw_tx_deinit(void) return; } - nrf_wifi_fmac_off_raw_tx_deinit(off_raw_tx_drv_priv.fmac_priv); + nrf_wifi_fmac_deinit(off_raw_tx_drv_priv.fmac_priv); k_spin_unlock(&off_raw_tx_drv_priv.lock, key); } @@ -361,7 +361,7 @@ int nrf70_off_raw_tx_conf_update(struct nrf_wifi_off_raw_tx_conf *conf) goto out; } - status = nrf_wifi_fmac_off_raw_tx_conf(fmac_dev_ctx, + status = nrf_wifi_off_raw_tx_fmac_conf(fmac_dev_ctx, off_ctrl_params, off_tx_params); if (status != NRF_WIFI_STATUS_SUCCESS) { @@ -398,7 +398,7 @@ int nrf70_off_raw_tx_start(struct nrf_wifi_off_raw_tx_conf *conf) goto out; } - status = nrf_wifi_fmac_off_raw_tx_start(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx); + status = nrf_wifi_off_raw_tx_fmac_start(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: nRF70 offloaded raw TX start failed", __func__); @@ -425,7 +425,7 @@ int nrf70_off_raw_tx_stop(void) goto out; } - status = nrf_wifi_fmac_off_raw_tx_stop(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx); + status = nrf_wifi_off_raw_tx_fmac_stop(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: nRF70 offloaded raw TX stop failed", __func__); @@ -454,10 +454,10 @@ int nrf70_off_raw_tx_stats(struct nrf_wifi_off_raw_tx_stats *off_raw_tx_stats) { int ret = -1; enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct rpu_op_stats stats; + struct rpu_off_raw_tx_op_stats stats; k_spinlock_key_t key; - memset(&stats, 0, sizeof(struct rpu_op_stats)); + memset(&stats, 0, sizeof(stats)); key = k_spin_lock(&off_raw_tx_drv_priv.lock); @@ -466,14 +466,16 @@ int nrf70_off_raw_tx_stats(struct nrf_wifi_off_raw_tx_stats *off_raw_tx_stats) goto out; } - status = nrf_wifi_fmac_stats_get(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx, 0, &stats); + status = nrf_wifi_off_raw_tx_fmac_stats_get(off_raw_tx_drv_priv.rpu_ctx_zep.rpu_ctx, + 0, + &stats); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: nRF70 offloaded raw TX stats failed", __func__); goto out; } - off_raw_tx_stats->off_raw_tx_pkt_sent = stats.fw.offloaded_raw_tx.offload_raw_tx_cnt; + off_raw_tx_stats->off_raw_tx_pkt_sent = stats.fw.offload_raw_tx_cnt; ret = 0; out: diff --git a/drivers/wifi/nrf_wifi/src/coex.c b/drivers/wifi/nrf_wifi/src/coex.c index 947bf8511a2..8177fb6f85b 100644 --- a/drivers/wifi/nrf_wifi/src/coex.c +++ b/drivers/wifi/nrf_wifi/src/coex.c @@ -17,7 +17,7 @@ #include "coex.h" #include "coex_struct.h" #include "fmac_main.h" -#include "fmac_api.h" +#include "common/fmac_api_common.h" LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL); diff --git a/drivers/wifi/nrf_wifi/src/debug_shell.c b/drivers/wifi/nrf_wifi/src/debug_shell.c new file mode 100644 index 00000000000..70fb77d6ed0 --- /dev/null +++ b/drivers/wifi/nrf_wifi/src/debug_shell.c @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* @file + * @brief NRF Wi-Fi debug shell module + */ +#include +#include +#include "host_rpu_umac_if.h" +#include "fmac_main.h" + +extern struct nrf_wifi_drv_priv_zep rpu_drv_priv_zep; +struct nrf_wifi_ctx_zep *dbg_ctx = &rpu_drv_priv_zep.rpu_ctx_zep; + + +static int nrf_wifi_dbg_read_mem(const struct shell *sh, + size_t argc, + const char *argv[]) +{ + enum nrf_wifi_status status; + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx; + char *ptr; + unsigned long mem_type; + unsigned long mem_offset; + unsigned long num_words; + unsigned int mem_val; + unsigned int mem_start_addr; + unsigned int mem_end_addr; + unsigned int i; + + fmac_dev_ctx = dbg_ctx->rpu_ctx; + mem_type = strtoul(argv[1], &ptr, 10); + mem_offset = strtoul(argv[2], &ptr, 10); + num_words = strtoul(argv[3], &ptr, 10); + + if (mem_type == 0) { + mem_start_addr = RPU_ADDR_PKTRAM_START + (mem_offset * 4); + mem_end_addr = RPU_ADDR_PKTRAM_END; + } else if (mem_type == 1) { + mem_start_addr = RPU_ADDR_GRAM_START + (mem_offset * 4); + mem_end_addr = RPU_ADDR_GRAM_END; + } else { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid memory type(%lu).\n", + mem_type); + return -ENOEXEC; + } + + if ((mem_start_addr % 4) != 0) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid memory word offset(%lu). Needs to be a multiple of 4\n", + mem_offset); + return -ENOEXEC; + } + + if (mem_start_addr + (num_words * 4) - 1 > mem_end_addr) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid number of words(%lu). Exceeds memory region\n", + num_words); + return -ENOEXEC; + } + + for (i = 0; i < (num_words * 4); i += 4) { + status = hal_rpu_mem_read(fmac_dev_ctx->hal_dev_ctx, + &mem_val, + mem_start_addr + i, + sizeof(mem_val)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + shell_fprintf(sh, + SHELL_ERROR, + "Failed to read memory at 0x%x.\n", + mem_start_addr + i); + return -ENOEXEC; + } + + if (i % 16 == 0) { + shell_fprintf(sh, + SHELL_INFO, + "\n0x%x: ", mem_start_addr + i); + } + + shell_fprintf(sh, + SHELL_INFO, + "0x%08x ", + mem_val); + } + + shell_fprintf(sh, + SHELL_INFO, + "\n"); + return 0; +} + + +static int nrf_wifi_dbg_write_mem(const struct shell *sh, + size_t argc, + const char *argv[]) +{ + enum nrf_wifi_status status; + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx; + char *ptr; + unsigned long mem_type; + unsigned long mem_offset; + unsigned int val; + unsigned int mem_start_addr; + unsigned int mem_end_addr; + + fmac_dev_ctx = dbg_ctx->rpu_ctx; + mem_type = strtoul(argv[1], &ptr, 10); + mem_offset = strtoul(argv[2], &ptr, 10); + val = strtoul(argv[3], &ptr, 10); + + if (mem_type == 0) { + mem_start_addr = RPU_ADDR_PKTRAM_START + (mem_offset * 4); + mem_end_addr = RPU_ADDR_PKTRAM_END; + } else if (mem_type == 1) { + mem_start_addr = RPU_ADDR_GRAM_START + (mem_offset * 4); + mem_end_addr = RPU_ADDR_GRAM_END; + } else { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid memory type(%lu).\n", + mem_type); + return -ENOEXEC; + } + + if ((mem_start_addr % 4) != 0) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid memory word offset(%lu). Needs to be a multiple of 4\n", + mem_offset); + return -ENOEXEC; + } + + if (mem_start_addr + 3 > mem_end_addr) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid memory word offset. Exceeds memory region\n"); + return -ENOEXEC; + } + + status = hal_rpu_mem_write(fmac_dev_ctx->hal_dev_ctx, + mem_start_addr, + &val, + sizeof(val)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + shell_fprintf(sh, + SHELL_ERROR, + "Failed to write memory at 0x%x.\n", + mem_start_addr); + return -ENOEXEC; + } + + return 0; +} + + +static int nrf_wifi_dbg_read_reg(const struct shell *sh, + size_t argc, + const char *argv[]) +{ + enum nrf_wifi_status status; + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx; + char *ptr; + unsigned long reg_type; + unsigned long reg_offset; + unsigned long num_regs; + unsigned int reg_val; + unsigned int reg_start_addr; + unsigned int reg_end_addr; + unsigned int i; + + fmac_dev_ctx = dbg_ctx->rpu_ctx; + reg_type = strtoul(argv[1], &ptr, 10); + reg_offset = strtoul(argv[2], &ptr, 10); + num_regs = strtoul(argv[3], &ptr, 10); + + if (reg_type == 0) { + reg_start_addr = RPU_ADDR_SBUS_START + (reg_offset * 4); + reg_end_addr = RPU_ADDR_SBUS_END; + } else if (reg_type == 1) { + reg_start_addr = RPU_ADDR_PBUS_START + (reg_offset * 4); + reg_end_addr = RPU_ADDR_PBUS_END; + } else { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid register type(%lu).\n", + reg_type); + return -ENOEXEC; + } + + if ((reg_start_addr % 4) != 0) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid register offset(%lu). Needs to be a multiple of 4\n", + reg_offset); + return -ENOEXEC; + } + + if (reg_start_addr + (num_regs * 4) - 1 > reg_end_addr) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid number of registers(%lu). Exceeds bus region\n", + num_regs); + return -ENOEXEC; + } + + for (i = 0; i < num_regs * 4; i += 4) { + status = hal_rpu_reg_read(fmac_dev_ctx->hal_dev_ctx, + ®_val, + reg_start_addr + i); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + shell_fprintf(sh, + SHELL_ERROR, + "Failed to read register at 0x%x.\n", + reg_start_addr + i); + return -ENOEXEC; + } + + shell_fprintf(sh, + SHELL_INFO, + "0x%x: 0x%08x\n", + reg_start_addr + i, + reg_val); + } + + shell_fprintf(sh, + SHELL_INFO, + "\n"); + return 0; +} + + +static int nrf_wifi_dbg_write_reg(const struct shell *sh, + size_t argc, + const char *argv[]) +{ + enum nrf_wifi_status status; + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx; + char *ptr; + unsigned long reg_type; + unsigned long reg_offset; + unsigned int val; + unsigned int reg_start_addr; + unsigned int reg_end_addr; + + fmac_dev_ctx = dbg_ctx->rpu_ctx; + reg_type = strtoul(argv[1], &ptr, 10); + reg_offset = strtoul(argv[2], &ptr, 10); + val = strtoul(argv[3], &ptr, 10); + + if (reg_type == 0) { + reg_start_addr = RPU_ADDR_SBUS_START + (reg_offset * 4); + reg_end_addr = RPU_ADDR_SBUS_END; + } else if (reg_type == 1) { + reg_start_addr = RPU_ADDR_PBUS_START + (reg_offset * 4); + reg_end_addr = RPU_ADDR_PBUS_END; + } else { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid register type(%lu).\n", + reg_type); + return -ENOEXEC; + } + + if ((reg_start_addr % 4) != 0) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid register offset(%lu). Needs to be a multiple of 4\n", + reg_offset); + return -ENOEXEC; + } + + if (reg_start_addr + 3 > reg_end_addr) { + shell_fprintf(sh, + SHELL_ERROR, + "Invalid register offset. Exceeds bus region\n"); + return -ENOEXEC; + } + + status = hal_rpu_reg_write(fmac_dev_ctx->hal_dev_ctx, + reg_start_addr, + val); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + shell_fprintf(sh, + SHELL_ERROR, + "Failed to write register at 0x%x.\n", + reg_start_addr); + return -ENOEXEC; + } + + return 0; +} + + + +SHELL_STATIC_SUBCMD_SET_CREATE( + nrf70_dbg, + SHELL_CMD_ARG(read_mem, + NULL, + " \n" + "where:\n" + " : One of the memory regions below\n" + "0 - PKTRAM\n" + "1 - GRAM\n" + " : Word offset in the memory region\n" + " : Number of words to read\n", + nrf_wifi_dbg_read_mem, + 4, + 0), + SHELL_CMD_ARG(write_mem, + NULL, + " \n" + "where:\n" + " : One of the memory regions below\n" + "0 - PKTRAM\n" + "1 - GRAM\n" + " : Word offset in the memory region\n" + " : Value to be written\n", + nrf_wifi_dbg_write_mem, + 4, + 0), + SHELL_CMD_ARG(read_reg, + NULL, + " \n" + "where:\n" + " : One of the bus regions below\n" + "0 - SYSBUS\n" + "1 - PBUS\n" + " : Register offset\n" + " : Number of registers to read\n", + nrf_wifi_dbg_read_reg, + 4, + 0), + SHELL_CMD_ARG(write_reg, + NULL, + " \n" + "where:\n" + " : One of the bus regions below\n" + "0 - SYSBUS\n" + "1 - PBUS\n" + " : Register offset\n" + " : Value to be written\n", + nrf_wifi_dbg_write_reg, + 4, + 0), + SHELL_SUBCMD_SET_END +); + + +SHELL_SUBCMD_ADD((nrf70), dbg, &nrf70_dbg, + "nRF70 advanced debug commands\n", + NULL, + 0, 0); diff --git a/drivers/wifi/nrf_wifi/src/fmac_main.c b/drivers/wifi/nrf_wifi/src/fmac_main.c index 341d4c15a55..5a7d79141bc 100644 --- a/drivers/wifi/nrf_wifi/src/fmac_main.c +++ b/drivers/wifi/nrf_wifi/src/fmac_main.c @@ -23,8 +23,7 @@ #include -#include -#include "fmac_util.h" +#include "common/fmac_util.h" #include #ifndef CONFIG_NRF70_RADIO_TEST @@ -37,8 +36,11 @@ #include #include #endif /* CONFIG_NRF70_STA_MODE */ -#include +#include +#include +#else +#include #endif /* !CONFIG_NRF70_RADIO_TEST */ #define DT_DRV_COMPAT nordic_wlan @@ -463,7 +465,8 @@ void reg_change_callbk_fn(void *vif_ctx, return; } - fmac_dev_ctx->reg_change = k_malloc(sizeof(struct nrf_wifi_event_regulatory_change)); + fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_alloc(sizeof(struct + nrf_wifi_event_regulatory_change)); if (!fmac_dev_ctx->reg_change) { LOG_ERR("%s: Failed to allocate memory for reg_change", __func__); return; @@ -582,7 +585,11 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv rpu_ctx_zep->drv_priv_zep = drv_priv_zep; - rpu_ctx = nrf_wifi_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep); +#ifdef CONFIG_NRF70_RADIO_TEST + rpu_ctx = nrf_wifi_rt_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep); +#else + rpu_ctx = nrf_wifi_sys_fmac_dev_add(drv_priv_zep->fmac_priv, rpu_ctx_zep); +#endif /* CONFIG_NRF70_RADIO_TEST */ if (!rpu_ctx) { LOG_ERR("%s: nrf_wifi_fmac_dev_add failed", __func__); @@ -618,7 +625,7 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv configure_board_dep_params(&board_params); #ifdef CONFIG_NRF70_RADIO_TEST - status = nrf_wifi_fmac_dev_init_rt(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_rt_fmac_dev_init(rpu_ctx_zep->rpu_ctx, #ifdef CONFIG_NRF_WIFI_LOW_POWER sleep_type, #endif /* CONFIG_NRF_WIFI_LOW_POWER */ @@ -630,7 +637,7 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv &board_params, STRINGIFY(CONFIG_NRF70_REG_DOMAIN)); #else - status = nrf_wifi_fmac_dev_init(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_dev_init(rpu_ctx_zep->rpu_ctx, #ifdef CONFIG_NRF_WIFI_LOW_POWER sleep_type, #endif /* CONFIG_NRF_WIFI_LOW_POWER */ @@ -645,18 +652,14 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_dev_init failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_dev_init failed", __func__); goto err; } return status; err: if (rpu_ctx) { -#ifdef CONFIG_NRF70_RADIO_TEST - nrf_wifi_fmac_dev_rem_rt(rpu_ctx); -#else nrf_wifi_fmac_dev_rem(rpu_ctx); -#endif /* CONFIG_NRF70_RADIO_TEST */ rpu_ctx_zep->rpu_ctx = NULL; } return status; @@ -668,16 +671,16 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_rem_zep(struct nrf_wifi_drv_priv_zep *drv rpu_ctx_zep = &drv_priv_zep->rpu_ctx_zep; #ifdef CONFIG_NRF70_RADIO_TEST - nrf_wifi_fmac_dev_deinit_rt(rpu_ctx_zep->rpu_ctx); - nrf_wifi_fmac_dev_rem_rt(rpu_ctx_zep->rpu_ctx); + nrf_wifi_rt_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx); #else - nrf_wifi_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx); - nrf_wifi_fmac_dev_rem(rpu_ctx_zep->rpu_ctx); + nrf_wifi_sys_fmac_dev_deinit(rpu_ctx_zep->rpu_ctx); #endif /* CONFIG_NRF70_RADIO_TEST */ - k_free(rpu_ctx_zep->extended_capa); + nrf_wifi_fmac_dev_rem(rpu_ctx_zep->rpu_ctx); + + nrf_wifi_osal_mem_free(rpu_ctx_zep->extended_capa); rpu_ctx_zep->extended_capa = NULL; - k_free(rpu_ctx_zep->extended_capa_mask); + nrf_wifi_osal_mem_free(rpu_ctx_zep->extended_capa_mask); rpu_ctx_zep->extended_capa_mask = NULL; rpu_ctx_zep->rpu_ctx = NULL; @@ -730,7 +733,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev) #ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS callbk_fns.rx_bcn_prb_resp_callbk_fn = nrf_wifi_rx_bcn_prb_resp_frm; #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */ -#if defined(CONFIG_NRF70_SYSTEM_MODE) || defined(CONFIG_NRF70_SYSTEM_WITH_RAW_MODES) +#ifdef CONFIG_NRF70_SYSTEM_MODE callbk_fns.set_if_callbk_fn = nrf_wifi_set_iface_event_handler; #endif /* CONFIG_NRF70_SYSTEM_MODE */ #ifdef CONFIG_NRF70_STA_MODE @@ -760,9 +763,9 @@ static int nrf_wifi_drv_main_zep(const struct device *dev) */ nrf_wifi_osal_init(&nrf_wifi_os_zep_ops); - rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init(&data_config, - rx_buf_pools, - &callbk_fns); + rpu_drv_priv_zep.fmac_priv = nrf_wifi_sys_fmac_init(&data_config, + rx_buf_pools, + &callbk_fns); #else /* !CONFIG_NRF70_RADIO_TEST */ enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -771,7 +774,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev) */ nrf_wifi_osal_init(&nrf_wifi_os_zep_ops); - rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init_rt(); + rpu_drv_priv_zep.fmac_priv = nrf_wifi_rt_fmac_init(); #endif /* CONFIG_NRF70_RADIO_TEST */ if (rpu_drv_priv_zep.fmac_priv == NULL) { @@ -781,18 +784,18 @@ static int nrf_wifi_drv_main_zep(const struct device *dev) } #ifdef CONFIG_NRF70_DATA_TX - struct nrf_wifi_fmac_priv_def *def_priv = NULL; + struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL; - def_priv = wifi_fmac_priv(rpu_drv_priv_zep.fmac_priv); - def_priv->max_ampdu_len_per_token = + sys_fpriv = wifi_fmac_priv(rpu_drv_priv_zep.fmac_priv); + 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; /* Align to 4-byte */ - def_priv->max_ampdu_len_per_token &= ~0x3; + sys_fpriv->max_ampdu_len_per_token &= ~0x3; /* Alignment overhead for size based coalesce */ - def_priv->avail_ampdu_len_per_token = - def_priv->max_ampdu_len_per_token - + sys_fpriv->avail_ampdu_len_per_token = + sys_fpriv->max_ampdu_len_per_token - (MAX_PKT_RAM_TX_ALIGN_OVERHEAD * max_tx_aggregation); #endif /* CONFIG_NRF70_DATA_TX */ @@ -811,7 +814,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev) return 0; #ifdef CONFIG_NRF70_RADIO_TEST fmac_deinit: - nrf_wifi_fmac_deinit_rt(rpu_drv_priv_zep.fmac_priv); + nrf_wifi_fmac_deinit(rpu_drv_priv_zep.fmac_priv); nrf_wifi_osal_deinit(); #endif /* CONFIG_NRF70_RADIO_TEST */ err: diff --git a/drivers/wifi/nrf_wifi/src/net_if.c b/drivers/wifi/nrf_wifi/src/net_if.c index 5c7fb9759f7..5f79e2de26d 100644 --- a/drivers/wifi/nrf_wifi/src/net_if.c +++ b/drivers/wifi/nrf_wifi/src/net_if.c @@ -23,8 +23,7 @@ LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL); #include "net_private.h" #include "util.h" -#include "fmac_api.h" -#include "fmac_util.h" +#include "common/fmac_util.h" #include "shim.h" #include "fmac_main.h" #include "wpa_supp_if.h" @@ -178,7 +177,7 @@ void nrf_wifi_rpu_recovery_cb(void *vif_ctx_handle, { struct nrf_wifi_fmac_vif_ctx *vif_ctx = vif_ctx_handle; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; if (!vif_ctx) { @@ -188,9 +187,9 @@ void nrf_wifi_rpu_recovery_cb(void *vif_ctx_handle, } fmac_dev_ctx = vif_ctx->fmac_dev_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - if (!def_dev_ctx) { - LOG_ERR("%s: def_dev_ctx is NULL", + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + if (!sys_dev_ctx) { + LOG_ERR("%s: sys_dev_ctx is NULL", __func__); goto out; } @@ -238,10 +237,10 @@ void nrf_wifi_if_sniffer_rx_frm(void *os_vif_ctx, void *frm, struct net_pkt *pkt; struct nrf_wifi_ctx_zep *rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); pkt = net_raw_pkt_from_nbuf(iface, frm, sizeof(struct raw_rx_pkt_header), raw_rx_hdr, @@ -269,11 +268,11 @@ void nrf_wifi_if_rx_frm(void *os_vif_ctx, void *frm) int status; struct nrf_wifi_ctx_zep *rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct rpu_host_stats *host_stats = NULL; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - host_stats = &def_dev_ctx->host_stats; + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + host_stats = &sys_dev_ctx->host_stats; host_stats->total_rx_pkts++; pkt = net_pkt_from_nbuf(iface, frm); @@ -356,7 +355,7 @@ int nrf_wifi_if_send(const struct device *dev, #ifdef CONFIG_NRF70_DATA_TX struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct rpu_host_stats *host_stats = NULL; void *nbuf = NULL; @@ -383,8 +382,8 @@ int nrf_wifi_if_send(const struct device *dev, goto unlock; } - def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); - host_stats = &def_dev_ctx->host_stats; + sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); + host_stats = &sys_dev_ctx->host_stats; nbuf = net_pkt_to_nbuf(pkt); if (!nbuf) { LOG_DBG("Failed to allocate net_pkt"); @@ -460,7 +459,7 @@ static void ip_maddr_event_handler(struct net_if *iface, goto unlock; } - mcast_info = k_calloc(sizeof(*mcast_info), sizeof(char)); + mcast_info = nrf_wifi_osal_mem_zalloc(sizeof(*mcast_info)); if (!mcast_info) { LOG_ERR("%s: Unable to allocate memory of size %d " @@ -490,7 +489,7 @@ static void ip_maddr_event_handler(struct net_if *iface, &mac_addr, NRF_WIFI_ETH_ADDR_LEN); - status = nrf_wifi_fmac_set_mcast_addr(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_mcast_addr(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, mcast_info); if (status == NRF_WIFI_STATUS_FAIL) { @@ -502,7 +501,7 @@ static void ip_maddr_event_handler(struct net_if *iface, sizeof(mac_string_buf))); } unlock: - k_free(mcast_info); + nrf_wifi_osal_mem_free(mcast_info); k_mutex_unlock(&vif_ctx_zep->vif_lock); } #endif /* CONFIG_NRF70_STA_MODE */ @@ -751,7 +750,7 @@ int nrf_wifi_if_start_zep(const struct device *dev) dev->name, strlen(dev->name)); - vif_ctx_zep->vif_idx = nrf_wifi_fmac_add_vif(fmac_dev_ctx, + vif_ctx_zep->vif_idx = nrf_wifi_sys_fmac_add_vif(fmac_dev_ctx, vif_ctx_zep, &add_vif_info); if (vif_ctx_zep->vif_idx >= MAX_NUM_VIFS) { @@ -785,7 +784,7 @@ int nrf_wifi_if_start_zep(const struct device *dev) mac_addr_len = WIFI_MAC_ADDR_LEN; } - status = nrf_wifi_fmac_set_vif_macaddr(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_vif_macaddr(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, mac_addr); @@ -806,12 +805,12 @@ int nrf_wifi_if_start_zep(const struct device *dev) dev->name, strlen(dev->name)); - status = nrf_wifi_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &vif_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_vif_state failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_vif_state failed", __func__); goto del_vif; } @@ -820,12 +819,12 @@ int nrf_wifi_if_start_zep(const struct device *dev) nrf_wifi_wpa_supp_event_mac_chgd(vif_ctx_zep); #ifdef CONFIG_NRF_WIFI_LOW_POWER - status = nrf_wifi_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, NRF_WIFI_PS_ENABLED); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_set_power_save failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_set_power_save failed", __func__); goto dev_rem; } @@ -838,9 +837,9 @@ int nrf_wifi_if_start_zep(const struct device *dev) goto out; del_vif: - status = nrf_wifi_fmac_del_vif(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + status = nrf_wifi_sys_fmac_del_vif(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_del_vif failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_del_vif failed", __func__); } dev_rem: @@ -891,12 +890,12 @@ int nrf_wifi_if_stop_zep(const struct device *dev) #ifdef CONFIG_NRF70_STA_MODE #ifdef CONFIG_NRF_WIFI_LOW_POWER - status = nrf_wifi_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, NRF_WIFI_PS_DISABLED); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_set_power_save failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_set_power_save failed", __func__); } #endif /* CONFIG_NRF_WIFI_LOW_POWER */ @@ -909,20 +908,20 @@ int nrf_wifi_if_stop_zep(const struct device *dev) vif_info.state = NRF_WIFI_FMAC_IF_OP_STATE_DOWN; vif_info.if_index = vif_ctx_zep->vif_idx; - status = nrf_wifi_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &vif_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_vif_state failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_vif_state failed", __func__); } - status = nrf_wifi_fmac_del_vif(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_del_vif(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_del_vif failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_del_vif failed", __func__); } @@ -951,7 +950,7 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; if (!dev || !config) { LOG_ERR("%s: Invalid parameters", @@ -979,9 +978,9 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, goto unlock; } fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - if (!def_dev_ctx) { - LOG_ERR("%s: def_dev_ctx is NULL", + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + if (!sys_dev_ctx) { + LOG_ERR("%s: sys_dev_ctx is NULL", __func__); goto unlock; } @@ -990,7 +989,7 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, if (type == ETHERNET_CONFIG_TYPE_TXINJECTION_MODE) { config->txinjection_mode = - def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode; + sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode; } #ifdef CONFIG_NRF70_TCP_IP_CHECKSUM_OFFLOAD if (type == ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT || @@ -1002,6 +1001,11 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, ETHERNET_CHECKSUM_SUPPORT_TCP | ETHERNET_CHECKSUM_SUPPORT_UDP; } +#endif +#ifdef CONFIG_NRF_WIFI_ZERO_COPY_TX + if (type == ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM) { + config->extra_tx_pkt_headroom = NRF_WIFI_EXTRA_TX_HEADROOM; + } #endif ret = 0; unlock: @@ -1018,7 +1022,7 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret = -1; if (!dev) { @@ -1067,9 +1071,9 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, } fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - if (!def_dev_ctx) { - LOG_ERR("%s: def_dev_ctx is NULL", + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + if (!sys_dev_ctx) { + LOG_ERR("%s: sys_dev_ctx is NULL", __func__); goto unlock; } @@ -1078,7 +1082,7 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, if (type == ETHERNET_CONFIG_TYPE_TXINJECTION_MODE) { unsigned char mode; - if (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode == + if (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode == config->txinjection_mode) { LOG_INF("%s: Driver TX injection setting is same as configured setting", __func__); @@ -1091,15 +1095,15 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, * as is */ if (config->txinjection_mode) { - mode = (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) | + mode = (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) | (NRF_WIFI_TX_INJECTION_MODE); } else { - mode = (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) ^ + mode = (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) ^ (NRF_WIFI_TX_INJECTION_MODE); } - ret = nrf_wifi_fmac_set_mode(rpu_ctx_zep->rpu_ctx, - vif_ctx_zep->vif_idx, mode); + ret = nrf_wifi_sys_fmac_set_mode(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, mode); if (ret != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: Mode set operation failed", __func__); @@ -1111,7 +1115,7 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, else if (type == ETHERNET_CONFIG_TYPE_PROMISC_MODE) { unsigned char mode; - if (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->promisc_mode == + if (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->promisc_mode == config->promisc_mode) { LOG_ERR("%s: Driver promisc mode setting is same as configured setting", __func__); @@ -1119,15 +1123,15 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, } if (config->promisc_mode) { - mode = (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) | + mode = (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) | (NRF_WIFI_PROMISCUOUS_MODE); } else { - mode = (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) ^ + mode = (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) ^ (NRF_WIFI_PROMISCUOUS_MODE); } - ret = nrf_wifi_fmac_set_mode(rpu_ctx_zep->rpu_ctx, - vif_ctx_zep->vif_idx, mode); + ret = nrf_wifi_sys_fmac_set_mode(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, mode); if (ret != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: mode set operation failed", __func__); @@ -1171,9 +1175,9 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats) struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; #ifdef CONFIG_NRF70_RAW_DATA_TX - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; #endif /* CONFIG_NRF70_RAW_DATA_TX */ - struct rpu_op_stats stats; + struct rpu_sys_op_stats stats; int ret = -1; if (!dev) { @@ -1204,8 +1208,8 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats) goto unlock; } - memset(&stats, 0, sizeof(struct rpu_op_stats)); - status = nrf_wifi_fmac_stats_get(rpu_ctx_zep->rpu_ctx, 0, &stats); + memset(&stats, 0, sizeof(struct rpu_sys_op_stats)); + status = nrf_wifi_sys_fmac_stats_get(rpu_ctx_zep->rpu_ctx, 0, &stats); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: nrf_wifi_fmac_stats_get failed", __func__); goto unlock; @@ -1229,8 +1233,8 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats) zstats->overrun_count = stats.host.total_tx_drop_pkts + stats.host.total_rx_drop_pkts; #ifdef CONFIG_NRF70_RAW_DATA_TX - def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); - zstats->errors.tx += def_dev_ctx->raw_pkt_stats.raw_pkt_send_failure; + sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); + zstats->errors.tx += sys_dev_ctx->raw_pkt_stats.raw_pkt_send_failure; #endif /* CONFIG_NRF70_RAW_DATA_TX */ ret = 0; unlock: @@ -1244,7 +1248,7 @@ int nrf_wifi_stats_reset(const struct device *dev) enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret = -1; if (!dev) { @@ -1277,8 +1281,8 @@ int nrf_wifi_stats_reset(const struct device *dev) goto unlock; } - def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); - memset(&def_dev_ctx->host_stats, 0, sizeof(struct rpu_host_stats)); + sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); + memset(&sys_dev_ctx->host_stats, 0, sizeof(struct rpu_host_stats)); ret = 0; unlock: diff --git a/drivers/wifi/nrf_wifi/src/shell.c b/drivers/wifi/nrf_wifi/src/shell.c new file mode 100644 index 00000000000..36d21d21d50 --- /dev/null +++ b/drivers/wifi/nrf_wifi/src/shell.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* @file + * @brief NRF Wi-Fi debug shell module + */ +#include +#include + +SHELL_SUBCMD_SET_CREATE(nrf70_commands, (nrf70)); + +SHELL_CMD_REGISTER(nrf70, &nrf70_commands, "nRF70 specific commands", NULL); diff --git a/drivers/wifi/nrf_wifi/src/wifi_mgmt.c b/drivers/wifi/nrf_wifi/src/wifi_mgmt.c index 9591ccf772e..875ce786b57 100644 --- a/drivers/wifi/nrf_wifi/src/wifi_mgmt.c +++ b/drivers/wifi/nrf_wifi/src/wifi_mgmt.c @@ -15,9 +15,9 @@ #include #include "util.h" -#include "fmac_api.h" -#include "fmac_tx.h" -#include "fmac_util.h" +#include "system/fmac_api.h" +#include "system/fmac_tx.h" +#include "common/fmac_util.h" #include "fmac_main.h" #include "wifi_mgmt.h" @@ -69,7 +69,7 @@ int nrf_wifi_set_power_save(const struct device *dev, WIFI_PS_PARAM_LISTEN_INTERVAL_RANGE_INVALID; return -EINVAL; } - status = nrf_wifi_fmac_set_listen_interval( + status = nrf_wifi_sys_fmac_set_listen_interval( rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, params->listen_interval); @@ -90,7 +90,7 @@ int nrf_wifi_set_power_save(const struct device *dev, goto out; } - status = nrf_wifi_fmac_set_power_save_timeout( + status = nrf_wifi_sys_fmac_set_power_save_timeout( rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, params->timeout_ms); @@ -100,17 +100,17 @@ int nrf_wifi_set_power_save(const struct device *dev, uapsd_queue = UAPSD_Q_MAX; /* WMM mode */ } - status = nrf_wifi_fmac_set_uapsd_queue(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_uapsd_queue(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, uapsd_queue); break; case WIFI_PS_PARAM_STATE: - status = nrf_wifi_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_power_save(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, params->enabled); break; case WIFI_PS_PARAM_WAKEUP_MODE: - status = nrf_wifi_fmac_set_ps_wakeup_mode( + status = nrf_wifi_sys_fmac_set_ps_wakeup_mode( rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, params->wakeup_mode); @@ -128,7 +128,7 @@ int nrf_wifi_set_power_save(const struct device *dev, return -EINVAL; } - status = nrf_wifi_fmac_set_ps_exit_strategy( + status = nrf_wifi_sys_fmac_set_ps_exit_strategy( rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, exit_strategy); @@ -211,11 +211,11 @@ int nrf_wifi_get_power_save_config(const struct device *dev, vif_ctx_zep->ps_config_info_evnt = false; - status = nrf_wifi_fmac_get_power_save_info(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_get_power_save_info(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_get_power_save_info failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_get_power_save_info failed", __func__); goto out; } @@ -468,7 +468,7 @@ int nrf_wifi_twt_teardown_flows(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep, continue; } twt_info.twt_flow_id = flow_id; - status = nrf_wifi_fmac_twt_teardown(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_twt_teardown(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &twt_info); if (status != NRF_WIFI_STATUS_SUCCESS) { @@ -569,7 +569,7 @@ int nrf_wifi_set_twt(const struct device *dev, twt_info.dialog_token = twt_params->dialog_token; twt_info.twt_wake_ahead_duration = twt_params->setup.twt_wake_ahead_duration; - status = nrf_wifi_fmac_twt_setup(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_twt_setup(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &twt_info); @@ -682,8 +682,8 @@ void nrf_wifi_event_proc_twt_sleep_zep(void *vif_ctx, struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; - struct nrf_wifi_fmac_priv_def *def_priv = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL; #ifdef CONFIG_NRF70_DATA_TX int desc = 0; int ac = 0; @@ -708,8 +708,8 @@ void nrf_wifi_event_proc_twt_sleep_zep(void *vif_ctx, } fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_fpriv = wifi_fmac_priv(fmac_dev_ctx->fpriv); if (!sleep_evnt) { LOG_ERR("%s: sleep_evnt is NULL", __func__); @@ -718,29 +718,29 @@ void nrf_wifi_event_proc_twt_sleep_zep(void *vif_ctx, switch (sleep_evnt->info.type) { case TWT_BLOCK_TX: - nrf_wifi_osal_spinlock_take(def_dev_ctx->tx_config.tx_lock); + nrf_wifi_osal_spinlock_take(sys_dev_ctx->tx_config.tx_lock); - def_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_SLEEP; + sys_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_SLEEP; wifi_mgmt_raise_twt_sleep_state(vif_ctx_zep->zep_net_if_ctx, WIFI_TWT_STATE_SLEEP); - nrf_wifi_osal_spinlock_rel(def_dev_ctx->tx_config.tx_lock); + nrf_wifi_osal_spinlock_rel(sys_dev_ctx->tx_config.tx_lock); break; case TWT_UNBLOCK_TX: - nrf_wifi_osal_spinlock_take(def_dev_ctx->tx_config.tx_lock); - def_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_AWAKE; + nrf_wifi_osal_spinlock_take(sys_dev_ctx->tx_config.tx_lock); + sys_dev_ctx->twt_sleep_status = NRF_WIFI_FMAC_TWT_STATE_AWAKE; wifi_mgmt_raise_twt_sleep_state(vif_ctx_zep->zep_net_if_ctx, WIFI_TWT_STATE_AWAKE); #ifdef CONFIG_NRF70_DATA_TX for (ac = NRF_WIFI_FMAC_AC_BE; ac <= NRF_WIFI_FMAC_AC_MAX; ++ac) { desc = tx_desc_get(fmac_dev_ctx, ac); - if (desc < def_priv->num_tx_tokens) { + if (desc < sys_fpriv->num_tx_tokens) { tx_pending_process(fmac_dev_ctx, desc, ac); } } #endif - nrf_wifi_osal_spinlock_rel(def_dev_ctx->tx_config.tx_lock); + nrf_wifi_osal_spinlock_rel(sys_dev_ctx->tx_config.tx_lock); break; default: break; @@ -757,7 +757,7 @@ int nrf_wifi_mode(const struct device *dev, struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret = -1; if (!dev || !mode) { @@ -784,7 +784,7 @@ int nrf_wifi_mode(const struct device *dev, } fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); if (!device_is_ready(dev)) { LOG_ERR("%s: Device %s is not ready", @@ -811,26 +811,27 @@ int nrf_wifi_mode(const struct device *dev, * context maps the correct network interface index to current driver * interface index. */ - status = nrf_wifi_fmac_set_mode(rpu_ctx_zep->rpu_ctx, - vif_ctx_zep->vif_idx, mode->mode); + status = nrf_wifi_sys_fmac_set_mode(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + mode->mode); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: mode set operation failed", __func__); goto out; } } else { - mode->mode = def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode; + mode->mode = sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode; /** * This is a work-around to handle current UMAC mode handling. * This might be removed in future versions when UMAC has more space. */ #ifdef CONFIG_NRF70_RAW_DATA_TX - if (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode == true) { + if (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode == true) { mode->mode ^= NRF_WIFI_TX_INJECTION_MODE; } #endif /* CONFIG_NRF70_RAW_DATA_TX */ #ifdef CONFIG_NRF70_PROMISC_DATA_RX - if (def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->promisc_mode == true) { + if (sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->promisc_mode == true) { mode->mode ^= NRF_WIFI_PROMISCUOUS_MODE; } #endif /* CONFIG_NRF70_PROMISC_DATA_RX */ @@ -849,7 +850,7 @@ int nrf_wifi_channel(const struct device *dev, enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; int ret = -1; @@ -882,7 +883,7 @@ int nrf_wifi_channel(const struct device *dev, } fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); if (channel->oper == WIFI_MGMT_SET) { /** @@ -891,15 +892,16 @@ int nrf_wifi_channel(const struct device *dev, * context maps the correct network interface index to current driver * interface index. */ - status = nrf_wifi_fmac_set_channel(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, - channel->channel); + status = nrf_wifi_sys_fmac_set_channel(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + channel->channel); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: set channel failed", __func__); goto out; } } else { - channel->channel = def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->channel; + channel->channel = sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->channel; } ret = 0; out: @@ -916,7 +918,7 @@ int nrf_wifi_filter(const struct device *dev, struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret = -1; if (!dev || !filter) { @@ -932,7 +934,7 @@ int nrf_wifi_filter(const struct device *dev, rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep; fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); if (filter->oper == WIFI_MGMT_SET) { /** @@ -942,9 +944,9 @@ int nrf_wifi_filter(const struct device *dev, * driver and filter packet type on packet receive by * checking the 802.11 header in the packet */ - if (((def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) & + if (((sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->mode) & (NRF_WIFI_PROMISCUOUS_MODE)) == NRF_WIFI_PROMISCUOUS_MODE) { - def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter = + sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter = filter->filter; ret = 0; goto out; @@ -963,7 +965,7 @@ int nrf_wifi_filter(const struct device *dev, filter->filter = 1; } else if (filter->filter == 0) { filter->filter = - def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter; + sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter; } /** @@ -972,14 +974,16 @@ int nrf_wifi_filter(const struct device *dev, * context maps the correct network interface index to current driver * interface index */ - status = nrf_wifi_fmac_set_packet_filter(rpu_ctx_zep->rpu_ctx, filter->filter, - vif_ctx_zep->vif_idx, filter->buffer_size); + status = nrf_wifi_sys_fmac_set_packet_filter(rpu_ctx_zep->rpu_ctx, + filter->filter, + vif_ctx_zep->vif_idx, + filter->buffer_size); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: Set filter operation failed\n", __func__); goto out; } } else { - filter->filter = def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter; + filter->filter = sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->packet_filter; } ret = 0; out: @@ -1036,7 +1040,7 @@ int nrf_wifi_set_rts_threshold(const struct device *dev, k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER); - status = nrf_wifi_fmac_set_wiphy_params(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_set_wiphy_params(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &wiphy_info); diff --git a/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c b/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c index e30f572aeb3..07560376987 100644 --- a/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c +++ b/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c @@ -15,8 +15,8 @@ #include #include "util.h" -#include "fmac_api.h" -#include "fmac_tx.h" +#include "system/fmac_api.h" +#include "system/fmac_tx.h" #include "fmac_main.h" #include "wifi_mgmt_scan.h" @@ -109,10 +109,9 @@ int nrf_wifi_disp_scan_zep(const struct device *dev, struct wifi_scan_params *pa vif_ctx_zep->disp_scan_cb = cb; - scan_info = k_calloc(sizeof(*scan_info) + + scan_info = nrf_wifi_osal_mem_zalloc(sizeof(*scan_info) + (num_scan_channels * - sizeof(scan_info->scan_params.center_frequency[0])), - sizeof(char)); + sizeof(scan_info->scan_params.center_frequency[0]))); if (!scan_info) { LOG_ERR("%s: Unable to allocate memory for scan_info (size: %d bytes)", @@ -210,10 +209,10 @@ int nrf_wifi_disp_scan_zep(const struct device *dev, struct wifi_scan_params *pa scan_info->scan_params.passive_scan = 1; #endif /* CONFIG_NRF70_PASSIVE_SCAN_ONLY */ - status = nrf_wifi_fmac_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, scan_info); + status = nrf_wifi_sys_fmac_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, scan_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_scan failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_scan failed", __func__); goto out; } @@ -226,7 +225,7 @@ int nrf_wifi_disp_scan_zep(const struct device *dev, struct wifi_scan_params *pa ret = 0; out: if (scan_info) { - k_free(scan_info); + nrf_wifi_osal_mem_free(scan_info); } k_mutex_unlock(&vif_ctx_zep->vif_lock); return ret; @@ -249,12 +248,12 @@ enum nrf_wifi_status nrf_wifi_disp_scan_res_get_zep(struct nrf_wifi_vif_ctx_zep goto out; } - status = nrf_wifi_fmac_scan_res_get(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_scan_res_get(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, SCAN_DISPLAY); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_scan failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_scan failed", __func__); goto out; } diff --git a/drivers/wifi/nrf_wifi/src/wifi_util.c b/drivers/wifi/nrf_wifi/src/wifi_util.c index 2d2ca2a2b5b..ec1dccb2a72 100644 --- a/drivers/wifi/nrf_wifi/src/wifi_util.c +++ b/drivers/wifi/nrf_wifi/src/wifi_util.c @@ -9,8 +9,8 @@ */ #include #include "host_rpu_umac_if.h" -#include "fmac_api.h" -#include "fmac_util.h" +#include "common/fmac_util.h" +#include "system/fmac_api.h" #include "fmac_main.h" #include "wifi_util.h" @@ -161,10 +161,10 @@ static int nrf_wifi_util_set_he_ltf_gi(const struct shell *sh, return -ENOEXEC; } - status = nrf_wifi_fmac_conf_ltf_gi(ctx->rpu_ctx, - ctx->conf_params.he_ltf, - ctx->conf_params.he_gi, - val); + status = nrf_wifi_sys_fmac_conf_ltf_gi(ctx->rpu_ctx, + ctx->conf_params.he_ltf, + ctx->conf_params.he_gi, + val); if (status != NRF_WIFI_STATUS_SUCCESS) { shell_fprintf(sh, @@ -199,7 +199,7 @@ static int nrf_wifi_util_set_uapsd_queue(const struct shell *sh, } if (ctx->conf_params.uapsd_queue != val) { - status = nrf_wifi_fmac_set_uapsd_queue(ctx->rpu_ctx, + status = nrf_wifi_sys_fmac_set_uapsd_queue(ctx->rpu_ctx, 0, val); @@ -272,7 +272,7 @@ static int nrf_wifi_util_tx_stats(const struct shell *sh, struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; void *queue = NULL; unsigned int tx_pending_pkts = 0; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret; vif_index = atoi(argv[1]); @@ -295,7 +295,7 @@ static int nrf_wifi_util_tx_stats(const struct shell *sh, } fmac_dev_ctx = ctx->rpu_ctx; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); /* TODO: Get peer_index from shell once AP mode is supported */ shell_fprintf(sh, @@ -304,7 +304,7 @@ static int nrf_wifi_util_tx_stats(const struct shell *sh, vif_index); for (int i = 0; i < NRF_WIFI_FMAC_AC_MAX ; i++) { - queue = def_dev_ctx->tx_config.data_pending_txq[peer_index][i]; + queue = sys_dev_ctx->tx_config.data_pending_txq[peer_index][i]; tx_pending_pkts = nrf_wifi_utils_q_len(queue); shell_fprintf( @@ -312,7 +312,7 @@ static int nrf_wifi_util_tx_stats(const struct shell *sh, SHELL_INFO, "Outstanding tokens: ac: %d -> %d (pending_q_len: %d)\n", i, - def_dev_ctx->tx_config.outstanding_descs[i], + sys_dev_ctx->tx_config.outstanding_descs[i], tx_pending_pkts); } @@ -373,9 +373,9 @@ static int nrf_wifi_util_tx_rate(const struct shell *sh, } - status = nrf_wifi_fmac_set_tx_rate(ctx->rpu_ctx, - rate_flag, - data_rate); + status = nrf_wifi_sys_fmac_set_tx_rate(ctx->rpu_ctx, + rate_flag, + data_rate); if (status != NRF_WIFI_STATUS_SUCCESS) { shell_fprintf(sh, @@ -399,8 +399,8 @@ static int nrf_wifi_util_show_host_rpu_ps_ctrl_state(const struct shell *sh, enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; int rpu_ps_state = -1; - status = nrf_wifi_fmac_get_host_rpu_ps_ctrl_state(ctx->rpu_ctx, - &rpu_ps_state); + status = nrf_wifi_sys_fmac_get_host_rpu_ps_ctrl_state(ctx->rpu_ctx, + &rpu_ps_state); if (status != NRF_WIFI_STATUS_SUCCESS) { shell_fprintf(sh, @@ -456,7 +456,7 @@ static int nrf_wifi_util_dump_rpu_stats(const struct shell *sh, { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct rpu_op_stats stats; + struct rpu_sys_op_stats stats; enum rpu_stats_type stats_type = RPU_STATS_TYPE_ALL; int ret; @@ -490,8 +490,8 @@ static int nrf_wifi_util_dump_rpu_stats(const struct shell *sh, } fmac_dev_ctx = ctx->rpu_ctx; - memset(&stats, 0, sizeof(struct rpu_op_stats)); - status = nrf_wifi_fmac_stats_get(fmac_dev_ctx, 0, &stats); + memset(&stats, 0, sizeof(struct rpu_sys_op_stats)); + status = nrf_wifi_sys_fmac_stats_get(fmac_dev_ctx, 0, &stats); if (status != NRF_WIFI_STATUS_SUCCESS) { shell_fprintf(sh, @@ -898,7 +898,7 @@ static int nrf_wifi_util_trigger_rpu_recovery(const struct shell *sh, fmac_dev_ctx = ctx->rpu_ctx; - status = nrf_wifi_fmac_rpu_recovery_callback(fmac_dev_ctx, NULL, 0); + status = nrf_wifi_sys_fmac_rpu_recovery_callback(fmac_dev_ctx, NULL, 0); if (status != NRF_WIFI_STATUS_SUCCESS) { shell_fprintf(sh, SHELL_ERROR, @@ -964,7 +964,7 @@ static int nrf_wifi_util_rpu_recovery_info(const struct shell *sh, #endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */ SHELL_STATIC_SUBCMD_SET_CREATE( - nrf_wifi_util_subcmds, + nrf70_util, SHELL_CMD_ARG(he_ltf, NULL, "0 - 1x HE LTF\n" @@ -1069,10 +1069,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE( SHELL_SUBCMD_SET_END); -SHELL_CMD_REGISTER(wifi_util, - &nrf_wifi_util_subcmds, - "nRF Wi-Fi utility shell commands", - NULL); +SHELL_SUBCMD_ADD((nrf70), util, &nrf70_util, "nRF70 utility commands\n", NULL, 0, 0); static int nrf_wifi_util_init(void) diff --git a/drivers/wifi/nrf_wifi/src/wifi_util.h b/drivers/wifi/nrf_wifi/src/wifi_util.h index 2ab188efed4..303d5feac99 100644 --- a/drivers/wifi/nrf_wifi/src/wifi_util.h +++ b/drivers/wifi/nrf_wifi/src/wifi_util.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include struct nrf_wifi_ctx_zep_rt { diff --git a/drivers/wifi/nrf_wifi/src/wpa_supp_if.c b/drivers/wifi/nrf_wifi/src/wpa_supp_if.c index 75a6fa6c6b5..6dc3315a64c 100644 --- a/drivers/wifi/nrf_wifi/src/wpa_supp_if.c +++ b/drivers/wifi/nrf_wifi/src/wpa_supp_if.c @@ -14,7 +14,7 @@ #include #include "fmac_main.h" -#include "fmac_util.h" +#include "common/fmac_util.h" #include "wifi_mgmt.h" #include "wpa_supp_if.h" @@ -174,7 +174,7 @@ void nrf_wifi_wpa_supp_event_proc_scan_res(void *if_priv, beacon_ie_len = scan_res->beacon_ies_len; } - r = k_calloc(sizeof(*r) + ie_len + beacon_ie_len, sizeof(char)); + r = nrf_wifi_osal_mem_zalloc(sizeof(*r) + ie_len + beacon_ie_len); if (!r) { LOG_ERR("%s: Unable to allocate memory for scan result", __func__); @@ -254,7 +254,7 @@ void nrf_wifi_wpa_supp_event_proc_scan_res(void *if_priv, vif_ctx_zep->scan_in_progress = false; } - k_free(r); + nrf_wifi_osal_mem_free(r); } void nrf_wifi_wpa_supp_event_proc_auth_resp(void *if_priv, @@ -519,8 +519,8 @@ int nrf_wifi_wpa_supp_scan2(void *if_priv, struct wpa_driver_scan_params *params } } - scan_info = k_calloc(sizeof(*scan_info) + (num_freqs * sizeof(unsigned int)), - sizeof(char)); + scan_info = nrf_wifi_osal_mem_zalloc(sizeof(*scan_info) + + (num_freqs * sizeof(unsigned int))); if (!scan_info) { LOG_ERR("%s: Unable to allocate memory for scan info", __func__); @@ -563,7 +563,7 @@ int nrf_wifi_wpa_supp_scan2(void *if_priv, struct wpa_driver_scan_params *params goto out; } - status = nrf_wifi_fmac_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, scan_info); + status = nrf_wifi_sys_fmac_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, scan_info); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: Scan trigger failed", __func__); @@ -579,7 +579,7 @@ int nrf_wifi_wpa_supp_scan2(void *if_priv, struct wpa_driver_scan_params *params ret = 0; out: if (scan_info) { - k_free(scan_info); + nrf_wifi_osal_mem_free(scan_info); } k_mutex_unlock(&vif_ctx_zep->vif_lock); return ret; @@ -614,10 +614,10 @@ int nrf_wifi_wpa_supp_scan_abort(void *if_priv) goto out; } - status = nrf_wifi_fmac_abort_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + status = nrf_wifi_sys_fmac_abort_scan(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_abort_scan failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_abort_scan failed", __func__); goto out; } @@ -660,11 +660,11 @@ int nrf_wifi_wpa_supp_scan_results_get(void *if_priv) goto out; } - status = nrf_wifi_fmac_scan_res_get(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, + status = nrf_wifi_sys_fmac_scan_res_get(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, SCAN_CONNECT); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_scan_res_get failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_scan_res_get failed", __func__); goto out; } @@ -706,10 +706,10 @@ int nrf_wifi_wpa_supp_deauthenticate(void *if_priv, const char *addr, unsigned s memcpy(deauth_info.mac_addr, addr, sizeof(deauth_info.mac_addr)); - status = nrf_wifi_fmac_deauth(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &deauth_info); + status = nrf_wifi_sys_fmac_deauth(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &deauth_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_deauth failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_deauth failed", __func__); goto out; } @@ -850,7 +850,7 @@ int nrf_wifi_wpa_supp_authenticate(void *if_priv, struct wpa_driver_auth_params auth_info.nrf_wifi_flags |= NRF_WIFI_CMD_AUTHENTICATE_LOCAL_STATE_CHANGE; } - status = nrf_wifi_fmac_auth(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &auth_info); + status = nrf_wifi_sys_fmac_auth(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &auth_info); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: MLME command failed (auth): count=%d ret=%d", __func__, count, ret); @@ -931,7 +931,7 @@ int nrf_wifi_wpa_supp_associate(void *if_priv, struct wpa_driver_associate_param assoc_info.bss_max_idle_time = params->bss_max_idle_period; } - status = nrf_wifi_fmac_assoc(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &assoc_info); + status = nrf_wifi_sys_fmac_assoc(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &assoc_info); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: MLME command failed (assoc)", __func__); @@ -1025,20 +1025,20 @@ int nrf_wifi_wpa_supp_set_key(void *if_priv, const unsigned char *ifname, enum w key_info.valid_fields |= NRF_WIFI_KEY_IDX_VALID; if (alg == WPA_ALG_NONE) { - status = nrf_wifi_fmac_del_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, + status = nrf_wifi_sys_fmac_del_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &key_info, mac_addr); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_del_key failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_del_key failed", __func__); } else { ret = 0; } } else { - status = nrf_wifi_fmac_add_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, + status = nrf_wifi_sys_fmac_add_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &key_info, mac_addr); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_add_key failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_add_key failed", __func__); } else { ret = 0; } @@ -1071,10 +1071,10 @@ int nrf_wifi_wpa_supp_set_key(void *if_priv, const unsigned char *ifname, enum w key_info.nrf_wifi_flags |= NRF_WIFI_KEY_DEFAULT_TYPE_UNICAST; } - status = nrf_wifi_fmac_set_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &key_info); + status = nrf_wifi_sys_fmac_set_key(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &key_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_set_key failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_set_key failed", __func__); ret = -1; } else { ret = 0; @@ -1129,10 +1129,12 @@ int nrf_wifi_wpa_set_supp_port(void *if_priv, int authorized, char *bssid) chg_sta_info.sta_flags2.nrf_wifi_set = 1 << 1; } - status = nrf_wifi_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &chg_sta_info); + status = nrf_wifi_sys_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + &chg_sta_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_sta failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_sta failed", __func__); ret = -1; goto out; } @@ -1178,7 +1180,9 @@ int nrf_wifi_wpa_supp_signal_poll(void *if_priv, struct wpa_signal_info *si, uns nrf_wifi_osal_time_elapsed_us(vif_ctx_zep->rssi_record_timestamp_us) / 1000; if (rssi_record_elapsed_time_ms > CONFIG_NRF70_RSSI_STALE_TIMEOUT_MS) { - ret = nrf_wifi_fmac_get_station(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, bssid); + ret = nrf_wifi_sys_fmac_get_station(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + bssid); if (ret != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: Failed to send get station info command", __func__); goto out; @@ -1194,7 +1198,7 @@ int nrf_wifi_wpa_supp_signal_poll(void *if_priv, struct wpa_signal_info *si, uns si->data.signal = (int)vif_ctx_zep->rssi; } - ret = nrf_wifi_fmac_get_interface(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + ret = nrf_wifi_sys_fmac_get_interface(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (ret != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: Failed to send get interface info command", __func__); goto out; @@ -1410,7 +1414,7 @@ int nrf_wifi_nl80211_send_mlme(void *if_priv, const u8 *data, k_mutex_lock(&mgmt_tx_lock, K_FOREVER); - mgmt_tx_info = k_calloc(sizeof(*mgmt_tx_info), sizeof(char)); + mgmt_tx_info = nrf_wifi_osal_mem_zalloc(sizeof(*mgmt_tx_info)); if (!mgmt_tx_info) { LOG_ERR("%s: Unable to allocate memory", __func__); @@ -1454,12 +1458,12 @@ int nrf_wifi_nl80211_send_mlme(void *if_priv, const u8 *data, LOG_DBG("%s: Sending frame to RPU: cookie=%d wait_time=%d no_ack=%d", __func__, cookie, wait_time, noack); - status = nrf_wifi_fmac_mgmt_tx(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_mgmt_tx(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, mgmt_tx_info); if (status == NRF_WIFI_STATUS_FAIL) { - LOG_ERR("%s: nrf_wifi_fmac_mgmt_tx failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_mgmt_tx failed", __func__); goto out; } @@ -1487,7 +1491,7 @@ int nrf_wifi_nl80211_send_mlme(void *if_priv, const u8 *data, out: if (mgmt_tx_info) { - k_free(mgmt_tx_info); + nrf_wifi_osal_mem_free(mgmt_tx_info); } k_mutex_unlock(&mgmt_tx_lock); k_mutex_unlock(&vif_ctx_zep->vif_lock); @@ -1606,22 +1610,24 @@ void nrf_wifi_wpa_supp_event_get_wiphy(void *if_priv, if ((wiphy_info->params_valid & NRF_WIFI_GET_WIPHY_VALID_EXTENDED_CAPABILITIES) && rpu_ctx_zep->extended_capa == NULL) { + /* To avoid overflowing the 100 column limit */ + unsigned char ec_len = wiphy_info->extended_capabilities_len; - rpu_ctx_zep->extended_capa = k_malloc(wiphy_info->extended_capabilities_len); + rpu_ctx_zep->extended_capa = nrf_wifi_osal_mem_alloc(ec_len); if (rpu_ctx_zep->extended_capa) { memcpy(rpu_ctx_zep->extended_capa, wiphy_info->extended_capabilities, - wiphy_info->extended_capabilities_len); + ec_len); } - rpu_ctx_zep->extended_capa_mask = k_malloc(wiphy_info->extended_capabilities_len); + rpu_ctx_zep->extended_capa_mask = nrf_wifi_osal_mem_alloc(ec_len); if (rpu_ctx_zep->extended_capa_mask) { memcpy(rpu_ctx_zep->extended_capa_mask, wiphy_info->extended_capabilities_mask, - wiphy_info->extended_capabilities_len); + ec_len); } else { - free(rpu_ctx_zep->extended_capa); + nrf_wifi_osal_mem_free(rpu_ctx_zep->extended_capa); rpu_ctx_zep->extended_capa = NULL; rpu_ctx_zep->extended_capa_len = 0; } @@ -1656,10 +1662,10 @@ int nrf_wifi_supp_get_wiphy(void *if_priv) goto out; } - status = nrf_wifi_fmac_get_wiphy(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + status = nrf_wifi_sys_fmac_get_wiphy(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_get_wiphy failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_get_wiphy failed", __func__); goto out; } out: @@ -1700,11 +1706,11 @@ int nrf_wifi_supp_register_frame(void *if_priv, frame_info.frame_match.frame_match_len = match_len; memcpy(frame_info.frame_match.frame_match, match, match_len); - status = nrf_wifi_fmac_register_frame(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, + status = nrf_wifi_sys_fmac_register_frame(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &frame_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_register_frame failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_register_frame failed", __func__); goto out; } out: @@ -1843,9 +1849,9 @@ int nrf_wifi_supp_get_conn_info(void *if_priv, struct wpa_conn_info *info) fmac_dev_ctx = rpu_ctx_zep->rpu_ctx; vif_ctx_zep->conn_info = info; - ret = nrf_wifi_fmac_get_conn_info(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + ret = nrf_wifi_sys_fmac_get_conn_info(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (ret != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_get_conn_info failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_get_conn_info failed", __func__); goto out; } @@ -1965,7 +1971,7 @@ static int nrf_wifi_vif_state_change(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep, unsigned int timeout = 0; struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; int ret = -1; if (!vif_ctx_zep) { @@ -1984,18 +1990,18 @@ static int nrf_wifi_vif_state_change(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep, goto out; } - def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); - vif_ctx = def_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]; + sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx); + vif_ctx = sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]; vif_state_info.state = state; vif_state_info.if_index = vif_ctx_zep->vif_idx; vif_ctx->ifflags = false; - status = nrf_wifi_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_chg_vif_state(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &vif_state_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_vif_state failed", + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_vif_state failed", __func__); goto out; } @@ -2047,9 +2053,11 @@ static int nrf_wifi_iftype_change(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep, int chg_vif_info.iftype = iftype; vif_ctx_zep->set_if_event_received = false; vif_ctx_zep->set_if_status = 0; - status = nrf_wifi_fmac_chg_vif(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &chg_vif_info); + status = nrf_wifi_sys_fmac_chg_vif(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + &chg_vif_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_vif failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_vif failed", __func__); goto out; } @@ -2261,11 +2269,11 @@ int nrf_wifi_supp_register_mgmt_frame(void *if_priv, } memcpy(mgmt_frame_info.frame_match.frame_match, match, match_len); - status = nrf_wifi_fmac_mgmt_frame_reg(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_mgmt_frame_reg(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &mgmt_frame_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_mgmt_frame_reg failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_mgmt_frame_reg failed", __func__); goto out; } @@ -2324,9 +2332,9 @@ static int nrf_wifi_set_bss(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep, bss_info.nrf_wifi_slot = params->short_slot_time; bss_info.ap_isolate = params->isolate; - status = nrf_wifi_fmac_set_bss(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &bss_info); + status = nrf_wifi_sys_fmac_set_bss(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &bss_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_set_bss failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_set_bss failed", __func__); goto out; } @@ -2423,9 +2431,11 @@ int nrf_wifi_wpa_supp_start_ap(void *if_priv, struct wpa_driver_ap_params *param NRF_WIFI_SET_FREQ_PARAMS_CHANNEL_TYPE_VALID; vif_ctx_zep->if_carr_state = NRF_WIFI_FMAC_IF_CARR_STATE_OFF; - status = nrf_wifi_fmac_start_ap(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &start_ap_info); + status = nrf_wifi_sys_fmac_start_ap(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + &start_ap_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_start_ap failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_start_ap failed", __func__); goto out; } @@ -2474,9 +2484,11 @@ int nrf_wifi_wpa_supp_change_beacon(void *if_priv, struct wpa_driver_ap_params * nrf_wifi_set_beacon_data(params, &chg_bcn_info.beacon_data); - status = nrf_wifi_fmac_chg_bcn(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &chg_bcn_info); + status = nrf_wifi_sys_fmac_chg_bcn(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + &chg_bcn_info); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_bcn failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_bcn failed", __func__); goto out; } @@ -2511,10 +2523,10 @@ int nrf_wifi_wpa_supp_stop_ap(void *if_priv) goto out; } - status = nrf_wifi_fmac_stop_ap(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); + status = nrf_wifi_sys_fmac_stop_ap(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_stop_ap failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_stop_ap failed", __func__); goto out; } @@ -2593,7 +2605,7 @@ int nrf_wifi_sta_flags_to_nrf(int wpas_sta_flags) nrf_sta_flags |= NRF_WIFI_STA_FLAG_TDLS_PEER; } /* Note: Do not set flags > NRF_WIFI_STA_FLAG_TDLS_PEER, else - * nrf_wifi_fmac_chg_sta will fail. This is equivalent to not + * nrf_wifi_sys_fmac_chg_sta will fail. This is equivalent to not * setting WPA_DRIVER_FLAGS_FULL_AP_CLIENT_STATE flag. */ @@ -2685,16 +2697,16 @@ int nrf_wifi_wpa_supp_sta_add(void *if_priv, struct hostapd_sta_add_params *para sta_info.sta_flags2.nrf_wifi_set, sta_info.sta_flags2.nrf_wifi_mask); if (params->set) { - status = nrf_wifi_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, (struct nrf_wifi_umac_chg_sta_info *)&sta_info); } else { - status = nrf_wifi_fmac_add_sta(rpu_ctx_zep->rpu_ctx, + status = nrf_wifi_sys_fmac_add_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &sta_info); } if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_add_sta failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_add_sta failed", __func__); goto out; } @@ -2732,9 +2744,9 @@ int nrf_wifi_wpa_supp_sta_remove(void *if_priv, const u8 *addr) memcpy(del_sta.mac_addr, addr, sizeof(del_sta.mac_addr)); - status = nrf_wifi_fmac_del_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &del_sta); + status = nrf_wifi_sys_fmac_del_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &del_sta); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_del_sta failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_del_sta failed", __func__); goto out; } @@ -2781,9 +2793,9 @@ int nrf_wifi_wpa_supp_sta_set_flags(void *if_priv, const u8 *addr, LOG_DBG("%s %x, %x", __func__, chg_sta.sta_flags2.nrf_wifi_set, chg_sta.sta_flags2.nrf_wifi_mask); - status = nrf_wifi_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &chg_sta); + status = nrf_wifi_sys_fmac_chg_sta(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &chg_sta); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_chg_sta failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_chg_sta failed", __func__); goto out; } @@ -2820,10 +2832,11 @@ int nrf_wifi_wpa_supp_sta_get_inact_sec(void *if_priv, const u8 *addr) goto out; } - status = nrf_wifi_fmac_get_station(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, - (unsigned char *) addr); + status = nrf_wifi_sys_fmac_get_station(rpu_ctx_zep->rpu_ctx, + vif_ctx_zep->vif_idx, + (unsigned char *) addr); if (status != NRF_WIFI_STATUS_SUCCESS) { - LOG_ERR("%s: nrf_wifi_fmac_get_station failed", __func__); + LOG_ERR("%s: nrf_wifi_sys_fmac_get_station failed", __func__); goto out; } diff --git a/include/zephyr/drivers/wifi/nrf_wifi/off_raw_tx/off_raw_tx_api.h b/include/zephyr/drivers/wifi/nrf_wifi/off_raw_tx/off_raw_tx_api.h index b14ae39488d..4f9c13ece31 100644 --- a/include/zephyr/drivers/wifi/nrf_wifi/off_raw_tx/off_raw_tx_api.h +++ b/include/zephyr/drivers/wifi/nrf_wifi/off_raw_tx/off_raw_tx_api.h @@ -16,7 +16,6 @@ #include #include -#include "osal_api.h" /* Minimum frame size for raw packet transmission */ #define NRF_WIFI_OFF_RAW_TX_FRAME_SIZE_MIN 26 diff --git a/include/zephyr/net/ethernet.h b/include/zephyr/net/ethernet.h index c870525c2e9..b4943a34692 100644 --- a/include/zephyr/net/ethernet.h +++ b/include/zephyr/net/ethernet.h @@ -230,7 +230,8 @@ enum ethernet_config_type { ETHERNET_CONFIG_TYPE_T1S_PARAM, ETHERNET_CONFIG_TYPE_TXINJECTION_MODE, ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT, - ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT + ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT, + ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM, }; enum ethernet_qav_param_type { @@ -525,6 +526,8 @@ struct ethernet_config { enum ethernet_checksum_support chksum_support; struct ethernet_filter filter; + + uint16_t extra_tx_pkt_headroom; }; }; diff --git a/modules/nrf_wifi/bus/CMakeLists.txt b/modules/nrf_wifi/bus/CMakeLists.txt index f939ce3287c..ac9a2f0fd84 100644 --- a/modules/nrf_wifi/bus/CMakeLists.txt +++ b/modules/nrf_wifi/bus/CMakeLists.txt @@ -9,15 +9,23 @@ if(NOT DEFINED ENV{ZEPHYR_BASE}) message(FATAL_ERROR "ZEPHYR_BASE environment variable is not set. Please set it to the Zephyr base directory.") endif() +set(NRF_WIFI_DIR ${ZEPHYR_CURRENT_MODULE_DIR}) + if (CONFIG_NRF70_BUSLIB) zephyr_library_named(nrf70-buslib) zephyr_library_include_directories( inc + ${NRF_WIFI_DIR}/os_if/inc ) zephyr_library_sources( rpu_hw_if.c device.c ) + if(NOT CONFIG_WIFI_NRF70) + zephyr_library_sources( + ${NRF_WIFI_DIR}/os_if/src/osal.c + ) + endif() zephyr_library_sources_ifdef(CONFIG_NRF70_ON_QSPI qspi_if.c ) diff --git a/modules/nrf_wifi/bus/qspi_if.c b/modules/nrf_wifi/bus/qspi_if.c index 8c381ff60c5..6107a5c4157 100644 --- a/modules/nrf_wifi/bus/qspi_if.c +++ b/modules/nrf_wifi/bus/qspi_if.c @@ -24,6 +24,7 @@ #include #include "spi_nor.h" +#include "osal_api.h" /* The QSPI bus node which the NRF70 is on */ #define QSPI_IF_BUS_NODE DT_NODELABEL(qspi) @@ -1287,7 +1288,7 @@ int qspi_hl_readw(unsigned int addr, void *data) len = len + (4 * qspi_cfg->qspi_slave_latency); - rxb = k_malloc(len); + rxb = nrf_wifi_osal_mem_alloc(len); if (rxb == NULL) { LOG_ERR("%s: ERROR ENOMEM line %d", __func__, __LINE__); @@ -1306,7 +1307,7 @@ int qspi_hl_readw(unsigned int addr, void *data) *(uint32_t *)data = *(uint32_t *)(rxb + (len - 4)); - k_free(rxb); + nrf_wifi_osal_mem_free(rxb); return status; } diff --git a/modules/nrf_wifi/os/CMakeLists.txt b/modules/nrf_wifi/os/CMakeLists.txt index 8821aa1eaae..e4f9cf2a0b6 100644 --- a/modules/nrf_wifi/os/CMakeLists.txt +++ b/modules/nrf_wifi/os/CMakeLists.txt @@ -4,184 +4,16 @@ if(NOT CONFIG_WIFI_NRF70) return() endif() -zephyr_interface_library_named(nrf-wifi-interface) -zephyr_library() -set(NRF_WIFI_DIR ${ZEPHYR_CURRENT_MODULE_DIR}) - -# Translate the configuration to the OS agnostic code -target_compile_definitions( - nrf-wifi-interface - INTERFACE - $<$:NRF_WIFI_LOW_POWER> - $<$:NRF_WIFI_RPU_RECOVERY> - $<$:NRF_WIFI_AP_DEAD_DETECT_TIMEOUT=${CONFIG_NRF_WIFI_AP_DEAD_DETECT_TIMEOUT}> - $<$:NRF_WIFI_IFACE_MTU=${CONFIG_NRF_WIFI_IFACE_MTU}> - $<$:NRF70_STA_MODE> - $<$:NRF70_DATA_TX> - $<$:NRF70_RAW_DATA_TX> - $<$:NRF70_RAW_DATA_RX> - $<$:NRF70_PROMISC_DATA_RX> - $<$:NRF70_TX_DONE_WQ_ENABLED> - $<$:NRF70_RX_WQ_ENABLED> - $<$:NRF70_UTIL> - $<$:NRF70_RADIO_TEST> - $<$:NRF70_OFFLOADED_RAW_TX> - $<$:NRF70_TCP_IP_CHECKSUM_OFFLOAD> - $<$:NRF70_RPU_EXTEND_TWT_SP> - $<$:NRF70_SYSTEM_WITH_RAW_MODES> - $<$:NRF70_SCAN_ONLY> - $<$:NRF70_SYSTEM_MODE> - $<$:NRF70_2_4G_ONLY> - $<$:NRF70_LOG_VERBOSE> - $<$:NRF70_AP_MODE> - $<$:NRF_WIFI_MGMT_BUFF_OFFLOAD> - $<$:NRF_WIFI_FEAT_KEEPALIVE> - $<$:NRF_WIFI_KEEPALIVE_PERIOD_S=${CONFIG_NRF_WIFI_KEEPALIVE_PERIOD_S}> - $<$:WIFI_MGMT_RAW_SCAN_RESULTS> - $<$:NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN> - NRF70_RX_NUM_BUFS=${CONFIG_NRF70_RX_NUM_BUFS} - NRF70_MAX_TX_TOKENS=${CONFIG_NRF70_MAX_TX_TOKENS} - NRF70_RX_MAX_DATA_SIZE=${CONFIG_NRF70_RX_MAX_DATA_SIZE} - NRF70_MAX_TX_PENDING_QLEN=${CONFIG_NRF70_MAX_TX_PENDING_QLEN} - NRF70_RPU_PS_IDLE_TIMEOUT_MS=${CONFIG_NRF70_RPU_PS_IDLE_TIMEOUT_MS} - NRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS} - NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_2G_UPPER_EDGE_BACKOFF_DSSS=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_DSSS} - NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE} - NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT} - NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE} - NRF70_PCB_LOSS_2G=${CONFIG_NRF70_PCB_LOSS_2G} - NRF70_PCB_LOSS_5G_BAND1=${CONFIG_NRF70_PCB_LOSS_5G_BAND1} - NRF70_PCB_LOSS_5G_BAND2=${CONFIG_NRF70_PCB_LOSS_5G_BAND2} - NRF70_PCB_LOSS_5G_BAND3=${CONFIG_NRF70_PCB_LOSS_5G_BAND3} - NRF70_ANT_GAIN_2G=${CONFIG_NRF70_ANT_GAIN_2G} - NRF70_ANT_GAIN_5G_BAND1=${CONFIG_NRF70_ANT_GAIN_5G_BAND1} - NRF70_ANT_GAIN_5G_BAND2=${CONFIG_NRF70_ANT_GAIN_5G_BAND2} - NRF70_ANT_GAIN_5G_BAND3=${CONFIG_NRF70_ANT_GAIN_5G_BAND3} - NRF_WIFI_PS_INT_PS=${CONFIG_NRF_WIFI_PS_INT_PS} - NRF_WIFI_RPU_RECOVERY_PS_ACTIVE_TIMEOUT_MS=${CONFIG_NRF_WIFI_RPU_RECOVERY_PS_ACTIVE_TIMEOUT_MS} - NRF_WIFI_DISPLAY_SCAN_BSS_LIMIT=${CONFIG_NRF_WIFI_DISPLAY_SCAN_BSS_LIMIT} -) - -target_include_directories( - nrf-wifi-interface - INTERFACE - ${CMAKE_CURRENT_LIST_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../bus - ${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 -) - -if(CONFIG_NRF70_RADIO_TEST) - target_include_directories(nrf-wifi-interface INTERFACE - ${NRF_WIFI_DIR}/fw_if/umac_if/inc/radio_test - ) -elseif(CONFIG_NRF70_OFFLOADED_RAW_TX) - target_include_directories(nrf-wifi-interface INTERFACE - ${NRF_WIFI_DIR}/fw_if/umac_if/inc/offload_raw_tx - off_raw_tx/inc - ) -else() - target_include_directories(nrf-wifi-interface INTERFACE - ${NRF_WIFI_DIR}/fw_if/umac_if/inc/default - ) -endif() - -zephyr_library_sources( - ${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 -) - -if(CONFIG_NRF70_RADIO_TEST) - zephyr_library_sources( - ${NRF_WIFI_DIR}/fw_if/umac_if/src/radio_test/fmac_api.c - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c - ) -elseif(CONFIG_NRF70_OFFLOADED_RAW_TX) - zephyr_library_sources( - ${NRF_WIFI_DIR}/fw_if/umac_if/src/offload_raw_tx/fmac_api.c - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c - ) -else() - zephyr_library_sources( - ${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 - ) -endif() - -zephyr_library_sources_ifdef(CONFIG_NRF70_DATA_TX - ${NRF_WIFI_DIR}/fw_if/umac_if/src/tx.c - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c -) - -zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c -) - -zephyr_library_sources_ifdef(CONFIG_NRF70_PROMISC_DATA_RX - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_promisc.c -) - -zephyr_library_sources_ifdef(CONFIG_NRF70_AP_MODE - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_ap.c -) - -# Without WPA supplicant we only support scan -zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c - ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c -) +add_subdirectory(${ZEPHYR_NRF_WIFI_MODULE_DIR} nrf_wifi_osal) +zephyr_library_named(nrf-wifi-shim) +zephyr_include_directories(${CMAKE_CURRENT_LIST_DIR}) +zephyr_include_directories(${ZEPHYR_NRF_WIFI_MODULE_DIR}/os_if/inc) zephyr_library_sources( shim.c timer.c work.c ) -target_link_libraries(zephyr_interface INTERFACE nrf-wifi-interface) -target_link_libraries(nrf_wifi PRIVATE nrf70-buslib) +zephyr_library_link_libraries(nrf-wifi-osal) diff --git a/modules/nrf_wifi/os/shim.c b/modules/nrf_wifi/os/shim.c index ed6acf95846..4d82fdf2bfb 100644 --- a/modules/nrf_wifi/os/shim.c +++ b/modules/nrf_wifi/os/shim.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "shim.h" #include "work.h" @@ -27,6 +28,14 @@ #include "osal_ops.h" LOG_MODULE_REGISTER(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL); +#if defined(CONFIG_NOCACHE_MEMORY) +K_HEAP_DEFINE_NOCACHE(wifi_drv_ctrl_mem_pool, CONFIG_NRF_WIFI_CTRL_HEAP_SIZE); +K_HEAP_DEFINE_NOCACHE(wifi_drv_data_mem_pool, CONFIG_NRF_WIFI_DATA_HEAP_SIZE); +#else +K_HEAP_DEFINE(wifi_drv_ctrl_mem_pool, CONFIG_NRF_WIFI_CTRL_HEAP_SIZE); +K_HEAP_DEFINE(wifi_drv_data_mem_pool, CONFIG_NRF_WIFI_DATA_HEAP_SIZE); +#endif /* CONFIG_NOCACHE_MEMORY */ +#define WORD_SIZE 4 struct zep_shim_intr_priv *intr_priv; @@ -34,14 +43,66 @@ static void *zep_shim_mem_alloc(size_t size) { size_t size_aligned = ROUND_UP(size, 4); - return k_malloc(size_aligned); + return k_heap_aligned_alloc(&wifi_drv_ctrl_mem_pool, WORD_SIZE, size_aligned, K_FOREVER); +} + +static void *zep_shim_data_mem_alloc(size_t size) +{ + size_t size_aligned = ROUND_UP(size, 4); + + return k_heap_aligned_alloc(&wifi_drv_data_mem_pool, WORD_SIZE, size_aligned, K_FOREVER); } static void *zep_shim_mem_zalloc(size_t size) { + void *ret; + size_t bounds; + size_t size_aligned = ROUND_UP(size, 4); - return k_calloc(size_aligned, sizeof(char)); + if (size_mul_overflow(size_aligned, sizeof(char), &bounds)) { + return NULL; + } + + ret = zep_shim_mem_alloc(bounds); + if (ret != NULL) { + (void)memset(ret, 0, bounds); + } + + return ret; +} + +static void *zep_shim_data_mem_zalloc(size_t size) +{ + void *ret; + size_t bounds; + + size_t size_aligned = ROUND_UP(size, 4); + + if (size_mul_overflow(size_aligned, sizeof(char), &bounds)) { + return NULL; + } + + ret = zep_shim_data_mem_alloc(bounds); + if (ret != NULL) { + (void)memset(ret, 0, bounds); + } + + return ret; +} + +static void zep_shim_mem_free(void *buf) +{ + if (buf) { + k_heap_free(&wifi_drv_ctrl_mem_pool, buf); + } +} + +static void zep_shim_data_mem_free(void *buf) +{ + if (buf) { + k_heap_free(&wifi_drv_data_mem_pool, buf); + } } static void *zep_shim_mem_cpy(void *dest, const void *src, size_t count) @@ -118,7 +179,7 @@ static void *zep_shim_spinlock_alloc(void) { struct k_mutex *lock = NULL; - lock = k_malloc(sizeof(*lock)); + lock = zep_shim_mem_zalloc(sizeof(*lock)); if (!lock) { LOG_ERR("%s: Unable to allocate memory for spinlock", __func__); @@ -129,7 +190,7 @@ static void *zep_shim_spinlock_alloc(void) static void zep_shim_spinlock_free(void *lock) { - k_free(lock); + k_heap_free(&wifi_drv_ctrl_mem_pool, lock); } static void zep_shim_spinlock_init(void *lock) @@ -207,22 +268,25 @@ struct nwb { void (*cleanup_cb)(); unsigned char priority; bool chksum_done; +#ifdef CONFIG_NRF_WIFI_ZERO_COPY_TX + struct net_pkt *pkt; +#endif }; static void *zep_shim_nbuf_alloc(unsigned int size) { struct nwb *nbuff; - nbuff = (struct nwb *)k_calloc(sizeof(struct nwb), sizeof(char)); + nbuff = (struct nwb *)zep_shim_data_mem_zalloc(sizeof(struct nwb)); if (!nbuff) { return NULL; } - nbuff->priv = k_calloc(size, sizeof(char)); + nbuff->priv = zep_shim_data_mem_zalloc(size); if (!nbuff->priv) { - k_free(nbuff); + zep_shim_data_mem_free(nbuff); return NULL; } @@ -240,9 +304,15 @@ static void zep_shim_nbuf_free(void *nbuf) if (!nbuf) { return; } +#ifdef CONFIG_NRF_WIFI_ZERO_COPY_TX + if (((struct nwb *)nbuf)->pkt) { + net_pkt_unref(((struct nwb *)nbuf)->pkt); + ((struct nwb *)nbuf)->pkt = NULL; + } +#endif /* CONFIG_NRF_WIFI_ZERO_COPY_TX */ - k_free(((struct nwb *)nbuf)->priv); - k_free(nbuf); + zep_shim_data_mem_free(((struct nwb *)nbuf)->priv); + zep_shim_data_mem_free(nbuf); } static void zep_shim_nbuf_headroom_res(void *nbuf, unsigned int size) @@ -326,12 +396,62 @@ static void zep_shim_nbuf_set_chksum_done(void *nbuf, unsigned char chksum_done) #include #include +#ifdef CONFIG_NRF_WIFI_ZERO_COPY_TX +void *net_pkt_to_nbuf_zc(struct net_pkt *pkt) +{ + struct nwb *nbuff; + + if (!pkt || !pkt->buffer) { + LOG_DBG("Invalid packet, dropping"); + return NULL; + } + + /* Check if packet has more than one fragment */ + if (pkt->buffer->frags) { + LOG_ERR("Zero-copy only supports single buffer packets"); + return NULL; + } + + nbuff = zep_shim_nbuf_alloc(NRF_WIFI_EXTRA_TX_HEADROOM); /* Just for headers */ + if (!nbuff) { + return NULL; + } + + zep_shim_nbuf_headroom_res(nbuff, NRF_WIFI_EXTRA_TX_HEADROOM); + + /* Zero-copy: point to the single data buffer */ + /* TODO: Use API for proper cursor access? */ + nbuff->data = pkt->buffer->data; + nbuff->len = pkt->buffer->len; + + nbuff->priority = net_pkt_priority(pkt); + nbuff->chksum_done = (bool)net_pkt_is_chksum_done(pkt); + + nbuff->pkt = pkt; + /* Ref the packet so that it is not freed */ + net_pkt_ref(pkt); + + return nbuff; +} +#endif /* CONFIG_NRF_WIFI_ZERO_COPY_TX */ + void *net_pkt_to_nbuf(struct net_pkt *pkt) { struct nwb *nbuff; unsigned char *data; unsigned int len; + if (!pkt) { + return NULL; + } + +#ifdef CONFIG_NRF_WIFI_ZERO_COPY_TX + /* For zero-copy, check if packet has single buffer */ + if (pkt->buffer && !pkt->buffer->frags) { + return net_pkt_to_nbuf_zc(pkt); + } +#endif /* CONFIG_NRF_WIFI_ZERO_COPY_TX */ + len = net_pkt_get_len(pkt); nbuff = zep_shim_nbuf_alloc(len + 100); @@ -406,7 +526,7 @@ void *net_raw_pkt_from_nbuf(void *iface, void *frm, nwb_data = zep_shim_nbuf_data_get(nwb); total_len = raw_hdr_len + nwb_len; - data = (unsigned char *)k_malloc(total_len); + data = (unsigned char *)zep_shim_data_mem_zalloc(total_len); if (!data) { LOG_ERR("%s: Unable to allocate memory for sniffer data packet", __func__); goto out; @@ -428,7 +548,7 @@ void *net_raw_pkt_from_nbuf(void *iface, void *frm, } out: if (data != NULL) { - k_free(data); + zep_shim_data_mem_free(data); } if (pkt_free) { @@ -443,7 +563,7 @@ static void *zep_shim_llist_node_alloc(void) { struct zep_shim_llist_node *llist_node = NULL; - llist_node = k_calloc(sizeof(*llist_node), sizeof(char)); + llist_node = zep_shim_data_mem_zalloc(sizeof(*llist_node)); if (!llist_node) { LOG_ERR("%s: Unable to allocate memory for linked list node", __func__); @@ -457,7 +577,7 @@ static void *zep_shim_llist_node_alloc(void) static void zep_shim_llist_node_free(void *llist_node) { - k_free(llist_node); + zep_shim_data_mem_free(llist_node); } static void *zep_shim_llist_node_data_get(void *llist_node) @@ -482,7 +602,20 @@ static void *zep_shim_llist_alloc(void) { struct zep_shim_llist *llist = NULL; - llist = k_calloc(sizeof(*llist), sizeof(char)); + llist = zep_shim_data_mem_zalloc(sizeof(*llist)); + + if (!llist) { + LOG_ERR("%s: Unable to allocate memory for linked list", __func__); + } + + return llist; +} + +static void *zep_shim_ctrl_llist_alloc(void) +{ + struct zep_shim_llist *llist = NULL; + + llist = zep_shim_mem_zalloc(sizeof(*llist)); if (!llist) { LOG_ERR("%s: Unable to allocate memory for linked list", __func__); @@ -493,7 +626,12 @@ static void *zep_shim_llist_alloc(void) static void zep_shim_llist_free(void *llist) { - k_free(llist); + zep_shim_data_mem_free(llist); +} + +static void zep_shim_ctrl_llist_free(void *llist) +{ + zep_shim_mem_free(llist); } static void zep_shim_llist_init(void *llist) @@ -698,7 +836,7 @@ static void *zep_shim_bus_qspi_init(void) { struct zep_shim_bus_qspi_priv *qspi_priv = NULL; - qspi_priv = k_calloc(sizeof(*qspi_priv), sizeof(char)); + qspi_priv = zep_shim_mem_zalloc(sizeof(*qspi_priv)); if (!qspi_priv) { LOG_ERR("%s: Unable to allocate memory for qspi_priv", __func__); @@ -714,7 +852,7 @@ static void zep_shim_bus_qspi_deinit(void *os_qspi_priv) qspi_priv = os_qspi_priv; - k_free(qspi_priv); + zep_shim_mem_free(qspi_priv); } #ifdef CONFIG_NRF_WIFI_LOW_POWER @@ -789,7 +927,7 @@ static enum nrf_wifi_status zep_shim_bus_qspi_intr_reg(void *os_dev_ctx, void *c ARG_UNUSED(os_dev_ctx); - intr_priv = k_calloc(sizeof(*intr_priv), sizeof(char)); + intr_priv = zep_shim_mem_zalloc(sizeof(*intr_priv)); if (!intr_priv) { LOG_ERR("%s: Unable to allocate memory for intr_priv", __func__); @@ -805,7 +943,7 @@ static enum nrf_wifi_status zep_shim_bus_qspi_intr_reg(void *os_dev_ctx, void *c if (ret) { LOG_ERR("%s: request_irq failed", __func__); - k_free(intr_priv); + zep_shim_mem_free(intr_priv); intr_priv = NULL; goto out; } @@ -831,7 +969,7 @@ static void zep_shim_bus_qspi_intr_unreg(void *os_qspi_dev_ctx) k_work_cancel_delayable_sync(&intr_priv->work, &sync); - k_free(intr_priv); + zep_shim_mem_free(intr_priv); intr_priv = NULL; } @@ -840,7 +978,7 @@ static void *zep_shim_timer_alloc(void) { struct timer_list *timer = NULL; - timer = k_malloc(sizeof(*timer)); + timer = zep_shim_mem_zalloc(sizeof(*timer)); if (!timer) { LOG_ERR("%s: Unable to allocate memory for work", __func__); @@ -859,7 +997,7 @@ static void zep_shim_timer_init(void *timer, void (*callback)(unsigned long), un static void zep_shim_timer_free(void *timer) { - k_free(timer); + zep_shim_mem_free(timer); } static void zep_shim_timer_schedule(void *timer, unsigned long duration) @@ -907,7 +1045,9 @@ static unsigned int zep_shim_strlen(const void *str) const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops = { .mem_alloc = zep_shim_mem_alloc, .mem_zalloc = zep_shim_mem_zalloc, - .mem_free = k_free, + .data_mem_zalloc = zep_shim_data_mem_zalloc, + .mem_free = zep_shim_mem_free, + .data_mem_free = zep_shim_data_mem_free, .mem_cpy = zep_shim_mem_cpy, .mem_set = zep_shim_mem_set, .mem_cmp = zep_shim_mem_cmp, @@ -936,7 +1076,9 @@ const struct nrf_wifi_osal_ops nrf_wifi_os_zep_ops = { .llist_node_data_set = zep_shim_llist_node_data_set, .llist_alloc = zep_shim_llist_alloc, + .ctrl_llist_alloc = zep_shim_ctrl_llist_alloc, .llist_free = zep_shim_llist_free, + .ctrl_llist_free = zep_shim_ctrl_llist_free, .llist_init = zep_shim_llist_init, .llist_add_node_tail = zep_shim_llist_add_node_tail, .llist_add_node_head = zep_shim_llist_add_node_head, diff --git a/modules/nrf_wifi/os/shim.h b/modules/nrf_wifi/os/shim.h index be26fd6355e..b479f5c8df8 100644 --- a/modules/nrf_wifi/os/shim.h +++ b/modules/nrf_wifi/os/shim.h @@ -16,6 +16,8 @@ #include #include +#define NRF_WIFI_EXTRA_TX_HEADROOM 100 + /** * struct zep_shim_bus_qspi_priv - Structure to hold context information for the Linux OS * shim. diff --git a/samples/net/zperf/boards/nrf7002dk_nrf5340_cpuapp.conf b/samples/net/zperf/boards/nrf7002dk_nrf5340_cpuapp.conf index 7842b0da31e..2b7f5e48de1 100644 --- a/samples/net/zperf/boards/nrf7002dk_nrf5340_cpuapp.conf +++ b/samples/net/zperf/boards/nrf7002dk_nrf5340_cpuapp.conf @@ -1,10 +1,11 @@ # Optimized networking settings for performance CONFIG_NET_PKT_RX_COUNT=28 -CONFIG_NET_PKT_TX_COUNT=27 +CONFIG_NET_PKT_TX_COUNT=28 CONFIG_NET_BUF_RX_COUNT=28 -CONFIG_NET_BUF_TX_COUNT=54 -CONFIG_NET_BUF_DATA_SIZE=1100 -CONFIG_HEAP_MEM_POOL_SIZE=260000 +CONFIG_NET_BUF_TX_COUNT=28 +CONFIG_NRF70_RX_NUM_BUFS=16 +CONFIG_NRF_WIFI_DATA_HEAP_SIZE=30000 +CONFIG_NET_PKT_BUF_TX_DATA_POOL_SIZE=20000 CONFIG_NRF70_MAX_TX_AGGREGATION=4 CONFIG_NRF70_QSPI_LOW_POWER=n diff --git a/subsys/net/l2/ethernet/Kconfig b/subsys/net/l2/ethernet/Kconfig index a07734fc0f8..3e5d1c5bb15 100644 --- a/subsys/net/l2/ethernet/Kconfig +++ b/subsys/net/l2/ethernet/Kconfig @@ -32,6 +32,14 @@ config NET_L2_ETHERNET_MGMT Enable support net_mgmt Ethernet interface which can be used to configure at run-time Ethernet drivers and L2 settings. + +config NET_L2_ETHERNET_ACCEPT_MISMATCH_L3_L2_ADDR + bool "Accept mismatched L3 and L2 addresses" + help + If enabled, then accept packets where the L3 and L2 addresses do not + conform to RFC1122 section 3.3.6. This is useful in dealing with + buggy devices that do not follow the RFC. + config NET_VLAN bool "Virtual LAN support" select NET_L2_VIRTUAL diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index 3f369e983b5..890940f87fc 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -176,6 +176,10 @@ static inline enum net_verdict ethernet_check_ipv4_bcast_addr(struct net_pkt *pkt, struct net_eth_hdr *hdr) { + if (IS_ENABLED(CONFIG_NET_L2_ETHERNET_ACCEPT_MISMATCH_L3_L2_ADDR)) { + return NET_OK; + } + if (net_eth_is_addr_broadcast(&hdr->dst) && !(net_ipv4_is_addr_mcast((struct in_addr *)NET_IPV4_HDR(pkt)->dst) || net_ipv4_is_addr_bcast(net_pkt_iface(pkt), @@ -660,23 +664,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt) #define ethernet_update_tx_stats(...) #endif /* CONFIG_NET_STATISTICS_ETHERNET */ -static void ethernet_remove_l2_header(struct net_pkt *pkt) -{ - size_t reserve = get_reserve_ll_header_size(net_pkt_iface(pkt)); - struct net_buf *buf; - - /* Remove the buffer added in ethernet_fill_header() */ - if (reserve == 0U) { - buf = pkt->buffer; - pkt->buffer = buf->frags; - buf->frags = NULL; - - net_pkt_frag_unref(buf); - } else { - net_buf_pull(pkt->buffer, reserve); - } -} - static int ethernet_send(struct net_if *iface, struct net_pkt *pkt) { const struct ethernet_api *api = net_if_get_device(iface)->api; @@ -812,14 +799,12 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt) ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt); if (ret != 0) { eth_stats_update_errors_tx(iface); - ethernet_remove_l2_header(pkt); goto arp_error; } ethernet_update_tx_stats(iface, pkt); ret = net_pkt_get_len(pkt); - ethernet_remove_l2_header(pkt); net_pkt_unref(pkt); error: @@ -880,8 +865,15 @@ static int ethernet_l2_alloc(struct net_if *iface, struct net_pkt *pkt, size_t size, enum net_ip_protocol proto, k_timeout_t timeout) { - return net_pkt_alloc_buffer_with_reserve(pkt, size, - get_reserve_ll_header_size(iface), + size_t reserve = get_reserve_ll_header_size(iface); + struct ethernet_config config; + + if (net_eth_get_hw_config(iface, ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM, + &config) == 0) { + reserve += config.extra_tx_pkt_headroom; + } + + return net_pkt_alloc_buffer_with_reserve(pkt, size, reserve, proto, timeout); } #else diff --git a/tests/boards/nrf/nrf70/bustest/testcase.yaml b/tests/boards/nrf/nrf70/bustest/testcase.yaml index 29dc054b823..fa520202bec 100644 --- a/tests/boards/nrf/nrf70/bustest/testcase.yaml +++ b/tests/boards/nrf/nrf70/bustest/testcase.yaml @@ -1,3 +1,8 @@ +common: + build_only: true + tags: + - drivers + - wifi tests: nrf_wifi.bustest.nrf7002: sysbuild: true diff --git a/tests/drivers/wifi/nrf_wifi/testcase.yaml b/tests/drivers/wifi/nrf_wifi/testcase.yaml index f8dac0a1ea8..f1888fcefc3 100644 --- a/tests/drivers/wifi/nrf_wifi/testcase.yaml +++ b/tests/drivers/wifi/nrf_wifi/testcase.yaml @@ -7,6 +7,8 @@ common: platform_allow: - nrf7002dk/nrf5340/cpuapp tests: + nrf70.build.sta: + extra_configs: [] nrf70.build.radio_test: extra_configs: - CONFIG_NRF70_RADIO_TEST=y @@ -44,3 +46,9 @@ tests: - CONFIG_NETWORKING=n - CONFIG_WIFI_NM_WPA_SUPPLICANT=n - CONFIG_NET_L2_WIFI_MGMT=n + nrf70.build.softap: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_AP=y + nrf70.build.p2p: + extra_configs: + - CONFIG_NRF70_P2P_MODE=y diff --git a/west.yml b/west.yml index 6e39a36fb26..d4bbd738e6a 100644 --- a/west.yml +++ b/west.yml @@ -318,7 +318,7 @@ manifest: revision: b84bd7314a239f818e78f6927f5673247816df53 path: modules/bsim_hw_models/nrf_hw_models - name: nrf_wifi - revision: 0f53c9ebab526661131d5d7e73c7a6cb3b2d2e11 + revision: f8dbe23c2af8eb06b7a4bd9aa928e93d032a8578 path: modules/lib/nrf_wifi - name: open-amp revision: 52bb1783521c62c019451cee9b05b8eda9d7425f