From 749e48e48a552f8d398f401ea35b00e0e5876867 Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Wed, 11 Dec 2024 18:33:37 +0800 Subject: [PATCH 1/5] drivers: wifi: nxp: add heap for NXP Wi-Fi Use HEAP_MEM_POOL_ADD_SIZE_ to add heap for NXP Wi-Fi. For supplicant case, define less heap, as CONFIG_HEAP_MEM_POOL_ADD_SIZE_HOSTAP and CONFIG_HEAP_MEM_POOL_ADD_SIZE_SOCKETPAIR are also enabled. Signed-off-by: Maochen Wang --- drivers/wifi/nxp/Kconfig.nxp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/wifi/nxp/Kconfig.nxp b/drivers/wifi/nxp/Kconfig.nxp index e68237a1dae5b5..06860b192c777b 100644 --- a/drivers/wifi/nxp/Kconfig.nxp +++ b/drivers/wifi/nxp/Kconfig.nxp @@ -17,6 +17,10 @@ if WIFI_NXP module = WIFI_NXP +config HEAP_MEM_POOL_ADD_SIZE_NXP_WIFI + def_int 25984 if WIFI_NM_WPA_SUPPLICANT + def_int 51200 + config WIFI_MGMT_SCAN_CHAN_MAX_MANUAL default 50 From 0702b42d77604359d99c5b40e81d86870750974b Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Wed, 11 Dec 2024 18:35:59 +0800 Subject: [PATCH 2/5] hostap: increase the default heap size of hostapd case Hostapd consumes more heap than supplicant AP case, so increase the default value of hostapd case. Signed-off-by: Maochen Wang --- modules/hostap/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig index 2e50cea2154c9a..4ef011496702f2 100644 --- a/modules/hostap/Kconfig +++ b/modules/hostap/Kconfig @@ -25,7 +25,8 @@ if WIFI_NM_WPA_SUPPLICANT config HEAP_MEM_POOL_ADD_SIZE_HOSTAP def_int 85000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE && !MBEDTLS_ENABLE_HEAP - def_int 40000 if WIFI_NM_WPA_SUPPLICANT_AP || WIFI_NM_HOSTAPD_AP + def_int 85000 if WIFI_NM_HOSTAPD_AP + def_int 40000 if WIFI_NM_WPA_SUPPLICANT_AP # 8192 for MbedTLS heap def_int 21808 if MBEDTLS_ENABLE_HEAP # 30K is mandatory, but might need more for long duration use cases From b6bfeac269d8816c9f220d189756359af0607ef3 Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Wed, 11 Dec 2024 18:40:25 +0800 Subject: [PATCH 3/5] samples: wifi: shell: remove CONFIG_HEAP_MEM_POOL_SIZE for RW612 Remove CONFIG_HEAP_MEM_POOL_SIZE for RW612, it will use HEAP_MEM_POOL_ADD_SIZE_ way to add all module's heap size together, to better control heap size for different case. Signed-off-by: Maochen Wang --- samples/net/wifi/shell/boards/frdm_rw612.conf | 1 - samples/net/wifi/shell/boards/rd_rw612_bga.conf | 1 - 2 files changed, 2 deletions(-) diff --git a/samples/net/wifi/shell/boards/frdm_rw612.conf b/samples/net/wifi/shell/boards/frdm_rw612.conf index 51009115645a79..2b17e4ea9ac832 100644 --- a/samples/net/wifi/shell/boards/frdm_rw612.conf +++ b/samples/net/wifi/shell/boards/frdm_rw612.conf @@ -20,7 +20,6 @@ CONFIG_LOG_PRINTK=n CONFIG_THREAD_CUSTOM_DATA=y CONFIG_EVENTS=y CONFIG_SYS_HEAP_AUTO=y -CONFIG_HEAP_MEM_POOL_SIZE=122880 CONFIG_SCHED_MULTIQ=y CONFIG_ZVFS_OPEN_MAX=30 diff --git a/samples/net/wifi/shell/boards/rd_rw612_bga.conf b/samples/net/wifi/shell/boards/rd_rw612_bga.conf index f963bd1969eb6b..b3880cc0670542 100644 --- a/samples/net/wifi/shell/boards/rd_rw612_bga.conf +++ b/samples/net/wifi/shell/boards/rd_rw612_bga.conf @@ -20,7 +20,6 @@ CONFIG_LOG_PRINTK=n CONFIG_THREAD_CUSTOM_DATA=y CONFIG_EVENTS=y CONFIG_SYS_HEAP_AUTO=y -CONFIG_HEAP_MEM_POOL_SIZE=122880 CONFIG_SCHED_MULTIQ=y CONFIG_ZVFS_OPEN_MAX=30 From bef518c4dc8612e11352b91cac234c5ec4ae3cd1 Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Wed, 11 Dec 2024 18:48:12 +0800 Subject: [PATCH 4/5] net: sockets: choose SOCKETPAIR_HEAP when MEM_POOL enabled Don't check 'HEAP_MEM_POOL_SIZE != 0', as HEAP_MEM_POOL_SIZE might be 0, but HEAP_MEM_POOL_ADD_SIZE_xxx is defined, which means the actual heap size is not zero. So check KERNEL_MEM_POOL instead. Signed-off-by: Maochen Wang --- subsys/net/lib/sockets/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/sockets/Kconfig b/subsys/net/lib/sockets/Kconfig index 53d56b5a61723e..b2fb9eb57392c5 100644 --- a/subsys/net/lib/sockets/Kconfig +++ b/subsys/net/lib/sockets/Kconfig @@ -340,7 +340,7 @@ config NET_SOCKETPAIR_BUFFER_SIZE choice prompt "Memory management for socketpair" - default NET_SOCKETPAIR_HEAP if HEAP_MEM_POOL_SIZE != 0 + default NET_SOCKETPAIR_HEAP if KERNEL_MEM_POOL config NET_SOCKETPAIR_STATIC bool "Pre-allocate memory statically" From f86f1f30a97ca2b905093cc14d17d04ab6cf3f6f Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Thu, 12 Dec 2024 15:29:32 +0800 Subject: [PATCH 5/5] samples: wifi: shell: use MBEDTLS_ENABLE_HEAP for RW612 For the latest upstream, if MBEDTLS_ENABLE_HEAP is not enabled, it will default select MBEDTLS_PSA_STATIC_KEY_SLOTS, and consume extra SRAM for about 35KB. Therefore, default enable MBEDTLS_ENABLE_HEAP. Signed-off-by: Maochen Wang --- samples/net/wifi/shell/boards/overlay_hostap_rw612.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/net/wifi/shell/boards/overlay_hostap_rw612.conf b/samples/net/wifi/shell/boards/overlay_hostap_rw612.conf index eb79c28e55dc7d..79fa9b7ed39171 100644 --- a/samples/net/wifi/shell/boards/overlay_hostap_rw612.conf +++ b/samples/net/wifi/shell/boards/overlay_hostap_rw612.conf @@ -25,7 +25,9 @@ CONFIG_ENTROPY_GENERATOR=y CONFIG_MBEDTLS_PSA_CRYPTO_C=y CONFIG_MBEDTLS_ENTROPY_C=y CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 -CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=80000 +# mbedtls heap for enterprise case +CONFIG_MBEDTLS_ENABLE_HEAP=y +CONFIG_MBEDTLS_HEAP_SIZE=69952 #priority CONFIG_WIFI_NM_WPA_SUPPLICANT_WQ_PRIO=3