From 728cd2489a3fd01e8d27a95260a03e0d0fdb6704 Mon Sep 17 00:00:00 2001 From: liuning Date: Fri, 16 Jun 2023 17:02:57 +0800 Subject: [PATCH] feat(esp_wifi): support ps-none mode at coexist --- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 2 +- components/esp_wifi/esp32/esp_adapter.c | 10 +--------- components/esp_wifi/esp32c2/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 +--------- components/esp_wifi/include/esp_coexist_internal.h | 8 +------- docs/en/api-guides/coexist.rst | 2 ++ docs/en/api-guides/wifi.rst | 6 +++++- docs/zh_CN/api-guides/coexist.rst | 1 + docs/zh_CN/api-guides/wifi.rst | 6 +++++- 11 files changed, 20 insertions(+), 55 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 2a79dfcded..3cc9b61587 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -1740,7 +1740,7 @@ pp_deattach = 0x40001ec8; hal_set_sta_tsf = 0x40001ed0; ic_update_sta_tsf = 0x40001ed4; ic_tx_pkt = 0x40001ed8; -pm_send_probe_stop = 0x40001edc; +/* pm_send_probe_stop = 0x40001edc; */ pm_send_probe_start = 0x40001ee0; pm_on_coex_schm_process_restart = 0x40001ee4; hal_mac_set_rxq_policy = 0x40001ee8; diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 3a99aeed04..7db26d5cc3 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -595,13 +595,6 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) #endif } -static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy) -{ -#if CONFIG_SW_COEXIST_ENABLE - coex_condition_set(type, dissatisfy); -#endif -} - static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { #if CONFIG_SW_COEXIST_ENABLE @@ -833,7 +826,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_enable = coex_enable_wrapper, ._coex_disable = coex_disable_wrapper, ._coex_status_get = coex_status_get_wrapper, - ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper, diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index bec2a25ac1..2fdca52491 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -517,13 +517,6 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) #endif } -static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy) -{ -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - coex_condition_set(type, dissatisfy); -#endif -} - static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE @@ -753,7 +746,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_enable = coex_enable_wrapper, ._coex_disable = coex_disable_wrapper, ._coex_status_get = coex_status_get_wrapper, - ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper, diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index 165f9e2fdf..79aa32e5a9 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -525,13 +525,6 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) #endif } -static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy) -{ -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - coex_condition_set(type, dissatisfy); -#endif -} - static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE @@ -761,7 +754,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_enable = coex_enable_wrapper, ._coex_disable = coex_disable_wrapper, ._coex_status_get = coex_status_get_wrapper, - ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper, diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 4a022638e1..446d782ed6 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -592,13 +592,6 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) #endif } -static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy) -{ -#if CONFIG_EXTERNAL_COEX_ENABLE - coex_condition_set(type, dissatisfy); -#endif -} - static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { #if CONFIG_EXTERNAL_COEX_ENABLE @@ -835,7 +828,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_enable = coex_enable_wrapper, ._coex_disable = coex_disable_wrapper, ._coex_status_get = coex_status_get_wrapper, - ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper, diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index dd67515fda..d866b98a41 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -614,13 +614,6 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) #endif } -static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy) -{ -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - coex_condition_set(type, dissatisfy); -#endif -} - static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE @@ -855,7 +848,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_enable = coex_enable_wrapper, ._coex_disable = coex_disable_wrapper, ._coex_status_get = coex_status_get_wrapper, - ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper, diff --git a/components/esp_wifi/include/esp_coexist_internal.h b/components/esp_wifi/include/esp_coexist_internal.h index c9fbd2a15a..34894aeff2 100644 --- a/components/esp_wifi/include/esp_coexist_internal.h +++ b/components/esp_wifi/include/esp_coexist_internal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -83,12 +83,6 @@ esp_err_t coex_preference_set(coex_prefer_t prefer); */ uint32_t coex_status_get(void); -/** - * @brief Set software coexist condition. - * @return : software coexist condition - */ -void coex_condition_set(uint32_t type, bool dissatisfy); - /** * @brief WiFi requests coexistence. * diff --git a/docs/en/api-guides/coexist.rst b/docs/en/api-guides/coexist.rst index b012998fc1..379dc5f899 100644 --- a/docs/en/api-guides/coexist.rst +++ b/docs/en/api-guides/coexist.rst @@ -111,6 +111,8 @@ The RF resource allocation mechanism is based on priority. As shown below, both } +.. _coexist_policy: + Coexistence Policy ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/en/api-guides/wifi.rst b/docs/en/api-guides/wifi.rst index a2bc0031e3..8a5b71c8e8 100644 --- a/docs/en/api-guides/wifi.rst +++ b/docs/en/api-guides/wifi.rst @@ -1665,7 +1665,11 @@ In maximum power-saving mode, station wakes up in every listen interval to recei Call ``esp_wifi_set_ps(WIFI_PS_MIN_MODEM)`` to enable Modem-sleep minimum power-saving mode or ``esp_wifi_set_ps(WIFI_PS_MAX_MODEM)`` to enable Modem-sleep maximum power-saving mode after calling :cpp:func:`esp_wifi_init()`. When station connects to AP, Modem-sleep will start. When station disconnects from AP, Modem-sleep will stop. -Call ``esp_wifi_set_ps(WIFI_PS_NONE)`` to disable Modem-sleep entirely. This has much higher power consumption, but provides minimum latency for receiving Wi-Fi data in real time. When Modem-sleep is enabled, received Wi-Fi data can be delayed for as long as the DTIM period (minimum power-saving mode) or the listen interval (maximum power-saving mode). Disabling Modem-sleep entirely is not possible for Wi-Fi and Bluetooth coexist mode. +Call ``esp_wifi_set_ps(WIFI_PS_NONE)`` to disable Modem-sleep entirely. This has much higher power consumption, but provides minimum latency for receiving Wi-Fi data in real time. When Modem-sleep is enabled, received Wi-Fi data can be delayed for as long as the DTIM period (minimum power-saving mode) or the listen interval (maximum power-saving mode). + +.. only:: SOC_SUPPORT_COEXISTENCE + + Notice that at coexist mode, Wi-Fi would still keep active state in Wi-Fi time slice and only keep sleep state in non Wi-Fi time slice even when calling "esp_wifi_set_ps(WIFI_PS_NONE)". Please refer to :ref:`coexist policy `. The default Modem-sleep mode is WIFI_PS_MIN_MODEM. diff --git a/docs/zh_CN/api-guides/coexist.rst b/docs/zh_CN/api-guides/coexist.rst index 5f9186c268..b4be5cda51 100644 --- a/docs/zh_CN/api-guides/coexist.rst +++ b/docs/zh_CN/api-guides/coexist.rst @@ -111,6 +111,7 @@ RF 共存 Coexistence -> RF; } +.. _coexist_policy-cn: 共存策略 ^^^^^^^^^^^^^^ diff --git a/docs/zh_CN/api-guides/wifi.rst b/docs/zh_CN/api-guides/wifi.rst index 7d23192065..82be472357 100644 --- a/docs/zh_CN/api-guides/wifi.rst +++ b/docs/zh_CN/api-guides/wifi.rst @@ -1657,7 +1657,11 @@ Modem-sleep 模式包括最小和最大节能模式。在最小节能模式下 调用 :cpp:func:`esp_wifi_init()` 后,调用 ``esp_wifi_set_ps(WIFI_PS_MIN_MODEM)`` 可使能 Modem-sleep 最小节能模式。调用 ``esp_wifi_set_ps(WIFI_PS_MAX_MODEM)`` 可使能 Modem-sleep 最大节能模式。station 连接到 AP 时,Modem-sleep 模式将启动。station 与 AP 断开连接时,Modem-sleep 模式将停止。 -调用 ``esp_wifi_set_ps(WIFI_PS_NONE)`` 可以完全禁用 Modem-sleep 模式。禁用会增大功耗,但可以最大限度减少实时接收 Wi-Fi 数据的延迟。使能 Modem-sleep 时,接收 Wi-Fi 数据的延迟时间可能与 DTIM 周期(最小节能模式)或监听间隔(最大节能模式)相同。在 Wi-Fi 与 Bluetooth LE 共存模式下,无法完全禁用 modem-sleep 模式。 +调用 ``esp_wifi_set_ps(WIFI_PS_NONE)`` 可以完全禁用 Modem-sleep 模式。禁用会增大功耗,但可以最大限度减少实时接收 Wi-Fi 数据的延迟。使能 Modem-sleep 时,接收 Wi-Fi 数据的延迟时间可能与 DTIM 周期(最小节能模式)或监听间隔(最大节能模式)相同。 + +.. only:: SOC_SUPPORT_COEXISTENCE + + 注意在共存模式下, 即使调用 ``esp_wifi_set_ps(WIFI_PS_NONE)``, Wi-Fi 也仅会在 Wi-Fi 时间片内保持活动状态, 非 Wi-Fi 时间片内仍然睡眠。请参照 :ref:`共存策略 `。 默认的 Modem-sleep 模式是 WIFI_PS_MIN_MODEM。