diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index ab1e04e80..a156b85c9 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -541,9 +541,50 @@ config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM number. Generally the number of dynamic rx buffer should be no less than static rx buffer number if it is not 0. +choice ESP32_WIFI_TX_BUFFER + prompt "Type of WiFi TX buffers" + depends on WIFI_ENABLED + default ESP32_WIFI_DYNAMIC_TX_BUFFER + help + Select type of WiFi tx buffers and show the submenu with the number of WiFi tx buffers choice. + If "STATIC" is selected, WiFi tx buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. If "DYNAMIC" is selected, WiFi tx buffer is allocated when tx + data is delivered from LWIP to WiFi and released when tx data is sent out by WiFi. + The size of each static tx buffers is fixed to about 1.6KB and the size of dynamic tx buffers is + depend on the length of the data delivered from LWIP. + If PSRAM is enabled, "STATIC" should be selected to guarantee enough WiFi tx buffers. + If PSRAM is disabled, "DYNAMIC" should be selected to improve the utilization of RAM. + +config ESP32_WIFI_STATIC_TX_BUFFER + bool "STATIC" +config ESP32_WIFI_DYNAMIC_TX_BUFFER + bool "DYNAMIC" +endchoice + +config ESP32_WIFI_TX_BUFFER_TYPE + int + depends on WIFI_ENABLED + default 0 if ESP32_WIFI_STATIC_TX_BUFFER + default 1 if ESP32_WIFI_DYNAMIC_TX_BUFFER + +config ESP32_WIFI_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on WIFI_ENABLED + depends on ESP32_WIFI_STATIC_TX_BUFFER + range 16 64 + default 32 + help + Set the number of WiFi static tx buffers. Each buffer takes approximately 1.6KB of RAM. + The static rx buffers are allocated when esp_wifi_init is called, they are not released + until esp_wifi_deinit is called. + For each tx packet from high layer stack, WiFi driver make a copy of it. For some applications, + especially the UDP application, the high layer deliver speed is faster than the WiFi tx + speed, we may run out of static tx buffers. + config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM int "Max number of WiFi dynamic TX buffers" - depends on WIFI_ENABLED + depends on WIFI_ENABLED + depends on ESP32_WIFI_DYNAMIC_TX_BUFFER range 16 64 default 32 help @@ -553,7 +594,6 @@ config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM especially the UDP application, the high layer deliver speed is faster than the WiFi tx speed, we may run out of memory if no limitation for the dynamic tx buffer number. - config ESP32_WIFI_AMPDU_ENABLED bool "WiFi AMPDU" depends on WIFI_ENABLED diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index f48146b25..88a477f12 100755 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -97,6 +97,8 @@ typedef struct { system_event_handler_t event_handler; /**< WiFi event handler */ int static_rx_buf_num; /**< WiFi static RX buffer number */ int dynamic_rx_buf_num; /**< WiFi dynamic RX buffer number */ + int tx_buf_type; /**< WiFi TX buffer type */ + int static_tx_buf_num; /**< WiFi static TX buffer number */ int dynamic_tx_buf_num; /**< WiFi dynamic TX buffer number */ int ampdu_enable; /**< WiFi AMPDU feature enable flag */ int nvs_enable; /**< WiFi NVS flash enable flag */ @@ -104,6 +106,18 @@ typedef struct { int magic; /**< WiFi init magic number, it should be the last field */ } wifi_init_config_t; +#ifdef CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM +#define WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM +#else +#define WIFI_STATIC_TX_BUFFER_NUM 0 +#endif + +#ifdef CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM +#define WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM +#else +#define WIFI_DYNAMIC_TX_BUFFER_NUM 0 +#endif + #if CONFIG_ESP32_WIFI_AMPDU_ENABLED #define WIFI_AMPDU_ENABLED 1 #else @@ -128,7 +142,9 @@ typedef struct { .event_handler = &esp_event_send, \ .static_rx_buf_num = CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM,\ .dynamic_rx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM,\ - .dynamic_tx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM,\ + .tx_buf_type = CONFIG_ESP32_WIFI_TX_BUFFER_TYPE,\ + .static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM,\ + .dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM,\ .ampdu_enable = WIFI_AMPDU_ENABLED,\ .nvs_enable = WIFI_NVS_ENABLED,\ .nano_enable = WIFI_NANO_FORMAT_ENABLED,\ diff --git a/components/esp32/lib b/components/esp32/lib index bd53ad194..ae20d8efc 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit bd53ad194dd85885d3d41f455e9debeb9409aef9 +Subproject commit ae20d8efce9c46dea9dc949b542d8dfaa3ea136c