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

drivers: wifi: Create dedicated mem pool for Wi-Fi driver #15169

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 8 additions & 0 deletions drivers/wifi/nrf700x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,14 @@ if NETWORKING
config HEAP_MEM_POOL_SIZE
default 153000

config NRF_WIFI_CONFIG_HEAP_MEM_POOL_SIZE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
config NRF_WIFI_CONFIG_HEAP_MEM_POOL_SIZE
config NRF_WIFI_CTRL_HEAP_SIZE

int "Dedicated memory pool for configuration"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int "Dedicated memory pool for configuration"
int "Dedicated memory pool for control path"

default 20480

config NRF_WIFI_DATA_HEAP_MEM_POOL_SIZE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
config NRF_WIFI_DATA_HEAP_MEM_POOL_SIZE
config NRF_WIFI_DATA_HEAP_SIZE

int "Dedicated memory pool for data plane"
default 61440

config SYSTEM_WORKQUEUE_STACK_SIZE
default 4096

Expand Down
69 changes: 66 additions & 3 deletions drivers/wifi/nrf700x/src/shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/sys/math_extras.h>

#include "rpu_hw_if.h"
#include "shim.h"
Expand All @@ -27,19 +28,79 @@
#include "qspi_if.h"

LOG_MODULE_REGISTER(wifi_nrf, CONFIG_WIFI_NRF700X_LOG_LEVEL);
#if defined(CONFIG_NOCACHE_MEMORY)
K_HEAP_DEFINE_NOCACHE(wifi_drv_ctrl_mem_pool, CONFIG_NRF_WIFI_CONFIG_HEAP_MEM_POOL_SIZE);
K_HEAP_DEFINE_NOCACHE(wifi_drv_data_mem_pool, CONFIG_NRF_WIFI_DATA_HEAP_MEM_POOL_SIZE);
#else
K_HEAP_DEFINE(wifi_drv_ctrl_mem_pool, CONFIG_NRF_WIFI_CONFIG_HEAP_MEM_POOL_SIZE);
K_HEAP_DEFINE(wifi_drv_data_mem_pool, CONFIG_NRF_WIFI_DATA_HEAP_MEM_POOL_SIZE);
#endif /* CONFIG_NOCACHE_MEMORY */
#define WORD_SIZE 4

struct zep_shim_intr_priv *intr_priv;

static void *zep_shim_mem_alloc(size_t size)
{
size = (size + 4) & 0xfffffffc;
return k_malloc(size);
return k_heap_aligned_alloc(&wifi_drv_ctrl_mem_pool, WORD_SIZE, size, K_FOREVER);
}

static void *zep_shim_data_mem_alloc(size_t size)
{
size = (size + 4) & 0xfffffffc;
return k_heap_aligned_alloc(&wifi_drv_data_mem_pool, WORD_SIZE, size, K_FOREVER);
}

static void *zep_shim_mem_zalloc(size_t size)
{
void *ret;
size_t bounds;

size = (size + 4) & 0xfffffffc;

if (size_mul_overflow(size, sizeof(char), &bounds)) {
rado17 marked this conversation as resolved.
Show resolved Hide resolved
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 = (size + 4) & 0xfffffffc;
return k_calloc(size, sizeof(char));

if (size_mul_overflow(size, 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, ISO C semantics are followed in Zephyr.

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)
Expand Down Expand Up @@ -884,7 +945,9 @@ static unsigned int zep_shim_strlen(const void *str)
static 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,
Expand Down
2 changes: 1 addition & 1 deletion samples/wifi/shell/overlay-zperf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CONFIG_NET_PKT_RX_COUNT=30
CONFIG_NET_PKT_TX_COUNT=29
CONFIG_NET_BUF_RX_COUNT=30
CONFIG_NET_BUF_TX_COUNT=58
CONFIG_HEAP_MEM_POOL_SIZE=230000
#CONFIG_HEAP_MEM_POOL_SIZE=140000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove commented code

CONFIG_NET_BUF_DATA_SIZE=1100
CONFIG_NRF700X_QSPI_LOW_POWER=n
# To enable optimization configuration options
Expand Down
4 changes: 2 additions & 2 deletions samples/wifi/shell/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ CONFIG_NET_PKT_TX_COUNT=8
# tuned for performance, but this will be revisited in the future.
CONFIG_NET_BUF_RX_COUNT=16
CONFIG_NET_BUF_TX_COUNT=16
CONFIG_NET_BUF_DATA_SIZE=128
CONFIG_NET_BUF_DATA_SIZE=1500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? Default config is only for ping

CONFIG_NRF700X_RX_NUM_BUFS=16
CONFIG_NRF700X_MAX_TX_AGGREGATION=4
# nRF700x is main consumer: (16 + 8) * 1600 = ~40KB + ~40KB control path (experimental)
CONFIG_HEAP_MEM_POOL_SIZE=80000
CONFIG_HEAP_MEM_POOL_SIZE=65000
CONFIG_NET_TC_TX_COUNT=1

CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=4
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ manifest:
- name: nrfxlib
repo-path: sdk-nrfxlib
path: nrfxlib
revision: cfcb4b065b963cb940fb3d41295ba78f55e7363f
revision: pull/1319/head
- name: trusted-firmware-m
repo-path: sdk-trusted-firmware-m
path: modules/tee/tf-m/trusted-firmware-m
Expand Down
Loading