From 9130b255f5140635530a7a3d1bdd6ebff9882d6c Mon Sep 17 00:00:00 2001 From: Xia Xiaotian Date: Thu, 10 Oct 2019 15:03:07 +0800 Subject: [PATCH] Coexist: fix some coexist bugs 1. Fix high beacon and broadcast packets loss ratio of WiFi to make MDNS test pass. 2. Improve stability of WiFi performance with a little sacrifice of throughput. 3. Improve BLE advertising and connection performance with dynamic priority. It sacrifices a little WiFi throughput, but achieves balance between WiFi and Bluetooth. --- components/bt/Kconfig | 14 ++++++++++++++ components/bt/bt.c | 7 +++++++ components/bt/lib | 2 +- components/esp32/esp_adapter.c | 8 ++++++++ components/esp32/include/esp_coexist_internal.h | 6 ++++++ components/esp32/include/esp_wifi_os_adapter.h | 3 ++- components/esp32/lib | 2 +- 7 files changed, 39 insertions(+), 3 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 4e7ae41e5..dbef9daf5 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -299,6 +299,20 @@ config BLE_ADV_REPORT_DISCARD_THRSHOLD If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it may cause adv packets lost more. +menuconfig BTDM_COEX_BT_OPTIONS + bool "Coexistence Bluetooth Side Options" + depends on SW_COEXIST_ENABLE + default n + help + Options of Bluetooth Side of WiFi and bluetooth coexistence. + +config BTDM_COEX_BLE_ADV_HIGH_PRIORITY + bool "Improve BLE ADV priority for WiFi & BLE coexistence" + depends on BTDM_COEX_BT_OPTIONS + default n + help + Improve BLE ADV coexistence priority to make it better performance. + For example, BLE mesh need to enable this option to improve BLE adv performance. endmenu diff --git a/components/bt/bt.c b/components/bt/bt.c index 365f7c81c..65e1bbd38 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -217,6 +217,7 @@ extern int coex_bt_release_wrapper(uint32_t event); extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb); extern uint32_t coex_bb_reset_lock_wrapper(void); extern void coex_bb_reset_unlock_wrapper(uint32_t restore); +extern void coex_ble_adv_priority_high_set(bool high); extern char _bss_start_btdm; extern char _bss_end_btdm; @@ -1156,6 +1157,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) goto error; } +#ifdef CONFIG_BTDM_COEX_BLE_ADV_HIGH_PRIORITY + coex_ble_adv_priority_high_set(true); +#else + coex_ble_adv_priority_high_set(false); +#endif + btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; return ESP_OK; diff --git a/components/bt/lib b/components/bt/lib index 61ccdf070..d60b092e8 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit 61ccdf07068a409b3a1dc7241f87963092b54178 +Subproject commit d60b092e8481ca588fb38fbf41189bafab1a4a7a diff --git a/components/esp32/esp_adapter.c b/components/esp32/esp_adapter.c index 2343bd8dc..1e2574d8d 100644 --- a/components/esp32/esp_adapter.c +++ b/components/esp32/esp_adapter.c @@ -441,6 +441,13 @@ static 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 @@ -593,6 +600,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._sc_ack_send = sc_ack_send_wrapper, ._sc_ack_send_stop = sc_ack_send_stop, ._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, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, diff --git a/components/esp32/include/esp_coexist_internal.h b/components/esp32/include/esp_coexist_internal.h index 1d94d6db7..63f35666d 100644 --- a/components/esp32/include/esp_coexist_internal.h +++ b/components/esp32/include/esp_coexist_internal.h @@ -79,6 +79,12 @@ 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/components/esp32/include/esp_wifi_os_adapter.h b/components/esp32/include/esp_wifi_os_adapter.h index 165caa6ed..c8b8766de 100644 --- a/components/esp32/include/esp_wifi_os_adapter.h +++ b/components/esp32/include/esp_wifi_os_adapter.h @@ -21,7 +21,7 @@ extern "C" { #endif -#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000002 +#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000004 #define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF #define OSI_FUNCS_TIME_BLOCKING 0xffffffff @@ -121,6 +121,7 @@ typedef struct { void (* _sc_ack_send)(void *param); void (* _sc_ack_send_stop)(void); uint32_t (* _coex_status_get)(void); + void (* _coex_condition_set)(uint32_t type, bool dissatisfy); int32_t (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration); int32_t (* _coex_wifi_release)(uint32_t event); int32_t _magic; diff --git a/components/esp32/lib b/components/esp32/lib index 8c893dd72..c8c149c65 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 8c893dd726ad5d51fe5778807582c8075f70c170 +Subproject commit c8c149c65bbac86a612b0a9e5c3c584291f0d0d8