From f9b7fa964ca306f0207d65023c3611628ae298b0 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Wed, 26 Jul 2023 11:47:33 +0800 Subject: [PATCH 1/4] feat(esp_wifi):static buf for management,control,qos null,null data rx packet --- .../esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld | 4 +-- components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 8 ++--- components/esp_wifi/Kconfig | 34 +++++++++++++++++++ components/esp_wifi/include/esp_wifi.h | 10 ++++++ components/esp_wifi/lib | 2 +- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld index ee5f22ad25..381bdbad2b 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld @@ -3,8 +3,8 @@ ESP32C3 ECO3 ROM address table Version 3 API's imported from the ROM */ -esf_buf_alloc_dynamic = 0x400015c0; -esf_buf_recycle = 0x400015c4; +/*esf_buf_alloc_dynamic = 0x400015c0;*/ +/*esf_buf_recycle = 0x400015c4;*/ /*lmacTxDone = 0x4000162c;*/ ppMapTxQueue = 0x400016d8; /*rcGetSched = 0x40001764;*/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index eb8b8ce8ce..07a787cf7c 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1583,7 +1583,7 @@ r_sch_plan_offset_req_hook = 0x40001ce4; esp_pp_rom_version_get = 0x400015b0; RC_GetBlockAckTime = 0x400015b4; ebuf_list_remove = 0x400015b8; -esf_buf_alloc = 0x400015bc; +/*esf_buf_alloc = 0x400015bc;*/ GetAccess = 0x400015c8; hal_mac_is_low_rate_enabled = 0x400015cc; hal_mac_tx_get_blockack = 0x400015d0; @@ -1708,7 +1708,7 @@ wDev_AppendRxBlocks = 0x400017b8; wDev_DiscardFrame = 0x400017bc; wDev_GetNoiseFloor = 0x400017c0; wDev_IndicateAmpdu = 0x400017c4; -wDev_IndicateFrame = 0x400017c8; +/*wDev_IndicateFrame = 0x400017c8;*/ wdev_bank_store = 0x400017cc; wdev_bank_load = 0x400017d0; wdev_mac_reg_load = 0x400017d4; @@ -1718,8 +1718,8 @@ wdev_mac_special_reg_store = 0x400017e0; wdev_mac_wakeup = 0x400017e4; wdev_mac_sleep = 0x400017e8; hal_mac_is_dma_enable = 0x400017ec; -/* wDev_ProcessFiq = 0x400017f0; */ -wDev_ProcessRxSucData = 0x400017f4; +/*wDev_ProcessFiq = 0x400017f0;*/ +/*wDev_ProcessRxSucData = 0x400017f4;*/ wdevProcessRxSucDataAll = 0x400017f8; wdev_csi_len_align = 0x400017fc; ppDequeueTxDone_Locked = 0x40001800; diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 715df929a7..eda723b3ed 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -117,6 +117,40 @@ menu "Wi-Fi" can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX buffers. + choice ESP_WIFI_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP_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 ESP_WIFI_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" + endchoice + + config ESP_WIFI_DYNAMIC_RX_MGMT_BUF + int + default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER + default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + + config ESP_WIFI_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 1 10 + default 5 + help + Set the number of WiFi RX_MGMT buffers. + + For Management buffers, the number of dynamic and static management buffers is the same. + In order to prevent memory fragmentation, the management buffer type should be set to static first. + config ESP32_WIFI_CSI_ENABLED bool "WiFi CSI(Channel State Information)" default n diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index cce949d179..5116e17689 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -95,6 +95,8 @@ typedef struct { 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 rx_mgmt_buf_type; /**< WiFi RX MGMT buffer type */ + int rx_mgmt_buf_num; /**< WiFi RX MGMT buffer number */ int cache_tx_buf_num; /**< WiFi TX cache buffer number */ int csi_enable; /**< WiFi channel state information enable flag */ int ampdu_rx_enable; /**< WiFi AMPDU RX feature enable flag */ @@ -129,6 +131,12 @@ typedef struct { #define WIFI_DYNAMIC_TX_BUFFER_NUM 0 #endif +#ifdef CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF +#define WIFI_RX_MGMT_BUF_NUM_DEF CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF +#else +#define WIFI_RX_MGMT_BUF_NUM_DEF 0 +#endif + #if CONFIG_ESP32_WIFI_CSI_ENABLED #define WIFI_CSI_ENABLED 1 #else @@ -214,6 +222,8 @@ extern uint64_t g_wifi_feature_caps; .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,\ + .rx_mgmt_buf_type = CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF,\ + .rx_mgmt_buf_num = WIFI_RX_MGMT_BUF_NUM_DEF,\ .cache_tx_buf_num = WIFI_CACHE_TX_BUFFER_NUM,\ .csi_enable = WIFI_CSI_ENABLED,\ .ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED,\ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index d0159b0764..1920f9c051 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit d0159b07641b8fbc929c9ce9f88313756a9369f2 +Subproject commit 1920f9c051ca208c248ba13efd3cb3919e6d3b16 From 37b1fc9d673c71ba8bf1081dc042161e38e38a52 Mon Sep 17 00:00:00 2001 From: alanmaxwell Date: Fri, 24 Nov 2023 17:05:55 +0800 Subject: [PATCH 2/4] fix(wifi): backport some wifi bugfix 1. Fix multi antenna issue 2. Fix typo in wifi api docs 3. Optimize BB filter timer to pass some corner case 4. Change fragment threshold to 256 5. Support fragment for LR mode 6. Fix rx fragment fail in Open mode. 7. Drop fragmented AMPDUs 8. Fix ampdu duration issue --- components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 8 ++++---- components/esp_wifi/include/esp_wifi.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index 07a787cf7c..dde580a629 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1639,10 +1639,10 @@ pm_rx_data_process = 0x40001694; pm_sleep_for = 0x4000169c; /* pm_tbtt_process = 0x400016a0; */ ppAMPDU2Normal = 0x400016a4; -ppAssembleAMPDU = 0x400016a8; +/* ppAssembleAMPDU = 0x400016a8; */ ppCalFrameTimes = 0x400016ac; ppCalSubFrameLength = 0x400016b0; -ppCalTxAMPDULength = 0x400016b4; +/* ppCalTxAMPDULength = 0x400016b4; */ ppCheckTxAMPDUlength = 0x400016b8; ppDequeueRxq_Locked = 0x400016bc; ppDequeueTxQ = 0x400016c0; @@ -1662,7 +1662,7 @@ ppRecycleRxPkt = 0x400016f8; ppResortTxAMPDU = 0x400016fc; ppResumeTxAMPDU = 0x40001700; /* ppRxFragmentProc = 0x40001704; */ -ppRxPkt = 0x40001708; +/* ppRxPkt = 0x40001708;*/ ppRxProtoProc = 0x4000170c; ppSearchTxQueue = 0x40001710; ppSearchTxframe = 0x40001714; @@ -1689,7 +1689,7 @@ rcLowerSched = 0x40001768; rcSetTxAmpduLimit = 0x4000176c; /* rcTxUpdatePer = 0x40001770; */ rcUpdateAckSnr = 0x40001774; -rcUpdateRate = 0x40001778; +/* rcUpdateRate = 0x40001778;*/ /* rcUpdateTxDone = 0x4000177c; */ rcUpdateTxDoneAmpdu2 = 0x40001780; rcUpSched = 0x40001784; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 5116e17689..ccfcc52de9 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -436,7 +436,7 @@ esp_err_t esp_wifi_scan_stop(void); /** * @brief Get number of APs found in last scan * - * @param[out] number store number of APIs found in last scan + * @param[out] number store number of APs found in last scan * * @attention This API can only be called when the scan is completed, otherwise it may get wrong value. * @@ -817,7 +817,7 @@ esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter * - ESP_ERR_WIFI_MODE: invalid mode * - ESP_ERR_WIFI_PASSWORD: invalid password * - ESP_ERR_WIFI_NVS: WiFi internal NVS error - * - others: refer to the erro code in esp_err.h + * - others: refer to the error code in esp_err.h */ esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf); From 34339565dc7a31736171779064f8e2e64c2bdb07 Mon Sep 17 00:00:00 2001 From: jgujarathi Date: Wed, 8 Nov 2023 16:04:41 +0530 Subject: [PATCH 3/4] fix(esp_wifi): Ensure beacon timeout gets trigerred for AP config change - Ensure that beacon timeout gets trigerred for AP config changes when we are in powersave. From 9b0309b31af053a33c9eb2409f4a7c755547400b Mon Sep 17 00:00:00 2001 From: jgujarathi Date: Mon, 6 Nov 2023 16:20:24 +0530 Subject: [PATCH 4/4] fix(wpa_supplicant): Add HT20_40 capability in assoc requests - Add the HT2040 capability indication in the extended caps IE of assoc requests. --- components/wpa_supplicant/src/common/ieee802_11_defs.h | 1 + .../wpa_supplicant/src/esp_supplicant/esp_common.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/wpa_supplicant/src/common/ieee802_11_defs.h b/components/wpa_supplicant/src/common/ieee802_11_defs.h index 4bc3c281df..5530650ce4 100644 --- a/components/wpa_supplicant/src/common/ieee802_11_defs.h +++ b/components/wpa_supplicant/src/common/ieee802_11_defs.h @@ -257,6 +257,7 @@ /* bits 0-3: Field length (n-1) */ #define WLAN_RSNX_CAPAB_SAE_H2E 5 +#define WLAN_EXT_CAPAB_20_40_COEX 0 #define WLAN_EXT_CAPAB_BSS_TRANSITION 19 /* Action frame categories (IEEE Std 802.11-2016, 9.4.1.11, Table 9-76) */ diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_common.c b/components/wpa_supplicant/src/esp_supplicant/esp_common.c index 3ad730a687..822a8949bf 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_common.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_common.c @@ -20,6 +20,7 @@ #include "esp_rrm.h" #include "esp_wnm.h" #include "rsn_supp/wpa.h" +#include "esp_private/wifi.h" struct wpa_supplicant g_wpa_supp; @@ -489,6 +490,7 @@ static uint8_t get_extended_caps_ie(uint8_t *ie, size_t len) uint8_t ext_caps_ie[5] = {0}; uint8_t ext_caps_ie_len = 3; uint8_t *pos = ext_caps_ie; + wifi_ioctl_config_t cfg = {0}; if (!esp_wifi_is_btm_enabled_internal(WIFI_IF_STA)) { return 0; @@ -496,7 +498,12 @@ static uint8_t get_extended_caps_ie(uint8_t *ie, size_t len) *pos++ = WLAN_EID_EXT_CAPAB; *pos++ = ext_caps_ie_len; - *pos++ = 0; + esp_err_t err = esp_wifi_internal_ioctl(WIFI_IOCTL_GET_STA_HT2040_COEX, &cfg); + if (err == ESP_OK && cfg.data.ht2040_coex.enable) { + *pos++ |= BIT(WLAN_EXT_CAPAB_20_40_COEX); + } else { + *pos++ = 0; + } *pos++ = 0; #define CAPAB_BSS_TRANSITION BIT(3) *pos |= CAPAB_BSS_TRANSITION;