Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedicated mem pools #2446

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions drivers/wifi/nrf_wifi/Kconfig.nrfwifi
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ config NRF70_SYSTEM_MODE_COMMON
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
config NRF70_STA_MODE
bool "nRF70 STA mode"
Expand Down Expand Up @@ -552,6 +546,16 @@ config NRF70_RSSI_STALE_TIMEOUT_MS

if NETWORKING
# Finetune defaults for certain system components used by the driver

config NRF_WIFI_CTRL_HEAP_SIZE
int "Dedicated memory pool for control path"
default 20000

config NRF_WIFI_DATA_HEAP_SIZE
int "Dedicated memory pool for data plane"
default 6000 if NRF70_SCAN_ONLY
default 100000

config SYSTEM_WORKQUEUE_STACK_SIZE
default 4096

Expand Down
7 changes: 4 additions & 3 deletions drivers/wifi/nrf_wifi/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,9 @@
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) {

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

View workflow job for this annotation

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

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/fmac_main.c:468 - fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_alloc(sizeof(struct - nrf_wifi_event_regulatory_change)); + fmac_dev_ctx->reg_change = + nrf_wifi_osal_mem_alloc(sizeof(struct nrf_wifi_event_regulatory_change));
LOG_ERR("%s: Failed to allocate memory for reg_change", __func__);
return;
}
Expand Down Expand Up @@ -675,9 +676,9 @@
nrf_wifi_fmac_dev_rem(rpu_ctx_zep->rpu_ctx);
#endif /* CONFIG_NRF70_RADIO_TEST */

k_free(rpu_ctx_zep->extended_capa);
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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/wifi/nrf_wifi/src/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,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 "
Expand Down Expand Up @@ -502,7 +502,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 */
Expand Down
7 changes: 3 additions & 4 deletions drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@

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])));

Check notice on line 115 in drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c

View workflow job for this annotation

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

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c:115 - scan_info = nrf_wifi_osal_mem_zalloc(sizeof(*scan_info) + - (num_scan_channels * - sizeof(scan_info->scan_params.center_frequency[0]))); + scan_info = nrf_wifi_osal_mem_zalloc( + sizeof(*scan_info) + + (num_scan_channels * sizeof(scan_info->scan_params.center_frequency[0])));
if (!scan_info) {
LOG_ERR("%s: Unable to allocate memory for scan_info (size: %d bytes)",
__func__,
Expand Down Expand Up @@ -226,7 +225,7 @@
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;
Expand Down
26 changes: 14 additions & 12 deletions drivers/wifi/nrf_wifi/src/wpa_supp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
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__);
Expand Down Expand Up @@ -254,7 +254,7 @@
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,
Expand Down Expand Up @@ -519,9 +519,9 @@
}
}

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)));

Check notice on line 524 in drivers/wifi/nrf_wifi/src/wpa_supp_if.c

View workflow job for this annotation

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

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wpa_supp_if.c:524 - scan_info = nrf_wifi_osal_mem_zalloc(sizeof(*scan_info) + - (num_freqs * sizeof(unsigned int))); + 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__);
ret = -ENOMEM;
Expand Down Expand Up @@ -579,7 +579,7 @@
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;
Expand Down Expand Up @@ -1410,7 +1410,7 @@

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__);
Expand Down Expand Up @@ -1487,7 +1487,7 @@

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);
Expand Down Expand Up @@ -1606,22 +1606,24 @@

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 {

Check notice on line 1625 in drivers/wifi/nrf_wifi/src/wpa_supp_if.c

View workflow job for this annotation

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

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wpa_supp_if.c:1625 - wiphy_info->extended_capabilities_mask, - ec_len); + wiphy_info->extended_capabilities_mask, ec_len);
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;
}
Expand Down
5 changes: 3 additions & 2 deletions modules/nrf_wifi/bus/qspi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <hal/nrf_gpio.h>

#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)
Expand Down Expand Up @@ -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__);
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions modules/nrf_wifi/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE
${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
)

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
Expand Down
Loading
Loading