From dd11e4514ba570e043d49c2916489cd22bb1decc Mon Sep 17 00:00:00 2001 From: xuxiao Date: Wed, 27 Nov 2024 10:25:40 +0800 Subject: [PATCH 01/11] feat(wifi): add phy support for esp32c5 beta5 --- components/esp_phy/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index f5f852b53c..0c849b3d31 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit f5f852b53c90c2a23bfbd6b9c4897c25f0ae6155 +Subproject commit 0c849b3d31d44c797c2b48f1b9c1607a8c6c4f82 From c725253d536ba8c4640ef9e4c731898f6b59aab3 Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Thu, 26 Dec 2024 14:31:09 +0800 Subject: [PATCH 02/11] feat(wifi): add wifi support for esp32c61 eco2 --- components/esp_phy/lib | 2 +- .../esp_rom/esp32c61/ld/esp32c61.rom.phy.ld | 4 ++- .../esp_rom/esp32c61/ld/esp32c61.rom.pp.ld | 25 +++++++++++-------- components/esp_wifi/lib | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 0c849b3d31..84a5574221 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 0c849b3d31d44c797c2b48f1b9c1607a8c6c4f82 +Subproject commit 84a55742211a32d3f68a6281a7180349ec165cfb diff --git a/components/esp_rom/esp32c61/ld/esp32c61.rom.phy.ld b/components/esp_rom/esp32c61/ld/esp32c61.rom.phy.ld index 82722f83ca..d7ab643c47 100644 --- a/components/esp_rom/esp32c61/ld/esp32c61.rom.phy.ld +++ b/components/esp_rom/esp32c61/ld/esp32c61.rom.phy.ld @@ -305,7 +305,9 @@ phy_rate_to_index = 0x400014b8; phy_get_target_pwr = 0x400014bc; phy_get_max_pwr = 0x400014c0; phy_get_pwr_index = 0x400014c4; -phy_chip_set_chan_ana = 0x40005a8a; +phy_chip_set_chan_ana = 0x400014d4; +phy_get_romfuncs = 0x400014d8; /* Data (.data, .bss, .rodata) */ phy_param_rom = 0x4084fc6c; rom_phyFuns = 0x4084fb84; +rom_phyFuns_eco2 = 0x4084fc68; diff --git a/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld b/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld index 0329814f33..7362e8be00 100644 --- a/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld +++ b/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld @@ -53,6 +53,9 @@ hal_tsf_get_tbttstart = 0x40000bcc; hal_get_tsf_time = 0x40000bd0; hal_get_sta_tsf = 0x40000bd4; tsf_hal_get_tbtt_interval = 0x40000bd8; +tsf_hal_get_time = 0x400014cc; +/*pm_get_tbtt_count = 0x400014c8;*/ +tsf_hal_get_counter_value = 0x400014d0; dbg_hal_check_clr_mplen_bitmap = 0x40000bdc; dbg_hal_check_set_mplen_bitmap = 0x40000be0; ic_get_trc = 0x40000be4; @@ -76,14 +79,14 @@ lmacReachLongLimit = 0x40000c28; lmacReachShortLimit = 0x40000c2c; lmacRecycleMPDU = 0x40000c30; lmacRxDone = 0x40000c34; -/*lmacSetTxFrame = 0x40000c38;*/ +lmacSetTxFrame = 0x40000c38; lmacTxDone = 0x40000c3c; lmacTxFrame = 0x40000c40; lmacDisableTransmit = 0x40000c44; lmacDiscardFrameExchangeSequence = 0x40000c48; lmacProcessCollision = 0x40000c4c; lmacProcessAckTimeout = 0x40000c50; -/*lmacProcessShortRetryFail = 0x40000c54;*/ +lmacProcessShortRetryFail = 0x40000c54; lmacProcessCollisions_task = 0x40000c58; lmacProcessTxRtsError = 0x40000c5c; lmacProcessTxError = 0x40000c60; @@ -119,7 +122,7 @@ pm_local_tsf_process = 0x40000cd4; pm_set_beacon_filter = 0x40000cd8; pm_is_in_wifi_slice_threshold = 0x40000cdc; pm_is_waked = 0x40000ce0; -/*pm_keep_alive = 0x40000ce4;*/ +pm_keep_alive = 0x40000ce4; pm_on_beacon_rx = 0x40000ce8; pm_on_data_rx = 0x40000cec; pm_on_data_tx = 0x40000cf0; @@ -137,7 +140,7 @@ pm_rx_data_process = 0x40000d1c; pm_sleep = 0x40000d20; pm_sleep_for = 0x40000d24; /*pm_tbtt_process = 0x40000d28;*/ -/*pm_tx_data_done_process = 0x40000d2c;*/ +pm_tx_data_done_process = 0x40000d2c; pm_allow_tx = 0x40000d30; pm_extend_tbtt_adaptive_servo = 0x40000d34; pm_scale_listen_interval = 0x40000d38; @@ -146,7 +149,7 @@ pm_disconnected_wake = 0x40000d40; /*pm_tx_data_process = 0x40000d44;*/ pm_is_twt_awake = 0x40000d48; pm_enable_twt_keep_alive = 0x40000d4c; -/*pm_twt_on_tsf_timer = 0x40000d50;*/ +pm_twt_on_tsf_timer = 0x40000d50; pm_twt_process = 0x40000d54; pm_is_twt_start = 0x40000d58; pm_twt_set_target_wdev_time = 0x40000d5c; @@ -197,7 +200,7 @@ ppSearchTxQueue = 0x40000e0c; ppSearchTxframe = 0x40000e10; ppSelectNextQueue = 0x40000e14; ppSubFromAMPDU = 0x40000e18; -/*ppTask = 0x40000e1c;*/ +ppTask = 0x40000e1c; ppTxPkt = 0x40000e20; ppTxProtoProc = 0x40000e24; ppTxqUpdateBitmap = 0x40000e28; @@ -241,13 +244,13 @@ rcSetTxAmpduLimit = 0x40000ebc; rcTxUpdatePer = 0x40000ec0; rcUpdateAckSnr = 0x40000ec4; rcUpdateRate = 0x40000ec8; -/*rcUpdateTxDone = 0x40000ecc;*/ -/*rcUpdateTxDoneAmpdu2 = 0x40000ed0;*/ +rcUpdateTxDone = 0x40000ecc; +rcUpdateTxDoneAmpdu2 = 0x40000ed0; rcUpSched = 0x40000ed4; rcReachRetryLimit = 0x40000ed8; rcGetDCMMaxRate = 0x40000edc; rcGetSMPDURate = 0x40000ee0; -/*rcGetRate = 0x40000ee4;*/ +rcGetRate = 0x40000ee4; rx11AXRate2AMPDULimit = 0x40000ee8; rx11NRate2AMPDULimit = 0x40000eec; rssi_margin = 0x40000ef0; @@ -263,7 +266,7 @@ trcAmpduSetState = 0x40000f14; trc_set_bf_report_rate = 0x40000f18; trc_onPPTxDone = 0x40000f1c; wDevCheckBlockError = 0x40000f20; -/*wDev_AppendRxBlocks = 0x40000f24;*/ +wDev_AppendRxBlocks = 0x40000f24; wDev_DiscardFrame = 0x40000f28; wDev_GetNoiseFloor = 0x40000f2c; wDev_IndicateAmpdu = 0x40000f30; @@ -275,7 +278,7 @@ wdev_mac_special_reg_store = 0x40000f44; wdev_mac_wakeup = 0x40000f48; wdev_mac_sleep = 0x40000f4c; wDev_ProcessFiq = 0x40000f50; -/*wDev_ProcessRxSucData = 0x40000f54;*/ +wDev_ProcessRxSucData = 0x40000f54; wdevProcessRxSucDataAll = 0x40000f58; wdev_csi_len_align = 0x40000f5c; wDev_IndicateBeaconMemoryFrame = 0x40000f60; diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index b15699a76c..8848c2e127 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit b15699a76c068ab7d7dc6cbee53eb6d559fe646f +Subproject commit 8848c2e127a25df01856404761de8eab89dee958 From bdc099af7f8b92bc243d3ad3a208269676b3f517 Mon Sep 17 00:00:00 2001 From: Aditi Date: Fri, 6 Dec 2024 18:24:03 +0530 Subject: [PATCH 03/11] fix(esp_wifi): Add fix for error handling for FT-Auth --- .../esp_supplicant/src/esp_common.c | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 65dc68697a..ceb71055d9 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -252,6 +252,19 @@ static int handle_assoc_frame(u8 *frame, size_t len, } return 0; } + +static void wpa_sta_clear_ft_auth_ie(void) +{ + struct wpa_sm *sm = &gWpaSm; + wpa_printf(MSG_DEBUG, "Clearing all FT IE parameters and keys"); + /* Reset FT parameters */ + wpa_sm_set_ft_params(sm, NULL, 0); + esp_wifi_unset_appie_internal(WIFI_APPIE_RAM_STA_AUTH); + sm->ft_reassoc_completed = 0; + sm->ft_protocol = 0; + /* Clear pmk and ptk */ + wpa_sm_drop_sa(sm); +} #endif /* CONFIG_IEEE80211R */ #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ @@ -454,6 +467,7 @@ void supplicant_sta_conn_handler(uint8_t *bssid) void supplicant_sta_disconn_handler(uint8_t reason_code) { + struct wpa_sm *sm = &gWpaSm; #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) struct wpa_supplicant *wpa_s = &g_wpa_supp; @@ -470,6 +484,12 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) if (wpa_s->current_bss) { wpa_s->current_bss = NULL; } +#if defined(CONFIG_IEEE80211R) + if (reason_code == WIFI_REASON_INVALID_PMKID || reason_code == WIFI_REASON_INVALID_MDE || reason_code == WIFI_REASON_INVALID_FTE || (sm->cur_pmksa == NULL)) { + /* clear all ft auth related IEs so that next will be open auth */ + wpa_sta_clear_ft_auth_ie(); + } +#endif #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ } @@ -808,7 +828,7 @@ static size_t add_mdie(uint8_t *bssid, uint8_t *ie, size_t len) int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md, const u8 *ies, size_t ies_len, bool auth_ie) { - wpa_printf(MSG_INFO, "Updating FT IEs (len=%d)", ies_len); + wpa_printf(MSG_INFO, "Updating FT IEs (len=%d), auth_ie %d ", ies_len, auth_ie); if (os_memcmp(sm->mobility_domain, md, MOBILITY_DOMAIN_ID_LEN) != 0) { return 0; } From 3f3c3d9a1426b47220327632e8fdc6089a732077 Mon Sep 17 00:00:00 2001 From: Aditi Date: Fri, 27 Sep 2024 00:51:29 +0530 Subject: [PATCH 04/11] fix(wpa_supplicant): Add some minor fixes in roaming 1) Add a fix in roaming example for 11kvr 2) Removed length constraint for neighbor report received. --- .../esp_wifi/include/esp_wifi_types_generic.h | 3 ++- components/esp_wifi/lib | 2 +- .../esp_supplicant/src/esp_common.c | 19 ++++++++++++------- .../roaming_11kvr/main/roaming_example.c | 3 +-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index 7b7363ea38..c50006fdb1 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -1312,8 +1312,9 @@ typedef struct { * @brief Argument structure for WIFI_EVENT_STA_NEIGHBOR_REP event */ typedef struct { - uint8_t report[ESP_WIFI_MAX_NEIGHBOR_REP_LEN]; /**< Neighbor Report received from the AP*/ + uint8_t report[ESP_WIFI_MAX_NEIGHBOR_REP_LEN]; /**< Neighbor Report received from the AP (will be deprecated in next major release, use n_report instead)*/ uint16_t report_len; /**< Length of the report*/ + uint8_t n_report[]; /**< Neighbor Report received from the AP*/ } wifi_event_neighbor_report_t; /** Argument structure for WIFI_EVENT_AP_WRONG_PASSWORD event */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 8848c2e127..f709d89ad9 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 8848c2e127a25df01856404761de8eab89dee958 +Subproject commit f709d89ad90f70c93c57b6de3152246d0614f959 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index ceb71055d9..27a9703a0c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -546,15 +546,20 @@ void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_le esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, NULL, 0, 0); return; } - if (report_len > ESP_WIFI_MAX_NEIGHBOR_REP_LEN) { - wpa_printf(MSG_ERROR, "RRM: Neighbor report too large (>%d bytes), hence not reporting", ESP_WIFI_MAX_NEIGHBOR_REP_LEN); - return; - } wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report (token = %d)", report[0]); - wifi_event_neighbor_report_t neighbor_report_event = {0}; - os_memcpy(neighbor_report_event.report, report, report_len); - neighbor_report_event.report_len = report_len; + + wifi_event_neighbor_report_t *neighbor_report_event = os_zalloc(sizeof(wifi_event_neighbor_report_t) + report_len); + if (neighbor_report_event == NULL) { + wpa_printf(MSG_DEBUG, "memory alloc failed"); + } + + if (report_len < ESP_WIFI_MAX_NEIGHBOR_REP_LEN) { + os_memcpy(neighbor_report_event->report, report, report_len); + } + os_memcpy(neighbor_report_event->n_report, report, report_len); + neighbor_report_event->report_len = report_len; esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &neighbor_report_event, sizeof(wifi_event_neighbor_report_t), 0); + os_free(neighbor_report_event); } int esp_rrm_send_neighbor_report_request(void) diff --git a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c index 3e47cbb158..edf0669494 100644 --- a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c +++ b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c @@ -364,9 +364,8 @@ static void esp_bss_rssi_low_handler(void* arg, esp_event_base_t event_base, { wifi_event_bss_rssi_low_t *event = event_data; - ESP_LOGI(TAG, "%s:bss rssi is=%d", __func__, event->rssi); + ESP_LOGI(TAG, "%s:bss rssi is=%ld", __func__, event->rssi); /* Lets check channel conditions */ - rrm_ctx++; if (esp_rrm_send_neighbor_report_request() < 0) { /* failed to send neighbor report request */ ESP_LOGI(TAG, "failed to send neighbor report request"); From 318ad17991fecdbdd839a2400a9b85bbecc71f41 Mon Sep 17 00:00:00 2001 From: Aditi Date: Tue, 1 Oct 2024 18:35:32 +0530 Subject: [PATCH 05/11] fix(wpa_supplicant): Add two separate flags for RRM and WNM Added two separate flags CONFIG_RRM(80211k) and CONFIG_WNM(80211v) flags under IEEE80211KV support flag. --- components/esp_wifi/Kconfig | 28 ++- .../wifi_apps/roaming_app/src/Kconfig.roaming | 8 +- .../wifi_apps/roaming_app/src/README.md | 2 +- components/wpa_supplicant/CMakeLists.txt | 13 +- .../esp_supplicant/src/esp_common.c | 199 +++++++++--------- .../esp_supplicant/src/esp_common_i.h | 4 +- .../esp_supplicant/src/esp_scan.c | 9 +- .../src/common/ieee802_11_common.c | 6 +- 8 files changed, 150 insertions(+), 119 deletions(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index c6548a4b8f..ab055708a8 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -555,20 +555,38 @@ menu "Wi-Fi" default n help Select this option to enable 802.11k 802.11v APIs(RRM and BTM support). + + config ESP_WIFI_RRM_SUPPORT + bool "Enable 802.11k APIs Support" + depends on ESP_WIFI_11KV_SUPPORT + default n + help + Select this option to enable 802.11k APIs(RRM support). Only APIs which are helpful for network assisted roaming are supported for now. - Enable this option with BTM and RRM enabled in sta config + Enable this option with RRM enabled in sta config to make device ready for network assisted roaming. - BTM: BSS transition management enables an AP to request a station to transition - to a specific AP, or to indicate to a station a set of preferred APs. RRM: Radio measurements enable STAs to understand the radio environment, it enables STAs to observe and gather data on radio link performance and on the radio environment. Current implementation adds beacon report, link measurement, neighbor report. + config ESP_WIFI_WNM_SUPPORT + bool "Enable 802.11v APIs Support" + depends on ESP_WIFI_11KV_SUPPORT + default n + help + Select this option to enable 802.11v APIs(BTM support). + Only APIs which are helpful for network assisted roaming + are supported for now. + Enable this option with BTM enabled in sta config + to make device ready for network assisted roaming. + BTM: BSS transition management enables an AP to request a station to transition + to a specific AP, or to indicate to a station a set of preferred APs. + config ESP_WIFI_SCAN_CACHE bool "Keep scan results in cache" - depends on ESP_WIFI_11KV_SUPPORT + depends on ESP_WIFI_RRM_SUPPORT default n help Keep scan results in cache, if not enabled, those @@ -578,6 +596,8 @@ menu "Wi-Fi" bool "Enable Multi Band Operation Certification Support" default n select ESP_WIFI_11KV_SUPPORT + select ESP_WIFI_RRM_SUPPORT + select ESP_WIFI_WNM_SUPPORT select ESP_WIFI_SCAN_CACHE help Select this option to enable WiFi Multiband operation certification support. diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/Kconfig.roaming b/components/esp_wifi/wifi_apps/roaming_app/src/Kconfig.roaming index 3effeed781..f36211db54 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/Kconfig.roaming +++ b/components/esp_wifi/wifi_apps/roaming_app/src/Kconfig.roaming @@ -66,13 +66,13 @@ menu "Roaming Methods" bool "Support Legacy roaming approach" default y help - Roaming between APs that do not support 802.11kv. + Roaming between APs that do not support 802.11v. This will allow station to roam even when connection is not BTM supported, by forcefully disconnecting from current AP and connecting to better AP. config ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM - bool "Support Network Assisted roaming using 802.11kv" - depends on ESP_WIFI_11KV_SUPPORT + bool "Support Network Assisted roaming using 802.11v" + depends on ESP_WIFI_WNM_SUPPORT default y help Roaming between APs using network assisted Roaming. @@ -151,7 +151,7 @@ config ESP_WIFI_ROAMING_BACKOFF_TIME config ESP_WIFI_ROAMING_PERIODIC_RRM_MONITORING bool "Send periodic neighbor report request to AP for internal list updation" - depends on ESP_WIFI_11KV_SUPPORT + depends on ESP_WIFI_RRM_SUPPORT default y help This option will enable station to keep sending RRM neighbor list request to AP and diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/README.md b/components/esp_wifi/wifi_apps/roaming_app/src/README.md index 182d621929..c8ad2f37e7 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/README.md +++ b/components/esp_wifi/wifi_apps/roaming_app/src/README.md @@ -39,7 +39,7 @@ Currently 2 methods of roaming are supported by the roaming app. (Roaming App Se 1) Network Assisted Roaming: -Enabled by “Support Network Assisted Roaming using 802.11kv”, this method primarily uses the BSS transition Management mechanisms outlined in IEEE 802.11v. It uses Candidates received from neighbor report requests (if enabled, explained later.) and scanning results to Send BSS transition Management Queries to the AP it is currently associated to. Depending on the current radio environment and vendor implementation on the side of the AP, this could then lead to BSS Transition Management Requests and corresponding BSS Transition Management responses which could lead to a seamless transition from one AP to another. For a better understanding of the mechanisms involved and the general implementation please look up the IEEE 802.11v specification and upstream wpa_supplicant’s implementation. +Enabled by “Support Network Assisted Roaming using 802.11v”, this method primarily uses the BSS transition Management mechanisms outlined in IEEE 802.11v. It uses Candidates received from neighbor report requests (if enabled, explained later.) and scanning results to Send BSS transition Management Queries to the AP it is currently associated to. Depending on the current radio environment and vendor implementation on the side of the AP, this could then lead to BSS Transition Management Requests and corresponding BSS Transition Management responses which could lead to a seamless transition from one AP to another. For a better understanding of the mechanisms involved and the general implementation please look up the IEEE 802.11v specification and upstream wpa_supplicant’s implementation. Please note that for this to work as expected, the APs should support 802.11k & 802.11v and be setup in a network where they are aware of each other. diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index 31b5fd7993..1de14f5f12 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -174,8 +174,11 @@ endif() if(CONFIG_ESP_WIFI_11KV_SUPPORT OR CONFIG_ESP_WIFI_11R_SUPPORT) set(roaming_src "src/common/ieee802_11_common.c") - if(CONFIG_ESP_WIFI_11KV_SUPPORT) - set(roaming_src ${roaming_src} "src/common/rrm.c" "src/common/wnm_sta.c") + if(CONFIG_ESP_WIFI_RRM_SUPPORT) + set(roaming_src ${roaming_src} "src/common/rrm.c") + endif() + if(CONFIG_ESP_WIFI_WNM_SUPPORT) + set(roaming_src ${roaming_src} "src/common/wnm_sta.c") endif() if(CONFIG_ESP_WIFI_11R_SUPPORT) set(roaming_src ${roaming_src} "src/rsn_supp/wpa_ft.c") @@ -291,6 +294,12 @@ endif() if(CONFIG_ESP_WIFI_11KV_SUPPORT) target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV) endif() +if(CONFIG_ESP_WIFI_RRM_SUPPORT) + target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_RRM) +endif() +if(CONFIG_ESP_WIFI_WNM_SUPPORT) + target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM) +endif() if(CONFIG_ESP_WIFI_11R_SUPPORT) target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_IEEE80211R) endif() diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 27a9703a0c..cb1f6a648b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -74,7 +74,7 @@ static int handle_action_frm(u8 *frame, size_t len, } #endif /* CONFIG_SUPPLICANT_TASK */ -#if defined(CONFIG_IEEE80211KV) +#if defined(CONFIG_RRM) static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender, u8 *payload, size_t len, int8_t rssi) { @@ -91,6 +91,7 @@ static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender, payload + 1, len - 1, rssi); } } +#endif /* CONFIG_RRM */ static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 channel) { @@ -106,15 +107,18 @@ static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 cha category = *frame++; len--; +#if defined(CONFIG_WNM) if (category == WLAN_ACTION_WNM) { ieee802_11_rx_wnm_action(wpa_s, sender, frame, len); - } else if (category == WLAN_ACTION_RADIO_MEASUREMENT) { + } +#endif /* CONFIG_WNM */ +#if defined(CONFIG_RRM) + if (category == WLAN_ACTION_RADIO_MEASUREMENT) { handle_rrm_frame(wpa_s, sender, frame, len, rssi); } - +#endif /* CONFIG_RRM */ return 0; } -#endif /* defined(CONFIG_IEEE80211KV) */ #ifdef CONFIG_SUPPLICANT_TASK static void btm_rrm_task(void *pvParameters) @@ -198,19 +202,20 @@ static void register_mgmt_frames(struct wpa_supplicant *wpa_s) /* subtype is defined only for action frame */ wpa_s->subtype = 0; -#ifdef CONFIG_IEEE80211KV +#ifdef CONFIG_RRM /* current supported features in supplicant: rrm and btm */ if (esp_wifi_is_rm_enabled_internal(WIFI_IF_STA)) { wpa_s->subtype = 1 << WLAN_ACTION_RADIO_MEASUREMENT; } +#endif /* CONFIG_RRM */ +#ifdef CONFIG_WNM if (esp_wifi_is_btm_enabled_internal(WIFI_IF_STA)) { wpa_s->subtype |= 1 << WLAN_ACTION_WNM; } - +#endif /* CONFIG_WNM */ if (wpa_s->subtype) { wpa_s->type |= 1 << WLAN_FC_STYPE_ACTION; } -#endif /* CONFIG_IEEE80211KV */ #ifdef CONFIG_IEEE80211R /* register auth/assoc frames if FT is enabled */ @@ -282,7 +287,7 @@ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender, int ret = 0; switch (type) { -#if defined(CONFIG_IEEE80211R) || defined(CONFIG_IEEE80211KV) +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) case WLAN_FC_STYPE_BEACON: case WLAN_FC_STYPE_PROBE_RESP: ret = esp_handle_beacon_probe(type, frame, len, sender, rssi, channel, current_tsf); @@ -377,10 +382,10 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb) } s_supplicant_task_init_done = true; #endif /* CONFIG_SUPPLICANT_TASK */ -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); -#endif /* CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_RRM) */ esp_scan_init(wpa_s); #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ @@ -410,10 +415,10 @@ void esp_supplicant_common_deinit(void) #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) esp_scan_deinit(wpa_s); -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); -#endif /* CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_RRM) */ #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ if (wpa_s->type) { wpa_s->type = 0; @@ -471,7 +476,7 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) struct wpa_supplicant *wpa_s = &g_wpa_supp; -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); /* Not clearing in case of roaming disconnect as BTM induced connection @@ -480,7 +485,7 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) if (reason_code != WIFI_REASON_ROAMING) { clear_bssid_flag_and_channel(wpa_s); } -#endif /* CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_RRM) */ if (wpa_s->current_bss) { wpa_s->current_bss = NULL; } @@ -494,7 +499,7 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) } #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) bool esp_rrm_is_rrm_supported_connection(void) { struct wpa_supplicant *wpa_s = &g_wpa_supp; @@ -587,6 +592,33 @@ int esp_rrm_send_neighbor_report_request(void) return wpas_rrm_send_neighbor_rep_request(wpa_s, &wpa_ssid, 0, 0, neighbor_report_recvd_cb, NULL); } +static size_t get_rm_enabled_ie(uint8_t *ie, size_t len) +{ + uint8_t rrm_ie[7] = {0}; + uint8_t rrm_ie_len = 5; + uint8_t *pos = rrm_ie; + + if (!esp_wifi_is_rm_enabled_internal(WIFI_IF_STA)) { + return 0; + } + + *pos++ = WLAN_EID_RRM_ENABLED_CAPABILITIES; + *pos++ = rrm_ie_len; + *pos |= WLAN_RRM_CAPS_LINK_MEASUREMENT; + + *pos |= WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE | +#ifdef SCAN_CACHE_SUPPORTED + WLAN_RRM_CAPS_BEACON_REPORT_TABLE | +#endif /* SCAN_CACHE_SUPPORTED */ + WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE; + + os_memcpy(ie, rrm_ie, sizeof(rrm_ie)); + + return rrm_ie_len + 2; +} + +#endif /* defined(CONFIG_RRM) */ +#if defined(CONFIG_WNM) bool esp_wnm_is_btm_supported_connection(void) { struct wpa_supplicant *wpa_s = &g_wpa_supp; @@ -622,6 +654,37 @@ int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason, return wnm_send_bss_transition_mgmt_query(wpa_s, query_reason, btm_candidates, cand_list); } +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}; + esp_err_t err = 0; + + if (!esp_wifi_is_btm_enabled_internal(WIFI_IF_STA)) { + return 0; + } + + *pos++ = WLAN_EID_EXT_CAPAB; + *pos++ = ext_caps_ie_len; + + 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; +#undef CAPAB_BSS_TRANSITION + os_memcpy(ie, ext_caps_ie, sizeof(ext_caps_ie)); + + return ext_caps_ie_len + 2; +} +#endif /* defined(CONFIG_WNM) */ + #ifdef CONFIG_MBO int esp_mbo_update_non_pref_chan(struct non_pref_chan_s *non_pref_chan) { @@ -629,56 +692,7 @@ int esp_mbo_update_non_pref_chan(struct non_pref_chan_s *non_pref_chan) return ret; } -#endif /* CONFIG_MBO */ -void wpa_supplicant_connect(struct wpa_supplicant *wpa_s, - struct wpa_bss *bss, char *ssid) -{ - wifi_config_t *config = os_zalloc(sizeof(wifi_config_t)); - - if (!config) { - wpa_printf(MSG_ERROR, "failed to allocate memory"); - return; - } - - esp_wifi_get_config(WIFI_IF_STA, config); - /* We only support roaming in same ESS, therefore only bssid setting is needed */ - os_memcpy(config->sta.bssid, bss->bssid, ETH_ALEN); - config->sta.bssid_set = 1; - config->sta.channel = bss->channel; - /* supplicant connect will only be called in case of bss transition(roaming) */ - esp_wifi_internal_issue_disconnect(WIFI_REASON_BSS_TRANSITION_DISASSOC); - esp_wifi_set_config(WIFI_IF_STA, config); - os_free(config); - esp_wifi_connect(); -} - -static size_t get_rm_enabled_ie(uint8_t *ie, size_t len) -{ - uint8_t rrm_ie[7] = {0}; - uint8_t rrm_ie_len = 5; - uint8_t *pos = rrm_ie; - - if (!esp_wifi_is_rm_enabled_internal(WIFI_IF_STA)) { - return 0; - } - - *pos++ = WLAN_EID_RRM_ENABLED_CAPABILITIES; - *pos++ = rrm_ie_len; - *pos |= WLAN_RRM_CAPS_LINK_MEASUREMENT; - - *pos |= WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE | -#ifdef SCAN_CACHE_SUPPORTED - WLAN_RRM_CAPS_BEACON_REPORT_TABLE | -#endif /* SCAN_CACHE_SUPPORTED */ - WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE; - - os_memcpy(ie, rrm_ie, sizeof(rrm_ie)); - - return rrm_ie_len + 2; -} - -#ifdef CONFIG_MBO static size_t get_mbo_oce_scan_ie(uint8_t *ie, size_t len) { uint8_t mbo_ie[32] = {0}; @@ -735,42 +749,31 @@ static uint8_t get_operating_class_ie(uint8_t *ie, size_t len) } #endif /* CONFIG_MBO */ -static uint8_t get_extended_caps_ie(uint8_t *ie, size_t len) +void wpa_supplicant_connect(struct wpa_supplicant *wpa_s, + struct wpa_bss *bss, char *ssid) { - 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}; - esp_err_t err = 0; + wifi_config_t *config = os_zalloc(sizeof(wifi_config_t)); - if (!esp_wifi_is_btm_enabled_internal(WIFI_IF_STA)) { - return 0; + if (!config) { + wpa_printf(MSG_ERROR, "failed to allocate memory"); + return; } - *pos++ = WLAN_EID_EXT_CAPAB; - *pos++ = ext_caps_ie_len; - - 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; -#undef CAPAB_BSS_TRANSITION - os_memcpy(ie, ext_caps_ie, sizeof(ext_caps_ie)); - - return ext_caps_ie_len + 2; + esp_wifi_get_config(WIFI_IF_STA, config); + /* We only support roaming in same ESS, therefore only bssid setting is needed */ + os_memcpy(config->sta.bssid, bss->bssid, ETH_ALEN); + config->sta.bssid_set = 1; + config->sta.channel = bss->channel; + /* supplicant connect will only be called in case of bss transition(roaming) */ + esp_wifi_internal_issue_disconnect(WIFI_REASON_BSS_TRANSITION_DISASSOC); + esp_wifi_set_config(WIFI_IF_STA, config); + os_free(config); + esp_wifi_connect(); } -#else /* CONFIG_IEEE80211KV */ -#endif /* CONFIG_IEEE80211KV */ - void esp_set_scan_ie(void) { -#ifdef CONFIG_IEEE80211KV +#ifdef CONFIG_WNM #define SCAN_IE_LEN 64 uint8_t *ie, *pos; size_t len = SCAN_IE_LEN, ie_len; @@ -793,7 +796,7 @@ void esp_set_scan_ie(void) esp_wifi_set_appie_internal(WIFI_APPIE_PROBEREQ, ie, SCAN_IE_LEN - len, 0); os_free(ie); #undef SCAN_IE_LEN -#endif /* CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_WNM) */ } #ifdef CONFIG_IEEE80211R @@ -827,9 +830,7 @@ static size_t add_mdie(uint8_t *bssid, uint8_t *ie, size_t len) return mdie_len; } -#endif /* CONFIG_IEEE80211R */ -#ifdef CONFIG_IEEE80211R int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md, const u8 *ies, size_t ies_len, bool auth_ie) { @@ -934,9 +935,7 @@ int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data) #endif /* CONFIG_SUPPLICANT_TASK */ #else /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ void esp_set_scan_ie(void) { } -#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ -#ifndef CONFIG_IEEE80211KV bool esp_rrm_is_rrm_supported_connection(void) { return false; @@ -964,7 +963,7 @@ int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason, return -1; } -#endif /* !CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) || defined(CONFIG_WPA3_SAE) void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool mdie) @@ -981,7 +980,7 @@ void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool mdie) return; } pos = ie; -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) ie_len = get_rm_enabled_ie(pos, len); pos += ie_len; len -= ie_len; @@ -993,7 +992,7 @@ void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool mdie) pos += ie_len; len -= ie_len; #endif /* CONFIG_MBO */ -#endif /* CONFIG_IEEE80211KV */ +#endif /* defined(CONFIG_RRM) */ #ifdef CONFIG_IEEE80211R if (mdie) { ie_len = add_mdie(bssid, pos, len); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h index 8a4857b139..1bf9e79b13 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h @@ -12,7 +12,7 @@ struct wpa_funcs; extern struct wpa_supplicant g_wpa_supp; -#ifdef CONFIG_IEEE80211KV +#if defined(CONFIG_RRM) || defined(CONFIG_WNM) struct ieee_mgmt_frame { u8 sender[ETH_ALEN]; u8 channel; @@ -39,7 +39,7 @@ void esp_get_tx_power(uint8_t *tx_power); #ifdef CONFIG_MBO bool mbo_bss_profile_match(u8 *bssid); #endif -#endif +#endif /* defined(CONFIG_RRM) || defined(CONFIG_WNM) */ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb); void esp_supplicant_common_deinit(void); void esp_supplicant_unset_all_appie(void); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c index ac4c995b66..acf68d187a 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c @@ -44,7 +44,7 @@ static void scan_done_event_handler(void *arg, ETS_STATUS status) #endif /*CONFIG_SUPPLICANT_TASK*/ } -#if defined(CONFIG_IEEE80211KV) +#if defined(CONFIG_WNM) static void handle_wnm_scan_done(struct wpa_supplicant *wpa_s) { struct wpa_bss *bss = wpa_bss_get_next_bss(wpa_s, wpa_s->current_bss); @@ -77,11 +77,14 @@ void esp_supplicant_handle_scan_done_evt(void) struct wpa_supplicant *wpa_s = &g_wpa_supp; wpa_printf(MSG_INFO, "scan done received"); -#if defined(CONFIG_IEEE80211KV) +#if defined(CONFIG_RRM) /* Check which module started this, call the respective function */ if (wpa_s->scan_reason == REASON_RRM_BEACON_REPORT) { wpas_beacon_rep_scan_process(wpa_s, wpa_s->scan_start_tsf); - } else if (wpa_s->scan_reason == REASON_WNM_BSS_TRANS_REQ) { + } +#endif +#if defined(CONFIG_WNM) + if (wpa_s->scan_reason == REASON_WNM_BSS_TRANS_REQ) { handle_wnm_scan_done(wpa_s); } #endif diff --git a/components/wpa_supplicant/src/common/ieee802_11_common.c b/components/wpa_supplicant/src/common/ieee802_11_common.c index 5af7ee47d9..58997d0e26 100644 --- a/components/wpa_supplicant/src/common/ieee802_11_common.c +++ b/components/wpa_supplicant/src/common/ieee802_11_common.c @@ -268,7 +268,7 @@ static int ieee802_11_parse_extension(struct wpa_supplicant *wpa_s, const struct */ int ieee802_11_parse_elems(struct wpa_supplicant *wpa_s, const u8 *start, size_t len) { -#if defined(CONFIG_RRM) || defined(CONFIG_SAE_PK) +#if defined(CONFIG_RRM) || defined(CONFIG_WNM) || defined(CONFIG_SAE_PK) const struct element *elem; u8 unknown = 0; @@ -297,7 +297,7 @@ int ieee802_11_parse_elems(struct wpa_supplicant *wpa_s, const u8 *start, size_t } break; #endif /*CONFIG_SAE_PK*/ -#ifdef CONFIG_RRM +#ifdef CONFIG_WNM case WLAN_EID_EXT_CAPAB: /* extended caps can go beyond 8 octacts but we aren't using them now */ os_memcpy(wpa_s->extend_caps, pos, 5); @@ -311,7 +311,7 @@ int ieee802_11_parse_elems(struct wpa_supplicant *wpa_s, const u8 *start, size_t if (unknown) return -1; -#endif /* defined(CONFIG_RRM) || defined(CONFIG_SAE_PK) */ +#endif /* defined(CONFIG_RRM) || defined(CONFIG_WNM) || defined(CONFIG_SAE_PK) */ return 0; } From 5f2fb567559113ee91849b78059903bf537fd033 Mon Sep 17 00:00:00 2001 From: Aditi Date: Fri, 8 Nov 2024 15:17:16 +0530 Subject: [PATCH 06/11] fix(wpa_supplicant): Fix for sending alternate ft-auth in roaming --- components/wpa_supplicant/esp_supplicant/src/esp_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index cb1f6a648b..dde0e3e079 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -300,10 +300,10 @@ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender, #endif /* CONFIG_IEEE80211R */ case WLAN_FC_STYPE_ASSOC_RESP: case WLAN_FC_STYPE_REASSOC_RESP: - wpa_sm_notify_assoc(&gWpaSm, sender); #ifdef CONFIG_IEEE80211R ret = handle_assoc_frame(frame, len, sender, rssi, channel); #endif /* CONFIG_IEEE80211R */ + wpa_sm_notify_assoc(&gWpaSm, sender); break; #if defined(CONFIG_IEEE80211KV) case WLAN_FC_STYPE_ACTION: From 7900eeca4e1dda5ea905989c40434d9c3441c9b6 Mon Sep 17 00:00:00 2001 From: Aditi Date: Thu, 14 Nov 2024 16:11:25 +0530 Subject: [PATCH 07/11] fix(wpa_supplicant): Remove the btm_rrm task from supplicant This commit removes btm_rrm_t task and CONFIG_SUPPLICANT_TASK from wpa_supplicant and make the functions work in wifi task's context. --- components/wpa_supplicant/CMakeLists.txt | 6 +- .../esp_supplicant/src/esp_common.c | 170 +----------------- .../esp_supplicant/src/esp_common_i.h | 14 -- .../esp_supplicant/src/esp_scan.c | 7 +- 4 files changed, 6 insertions(+), 191 deletions(-) diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index 1de14f5f12..d812d3272d 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -292,13 +292,13 @@ if(CONFIG_ESP_WIFI_DPP_SUPPORT) target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_DPP) endif() if(CONFIG_ESP_WIFI_11KV_SUPPORT) - target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV) + target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV) endif() if(CONFIG_ESP_WIFI_RRM_SUPPORT) - target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_RRM) + target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_RRM) endif() if(CONFIG_ESP_WIFI_WNM_SUPPORT) - target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM) + target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WNM) endif() if(CONFIG_ESP_WIFI_11R_SUPPORT) target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_IEEE80211R) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index dde0e3e079..698929990a 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -39,40 +39,7 @@ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6]) struct wpa_supplicant g_wpa_supp; #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) - -#ifdef CONFIG_SUPPLICANT_TASK -static void *s_supplicant_task_hdl = NULL; -static void *s_supplicant_evt_queue = NULL; -static void *s_supplicant_api_lock = NULL; -static bool s_supplicant_task_init_done; -#define SUPPLICANT_API_LOCK() os_mutex_lock(s_supplicant_api_lock) -#define SUPPLICANT_API_UNLOCK() os_mutex_unlock(s_supplicant_api_lock) -#define SUPPLICANT_TASK_STACK_SIZE (6144 + TASK_STACK_SIZE_ADD) - -static int handle_action_frm(u8 *frame, size_t len, - u8 *sender, int8_t rssi, u8 channel) -{ - struct ieee_mgmt_frame *frm = os_malloc(sizeof(struct ieee_mgmt_frame) + len); - - if (!frm) { - wpa_printf(MSG_ERROR, "memory allocation failed"); - return -1; - } - - os_memcpy(frm->sender, sender, ETH_ALEN); - frm->len = len; - frm->channel = channel; - frm->rssi = rssi; - - os_memcpy(frm->payload, frame, len); - if (esp_supplicant_post_evt(SIG_SUPPLICANT_RX_ACTION, (u32)frm) != 0) { - os_free(frm); - return -1; - } - - return 0; -} -#endif /* CONFIG_SUPPLICANT_TASK */ +static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 channel); #if defined(CONFIG_RRM) static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender, @@ -120,56 +87,6 @@ static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 cha return 0; } -#ifdef CONFIG_SUPPLICANT_TASK -static void btm_rrm_task(void *pvParameters) -{ - supplicant_event_t *evt; - bool task_del = false; - - while (1) { - if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE) { - continue; - } - - /* event validation failed */ - if (evt->id >= SIG_SUPPLICANT_MAX) { - os_free(evt); - continue; - } - - switch (evt->id) { - case SIG_SUPPLICANT_RX_ACTION: { - struct ieee_mgmt_frame *frm = (struct ieee_mgmt_frame *)evt->data; - mgmt_rx_action(frm->payload, frm->len, frm->sender, frm->rssi, frm->channel); - os_free(frm); - break; - } - - case SIG_SUPPLICANT_SCAN_DONE: - esp_supplicant_handle_scan_done_evt(); - break; - case SIG_SUPPLICANT_DEL_TASK: - task_del = true; - break; - default: - break; - } - - os_free(evt); - - if (task_del) { - break; - } - } - - os_queue_delete(s_supplicant_evt_queue); - s_supplicant_evt_queue = NULL; - - /* At this point, we completed */ - os_task_delete(NULL); -} -#endif /* CONFIG_SUPPLICANT_TASK */ - static void clear_bssid_flag_and_channel(struct wpa_supplicant *wpa_s) { wifi_config_t *config; @@ -307,11 +224,7 @@ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender, break; #if defined(CONFIG_IEEE80211KV) case WLAN_FC_STYPE_ACTION: -#ifdef CONFIG_SUPPLICANT_TASK - ret = handle_action_frm(frame, len, sender, rssi, channel); -#else /* CONFIG_SUPPLICANT_TASK */ - ret = mgmt_rx_action(frame, len, sender, rssi, channel); -#endif /* CONFIG_SUPPLICANT_TASK */ + mgmt_rx_action(frame, len, sender, rssi, channel); break; #endif /* defined(CONFIG_IEEE80211KV) */ default: @@ -356,32 +269,6 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb) int ret = 0; #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) -#ifdef CONFIG_SUPPLICANT_TASK - if (!s_supplicant_api_lock) { - s_supplicant_api_lock = os_recursive_mutex_create(); - } - - if (!s_supplicant_api_lock) { - wpa_printf(MSG_ERROR, "%s: failed to create Supplicant API lock", __func__); - ret = -1; - goto err; - } - - s_supplicant_evt_queue = os_queue_create(3, sizeof(supplicant_event_t)); - - if (!s_supplicant_evt_queue) { - wpa_printf(MSG_ERROR, "%s: failed to create Supplicant event queue", __func__); - ret = -1; - goto err; - } - ret = os_task_create(btm_rrm_task, "btm_rrm_t", SUPPLICANT_TASK_STACK_SIZE, NULL, 2, &s_supplicant_task_hdl); - if (ret != TRUE) { - wpa_printf(MSG_ERROR, "btm: failed to create task"); - ret = -1; - goto err; - } - s_supplicant_task_init_done = true; -#endif /* CONFIG_SUPPLICANT_TASK */ #if defined(CONFIG_RRM) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); @@ -425,26 +312,6 @@ void esp_supplicant_common_deinit(void) esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype); } #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) -#ifdef CONFIG_SUPPLICANT_TASK - /* We have failed to create task, delete queue and exit */ - if (!s_supplicant_task_hdl) { - if (s_supplicant_evt_queue) { - os_queue_delete(s_supplicant_evt_queue); - s_supplicant_evt_queue = NULL; - } - if (s_supplicant_api_lock) { - os_mutex_delete(s_supplicant_api_lock); - s_supplicant_api_lock = NULL; - } - } else if (esp_supplicant_post_evt(SIG_SUPPLICANT_DEL_TASK, 0) != 0) { - /* failed to post delete event, just delete event queue and exit */ - if (s_supplicant_evt_queue) { - os_queue_delete(s_supplicant_evt_queue); - s_supplicant_evt_queue = NULL; - } - } - s_supplicant_task_init_done = false; -#endif /* CONFIG_SUPPLICANT_TASK */ #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ } @@ -900,39 +767,6 @@ cleanup: return ret; } -#ifdef CONFIG_SUPPLICANT_TASK -int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data) -{ - supplicant_event_t *evt = os_zalloc(sizeof(supplicant_event_t)); - if (!evt) { - wpa_printf(MSG_ERROR, "Failed to allocated memory"); - return -1; - } - evt->id = evt_id; - evt->data = data; - - /* Make sure lock exists before taking it */ - SUPPLICANT_API_LOCK(); - - /* Make sure no event can be sent when deletion event is sent or task not initialized */ - if (!s_supplicant_task_init_done) { - SUPPLICANT_API_UNLOCK(); - os_free(evt); - return -1; - } - - if (os_queue_send(s_supplicant_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) { - SUPPLICANT_API_UNLOCK(); - os_free(evt); - return -1; - } - if (evt_id == SIG_SUPPLICANT_DEL_TASK) { - s_supplicant_task_init_done = false; - } - SUPPLICANT_API_UNLOCK(); - return 0; -} -#endif /* CONFIG_SUPPLICANT_TASK */ #else /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ void esp_set_scan_ie(void) { } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h index 1bf9e79b13..0e9581b057 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h @@ -21,20 +21,6 @@ struct ieee_mgmt_frame { u8 payload[0]; }; -int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data); - -typedef struct { - uint32_t id; - uint32_t data; -} supplicant_event_t; - -enum SIG_SUPPLICANT { - SIG_SUPPLICANT_RX_ACTION, - SIG_SUPPLICANT_SCAN_DONE, - SIG_SUPPLICANT_DEL_TASK, - SIG_SUPPLICANT_MAX, -}; - void esp_get_tx_power(uint8_t *tx_power); #ifdef CONFIG_MBO bool mbo_bss_profile_match(u8 *bssid); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c index acf68d187a..12e5865a47 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c @@ -22,6 +22,7 @@ #include "common/wnm_sta.h" #include "esp_scan_i.h" #include "esp_common_i.h" +#include "eloop.h" extern struct wpa_supplicant g_wpa_supp; @@ -35,13 +36,7 @@ static void scan_done_event_handler(void *arg, ETS_STATUS status) wpa_s->type &= ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP); esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype); } -#ifdef CONFIG_SUPPLICANT_TASK - if (esp_supplicant_post_evt(SIG_SUPPLICANT_SCAN_DONE, 0) != 0) { - wpa_printf(MSG_ERROR, "Posting of scan done failed!"); - } -#else esp_supplicant_handle_scan_done_evt(); -#endif /*CONFIG_SUPPLICANT_TASK*/ } #if defined(CONFIG_WNM) From 85156cceff5a100d26acb595fe8a32d64b10f53f Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Sat, 21 Dec 2024 11:33:47 +0530 Subject: [PATCH 08/11] fix(esp_wifi): Address some review comments --- components/esp_wifi/lib | 2 +- .../esp_supplicant/src/esp_common.c | 22 +++++++++---------- .../esp_supplicant/src/esp_scan.c | 1 - .../esp_supplicant/src/esp_wpa_main.c | 2 ++ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index f709d89ad9..ee87d8f94e 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit f709d89ad90f70c93c57b6de3152246d0614f959 +Subproject commit ee87d8f94eb6c2c4eeadd94aa25e68d8d0b5ad9b diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 698929990a..ce54df38c4 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,9 +38,8 @@ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6]) } struct wpa_supplicant g_wpa_supp; -#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) -static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 channel); +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) #if defined(CONFIG_RRM) static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender, u8 *payload, size_t len, int8_t rssi) @@ -339,8 +338,8 @@ void supplicant_sta_conn_handler(uint8_t *bssid) void supplicant_sta_disconn_handler(uint8_t reason_code) { - struct wpa_sm *sm = &gWpaSm; #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) + struct wpa_sm *sm = &gWpaSm; struct wpa_supplicant *wpa_s = &g_wpa_supp; #if defined(CONFIG_RRM) @@ -357,7 +356,7 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) wpa_s->current_bss = NULL; } #if defined(CONFIG_IEEE80211R) - if (reason_code == WIFI_REASON_INVALID_PMKID || reason_code == WIFI_REASON_INVALID_MDE || reason_code == WIFI_REASON_INVALID_FTE || (sm->cur_pmksa == NULL)) { + if (!sm->cur_pmksa) { /* clear all ft auth related IEs so that next will be open auth */ wpa_sta_clear_ft_auth_ie(); } @@ -413,24 +412,23 @@ int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb, void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_len) { - if (report == NULL) { + if (!report) { wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report - NONE"); esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, NULL, 0, 0); return; } wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report (token = %d)", report[0]); - + wifi_event_neighbor_report_t *neighbor_report_event = os_zalloc(sizeof(wifi_event_neighbor_report_t) + report_len); - if (neighbor_report_event == NULL) { + if (!neighbor_report_event) { wpa_printf(MSG_DEBUG, "memory alloc failed"); + return; } - if (report_len < ESP_WIFI_MAX_NEIGHBOR_REP_LEN) { - os_memcpy(neighbor_report_event->report, report, report_len); - } + os_memcpy(neighbor_report_event->report, report, ESP_WIFI_MAX_NEIGHBOR_REP_LEN); os_memcpy(neighbor_report_event->n_report, report, report_len); neighbor_report_event->report_len = report_len; - esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &neighbor_report_event, sizeof(wifi_event_neighbor_report_t), 0); + esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, neighbor_report_event, sizeof(wifi_event_neighbor_report_t) + report_len, 0); os_free(neighbor_report_event); } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c index 12e5865a47..9836dee18f 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c @@ -22,7 +22,6 @@ #include "common/wnm_sta.h" #include "esp_scan_i.h" #include "esp_common_i.h" -#include "eloop.h" extern struct wpa_supplicant g_wpa_supp; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index ae734b40cd..a891b97a62 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -295,6 +295,8 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) case WIFI_REASON_ASSOC_FAIL: case WIFI_REASON_CONNECTION_FAIL: case WIFI_REASON_HANDSHAKE_TIMEOUT: + case WIFI_REASON_INVALID_MDE: + case WIFI_REASON_INVALID_FTE: wpa_sta_clear_curr_pmksa(); wpa_sm_notify_disassoc(&gWpaSm); break; From e7895549974cf2d25b1bc85d5343929c7046b140 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Tue, 7 Jan 2025 11:32:26 +0530 Subject: [PATCH 09/11] fix(wifi): Fix bug in authmode detection for wpa2/wpa3 enterprise WPA3-Enterprise mandates the use of AKM suite selector 00:0F:AC:5 (IEEE80211 802.1X with SHA-256) --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index ee87d8f94e..82385ea482 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit ee87d8f94eb6c2c4eeadd94aa25e68d8d0b5ad9b +Subproject commit 82385ea482e178147d12b615f17117e260689ee2 From 9195bcbe2255dcb046e10b6faef60b252b51f4b4 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 9 Jan 2025 12:06:14 +0800 Subject: [PATCH 10/11] fix(wifi/mesh): fixed the mesh connection failure in WPA3 mode after erasing flash Closes https://github.com/espressif/esp-idf/issues/14095 --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 82385ea482..83cfa7ecce 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 82385ea482e178147d12b615f17117e260689ee2 +Subproject commit 83cfa7ecceb7a3ce277f8c2e5e682ccdf5f02e5e From e6e09dbc4c8d0dafe7057c4b6609a11c6a8611c0 Mon Sep 17 00:00:00 2001 From: linruihao Date: Fri, 3 Jan 2025 14:49:11 +0800 Subject: [PATCH 11/11] feat(coex): add coexist scheme for bt inquiry/page coexist with wifi --- components/bt/controller/lib_esp32 | 2 +- components/esp_coex/lib | 2 +- components/esp_wifi/lib | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index 35fb599d37..b0b9cff14b 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 35fb599d3733f50254c056171edebcaa3c57d06b +Subproject commit b0b9cff14b4f72482300975368b3b258f30120ac diff --git a/components/esp_coex/lib b/components/esp_coex/lib index 7b588f2dbb..f8196c5811 160000 --- a/components/esp_coex/lib +++ b/components/esp_coex/lib @@ -1 +1 @@ -Subproject commit 7b588f2dbb12ddcd46c075dcd041f4d03a59154f +Subproject commit f8196c58116bed53358608ec9499ea72720e2acf diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 83cfa7ecce..73ba41ad38 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 83cfa7ecceb7a3ce277f8c2e5e682ccdf5f02e5e +Subproject commit 73ba41ad38632ee8e36e5354aa565487fbfb156c