Add WiFi static and dynamic tx buffer choice

If static tx buffer is selected, WiFi tx buffers are allocated when WiFi is initialized and released

    when WiFi is de-initialized. If dynamic tx buffer 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.
This commit is contained in:
XiaXiaotian 2017-03-14 21:03:41 +08:00
parent 73612b004f
commit 4f89cc73e6
3 changed files with 60 additions and 4 deletions

View file

@ -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

View file

@ -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,\

@ -1 +1 @@
Subproject commit bd53ad194dd85885d3d41f455e9debeb9409aef9
Subproject commit ae20d8efce9c46dea9dc949b542d8dfaa3ea136c