Skip to content

Commit 0959bee

Browse files
feat(bt/bluedroid): delete unused host congest check
1 parent 7bf01c9 commit 0959bee

File tree

9 files changed

+14
-205
lines changed

9 files changed

+14
-205
lines changed

components/bt/common/btc/core/btc_task.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -530,9 +530,6 @@ bt_status_t btc_init(void)
530530
btc_gap_ble_init();
531531
#endif ///BLE_INCLUDED == TRUE
532532

533-
#if SCAN_QUEUE_CONGEST_CHECK
534-
btc_adv_list_init();
535-
#endif
536533
/* TODO: initial the profile_tab */
537534
return BT_STATUS_SUCCESS;
538535
}
@@ -548,18 +545,6 @@ void btc_deinit(void)
548545
#if (BLE_INCLUDED == TRUE)
549546
btc_gap_ble_deinit();
550547
#endif ///BLE_INCLUDED == TRUE
551-
#if SCAN_QUEUE_CONGEST_CHECK
552-
btc_adv_list_deinit();
553-
#endif
554-
}
555-
556-
bool btc_check_queue_is_congest(void)
557-
{
558-
if (osi_thread_queue_wait_size(btc_thread, 0) >= BT_QUEUE_CONGEST_SIZE) {
559-
return true;
560-
}
561-
562-
return false;
563548
}
564549

565550
int get_btc_work_queue_size(void)

components/bt/common/btc/include/btc/btc_task.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ bt_status_t btc_inter_profile_call(btc_msg_t *msg);
146146

147147
bt_status_t btc_init(void);
148148
void btc_deinit(void);
149-
bool btc_check_queue_is_congest(void);
150149
int get_btc_work_queue_size(void);
151150

152151
/**

components/bt/host/bluedroid/Kconfig.in

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ config BT_GATTS_PPCP_CHAR_GAP
241241
depends on BT_GATTS_ENABLE
242242
default n
243243
help
244-
This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04) in GAP service that has
245-
connection parameters like min/max connection interval, slave latency and supervision timeout multiplier
244+
This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04)
245+
in GAP service that has connection parameters like min/max connection interval, slave
246+
latency and supervision timeout multiplier
246247

247248
config BT_BLE_BLUFI_ENABLE
248249
bool "Include blufi function"
@@ -1169,15 +1170,6 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
11691170
help
11701171
This select can make the allocation of memory will become more flexible
11711172

1172-
config BT_BLE_HOST_QUEUE_CONG_CHECK
1173-
bool "BLE queue congestion check"
1174-
depends on BT_BLE_ENABLED
1175-
default n
1176-
help
1177-
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around
1178-
or application layer handling adv packets is slow, it will cause the controller memory
1179-
to run out. if enabled, adv packets will be lost when host queue is congested.
1180-
11811173
config BT_SMP_ENABLE
11821174
bool
11831175
depends on BT_BLUEDROID_ENABLED
@@ -1256,16 +1248,6 @@ config BT_BLE_50_FEATURES_SUPPORTED
12561248
This option is universally supported in chips that support BLE, except for ESP32.
12571249
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
12581250

1259-
1260-
config BT_BLE_42_FEATURES_SUPPORTED
1261-
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
1262-
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
1263-
default n
1264-
help
1265-
This enables BLE 4.2 features.
1266-
This option is universally supported by all ESP chips with BLE capabilities.
1267-
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
1268-
12691251
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
12701252
bool "Enable BLE periodic advertising sync transfer feature"
12711253
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
12871269
help
12881270
Enable the create sync enhancements
12891271

1272+
config BT_BLE_42_FEATURES_SUPPORTED
1273+
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
1274+
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
1275+
default n
1276+
help
1277+
This enables BLE 4.2 features.
1278+
This option is universally supported by all ESP chips with BLE capabilities.
1279+
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
1280+
12901281
config BT_BLE_HIGH_DUTY_ADV_INTERVAL
12911282
bool "Enable BLE high duty advertising interval feature"
12921283
depends on BT_BLE_ENABLED

components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -39,20 +39,6 @@ tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr;
3939
#endif
4040
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
4141

42-
#if SCAN_QUEUE_CONGEST_CHECK
43-
static list_t *adv_filter_list;
44-
static osi_mutex_t adv_list_lock;
45-
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type);
46-
uint32_t btc_get_adv_list_length(void);
47-
void btc_adv_list_refresh(void);
48-
void btc_adv_list_lock(void);
49-
void btc_adv_list_unlock(void);
50-
static uint16_t btc_adv_list_count = 0;
51-
52-
#define BTC_ADV_LIST_MAX_LENGTH 50
53-
#define BTC_ADV_LIST_MAX_COUNT 200
54-
#endif
55-
5642
#define BTC_GAP_BLE_ADV_RPT_QUEUE_IDX (1)
5743
#define BTC_GAP_BLE_ADV_RPT_BATCH_SIZE (10)
5844
#define BTC_GAP_BLE_ADV_RPT_QUEUE_LEN_MAX (200)
@@ -641,20 +627,6 @@ static void btc_gap_ble_adv_pkt_handler(void *arg)
641627

642628
static void btc_process_adv_rpt_pkt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
643629
{
644-
#if SCAN_QUEUE_CONGEST_CHECK
645-
if(btc_check_queue_is_congest()) {
646-
BTC_TRACE_DEBUG("BtcQueue is congested");
647-
if(btc_get_adv_list_length() > BTC_ADV_LIST_MAX_LENGTH || btc_adv_list_count > BTC_ADV_LIST_MAX_COUNT) {
648-
btc_adv_list_refresh();
649-
btc_adv_list_count = 0;
650-
}
651-
if(btc_check_adv_list(p_data->inq_res.bd_addr, p_data->inq_res.ble_addr_type)) {
652-
return;
653-
}
654-
}
655-
btc_adv_list_count ++;
656-
#endif
657-
658630
// drop ADV packets if data queue length goes above threshold
659631
btc_gap_ble_env_t *p_env = &btc_gap_ble_env;
660632
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)
770742
if (ret != BT_STATUS_SUCCESS) {
771743
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
772744
}
773-
#if SCAN_QUEUE_CONGEST_CHECK
774-
btc_adv_list_refresh();
775-
#endif
776745
}
777746
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
778747
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,
13931362
tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb)
13941363
{
13951364
if ((results_cb != NULL) && (start_scan_cb != NULL)) {
1396-
#if SCAN_QUEUE_CONGEST_CHECK
1397-
btc_adv_list_refresh();
1398-
#endif
13991365
//Start scan the device
14001366
BTA_DmBleScan(true, duration, results_cb, start_scan_cb);
14011367
} else {
@@ -2470,100 +2436,4 @@ void btc_gap_ble_deinit(void)
24702436
btc_cleanup_adv_data(&gl_bta_scan_rsp_data);
24712437
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
24722438
}
2473-
2474-
#if SCAN_QUEUE_CONGEST_CHECK
2475-
void btc_adv_list_free(void *data)
2476-
{
2477-
osi_free(data);
2478-
}
2479-
2480-
void btc_adv_list_init(void)
2481-
{
2482-
osi_mutex_new(&adv_list_lock);
2483-
adv_filter_list = list_new(btc_adv_list_free);
2484-
}
2485-
2486-
void btc_adv_list_deinit(void)
2487-
{
2488-
osi_mutex_free(&adv_list_lock);
2489-
if(adv_filter_list) {
2490-
list_free(adv_filter_list);
2491-
adv_filter_list = NULL;
2492-
}
2493-
}
2494-
void btc_adv_list_add_packet(void * data)
2495-
{
2496-
if(!data) {
2497-
BTC_TRACE_ERROR("%s data is NULL", __func__);
2498-
return;
2499-
}
2500-
btc_adv_list_lock();
2501-
list_prepend(adv_filter_list, data);
2502-
btc_adv_list_unlock();
2503-
}
2504-
2505-
uint32_t btc_get_adv_list_length(void)
2506-
{
2507-
if(!adv_filter_list) {
2508-
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
2509-
return 0;
2510-
}
2511-
btc_adv_list_lock();
2512-
size_t length = list_length(adv_filter_list);
2513-
btc_adv_list_unlock();
2514-
2515-
return length;
2516-
}
2517-
2518-
void btc_adv_list_refresh(void)
2519-
{
2520-
if(!adv_filter_list) {
2521-
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
2522-
return ;
2523-
}
2524-
btc_adv_list_lock();
2525-
list_clear(adv_filter_list);
2526-
btc_adv_list_unlock();
2527-
}
2528-
2529-
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type)
2530-
{
2531-
bool found = false;
2532-
if(!adv_filter_list || !addr) {
2533-
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
2534-
return found;
2535-
}
2536-
2537-
btc_adv_list_lock();
2538-
for (const list_node_t *node = list_begin(adv_filter_list); node != list_end(adv_filter_list); node = list_next(node)) {
2539-
btc_adv_packet_t *packet = (btc_adv_packet_t *)list_node(node);
2540-
if(!bdcmp(addr, packet->addr) && packet->addr_type == addr_type) {
2541-
found = true;
2542-
break;
2543-
}
2544-
}
2545-
btc_adv_list_unlock();
2546-
if(!found) {
2547-
btc_adv_packet_t *adv_packet = osi_malloc(sizeof(btc_adv_packet_t));
2548-
if(adv_packet) {
2549-
adv_packet->addr_type = addr_type;
2550-
bdcpy(adv_packet->addr, addr);
2551-
btc_adv_list_add_packet(adv_packet);
2552-
} else {
2553-
BTC_TRACE_ERROR("%s adv_packet malloc failed", __func__);
2554-
}
2555-
}
2556-
return found;
2557-
}
2558-
2559-
void btc_adv_list_lock(void)
2560-
{
2561-
osi_mutex_lock(&adv_list_lock, OSI_MUTEX_MAX_TIMEOUT);
2562-
}
2563-
2564-
void btc_adv_list_unlock(void)
2565-
{
2566-
osi_mutex_unlock(&adv_list_lock);
2567-
}
2568-
#endif
25692439
#endif ///BLE_INCLUDED == TRUE

components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,6 @@
352352
#define UC_BT_BLE_ESTAB_LINK_CONN_TOUT 30
353353
#endif
354354

355-
356-
//HOST QUEUE CONGEST CHECK
357-
#ifdef CONFIG_BT_BLE_HOST_QUEUE_CONGESTION_CHECK
358-
#define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_QUEUE_CONGESTION_CHECK
359-
#else
360-
#define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK FALSE
361-
#endif
362-
363355
#ifdef CONFIG_BT_GATTS_PPCP_CHAR_GAP
364356
#define UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP CONFIG_BT_GATTS_PPCP_CHAR_GAP
365357
#else

components/bt/host/bluedroid/common/include/common/bt_target.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,6 @@
573573
#define BTA_AV_CO_CP_SCMS_T FALSE
574574
#endif
575575

576-
#if UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK
577-
#define SCAN_QUEUE_CONGEST_CHECK TRUE
578-
#else
579-
#define SCAN_QUEUE_CONGEST_CHECK FALSE
580-
#endif
581-
582576
#ifdef UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP
583577
#define BTM_PERIPHERAL_ENABLED UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP
584578
#endif

components/bt/host/bluedroid/hci/hci_hal_h4.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252
#define HCI_HAL_BLE_ADV_RPT_QUEUE_LEN_MAX (200)
5353
#endif
5454

55-
extern bool BTU_check_queue_is_congest(void);
56-
57-
5855
static const uint8_t preamble_sizes[] = {
5956
HCI_COMMAND_PREAMBLE_SIZE,
6057
HCI_ACL_PREAMBLE_SIZE,
@@ -511,13 +508,6 @@ static void hci_hal_h4_hdl_rx_adv_rpt(pkt_linked_item_t *linked_pkt)
511508
goto _discard_packet;
512509
}
513510

514-
#if SCAN_QUEUE_CONGEST_CHECK
515-
if(BTU_check_queue_is_congest()) {
516-
HCI_TRACE_DEBUG("BtuQueue is congested");
517-
goto _discard_packet;
518-
}
519-
#endif
520-
521511
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
522512
hci_hal_env.callbacks->adv_rpt_ready(linked_pkt);
523513

components/bt/host/bluedroid/stack/btu/btu_init.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,6 @@ UINT16 BTU_BleAclPktSize(void)
254254
#endif
255255
}
256256

257-
#if SCAN_QUEUE_CONGEST_CHECK
258-
bool BTU_check_queue_is_congest(void)
259-
{
260-
if (osi_thread_queue_wait_size(btu_thread, 0) >= BT_QUEUE_CONGEST_SIZE) {
261-
return true;
262-
}
263-
264-
return false;
265-
}
266-
#endif
267-
268257
int get_btu_work_queue_size(void)
269258
{
270259
return osi_thread_queue_wait_size(btu_thread, 0);

components/bt/sdkconfig.rename

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ CONFIG_BLUFI_TRACE_LEVEL_EVENT CONFIG_BT_LOG_BLUFI_
220220
CONFIG_BLUFI_TRACE_LEVEL_DEBUG CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_DEBUG
221221
CONFIG_BLUFI_TRACE_LEVEL_VERBOSE CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_VERBOSE
222222

223-
CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK
224223
CONFIG_SMP_ENABLE CONFIG_BT_SMP_ENABLE
225224
CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN
226225
CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT

0 commit comments

Comments
 (0)