diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 40bc62a5f6..e1851538f7 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -513,7 +513,7 @@ lmacRecycleMPDU = 0x40001b44; lmacRxDone = 0x40001b48; /*lmacSetTxFrame = 0x40001b4c;*/ lmacTxDone = 0x40001b50; -lmacTxFrame = 0x40001b54; +/*lmacTxFrame = 0x40001b54;*/ mac_tx_set_duration = 0x40001b58; mac_tx_set_htsig = 0x40001b5c; mac_tx_set_plcp0 = 0x40001b60; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index b8a058d769..7d6e80529b 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1788,6 +1788,29 @@ esp_err_t esp_wifi_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t* bw); */ esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw); +/** + * @brief Send action frame on target channel + * + * @param req action tx request structure containing relevant fields + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_FAIL: failed to send frame + */ +esp_err_t esp_wifi_action_tx_req(wifi_action_tx_req_t *req); + +/** + * @brief Remain on the target channel for required duration + * + * @param req roc request structure containing relevant fields + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_FAIL: failed to perform roc operation + */ +esp_err_t esp_wifi_remain_on_channel(wifi_roc_req_t * req); #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index 5d18ca383a..aca504e529 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -41,15 +41,15 @@ typedef enum { WIFI_IF_MAX /**< Maximum number of interfaces */ } wifi_interface_t; -enum { +typedef enum { WIFI_OFFCHAN_TX_CANCEL, /**< Cancel off-channel transmission */ WIFI_OFFCHAN_TX_REQ, /**< Request off-channel transmission */ -}; +} wifi_action_tx_t; -enum { +typedef enum { WIFI_ROC_CANCEL, /**< Cancel remain on channel */ WIFI_ROC_REQ, /**< Request remain on channel */ -}; +} wifi_roc_t; /** * @brief Wi-Fi country policy */ @@ -774,8 +774,11 @@ typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, typedef struct { wifi_interface_t ifx; /**< Wi-Fi interface to send request to */ uint8_t dest_mac[6]; /**< Destination MAC address */ + wifi_action_tx_t type; /**< ACTION TX operation type */ + uint8_t channel; /**< Channel on which to perform ACTION TX Operation */ + uint32_t wait_time_ms; /**< Duration to wait for on target channel */ bool no_ack; /**< Indicates no ack required */ - wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive any response */ + wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive action frames */ uint8_t op_id; /**< Unique Identifier for operation provided by wifi driver */ uint32_t data_len; /**< Length of the appended Data */ uint8_t data[0]; /**< Appended Data payload */ @@ -805,7 +808,7 @@ typedef void (* wifi_action_roc_done_cb_t)(uint32_t context, uint8_t op_id, */ typedef struct { wifi_interface_t ifx; /**< WiFi interface to send request to */ - uint8_t type; /**< ROC operation type */ + wifi_roc_t type; /**< ROC operation type */ uint8_t channel; /**< Channel on which to perform ROC Operation */ wifi_second_chan_t sec_channel; /**< Secondary channel */ uint32_t wait_time_ms; /**< Duration to wait for on target channel */ @@ -1236,6 +1239,7 @@ typedef struct { #define WIFI_STATIS_ALL (-1) /**< All status */ /** Status codes for WIFI_EVENT_ACTION_TX_STATUS evt */ +/** There will be back to back events in success case TX_DONE and TX_DURATION_COMPLETED */ typedef enum { WIFI_ACTION_TX_DONE = 0, /**< ACTION_TX operation was completed successfully */ WIFI_ACTION_TX_FAILED, /**< ACTION_TX operation failed during tx */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index b3fbda3436..f6b785ece0 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit b3fbda3436293689ed80dd3dfbe4106dd3b697bc +Subproject commit f6b785ece04d4a2c22da31ea5f7761344a2fd367 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 8eb43cc1db..a28ad57592 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.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 */ @@ -101,7 +101,7 @@ static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx) esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, uint8_t channel, uint32_t wait_time_ms) { - wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len);; + wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len); if (!req) { return ESP_FAIL; } @@ -111,13 +111,15 @@ esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint3 req->no_ack = false; req->data_len = len; req->rx_cb = s_action_rx_cb; + req->channel = channel; + req->wait_time_ms = wait_time_ms; + req->type = WIFI_OFFCHAN_TX_REQ; memcpy(req->data, buf, req->data_len); wpa_printf(MSG_DEBUG, "DPP: Mgmt Tx - MAC:" MACSTR ", Channel-%d, WaitT-%d", MAC2STR(dest_mac), channel, wait_time_ms); - if (ESP_OK != esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_REQ, channel, - wait_time_ms, req)) { + if (ESP_OK != esp_wifi_action_tx_req(req)) { wpa_printf(MSG_ERROR, "DPP: Failed to perform offchannel operation"); esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_TX_FAILURE); os_free(req); @@ -665,8 +667,8 @@ static void offchan_event_handler(void *arg, esp_event_base_t event_base, wifi_event_action_tx_status_t *evt = (wifi_event_action_tx_status_t *)event_data; if (evt->op_id == s_current_tx_op_id) { - wpa_printf(MSG_DEBUG, "Mgmt Tx Status - %d, Context - 0x%x Operation ID : %d", - evt->status, (uint32_t)evt->context, evt->op_id); + wpa_printf(MSG_DEBUG, + "Mgmt Tx Status - %d, Context - 0x%x Operation ID : %d", evt->status, (uint32_t)evt->context, evt->op_id); if (evt->status == WIFI_ACTION_TX_FAILED) { eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL); 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 c5d64eb1ad..e6732989cf 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -284,9 +284,6 @@ bool esp_wifi_is_btm_enabled_internal(uint8_t if_index); esp_err_t esp_wifi_register_mgmt_frame_internal(uint32_t type, uint32_t subtype); esp_err_t esp_wifi_send_mgmt_frm_internal(const wifi_mgmt_frm_req_t *req); uint8_t esp_wifi_ap_get_prof_pairwise_cipher_internal(void); -esp_err_t esp_wifi_action_tx_req(uint8_t type, uint8_t channel, - uint32_t wait_time_ms, wifi_action_tx_req_t *req); -esp_err_t esp_wifi_remain_on_channel(wifi_roc_req_t * req); bool esp_wifi_is_mbo_enabled_internal(uint8_t if_index); void esp_wifi_get_pmf_config_internal(wifi_pmf_config_t *pmf_cfg, uint8_t ifx); bool esp_wifi_is_ft_enabled_internal(uint8_t if_index); diff --git a/components/wpa_supplicant/test_apps/main/test_offchannel.c b/components/wpa_supplicant/test_apps/main/test_offchannel.c index f8043e8a10..b616c19961 100644 --- a/components/wpa_supplicant/test_apps/main/test_offchannel.c +++ b/components/wpa_supplicant/test_apps/main/test_offchannel.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: Unlicense OR CC0-1.0 * @@ -137,12 +137,16 @@ void esp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, req->no_ack = false; req->data_len = len; req->rx_cb = dummy_rx_action; + req->channel = channel; + req->wait_time_ms = wait_time_ms; + req->type = WIFI_OFFCHAN_TX_REQ; + memcpy(req->data, buf, req->data_len); ESP_LOGI(TAG, "Action Tx - MAC:" MACSTR ", Channel-%d, WaitT-%" PRId32 "", MAC2STR(dest_mac), channel, wait_time_ms); - TEST_ESP_OK(esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_REQ, channel, wait_time_ms, req)); + TEST_ESP_OK(esp_wifi_action_tx_req(req)); os_free(req); }