-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -596,6 +596,14 @@ if NETWORKING | |||||
config HEAP_MEM_POOL_SIZE | ||||||
default 153000 | ||||||
|
||||||
config NRF_WIFI_CONFIG_HEAP_MEM_POOL_SIZE | ||||||
int "Dedicated memory pool for configuration" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
default 20480 | ||||||
|
||||||
config NRF_WIFI_DATA_HEAP_MEM_POOL_SIZE | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
int "Dedicated memory pool for data plane" | ||||||
default 61440 | ||||||
|
||||||
config SYSTEM_WORKQUEUE_STACK_SIZE | ||||||
default 4096 | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
@@ -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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.