Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-16 Thread via GitHub


fdcavalcanti commented on code in PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#discussion_r2343988365


##
arch/xtensa/src/common/espressif/esp_wifi_api.c:
##
@@ -0,0 +1,2158 @@
+/
+ * arch/xtensa/src/common/espressif/esp_wifi_api.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+
+#include "esp_mac.h"
+#include "esp_wifi_types_generic.h"
+#include "esp_wifi.h"
+#include "esp_private/wifi.h"
+
+#include "esp_wifi_utils.h"
+#include "esp_wifi_api.h"
+
+/
+ * Pre-processor Definitions
+ /
+
+#define WIFI_CONNECT_TIMEOUT   CONFIG_ESPRESSIF_WIFI_CONNECT_TIMEOUT
+#define WIFI_CONNECT_RETRY_CNT 3
+
+#define ESP_WIFI_11B_MAX_BITRATE   11
+#define ESP_WIFI_11G_MAX_BITRATE   54
+#define ESP_WIFI_11N_MCS7_HT20_BITRATE 72
+#define ESP_WIFI_11N_MCS7_HT40_BITRATE 150
+
+/* Number of fractional bits in values returned by rtc_clk_cal */
+
+#define RTC_CLK_CAL_FRACT 19
+
+#define PWD_MAX_LEN (64)
+
+/
+ * Private Types
+ /
+
+/
+ * Public Functions
+ /
+
+/
+ * Name: esp_wifi_api_adapter_deinit
+ *
+ * Description:
+ *   De-initialize Wi-Fi adapter, freeing all resources allocated by
+ *   esp_wifi_init. Also stops the Wi-Fi task.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   OK on success; Negated errno on failure.
+ *
+ /
+
+int esp_wifi_api_adapter_deinit(void)
+{
+  int ret;
+
+  ret = esp_wifi_deinit();
+  if (ret)
+{
+  ret = esp_wifi_to_errno(ret);
+  wlerr("Failed to deinitialize Wi-Fi error=%d\n", ret);
+  return ret;
+}
+
+  return ret;
+}
+
+/
+ * Name: esp_wifi_api_adapter_init
+ *
+ * Description:
+ *   Initialize the Wi-Fi driver, control structure, buffers and Wi-Fi task.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   OK on success; Negated errno on failure.
+ *
+ /
+
+int esp_wifi_api_adapter_init(void)
+{
+  int ret;
+  wifi_init_config_t wifi_cfg = WIFI_INIT_CONFIG_DEFAULT();
+
+  esp_wifi_lock(true);
+
+  esp_evt_work_init();
+
+  wifi_cfg.nvs_enable = 0;
+
+#ifdef CONFIG_ESPRESSIF_WIFI_AMPDU_TX_ENABLED
+  wifi_cfg.ampdu_tx_enable = 1;
+#else
+  wifi_cfg.ampdu_tx_enable = 0;
+#endif
+
+#ifdef CONFIG_ESPRESSIF_WIFI_AMPDU_RX_ENABLED
+  wifi_cfg.ampdu_rx_enable = 1;
+#else
+  wifi_cfg.ampdu_rx_enable = 0;
+#endif
+
+#ifdef CONFIG_ESPRESSIF_WIFI_STA_DISCONNECT_PM
+  wifi_cfg.sta_disconnected_pm = true;
+#else
+  wifi_cfg.sta_disconnected_pm = false;
+#endif
+
+  wifi_cfg.rx_ba_win  = CONFIG_ESPRESSIF_WIFI_TX_BA_WIN;
+  wifi_cfg.static_rx_buf_num  = CONFIG_ESPRESSIF_WIFI_STATIC_RX_BUFFER_NUM;
+  wifi_cfg.static_tx_buf_num  = CONFIG_ESPRESSIF_WIFI_STATIC_TX_BUFFER_NUM;
+  wifi_cfg.dynamic_rx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_RX_BUFFER_NUM;
+  wifi_cfg.dynamic_tx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER_NUM;
+  wifi_cfg.tx_buf_type= CONFIG_ESPRESSIF_WIFI_TX_BUFFER_TYPE;
+
+  ret = esp_wifi_init(&wifi_cfg);
+  if (ret)
+{
+  wlerr("Failed to initialize Wi-Fi error=%d\n", ret);
+  ret = esp_wifi_to_errno(ret);
+  goto errout_init_wi

Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-13 Thread via GitHub


xiaoxiang781216 merged PR #17008:
URL: https://github.com/apache/nuttx/pull/17008


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


simbit18 commented on code in PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#discussion_r2344252312


##
arch/xtensa/src/common/espressif/Kconfig:
##
@@ -1288,49 +1319,182 @@ config ESPRESSIF_WIFI_ENABLE_SAE_H2E
---help---
Select this option to enable SAE-H2E
 
-config ESP_WIFI_ENABLE_WPA3_OWE_STA
+config ESPRESSIF_WIFI_SOFTAP_SAE_SUPPORT
+   bool "Enable WPA3 Personal(SAE) SoftAP"
+   default y
+   depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
+   depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
+   ---help---
+   Select this option to enable SAE support in softAP mode.
+
+config ESPRESSIF_WIFI_ENABLE_WPA3_OWE_STA
bool "Enable OWE STA"
default y
---help---
Select this option to allow the device to establish OWE 
connection with eligible AP's.
PMF (Protected Management Frames) is a prerequisite feature for 
a WPA3 connection, it needs to be
explicitly configured before attempting connection. Please 
refer to the Wi-Fi Driver API Guide for details.
 
-config ESPRESSIF_WIFI_STATIC_RXBUF_NUM
-   int "Wi-Fi static RX buffer number"
+choice ESPRESSIF_WIFI_MGMT_RX_BUFFER
+   prompt "Type of WiFi RX MGMT buffers"
+   default ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   ---help---
+   Select type of WiFi RX MGMT buffers:
+
+   If "Static" is selected, WiFi RX MGMT buffers are allocated 
when WiFi is initialized and released
+   when WiFi is de-initialized. The size of each static RX MGMT 
buffer is fixed to about 500 Bytes.
+
+   If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated 
as needed when a MGMT data frame is
+   received. The MGMT buffer is freed after the MGMT data frame 
has been processed by the WiFi driver.
+
+   config ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   bool "Static"
+   config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
+   bool "Dynamic"
+endchoice
+
+config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER_TYPE
+   int
+   default 0 if ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   default 1 if ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
+
+config ESPRESSIF_WIFI_STATIC_RX_BUFFER_NUM
+   int "Max number of WiFi static RX buffers"
+   range 2 25
default 10
+   ---help---
+   Set the number of WiFi static RX buffers. Each buffer takes 
approximately 1.6KB of RAM.
+   The static rx buffers are allocated when esp_wifi_init is 
called, they are not freed
+   until esp_wifi_deinit is called.
 
-config ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM
-   int "Wi-Fi dynamic RX buffer number"
+   WiFi hardware use these buffers to receive all 802.11 frames.
+   A higher number may allow higher throughput but increases 
memory use. If ESPRESSIF_WIFI_AMPDU_RX_ENABLED
+   is enabled, this value is recommended to set equal or bigger 
than ESPRESSIF_WIFI_RX_BA_WIN in order to
+   achieve better throughput and compatibility with both stations 
and APs.
+
+config ESPRESSIF_WIFI_DYNAMIC_RX_BUFFER_NUM
+   int "Max number of WiFi dynamic RX buffers"
default 32
+   ---help---
+   Set the number of WiFi dynamic RX buffers, 0 means unlimited RX 
buffers will be allocated
+   (provided sufficient free RAM). The size of each dynamic RX 
buffer depends on the size of
+   the received data frame.
 
-config ESPRESSIF_WIFI_DYNAMIC_TXBUF_NUM
-   int "Wi-Fi dynamic TX buffer number"
+   For each received data frame, the WiFi driver makes a copy to 
an RX buffer and then delivers
+   it to the high layer TCP/IP stack. The dynamic RX buffer is 
freed after the higher layer has
+   successfully received the data frame.
+
+   For some applications, WiFi data frames may be received faster 
than the application can
+   process them. In these cases we may run out of memory if RX 
buffer number is unlimited (0).
+
+   If a dynamic RX buffer limit is set, it should be at least the 
number of static RX buffers.
+
+choice ESPRESSIF_WIFI_TX_BUFFER
+   prompt "Type of WiFi TX buffers"
+   default ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER
+   ---help---
+   Select type of WiFi TX buffers:
+
+   If "Static" is selected, WiFi TX buffers are allocated when 
WiFi is initialized and released
+   when WiFi is de-initialized. The size of each static TX buffer 
is fixed to about 1.6KB.
+
+   If "Dynamic" is selected, each WiFi TX buffer is allocated as 
needed when a data frame is
+   delivered to the Wifi driver from the TCP/IP stack. The buffer 
is freed after the data frame
+   has been sent by the WiFi driver. The size of each dynamic TX 
buffer depends on the length
+   of 

Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


simbit18 commented on code in PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#discussion_r2344248120


##
arch/xtensa/src/common/espressif/Kconfig:
##
@@ -1288,49 +1319,182 @@ config ESPRESSIF_WIFI_ENABLE_SAE_H2E
---help---
Select this option to enable SAE-H2E
 
-config ESP_WIFI_ENABLE_WPA3_OWE_STA
+config ESPRESSIF_WIFI_SOFTAP_SAE_SUPPORT
+   bool "Enable WPA3 Personal(SAE) SoftAP"
+   default y
+   depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
+   depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
+   ---help---
+   Select this option to enable SAE support in softAP mode.
+
+config ESPRESSIF_WIFI_ENABLE_WPA3_OWE_STA
bool "Enable OWE STA"
default y
---help---
Select this option to allow the device to establish OWE 
connection with eligible AP's.
PMF (Protected Management Frames) is a prerequisite feature for 
a WPA3 connection, it needs to be
explicitly configured before attempting connection. Please 
refer to the Wi-Fi Driver API Guide for details.
 
-config ESPRESSIF_WIFI_STATIC_RXBUF_NUM
-   int "Wi-Fi static RX buffer number"
+choice ESPRESSIF_WIFI_MGMT_RX_BUFFER
+   prompt "Type of WiFi RX MGMT buffers"
+   default ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   ---help---
+   Select type of WiFi RX MGMT buffers:
+
+   If "Static" is selected, WiFi RX MGMT buffers are allocated 
when WiFi is initialized and released
+   when WiFi is de-initialized. The size of each static RX MGMT 
buffer is fixed to about 500 Bytes.
+
+   If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated 
as needed when a MGMT data frame is
+   received. The MGMT buffer is freed after the MGMT data frame 
has been processed by the WiFi driver.
+
+   config ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   bool "Static"
+   config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
+   bool "Dynamic"

Review Comment:
   @fdcavalcanti remove extra tabs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


fdcavalcanti commented on PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#issuecomment-3284980965

   @acassis I think a "check other occurrences" would have sufficed! :)
   But thanks for the review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


acassis commented on PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#issuecomment-3284998572

   > @acassis I think a "check other occurrences" would have sufficed! :) But 
thanks for the review.
   
   Agreed! Or just "s/if (ret)/if (ret < 0)/g" if you use a good editor :-D
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


acassis commented on code in PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#discussion_r2344003589


##
arch/xtensa/src/common/espressif/esp_wifi_event_handler.c:
##
@@ -0,0 +1,359 @@
+/
+ * arch/xtensa/src/common/espressif/esp_wifi_event_handler.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "esp_wifi.h"
+
+#include "esp_wifi_utils.h"
+#include "esp_wifi_api.h"
+
+#ifndef CONFIG_SCHED_LPWORK
+#  error "CONFIG_SCHED_LPWORK must be defined"
+#endif
+
+/
+ * Pre-processor Definitions
+ /
+
+/* CONFIG_POWER_SAVE_MODEM */
+
+#if defined(CONFIG_ESPRESSIF_POWER_SAVE_MIN_MODEM)
+#  define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM
+#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM)
+#  define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM
+#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_NONE)
+#  define DEFAULT_PS_MODE WIFI_PS_NONE
+#else
+#  define DEFAULT_PS_MODE WIFI_PS_NONE
+#endif
+
+/
+ * Private Types
+ /
+
+/* Wi-Fi event notification private data */
+
+struct wifi_notify
+{
+  bool assigned;/* Flag indicate if it is used */
+  pid_t pid;/* Signal's target thread PID */
+  struct sigevent event;/* Signal event private data */
+  struct sigwork_s work;/* Signal work private data */
+};
+
+/* Wi-Fi event private data */
+
+struct evt_adpt
+{
+  sq_entry_t entry; /* Sequence entry */
+  wifi_event_t id;  /* Event ID */
+  uint8_t buf[0];   /* Event private data */
+};
+
+/
+ * Private Data
+ /
+
+static struct wifi_notify g_wifi_notify[WIFI_EVENT_MAX];
+static struct work_s g_wifi_evt_work;
+static sq_queue_t g_wifi_evt_queue;
+static spinlock_t g_lock;
+
+/
+ * Private Functions
+ /
+
+/
+ * Name: esp_reconnect_work_cb
+ *
+ * Description:
+ *   Function called by a work queue to reconnect to Wi-Fi in case of
+ *   a disconnection event and WIFI_REASON_ASSOC_LEAVE reason.
+ *   Must check if the failure_retry_cnt is not 0, otherwise it may
+ *   reconnect when not desired, such as when the user has actually
+ *   asked to disconnect from the AP.
+ *
+ * Input Parameters:
+ *   arg - Not used.
+ *
+ * Returned Value:
+ *   None.
+ *
+ /
+
+#ifdef ESP_WLAN_HAS_STA
+static void esp_reconnect_work_cb(void *arg)
+{
+  UNUSED(arg);
+  int ret;
+  wifi_config_t wifi_config;
+
+  esp_wifi_get_config(WIFI_IF_STA, &wifi_config);
+  if (wifi_config.sta.failure_retry_cnt == 0)
+{
+  wlinfo("Reconnect to Wi-Fi on callback: failure_retry_cnt is 0\n");
+  return;
+}
+
+  ret = esp_wifi_sta_connect();
+  if (ret < 0)
+{
+  wlerr("Failed to reconnect to Wi-Fi on callback\n");
+}
+}
+#endif /* ESP_WLAN_HAS_STA */
+
+/
+ * Name: esp_evt_work_cb
+ *
+ * Description:
+ *   Process Wi-Fi events.
+ *
+ * Input Parameters:
+ *   arg - Not used.
+ *
+ * Returned Value:
+ *   None.
+ *
+ /
+
+static void esp_evt_work_cb(void *arg)
+{
+  int ret;
+  irqstate_t 

Re: [PR] arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3 [nuttx]

2025-09-12 Thread via GitHub


simbit18 commented on code in PR #17008:
URL: https://github.com/apache/nuttx/pull/17008#discussion_r2343356918


##
arch/xtensa/src/common/espressif/Kconfig:
##
@@ -1288,49 +1319,182 @@ config ESPRESSIF_WIFI_ENABLE_SAE_H2E
---help---
Select this option to enable SAE-H2E
 
-config ESP_WIFI_ENABLE_WPA3_OWE_STA
+config ESPRESSIF_WIFI_SOFTAP_SAE_SUPPORT
+   bool "Enable WPA3 Personal(SAE) SoftAP"
+   default y
+   depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
+   depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
+   ---help---
+   Select this option to enable SAE support in softAP mode.
+
+config ESPRESSIF_WIFI_ENABLE_WPA3_OWE_STA
bool "Enable OWE STA"
default y
---help---
Select this option to allow the device to establish OWE 
connection with eligible AP's.
PMF (Protected Management Frames) is a prerequisite feature for 
a WPA3 connection, it needs to be
explicitly configured before attempting connection. Please 
refer to the Wi-Fi Driver API Guide for details.
 
-config ESPRESSIF_WIFI_STATIC_RXBUF_NUM
-   int "Wi-Fi static RX buffer number"
+choice ESPRESSIF_WIFI_MGMT_RX_BUFFER
+   prompt "Type of WiFi RX MGMT buffers"
+   default ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   help
+   Select type of WiFi RX MGMT buffers:
+
+   If "Static" is selected, WiFi RX MGMT buffers are allocated 
when WiFi is initialized and released
+   when WiFi is de-initialized. The size of each static RX MGMT 
buffer is fixed to about 500 Bytes.
+
+   If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated 
as needed when a MGMT data frame is
+   received. The MGMT buffer is freed after the MGMT data frame 
has been processed by the WiFi driver.
+
+   config ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   bool "Static"
+   config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
+   bool "Dynamic"
+endchoice
+
+config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER_TYPE
+   int
+   default 0 if ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
+   default 1 if ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
+
+config ESPRESSIF_WIFI_STATIC_RX_BUFFER_NUM
+   int "Max number of WiFi static RX buffers"
+   range 2 25
default 10
+   ---help---
+   Set the number of WiFi static RX buffers. Each buffer takes 
approximately 1.6KB of RAM.
+   The static rx buffers are allocated when esp_wifi_init is 
called, they are not freed
+   until esp_wifi_deinit is called.
+
+   WiFi hardware use these buffers to receive all 802.11 frames.
+   A higher number may allow higher throughput but increases 
memory use. If ESPRESSIF_WIFI_AMPDU_RX_ENABLED
+   is enabled, this value is recommended to set equal or bigger 
than ESPRESSIF_WIFI_RX_BA_WIN in order to
+   achieve better throughput and compatibility with both stations 
and APs.
 
-config ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM
-   int "Wi-Fi dynamic RX buffer number"
+config ESPRESSIF_WIFI_DYNAMIC_RX_BUFFER_NUM
+   int "Max number of WiFi dynamic RX buffers"
default 32
+   ---help---
+   Set the number of WiFi dynamic RX buffers, 0 means unlimited RX 
buffers will be allocated
+   (provided sufficient free RAM). The size of each dynamic RX 
buffer depends on the size of
+   the received data frame.
+
+   For each received data frame, the WiFi driver makes a copy to 
an RX buffer and then delivers
+   it to the high layer TCP/IP stack. The dynamic RX buffer is 
freed after the higher layer has
+   successfully received the data frame.
+
+   For some applications, WiFi data frames may be received faster 
than the application can
+   process them. In these cases we may run out of memory if RX 
buffer number is unlimited (0).
+
+   If a dynamic RX buffer limit is set, it should be at least the 
number of static RX buffers.
+
+choice ESPRESSIF_WIFI_TX_BUFFER
+   prompt "Type of WiFi TX buffers"
+   default ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER
+   help
+   Select type of WiFi TX buffers:
+
+   If "Static" is selected, WiFi TX buffers are allocated when 
WiFi is initialized and released
+   when WiFi is de-initialized. The size of each static TX buffer 
is fixed to about 1.6KB.
+
+   If "Dynamic" is selected, each WiFi TX buffer is allocated as 
needed when a data frame is
+   delivered to the Wifi driver from the TCP/IP stack. The buffer 
is freed after the data frame
+   has been sent by the WiFi driver. The size of each dynamic TX 
buffer depends on the length
+   of each data frame sent by the TCP/IP layer.
+
+   If PSRAM is enabled, "Static" should b