From 0959beef7295b6303b6b1c5b6ee3f42477fa7a3a Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Thu, 9 Jan 2025 10:31:21 +0800 Subject: [PATCH] feat(bt/bluedroid): delete unused host congest check --- components/bt/common/btc/core/btc_task.c | 17 +-- .../bt/common/btc/include/btc/btc_task.h | 1 - components/bt/host/bluedroid/Kconfig.in | 33 ++--- .../btc/profile/std/gap/btc_gap_ble.c | 132 +----------------- .../include/common/bluedroid_user_config.h | 8 -- .../common/include/common/bt_target.h | 6 - components/bt/host/bluedroid/hci/hci_hal_h4.c | 10 -- .../bt/host/bluedroid/stack/btu/btu_init.c | 11 -- components/bt/sdkconfig.rename | 1 - 9 files changed, 14 insertions(+), 205 deletions(-) diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 0049328f50..877b36e5bf 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -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 */ @@ -530,9 +530,6 @@ bt_status_t btc_init(void) btc_gap_ble_init(); #endif ///BLE_INCLUDED == TRUE -#if SCAN_QUEUE_CONGEST_CHECK - btc_adv_list_init(); -#endif /* TODO: initial the profile_tab */ return BT_STATUS_SUCCESS; } @@ -548,18 +545,6 @@ void btc_deinit(void) #if (BLE_INCLUDED == TRUE) btc_gap_ble_deinit(); #endif ///BLE_INCLUDED == TRUE -#if SCAN_QUEUE_CONGEST_CHECK - btc_adv_list_deinit(); -#endif -} - -bool btc_check_queue_is_congest(void) -{ - if (osi_thread_queue_wait_size(btc_thread, 0) >= BT_QUEUE_CONGEST_SIZE) { - return true; - } - - return false; } int get_btc_work_queue_size(void) diff --git a/components/bt/common/btc/include/btc/btc_task.h b/components/bt/common/btc/include/btc/btc_task.h index 166b7e0f16..24bacde869 100644 --- a/components/bt/common/btc/include/btc/btc_task.h +++ b/components/bt/common/btc/include/btc/btc_task.h @@ -146,7 +146,6 @@ bt_status_t btc_inter_profile_call(btc_msg_t *msg); bt_status_t btc_init(void); void btc_deinit(void); -bool btc_check_queue_is_congest(void); int get_btc_work_queue_size(void); /** diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index d9fa589123..df307a875a 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -241,8 +241,9 @@ config BT_GATTS_PPCP_CHAR_GAP depends on BT_GATTS_ENABLE default n help - This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04) in GAP service that has - connection parameters like min/max connection interval, slave latency and supervision timeout multiplier + This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04) + in GAP service that has connection parameters like min/max connection interval, slave + latency and supervision timeout multiplier config BT_BLE_BLUFI_ENABLE bool "Include blufi function" @@ -1169,15 +1170,6 @@ config BT_BLE_DYNAMIC_ENV_MEMORY help This select can make the allocation of memory will become more flexible -config BT_BLE_HOST_QUEUE_CONG_CHECK - bool "BLE queue congestion check" - depends on BT_BLE_ENABLED - default n - help - When scanning and scan duplicate is not enabled, if there are a lot of adv packets around - or application layer handling adv packets is slow, it will cause the controller memory - to run out. if enabled, adv packets will be lost when host queue is congested. - config BT_SMP_ENABLE bool depends on BT_BLUEDROID_ENABLED @@ -1256,16 +1248,6 @@ config BT_BLE_50_FEATURES_SUPPORTED This option is universally supported in chips that support BLE, except for ESP32. BLE 4.2 and BLE 5.0 cannot be used simultaneously. - -config BT_BLE_42_FEATURES_SUPPORTED - bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" - depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED)) - default n - help - This enables BLE 4.2 features. - This option is universally supported by all ESP chips with BLE capabilities. - BLE 4.2 and BLE 5.0 cannot be used simultaneously. - config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER bool "Enable BLE periodic advertising sync transfer feature" depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR @@ -1287,6 +1269,15 @@ config BT_BLE_FEAT_CREATE_SYNC_ENH help Enable the create sync enhancements +config BT_BLE_42_FEATURES_SUPPORTED + bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" + depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED)) + default n + help + This enables BLE 4.2 features. + This option is universally supported by all ESP chips with BLE capabilities. + BLE 4.2 and BLE 5.0 cannot be used simultaneously. + config BT_BLE_HIGH_DUTY_ADV_INTERVAL bool "Enable BLE high duty advertising interval feature" depends on BT_BLE_ENABLED diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index ecbea5124c..60b9f598eb 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -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 */ @@ -39,20 +39,6 @@ tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #endif #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) -#if SCAN_QUEUE_CONGEST_CHECK -static list_t *adv_filter_list; -static osi_mutex_t adv_list_lock; -bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type); -uint32_t btc_get_adv_list_length(void); -void btc_adv_list_refresh(void); -void btc_adv_list_lock(void); -void btc_adv_list_unlock(void); -static uint16_t btc_adv_list_count = 0; - -#define BTC_ADV_LIST_MAX_LENGTH 50 -#define BTC_ADV_LIST_MAX_COUNT 200 -#endif - #define BTC_GAP_BLE_ADV_RPT_QUEUE_IDX (1) #define BTC_GAP_BLE_ADV_RPT_BATCH_SIZE (10) #define BTC_GAP_BLE_ADV_RPT_QUEUE_LEN_MAX (200) @@ -641,20 +627,6 @@ static void btc_gap_ble_adv_pkt_handler(void *arg) static void btc_process_adv_rpt_pkt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) { -#if SCAN_QUEUE_CONGEST_CHECK - if(btc_check_queue_is_congest()) { - BTC_TRACE_DEBUG("BtcQueue is congested"); - if(btc_get_adv_list_length() > BTC_ADV_LIST_MAX_LENGTH || btc_adv_list_count > BTC_ADV_LIST_MAX_COUNT) { - btc_adv_list_refresh(); - btc_adv_list_count = 0; - } - if(btc_check_adv_list(p_data->inq_res.bd_addr, p_data->inq_res.ble_addr_type)) { - return; - } - } - btc_adv_list_count ++; -#endif - // drop ADV packets if data queue length goes above threshold btc_gap_ble_env_t *p_env = &btc_gap_ble_env; if (pkt_queue_length(p_env->adv_rpt_queue) >= BTC_GAP_BLE_ADV_RPT_QUEUE_LEN_MAX) { @@ -770,9 +742,6 @@ static void btc_stop_scan_callback(tBTA_STATUS status) if (ret != BT_STATUS_SUCCESS) { BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } -#if SCAN_QUEUE_CONGEST_CHECK - btc_adv_list_refresh(); -#endif } #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params) @@ -1393,9 +1362,6 @@ static void btc_ble_start_scanning(uint32_t duration, tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb) { if ((results_cb != NULL) && (start_scan_cb != NULL)) { -#if SCAN_QUEUE_CONGEST_CHECK - btc_adv_list_refresh(); -#endif //Start scan the device BTA_DmBleScan(true, duration, results_cb, start_scan_cb); } else { @@ -2470,100 +2436,4 @@ void btc_gap_ble_deinit(void) btc_cleanup_adv_data(&gl_bta_scan_rsp_data); #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) } - -#if SCAN_QUEUE_CONGEST_CHECK -void btc_adv_list_free(void *data) -{ - osi_free(data); -} - -void btc_adv_list_init(void) -{ - osi_mutex_new(&adv_list_lock); - adv_filter_list = list_new(btc_adv_list_free); -} - -void btc_adv_list_deinit(void) -{ - osi_mutex_free(&adv_list_lock); - if(adv_filter_list) { - list_free(adv_filter_list); - adv_filter_list = NULL; - } -} -void btc_adv_list_add_packet(void * data) -{ - if(!data) { - BTC_TRACE_ERROR("%s data is NULL", __func__); - return; - } - btc_adv_list_lock(); - list_prepend(adv_filter_list, data); - btc_adv_list_unlock(); -} - -uint32_t btc_get_adv_list_length(void) -{ - if(!adv_filter_list) { - BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__); - return 0; - } - btc_adv_list_lock(); - size_t length = list_length(adv_filter_list); - btc_adv_list_unlock(); - - return length; -} - -void btc_adv_list_refresh(void) -{ - if(!adv_filter_list) { - BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__); - return ; - } - btc_adv_list_lock(); - list_clear(adv_filter_list); - btc_adv_list_unlock(); -} - -bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type) -{ - bool found = false; - if(!adv_filter_list || !addr) { - BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__); - return found; - } - - btc_adv_list_lock(); - for (const list_node_t *node = list_begin(adv_filter_list); node != list_end(adv_filter_list); node = list_next(node)) { - btc_adv_packet_t *packet = (btc_adv_packet_t *)list_node(node); - if(!bdcmp(addr, packet->addr) && packet->addr_type == addr_type) { - found = true; - break; - } - } - btc_adv_list_unlock(); - if(!found) { - btc_adv_packet_t *adv_packet = osi_malloc(sizeof(btc_adv_packet_t)); - if(adv_packet) { - adv_packet->addr_type = addr_type; - bdcpy(adv_packet->addr, addr); - btc_adv_list_add_packet(adv_packet); - } else { - BTC_TRACE_ERROR("%s adv_packet malloc failed", __func__); - } - } - return found; -} - -void btc_adv_list_lock(void) -{ - osi_mutex_lock(&adv_list_lock, OSI_MUTEX_MAX_TIMEOUT); -} - -void btc_adv_list_unlock(void) -{ - osi_mutex_unlock(&adv_list_lock); -} -#endif #endif ///BLE_INCLUDED == TRUE diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 2f109219d5..7026581804 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -352,14 +352,6 @@ #define UC_BT_BLE_ESTAB_LINK_CONN_TOUT 30 #endif - -//HOST QUEUE CONGEST CHECK -#ifdef CONFIG_BT_BLE_HOST_QUEUE_CONGESTION_CHECK -#define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_QUEUE_CONGESTION_CHECK -#else -#define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK FALSE -#endif - #ifdef CONFIG_BT_GATTS_PPCP_CHAR_GAP #define UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP CONFIG_BT_GATTS_PPCP_CHAR_GAP #else diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index c7dff7606d..91312484d9 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -573,12 +573,6 @@ #define BTA_AV_CO_CP_SCMS_T FALSE #endif -#if UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK -#define SCAN_QUEUE_CONGEST_CHECK TRUE -#else -#define SCAN_QUEUE_CONGEST_CHECK FALSE -#endif - #ifdef UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP #define BTM_PERIPHERAL_ENABLED UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP #endif diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index f5b16385eb..13e50b96a0 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -52,9 +52,6 @@ #define HCI_HAL_BLE_ADV_RPT_QUEUE_LEN_MAX (200) #endif -extern bool BTU_check_queue_is_congest(void); - - static const uint8_t preamble_sizes[] = { HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, @@ -511,13 +508,6 @@ static void hci_hal_h4_hdl_rx_adv_rpt(pkt_linked_item_t *linked_pkt) goto _discard_packet; } -#if SCAN_QUEUE_CONGEST_CHECK - if(BTU_check_queue_is_congest()) { - HCI_TRACE_DEBUG("BtuQueue is congested"); - goto _discard_packet; - } -#endif - packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)]; hci_hal_env.callbacks->adv_rpt_ready(linked_pkt); diff --git a/components/bt/host/bluedroid/stack/btu/btu_init.c b/components/bt/host/bluedroid/stack/btu/btu_init.c index 9ede9c2da9..a00b324398 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_init.c +++ b/components/bt/host/bluedroid/stack/btu/btu_init.c @@ -254,17 +254,6 @@ UINT16 BTU_BleAclPktSize(void) #endif } -#if SCAN_QUEUE_CONGEST_CHECK -bool BTU_check_queue_is_congest(void) -{ - if (osi_thread_queue_wait_size(btu_thread, 0) >= BT_QUEUE_CONGEST_SIZE) { - return true; - } - - return false; -} -#endif - int get_btu_work_queue_size(void) { return osi_thread_queue_wait_size(btu_thread, 0); diff --git a/components/bt/sdkconfig.rename b/components/bt/sdkconfig.rename index 0d38d15e70..7e3b5e3ea2 100644 --- a/components/bt/sdkconfig.rename +++ b/components/bt/sdkconfig.rename @@ -220,7 +220,6 @@ CONFIG_BLUFI_TRACE_LEVEL_EVENT CONFIG_BT_LOG_BLUFI_ CONFIG_BLUFI_TRACE_LEVEL_DEBUG CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_DEBUG CONFIG_BLUFI_TRACE_LEVEL_VERBOSE CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_VERBOSE -CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK CONFIG_SMP_ENABLE CONFIG_BT_SMP_ENABLE CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT