From e0decf4839521534439a858aad47d71959074247 Mon Sep 17 00:00:00 2001 From: liuning Date: Tue, 15 Mar 2022 17:08:12 +0800 Subject: [PATCH] esp_wifi: fully support connectionless traffic with ps and coex --- components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld | 4 ++-- components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 6 +++--- components/esp_rom/esp32s3/ld/esp32s3.rom.ld | 10 +++++----- components/esp_wifi/esp32/esp_adapter.c | 10 ++++++++++ components/esp_wifi/esp32c3/esp_adapter.c | 10 ++++++++++ components/esp_wifi/esp32s2/esp_adapter.c | 10 ++++++++++ components/esp_wifi/esp32s3/esp_adapter.c | 10 ++++++++++ .../esp_wifi/include/esp_coexist_internal.h | 4 +++- components/esp_wifi/include/esp_now.h | 12 +++++------- .../include/esp_private/wifi_os_adapter.h | 4 +--- components/esp_wifi/include/esp_wifi.h | 15 ++++++++------- components/esp_wifi/lib | 2 +- 12 files changed, 68 insertions(+), 29 deletions(-) diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld index 461f70694d..c7b882576b 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld @@ -6,10 +6,10 @@ Version 3 API's imported from the ROM esf_buf_alloc_dynamic = 0x400015c0; esf_buf_recycle = 0x400015c4; /*lmacTxDone = 0x4000162c;*/ -ppMapTxQueue = 0x400016d8; +/*ppMapTxQueue = 0x400016d8;*/ rcGetSched = 0x40001764; wDevCheckBlockError = 0x400017b4; -ppProcTxDone = 0x40001804; +/*ppProcTxDone = 0x40001804;*/ sta_input = rom_sta_input; /*************************************** diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index 73d510c2d0..f1394b3242 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1525,7 +1525,7 @@ lmacReachShortLimit = 0x4000161c; lmacRecycleMPDU = 0x40001620; lmacRxDone = 0x40001624; lmacSetTxFrame = 0x40001628; -lmacTxFrame = 0x40001630; +/*lmacTxFrame = 0x40001630;*/ mac_tx_set_duration = 0x40001634; /* mac_tx_set_htsig = 0x40001638;*/ mac_tx_set_plcp0 = 0x4000163c; @@ -1553,7 +1553,7 @@ pm_rx_beacon_process = 0x40001690; pm_rx_data_process = 0x40001694; /*pm_sleep = 0x40001698;*/ pm_sleep_for = 0x4000169c; -pm_tbtt_process = 0x400016a0; +/*pm_tbtt_process = 0x400016a0;*/ ppAMPDU2Normal = 0x400016a4; ppAssembleAMPDU = 0x400016a8; ppCalFrameTimes = 0x400016ac; @@ -1761,7 +1761,7 @@ coex_core_pti_get = 0x400018c0; coex_core_release = 0x400018c4; coex_core_request = 0x400018c8; coex_core_status_get = 0x400018cc; -coex_core_timer_idx_get = 0x400018d0; +/*coex_core_timer_idx_get = 0x400018d0;*/ coex_event_duration_get = 0x400018d4; coex_hw_timer_disable = 0x400018d8; coex_hw_timer_enable = 0x400018dc; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld index 712fdd8ec2..24aba6277a 100644 --- a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld @@ -1830,7 +1830,7 @@ lmacRecycleMPDU = 0x400053a0; lmacRxDone = 0x400053ac; lmacSetTxFrame = 0x400053b8; lmacTxDone = 0x400053c4; -lmacTxFrame = 0x400053d0; +/*lmacTxFrame = 0x400053d0;*/ mac_tx_set_duration = 0x400053dc; /* mac_tx_set_htsig = 0x400053e8;*/ mac_tx_set_plcp0 = 0x400053f4; @@ -1858,7 +1858,7 @@ pm_rx_beacon_process = 0x400054f0; pm_rx_data_process = 0x400054fc; /*pm_sleep = 0x40005508;*/ pm_sleep_for = 0x40005514; -pm_tbtt_process = 0x40005520; +/*pm_tbtt_process = 0x40005520;*/ ppAMPDU2Normal = 0x4000552c; ppAssembleAMPDU = 0x40005538; ppCalFrameTimes = 0x40005544; @@ -1872,7 +1872,7 @@ ppEnqueueRxq = 0x40005598; ppEnqueueTxDone = 0x400055a4; ppGetTxQFirstAvail_Locked = 0x400055b0; ppGetTxframe = 0x400055bc; -ppMapTxQueue = 0x400055c8; +/*ppMapTxQueue = 0x400055c8;*/ ppProcessRxPktHdr = 0x400055e0; ppProcessTxQ = 0x400055ec; ppRecordBarRRC = 0x400055f8; @@ -1946,7 +1946,7 @@ wDev_ProcessRxSucData = 0x4000591c; wdevProcessRxSucDataAll = 0x40005928; wdev_csi_len_align = 0x40005934; ppDequeueTxDone_Locked = 0x40005940; -ppProcTxDone = 0x4000594c; +/*ppProcTxDone = 0x4000594c;*/ /*pm_tx_data_done_process = 0x40005958;*/ config_is_cache_tx_buf_enabled = 0x40005964; ppMapWaitTxq = 0x40005970; @@ -2073,7 +2073,7 @@ coex_core_pti_get = 0x40005ba4; coex_core_release = 0x40005bb0; coex_core_request = 0x40005bbc; coex_core_status_get = 0x40005bc8; -coex_core_timer_idx_get = 0x40005bd4; +/*coex_core_timer_idx_get = 0x40005bd4;*/ coex_event_duration_get = 0x40005be0; coex_hw_timer_disable = 0x40005bec; coex_hw_timer_enable = 0x40005bf8; diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 315e39fb48..1309509e2f 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -646,6 +646,15 @@ static int coex_schm_curr_phase_idx_get_wrapper(void) #endif } +static int coex_register_start_cb_wrapper(int (* cb)(void)) +{ +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); +#else + return 0; +#endif +} + static void IRAM_ATTR esp_empty_wrapper(void) { @@ -773,6 +782,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, + ._coex_register_start_cb = coex_register_start_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index a5e52a62b9..6ad5db4aff 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -642,6 +642,15 @@ static int coex_schm_curr_phase_idx_get_wrapper(void) #endif } +static int coex_register_start_cb_wrapper(int (* cb)(void)) +{ +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); +#else + return 0; +#endif +} + static void IRAM_ATTR esp_empty_wrapper(void) { @@ -763,6 +772,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, + ._coex_register_start_cb = coex_register_start_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 8d5ac5f2cf..f953aa80ed 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -649,6 +649,15 @@ static int coex_schm_curr_phase_idx_get_wrapper(void) #endif } +static int coex_register_start_cb_wrapper(int (* cb)(void)) +{ +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); +#else + return 0; +#endif +} + static void IRAM_ATTR esp_empty_wrapper(void) { @@ -775,6 +784,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, + ._coex_register_start_cb = coex_register_start_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index f2ce2614bd..bec1ab0265 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -666,6 +666,15 @@ static int coex_schm_curr_phase_idx_get_wrapper(void) #endif } +static int coex_register_start_cb_wrapper(int (* cb)(void)) +{ +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); +#else + return 0; +#endif +} + static void IRAM_ATTR esp_empty_wrapper(void) { @@ -792,6 +801,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, + ._coex_register_start_cb = coex_register_start_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/include/esp_coexist_internal.h b/components/esp_wifi/include/esp_coexist_internal.h index 1011ee50fd..b4137785d8 100644 --- a/components/esp_wifi/include/esp_coexist_internal.h +++ b/components/esp_wifi/include/esp_coexist_internal.h @@ -196,8 +196,10 @@ int coex_schm_curr_phase_idx_set(int idx); int coex_schm_curr_phase_idx_get(void); /** - * @brief TODO - WIFI-4423 + * @brief Register WiFi callback for coexistence starts. * + * @param cb : WiFi callback + * @return : 0 - success, other - failed */ int coex_register_start_cb(int (* cb)(void)); diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 191d1d1cce..f3e2a88145 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -309,15 +309,13 @@ esp_err_t esp_now_get_peer_num(esp_now_peer_num_t *num); esp_err_t esp_now_set_pmk(const uint8_t *pmk); /** - * @brief Set esp_now wake window for sta_disconnected power management + * @brief Set wake window for esp_now to wake up in interval unit * - * @param window how much microsecond would the chip keep waked each interval, vary from 0 to 65535 + * @param window Milliseconds would the chip keep waked each interval, from 0 to 65535. * - * @attention 1. Only when ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work - * @attention 2. This configuration only work for station mode and disconnected status - * @attention 3. If more than one module has configured its wake_window, chip would choose the largest one to stay waked - * @attention 4. If the gap between interval and window is smaller than 5ms, the chip would keep waked all the time - * @attention 5. If never configured wake_window, the chip would keep waked at disconnected once it uses esp_now + * @attention 1. This configuration could work at connected status. + * When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work at disconnected status. + * @attention 2. Default value is the maximum. * * @return * - ESP_OK : succeed diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index adf95ea7b5..fa0f152936 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -22,8 +22,6 @@ extern "C" { #define OSI_QUEUE_SEND_BACK 1 #define OSI_QUEUE_SEND_OVERWRITE 2 -typedef int(* coex_start_wifi_cb_t)(void); - typedef struct { int32_t _version; bool (* _env_is_chip)(void); @@ -146,7 +144,7 @@ typedef struct { void * (* _coex_schm_curr_phase_get)(void); int (* _coex_schm_curr_phase_idx_set)(int idx); int (* _coex_schm_curr_phase_idx_get)(void); - int (* _coex_register_start_cb)(coex_start_wifi_cb_t cb); + int (* _coex_register_start_cb)(int (* cb)(void)); int32_t _magic; } wifi_osi_funcs_t; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 5692c066fe..7c7a2319ac 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1209,16 +1209,17 @@ esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm); esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); /** - * @brief Set interval for station to wake up periodically at disconnected. + * @brief Set wake interval for connectionless modules to wake up periodically. * - * @attention 1. Only when ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work - * @attention 2. This configuration only work for station mode and disconnected status - * @attention 3. This configuration would influence nothing until some module configure wake_window - * @attention 4. A sensible interval which is not too small is recommended (e.g. 100ms) + * @attention 1. Only one wake interval for all connectionless modules. + * @attention 2. This configuration could work at connected status. + * When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work at disconnected status. + * @attention 3. Event WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START would be posted each time wake interval starts. + * @attention 4. Recommend to configure interval in multiples of hundred. (e.g. 100ms) * - * @param interval how much micriosecond would the chip wake up, from 1 to 65535. + * @param wake_interval Milliseconds after would the chip wake up, from 1 to 65535. */ -esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t interval); +esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t wake_interval); /** * @brief configure country diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index a0b316b22a..05794b1c88 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit a0b316b22acb6fbc6001f8dc7da8d26cd564cc05 +Subproject commit 05794b1c8898c9b43bd8c1b3418dea0f140ec303