From 55d44e0beef86868132bbf74b00c20705e85cbde Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 6 Apr 2023 18:07:12 +0800 Subject: [PATCH 1/9] wifi_mesh: fix the heap corrupt issue in MTXON task --- 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 6484d097a3..8a5ac6e557 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 6484d097a356caae907327d5ce87d60a822ab25a +Subproject commit 8a5ac6e557ec80c1c143507c4cb10d1d3d631164 From c020a68e1ee8514e77dd29e33fa8d08caf1a4c91 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 6 Apr 2023 18:10:55 +0800 Subject: [PATCH 2/9] Update the ESP-NOW frame length in docs --- docs/en/api-reference/network/esp_now.rst | 2 +- docs/zh_CN/api-reference/network/esp_now.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index a358291065..8539ca16d9 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -21,7 +21,7 @@ ESP-NOW uses a vendor-specific action frame to transmit ESP-NOW data. The defaul ------------------------------------------------------------------------------------------------------------ | MAC Header | Category Code | Organization Identifier | Random Values | Vendor Specific Content | FCS | ------------------------------------------------------------------------------------------------------------ - 24 bytes 1 byte 3 bytes 4 bytes 7~255 bytes 4 bytes + 24 bytes 1 byte 3 bytes 4 bytes 7~257 bytes 4 bytes - Category Code: The Category Code field is set to the value(127) indicating the vendor-specific category. - Organization Identifier: The Organization Identifier contains a unique identifier (0x18fe34), which is the first three bytes of MAC address applied by Espressif. diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index 09055519a7..4288062f87 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -21,7 +21,7 @@ ESP-NOW 使用各个供应商的动作帧传输数据,默认比特率为 1 Mbp ----------------------------------------------------------------------------------------- | MAC 报头 | 分类代码 | 组织标识符 | 随机值 | 供应商特定内容 | FCS | ----------------------------------------------------------------------------------------- - 24 字节 1 字节 3 字节 4 字节 7~255 字节 4 字节 + 24 字节 1 字节 3 字节 4 字节 7~257 字节 4 字节 - 分类代码:分类代码字段可用于指示各个供应商的类别(比如 127)。 - 组织标识符:组织标识符包含一个唯一标识符 (比如 0x18fe34),为乐鑫指定的 MAC 地址的前三个字节。 From 7a410499f32356477c21b3a7bda611ff3238e5eb Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Thu, 6 Apr 2023 16:39:53 +0530 Subject: [PATCH 3/9] esp_wifi: Validate softap interface when sending beacon frame --- 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 8a5ac6e557..2887099fd8 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 8a5ac6e557ec80c1c143507c4cb10d1d3d631164 +Subproject commit 2887099fd855804f057e02d32273192a5993d294 From 8438887cb42cba679ef5baf678f7425b91be3fac Mon Sep 17 00:00:00 2001 From: xuxiao Date: Mon, 10 Apr 2023 18:09:01 +0800 Subject: [PATCH 4/9] esp_wifi: update phy_init_data.h for c6 mcs 8 9 power issue --- .../esp_phy/esp32c6/include/phy_init_data.h | 45 ++++++++++++------- components/esp_phy/lib | 2 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/components/esp_phy/esp32c6/include/phy_init_data.h b/components/esp_phy/esp32c6/include/phy_init_data.h index 9f173ca95c..aa6e9b4030 100644 --- a/components/esp_phy/esp32c6/include/phy_init_data.h +++ b/components/esp_phy/esp32c6/include/phy_init_data.h @@ -41,7 +41,7 @@ static const esp_phy_init_data_t phy_init_data= { { 0x00, LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x54), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x54), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x54), + LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), @@ -49,19 +49,10 @@ static const esp_phy_init_data_t phy_init_data= { { LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), - LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x28), + LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), + LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), + LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), + LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), 0x00, 0x00, 0x00, @@ -149,7 +140,31 @@ static const esp_phy_init_data_t phy_init_data= { { 0, 0, 0, - 0x9B + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0x70 } }; static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 6b2f06a44d..03c270c901 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 6b2f06a44d311d84700c55df60354a634239cb32 +Subproject commit 03c270c901c1106931ea6299523928c64d457b91 From a4dbb3a0a1937ba9f28951be454a338bc29068f5 Mon Sep 17 00:00:00 2001 From: Shyamal Khachane Date: Fri, 7 Apr 2023 17:12:03 +0530 Subject: [PATCH 5/9] esp_wifi: Update wifi libs Fix some NAN issues related to followup and matching filters --- 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 2887099fd8..ce8f0a4e7b 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 2887099fd855804f057e02d32273192a5993d294 +Subproject commit ce8f0a4e7b2fc7840f54322b9216cc1f1329081a From 79dabf50b05913bce0d9ecb6c34621fc443ac0ad Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Thu, 6 Apr 2023 18:43:06 +0530 Subject: [PATCH 6/9] esp_wifi: Install keys after successful transmission of EAPOL 4/4 Message --- components/esp_wifi/lib | 2 +- .../wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h | 1 + components/wpa_supplicant/src/rsn_supp/wpa.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index ce8f0a4e7b..0569815906 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit ce8f0a4e7b2fc7840f54322b9216cc1f1329081a +Subproject commit 056981590639e05947f0f3a2db5c79ac05683a01 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index 31c7ee72b5..57b036f9a1 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -294,5 +294,6 @@ uint8_t esp_wifi_get_config_sae_pwe_h2e_internal(uint8_t ifx); bool esp_wifi_ap_notify_node_sae_auth_done(uint8_t *mac); bool esp_wifi_ap_is_sta_sae_reauth_node(uint8_t *mac); uint8_t* esp_wifi_sta_get_sae_identifier_internal(void); +bool esp_wifi_eb_tx_status_success_internal(void *eb); #endif /* _ESP_WIFI_DRIVER_H_ */ diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index ab8ea2b4fe..a5ebab6017 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -2621,6 +2621,12 @@ void eapol_txcb(void *eb) case WPA_FIRST_HALF_4WAY_HANDSHAKE: break; case WPA_LAST_HALF_4WAY_HANDSHAKE: + + if (esp_wifi_eb_tx_status_success_internal(eb) != true) { + wpa_printf(MSG_ERROR, "Eapol message 4/4 tx failure, not installing keys"); + return; + } + if (sm->txcb_flags & WPA_4_4_HANDSHAKE_BIT) { sm->txcb_flags &= ~WPA_4_4_HANDSHAKE_BIT; isdeauth = wpa_supplicant_send_4_of_4_txcallback(sm); From ce5444d349b8959114a0281b359eafecd8d72c34 Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Fri, 14 Apr 2023 10:53:48 +0530 Subject: [PATCH 7/9] esp_wifi: Bugfix store authmode security in NVS --- 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 0569815906..160111ebac 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 056981590639e05947f0f3a2db5c79ac05683a01 +Subproject commit 160111ebacd684be91b629dcfade9e1a07e9e131 From 39caffc5925f9f90759502a06a435a117c7de6c4 Mon Sep 17 00:00:00 2001 From: xuxiao Date: Tue, 14 Mar 2023 15:22:44 +0800 Subject: [PATCH 8/9] esp_wifi: espnow support using 11ax rate to send frame --- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 2 +- .../esp_rom/esp32c6/ld/esp32c6.rom.pp.ld | 16 ++--- components/esp_wifi/include/esp_now.h | 29 ++++++++ components/esp_wifi/include/esp_wifi_types.h | 72 +++++++++++++------ components/esp_wifi/lib | 2 +- 5 files changed, 90 insertions(+), 31 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 8f3d758506..7937ef4d9c 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -1929,7 +1929,7 @@ wep_encap = 0x40002024; wep_decap = 0x40002028; dbg_hmac_rxtx_statis_dump = 0x4000202c; dbg_hmac_statis_dump = 0x40002030; -ieee80211_send_action_vendor_spec = 0x40002034; +/* ieee80211_send_action_vendor_spec = 0x40002034; */ ieee80211_vnd_lora_ie_size = 0x40002048; ieee80211_vnd_ie_size = 0x4000204c; ieee80211_add_ssid = 0x40002050; diff --git a/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld b/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld index 29fb9c7950..0203afed0d 100644 --- a/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld +++ b/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld @@ -50,11 +50,11 @@ lmacReachShortLimit = 0x40000c48; lmacRecycleMPDU = 0x40000c4c; lmacRxDone = 0x40000c50; //lmacSetTxFrame = 0x40000c54; -lmacTxDone = 0x40000c58; +//lmacTxDone = 0x40000c58; lmacTxFrame = 0x40000c5c; mac_tx_set_duration = 0x40000c60; //mac_tx_set_plcp0 = 0x40000c64; -mac_tx_set_plcp1 = 0x40000c68; +//mac_tx_set_plcp1 = 0x40000c68; mac_tx_set_plcp2 = 0x40000c6c; pm_check_state = 0x40000c70; /* pm_disable_dream_timer = 0x40000c74; */ @@ -92,7 +92,7 @@ ppEnqueueRxq = 0x40000cf0; ppEnqueueTxDone = 0x40000cf4; ppGetTxframe = 0x40000cf8; //ppMapTxQueue = 0x40000cfc; -ppProcTxSecFrame = 0x40000d00; +//ppProcTxSecFrame = 0x40000d00; ppProcessRxPktHdr = 0x40000d04; //ppProcessTxQ = 0x40000d08; ppRecordBarRRC = 0x40000d0c; @@ -171,7 +171,7 @@ ppDisableQueue = 0x40000e2c; pm_allow_tx = 0x40000e30; //wdev_is_data_in_rxlist = 0x40000e34; ppProcTxCallback = 0x40000e38; -mac_tx_set_hesig = 0x40000e3c; +//mac_tx_set_hesig = 0x40000e3c; ppCalPreFecPaddingFactor = 0x40000e40; mac_tx_set_tb = 0x40000e44; mac_tx_set_mplen = 0x40000e48; @@ -294,8 +294,8 @@ tsf_hal_set_tsf_time_deviation = 0x40001018; tsf_hal_set_tsf_time_deviation_sync_disable = 0x4000101c; tsf_hal_set_tsf_time_deviation_sync_enable = 0x40001020; tsf_hal_unmap_tbtt_target_to_rx_frame = 0x40001024; -ppSelectTxFormat = 0x40001028; -ppCertSetRate = 0x4000102c; +//ppSelectTxFormat = 0x40001028; +//ppCertSetRate = 0x4000102c; //ppHEAMPDU2Normal = 0x40001030; ppCalTxHEAMPDULength = 0x40001034; ppCalTxHESMPDULength = 0x40001038; @@ -435,8 +435,8 @@ s_mplen_vi_bitmap = 0x4087fdac; s_mplen_bk_bitmap = 0x4087fda8; esp_wifi_cert_tx_mcs = 0x4087fcfc; esp_wifi_cert_tx_bcc = 0x4087fcf8; -esp_wifi_cert_tx_ltf = 0x4087fcf4; -esp_wifi_cert_tx_gi = 0x4087fcf0; +//esp_wifi_cert_tx_ltf = 0x4087fcf4; +//esp_wifi_cert_tx_gi = 0x4087fcf0; esp_wifi_cert_tx_nss = 0x4087fcec; esp_test_tx_statistics_aci_bitmap = 0x4087fda4; esp_test_tx_statistics = 0x4087fd94; diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 7425f9d52d..2a39856601 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -89,6 +89,16 @@ typedef struct esp_now_recv_info { wifi_pkt_rx_ctrl_t * rx_ctrl; /**< Rx control info of ESPNOW packet */ } esp_now_recv_info_t; +/** + * @brief ESPNOW rate config + * + */ +typedef struct esp_now_rate_config { + wifi_phy_mode_t phymode; /**< ESPNOW phymode of specified interface */ + wifi_phy_rate_t rate; /**< ESPNOW rate of specified interface*/ + bool ersu; /**< ESPNOW using ersu send frame*/ +} esp_now_rate_config_t; + /** * @brief Callback function of receiving ESPNOW data * @param esp_now_info received ESPNOW packet information @@ -242,7 +252,10 @@ esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer); /** * @brief Config ESPNOW rate of specified interface * + * @deprecated please use esp_now_set_peer_rate_config() instead. + * * @attention 1. This API should be called after esp_wifi_start(). + * @attention 2. This API only work when not use Wi-Fi 6 and esp_now_set_peer_rate_config() not called. * * @param ifx Interface to be configured. * @param rate Phy rate to be configured. @@ -253,6 +266,22 @@ esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer); */ esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Set ESPNOW rate config for each peer + * + * @attention 1. This API should be called after esp_wifi_start() and esp_now_init(). + * + * @param peer_addr peer MAC address + * @param config rate config to be configured. + * + * @return + * - ESP_OK : succeed + * - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized + * - ESP_ERR_ESPNOW_ARG : invalid argument + * - ESP_ERR_ESPNOW_INTERNAL : internal error + */ +esp_err_t esp_now_set_peer_rate_config(const uint8_t *peer_addr, esp_now_rate_config_t *config); + /** * @brief Get a peer whose MAC address matches peer_addr from peer list * diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 614bcd2cb5..6b43d113a1 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -779,36 +779,66 @@ typedef enum { WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */ WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */ WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */ - WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI, 6.5 Mbps for 20MHz, 13.5 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI, 13 Mbps for 20MHz, 27 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI, 19.5 Mbps for 20MHz, 40.5 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI, 26 Mbps for 20MHz, 54 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI, 39 Mbps for 20MHz, 81 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI, 52 Mbps for 20MHz, 108 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI, 58.5 Mbps for 20MHz, 121.5 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */ + /**< rate table and guard interval information for each MCS rate*/ + /* + ----------------------------------------------------------------------------------------------------------- + MCS RATE | HT20 | HT40 | HE20 | + WIFI_PHY_RATE_MCS0_LGI | 6.5 Mbps (800ns) | 13.5 Mbps (800ns) | 8.1 Mbps (1600ns) | + WIFI_PHY_RATE_MCS1_LGI | 13 Mbps (800ns) | 27 Mbps (800ns) | 16.3 Mbps (1600ns) | + WIFI_PHY_RATE_MCS2_LGI | 19.5 Mbps (800ns) | 40.5 Mbps (800ns) | 24.4 Mbps (1600ns) | + WIFI_PHY_RATE_MCS3_LGI | 26 Mbps (800ns) | 54 Mbps (800ns) | 32.5 Mbps (1600ns) | + WIFI_PHY_RATE_MCS4_LGI | 39 Mbps (800ns) | 81 Mbps (800ns) | 48.8 Mbps (1600ns) | + WIFI_PHY_RATE_MCS5_LGI | 52 Mbps (800ns) | 108 Mbps (800ns) | 65 Mbps (1600ns) | + WIFI_PHY_RATE_MCS6_LGI | 58.5 Mbps (800ns) | 121.5 Mbps (800ns) | 73.1 Mbps (1600ns) | + WIFI_PHY_RATE_MCS7_LGI | 65 Mbps (800ns) | 135 Mbps (800ns) | 81.3 Mbps (1600ns) | + WIFI_PHY_RATE_MCS8_LGI | ----- | ----- | 97.5 Mbps (1600ns) | + WIFI_PHY_RATE_MCS9_LGI | ----- | ----- | 108.3 Mbps (1600ns) | + ----------------------------------------------------------------------------------------------------------- + */ + WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI */ + WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI */ + WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI */ + WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI */ + WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI */ + WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI */ + WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI */ + WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI */ #if CONFIG_SOC_WIFI_HE_SUPPORT - WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 */ - WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 */ + WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 with long GI */ + WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 with long GI */ #endif - WIFI_PHY_RATE_MCS0_SGI, /**< MCS0 with short GI, 7.2 Mbps for 20MHz, 15 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS1_SGI, /**< MCS1 with short GI, 14.4 Mbps for 20MHz, 30 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS2_SGI, /**< MCS2 with short GI, 21.7 Mbps for 20MHz, 45 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS3_SGI, /**< MCS3 with short GI, 28.9 Mbps for 20MHz, 60 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS4_SGI, /**< MCS4 with short GI, 43.3 Mbps for 20MHz, 90 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI, 57.8 Mbps for 20MHz, 120 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */ - WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI, 72.2 Mbps for 20MHz, 150 Mbps for 40MHz */ + /* + ----------------------------------------------------------------------------------------------------------- + MCS RATE | HT20 | HT40 | HE20 | + WIFI_PHY_RATE_MCS0_SGI | 7.2 Mbps (400ns) | 15 Mbps (400ns) | 8.6 Mbps (800ns) | + WIFI_PHY_RATE_MCS1_SGI | 14.4 Mbps (400ns) | 30 Mbps (400ns) | 17.2 Mbps (800ns) | + WIFI_PHY_RATE_MCS2_SGI | 21.7 Mbps (400ns) | 45 Mbps (400ns) | 25.8 Mbps (800ns) | + WIFI_PHY_RATE_MCS3_SGI | 28.9 Mbps (400ns) | 60 Mbps (400ns) | 34.4 Mbps (800ns) | + WIFI_PHY_RATE_MCS4_SGI | 43.3 Mbps (400ns) | 90 Mbps (400ns) | 51.6 Mbps (800ns) | + WIFI_PHY_RATE_MCS5_SGI | 57.8 Mbps (400ns) | 120 Mbps (400ns) | 68.8 Mbps (800ns) | + WIFI_PHY_RATE_MCS6_SGI | 65 Mbps (400ns) | 135 Mbps (400ns) | 77.4 Mbps (800ns) | + WIFI_PHY_RATE_MCS7_SGI | 72.2 Mbps (400ns) | 150 Mbps (400ns) | 86 Mbps (800ns) | + WIFI_PHY_RATE_MCS8_SGI | ----- | ----- | 103.2 Mbps (800ns) | + WIFI_PHY_RATE_MCS9_SGI | ----- | ----- | 114.7 Mbps (800ns) | + ----------------------------------------------------------------------------------------------------------- + */ + WIFI_PHY_RATE_MCS0_SGI, /**< MCS0 with short GI */ + WIFI_PHY_RATE_MCS1_SGI, /**< MCS1 with short GI */ + WIFI_PHY_RATE_MCS2_SGI, /**< MCS2 with short GI */ + WIFI_PHY_RATE_MCS3_SGI, /**< MCS3 with short GI */ + WIFI_PHY_RATE_MCS4_SGI, /**< MCS4 with short GI */ + WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI */ + WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI */ + WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI */ #if CONFIG_SOC_WIFI_HE_SUPPORT - WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 */ - WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 */ + WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 with short GI */ + WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 with short GI */ #endif WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */ WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */ WIFI_PHY_RATE_MAX, } wifi_phy_rate_t; - /** WiFi event declarations */ typedef enum { WIFI_EVENT_WIFI_READY = 0, /**< WiFi ready */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 160111ebac..522229f2ce 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 160111ebacd684be91b629dcfade9e1a07e9e131 +Subproject commit 522229f2ce39d6347f0de511a2edb627f4873bd2 From f9ebbdf6eaf8ee8e8822ede95659d8e3cdf675a8 Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Mon, 3 Apr 2023 03:51:14 +0530 Subject: [PATCH 9/9] esp_wifi:Enable wpsreg to initialize in APSTA mode --- .../esp_supplicant/src/esp_hostap.c | 8 +++- .../esp_supplicant/src/esp_hostpad_wps.c | 40 ++++++++++++++----- .../esp_supplicant/src/esp_wpa2.c | 4 ++ .../esp_supplicant/src/esp_wpa_main.c | 9 ++++- .../esp_supplicant/src/esp_wps.c | 36 ++++++++++------- .../wpa_supplicant/src/rsn_supp/wpa_i.h | 2 + 6 files changed, 72 insertions(+), 27 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c index 4bc5716763..d160b7c336 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c @@ -18,6 +18,7 @@ #include "esp_wifi_driver.h" #include "esp_wifi_types.h" #include "esp_wpa3_i.h" +#include "esp_wps.h" #define WIFI_PASSWORD_LEN_MAX 65 @@ -211,7 +212,12 @@ void hostapd_cleanup(struct hostapd_data *hapd) } #endif /* CONFIG_SAE */ - +#ifdef CONFIG_WPS_REGISTRAR + if (esp_wifi_get_wps_type_internal () != WPS_TYPE_DISABLE || + esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) { + esp_wifi_ap_wps_disable(); + } +#endif /* CONFIG_WPS_REGISTRAR */ os_free(hapd); global_hapd = NULL; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c index b436b810e1..84a8177dc6 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c @@ -37,8 +37,9 @@ static int wifi_ap_wps_init(const esp_wps_config_t *config) struct wps_sm *sm = NULL; uint8_t mac[ETH_ALEN]; struct wps_config cfg = {0}; + struct hostapd_data *hapd = hostapd_get_hapd_data(); - if (gWpsSm) { + if (!hapd || gWpsSm) { goto _out; } @@ -76,7 +77,7 @@ static int wifi_ap_wps_init(const esp_wps_config_t *config) goto _err; } - hostapd_init_wps(hostapd_get_hapd_data(), sm->wps, sm->wps_ctx); + hostapd_init_wps(hapd, sm->wps, sm->wps_ctx); /* Report PIN */ if (wps_get_type() == WPS_TYPE_PIN) { @@ -171,19 +172,37 @@ int wifi_ap_wps_enable_internal(const esp_wps_config_t *config) int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) { - int ret; + int ret = ESP_OK; + struct wps_sm *sm = gWpsSm; wifi_mode_t mode = WIFI_MODE_NULL; + if (esp_wifi_get_user_init_flag_internal() == 0) { + wpa_printf(MSG_ERROR, "wps enable: wifi not started cannot enable wpsreg"); + return ESP_ERR_WIFI_STATE; + } + ret = esp_wifi_get_mode(&mode); - if (mode != WIFI_MODE_AP) { + if (mode != WIFI_MODE_AP && mode != WIFI_MODE_APSTA) { + wpa_printf(MSG_ERROR, "wps enable: mode=%d does not include AP", mode); + return ESP_ERR_WIFI_MODE; + } + + if (esp_wifi_ap_get_prof_authmode_internal() == WIFI_AUTH_OPEN) { + wpa_printf(MSG_ERROR, "wps enable: wpsreg not supported when authmode is open"); return ESP_ERR_WIFI_MODE; } API_MUTEX_TAKE(); if (s_wps_enabled) { + if (sm && os_memcmp(sm->identity, WSC_ID_ENROLLEE, sm->identity_len) == 0) { + wpa_printf(MSG_ERROR, "wps enable: wps enrollee already enabled cannot enable wpsreg"); + ret = ESP_ERR_WIFI_MODE; + } else { + wpa_printf(MSG_DEBUG, "wps enable: already enabled"); + ret = ESP_OK; + } API_MUTEX_GIVE(); - wpa_printf(MSG_DEBUG, "wps enable: already enabled"); - return ESP_OK; + return ret; } ret = wifi_ap_wps_enable_internal(config); @@ -195,10 +214,9 @@ int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) int esp_wifi_ap_wps_disable(void) { int ret = 0; - wifi_mode_t mode = WIFI_MODE_NULL; + struct wps_sm *sm = gWpsSm; - ret = esp_wifi_get_mode(&mode); - if (mode != WIFI_MODE_AP) { + if (sm && os_memcmp(sm->identity, WSC_ID_ENROLLEE, sm->identity_len) == 0) { return ESP_ERR_WIFI_MODE; } @@ -230,8 +248,8 @@ int esp_wifi_ap_wps_start(const unsigned char *pin) wifi_mode_t mode = WIFI_MODE_NULL; esp_wifi_get_mode(&mode); - if (mode != WIFI_MODE_AP) { - wpa_printf(MSG_ERROR, "wps start: mode=%d is not AP", mode); + if (mode != WIFI_MODE_AP && mode != WIFI_MODE_APSTA) { + wpa_printf(MSG_ERROR, "wps start: mode=%d does not include AP", mode); return ESP_ERR_WIFI_MODE; } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c index 18353777c5..290c4fa6cc 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c @@ -817,6 +817,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable(void) { wifi_wpa2_param_t param; esp_err_t ret; + struct wpa_sm *sm = &gWpaSm; wpa2_api_lock(); @@ -833,6 +834,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable(void) if (ESP_OK == ret) { wpa2_set_state(WPA2_STATE_ENABLED); + sm->wpa_sm_wpa2_ent_disable = esp_wifi_sta_wpa2_ent_disable; } else { wpa_printf(MSG_ERROR, "failed to enable wpa2 ret=%d", ret); } @@ -844,6 +846,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable(void) esp_err_t esp_wifi_sta_wpa2_ent_disable_fn(void *param) { + struct wpa_sm *sm = &gWpaSm; wpa_printf(MSG_INFO, "WPA2 ENTERPRISE VERSION: [%s] disable", WPA2_VERSION); esp_wifi_unregister_wpa2_cb_internal(); @@ -855,6 +858,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_disable_fn(void *param) eap_peer_unregister_methods(); #endif + sm->wpa_sm_wpa2_ent_disable = NULL; return ESP_OK; } 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 43d7f9c1ae..889cb2ef0b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -181,8 +181,15 @@ void wpa_ap_get_peer_spp_msg(void *sm_data, bool *spp_cap, bool *spp_req) bool wpa_deattach(void) { + struct wpa_sm *sm = &gWpaSm; esp_wpa3_free_sae_data(); - esp_wifi_sta_wpa2_ent_disable(); + if (sm->wpa_sm_wpa2_ent_disable) { + sm->wpa_sm_wpa2_ent_disable(); + } + if (sm->wpa_sm_wps_disable) { + sm->wpa_sm_wps_disable(); + } + wpa_sm_deinit(); return true; } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c index 1dd0451e9c..98c7efe821 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c @@ -1771,7 +1771,6 @@ int wps_post_block(uint32_t sig, void *arg) int wps_check_wifi_mode(void) { - bool sniffer = false; wifi_mode_t mode; int ret; @@ -1781,18 +1780,12 @@ int wps_check_wifi_mode(void) return ESP_FAIL; } - ret = esp_wifi_get_promiscuous(&sniffer); - if (ESP_OK != ret) { - wpa_printf(MSG_ERROR, "wps check wifi mode: failed to get sniffer mode ret=%d", ret); - return ESP_FAIL; - } - if ( #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT mode == WIFI_MODE_AP || #endif - mode == WIFI_MODE_NULL || sniffer == true) { - wpa_printf(MSG_ERROR, "wps check wifi mode: wrong wifi mode=%d sniffer=%d", mode, sniffer); + mode == WIFI_MODE_NULL) { + wpa_printf(MSG_ERROR, "wps check wifi mode: wrong wifi mode=%d ", mode); return ESP_ERR_WIFI_MODE; } @@ -1801,7 +1794,13 @@ int wps_check_wifi_mode(void) int esp_wifi_wps_enable(const esp_wps_config_t *config) { - int ret; + int ret = ESP_OK; + struct wps_sm *sm = gWpsSm; + + if (esp_wifi_get_user_init_flag_internal() == 0) { + wpa_printf(MSG_ERROR, "wps enable: wifi not started cannot disable wpsreg"); + return ESP_ERR_WIFI_STATE; + } if (ESP_OK != wps_check_wifi_mode()) { return ESP_ERR_WIFI_MODE; @@ -1809,9 +1808,14 @@ int esp_wifi_wps_enable(const esp_wps_config_t *config) API_MUTEX_TAKE(); if (s_wps_enabled) { + if (sm && os_memcmp(sm->identity, WSC_ID_REGISTRAR, sm->identity_len) == 0) { + wpa_printf(MSG_ERROR, "wps enable: wpsreg already enabled cannot enable wps enrollee"); + ret = ESP_ERR_WIFI_MODE; + } else { + wpa_printf(MSG_DEBUG, "wps enable: already enabled"); + } API_MUTEX_GIVE(); - wpa_printf(MSG_DEBUG, "wps enable: already enabled"); - return ESP_OK; + return ret; } #ifdef USE_WPS_TASK @@ -1842,6 +1846,7 @@ int esp_wifi_wps_enable(const esp_wps_config_t *config) int wifi_wps_enable_internal(const esp_wps_config_t *config) { int ret = 0; + struct wpa_sm *wpa_sm = &gWpaSm; wpa_printf(MSG_DEBUG, "ESP WPS crypto initialize!"); if (config->wps_type == WPS_TYPE_DISABLE) { @@ -1867,7 +1872,7 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config) wps_set_status(WPS_STATUS_DISABLE); return ESP_FAIL; } - + wpa_sm->wpa_sm_wps_disable = esp_wifi_wps_disable; return ESP_OK; } @@ -1882,8 +1887,10 @@ int esp_wifi_wps_disable(void) { int ret = 0; int wps_status; + struct wps_sm *wps_sm = gWpsSm; + struct wpa_sm *wpa_sm = &gWpaSm; - if (ESP_OK != wps_check_wifi_mode()) { + if (wps_sm && os_memcmp(wps_sm->identity, WSC_ID_REGISTRAR, wps_sm->identity_len) == 0) { return ESP_ERR_WIFI_MODE; } @@ -1922,6 +1929,7 @@ int esp_wifi_wps_disable(void) wps_task_deinit(); s_wps_enabled = false; API_MUTEX_GIVE(); + wpa_sm->wpa_sm_wps_disable = NULL; return ESP_OK; } diff --git a/components/wpa_supplicant/src/rsn_supp/wpa_i.h b/components/wpa_supplicant/src/rsn_supp/wpa_i.h index 0728146cae..b4b0ce75d9 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa_i.h +++ b/components/wpa_supplicant/src/rsn_supp/wpa_i.h @@ -116,6 +116,8 @@ struct wpa_sm { u16 owe_group; struct wpabuf *owe_ie; #endif /* CONFIG_OWE_STA */ + int (*wpa_sm_wps_disable)(void); + esp_err_t (*wpa_sm_wpa2_ent_disable)(void); }; /**