mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: fix hci_hal_env.rx_q and xHciH4Queue blocking when scanning
This commit is contained in:
parent
bba047fb3e
commit
658668b386
@ -1009,6 +1009,15 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
|
||||
help
|
||||
This select can make the allocation of memory will become more flexible
|
||||
|
||||
config BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
bool "BLE queue congestion check"
|
||||
depends on BLUEDROID_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 BLE_SCAN_DUPLICATE
|
||||
bool "BLE Scan Duplicate Options "
|
||||
depends on BLUEDROID_ENABLED
|
||||
@ -1019,8 +1028,8 @@ config BLE_SCAN_DUPLICATE
|
||||
config DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of devices in scan duplicate filter"
|
||||
depends on BLE_SCAN_DUPLICATE
|
||||
range 10 200
|
||||
default 20
|
||||
range 10 1000
|
||||
default 50
|
||||
help
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
@ -1035,8 +1044,8 @@ config BLE_MESH_SCAN_DUPLICATE_EN
|
||||
config MESH_DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of Mesh adv packets in scan duplicate filter"
|
||||
depends on BLE_MESH_SCAN_DUPLICATE_EN
|
||||
range 10 200
|
||||
default 50
|
||||
range 10 1000
|
||||
default 100
|
||||
help
|
||||
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
@ -170,6 +170,9 @@ int btc_init(void)
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
btc_gap_callback_init();
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_init();
|
||||
#endif
|
||||
/* TODO: initial the profile_tab */
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
@ -178,7 +181,18 @@ void btc_deinit(void)
|
||||
{
|
||||
vTaskDelete(xBtcTaskHandle);
|
||||
vQueueDelete(xBtcQueue);
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_deinit();
|
||||
#endif
|
||||
xBtcTaskHandle = NULL;
|
||||
xBtcQueue = 0;
|
||||
}
|
||||
|
||||
bool btc_check_queue_is_congest(void)
|
||||
{
|
||||
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtcQueue);
|
||||
if(wait_size >= QUEUE_CONGEST_SIZE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ typedef struct btc_msg {
|
||||
void *arg; //param for btc function or function param
|
||||
} btc_msg_t;
|
||||
|
||||
typedef struct btc_adv_packet {
|
||||
uint8_t addr[6];
|
||||
uint8_t addr_type;
|
||||
} btc_adv_packet_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_SIG_API_CALL = 0, // APP TO STACK
|
||||
BTC_SIG_API_CB, // STACK TO APP
|
||||
@ -72,5 +77,6 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
||||
|
||||
int btc_init(void);
|
||||
void btc_deinit(void);
|
||||
bool btc_check_queue_is_congest(void);
|
||||
|
||||
#endif /* __BTC_TASK_H__ */
|
||||
|
@ -763,7 +763,7 @@ static void btc_a2dp_sink_thread_init(UNUSED_ATTR void *context)
|
||||
|
||||
btc_a2dp_sink_state = BTC_A2DP_SINK_STATE_ON;
|
||||
|
||||
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(SIZE_MAX);
|
||||
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
btc_a2dp_control_init();
|
||||
}
|
||||
|
@ -1616,7 +1616,7 @@ static void btc_a2dp_source_thread_init(UNUSED_ATTR void *context)
|
||||
|
||||
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_ON;
|
||||
|
||||
btc_aa_src_cb.TxAaQ = fixed_queue_new(SIZE_MAX);
|
||||
btc_aa_src_cb.TxAaQ = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
btc_a2dp_control_init();
|
||||
}
|
||||
|
@ -28,9 +28,23 @@
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "osi/mutex.h"
|
||||
|
||||
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
||||
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
||||
#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
|
||||
|
||||
static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
|
||||
{
|
||||
@ -510,6 +524,19 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
param.scan_rst.search_evt = event;
|
||||
switch (event) {
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
#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
|
||||
bdcpy(param.scan_rst.bda, p_data->inq_res.bd_addr);
|
||||
param.scan_rst.dev_type = p_data->inq_res.device_type;
|
||||
param.scan_rst.rssi = p_data->inq_res.rssi;
|
||||
@ -585,6 +612,9 @@ 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
|
||||
}
|
||||
|
||||
void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
|
||||
@ -725,6 +755,9 @@ 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 {
|
||||
@ -1134,3 +1167,99 @@ void btc_gap_ble_deinit(void)
|
||||
btc_cleanup_adv_data(&gl_bta_adv_data);
|
||||
btc_cleanup_adv_data(&gl_bta_scan_rsp_data);
|
||||
}
|
||||
|
||||
#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
|
||||
|
@ -166,5 +166,7 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_callback_init(void);
|
||||
void btc_gap_ble_deinit(void);
|
||||
void btc_adv_list_init(void);
|
||||
void btc_adv_list_deinit(void);
|
||||
|
||||
#endif /* __BTC_GAP_BLE_H__ */
|
||||
|
@ -26,9 +26,6 @@
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX 254
|
||||
#endif
|
||||
/*Timer Related Defination*/
|
||||
|
||||
//by Snake.T
|
||||
|
@ -313,6 +313,16 @@
|
||||
#define BTA_AV_CO_CP_SCMS_T FALSE//FALSE
|
||||
#endif
|
||||
|
||||
#ifndef QUEUE_CONGEST_SIZE
|
||||
#define QUEUE_CONGEST_SIZE 40
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
#define SCAN_QUEUE_CONGEST_CHECK FALSE
|
||||
#else
|
||||
#define SCAN_QUEUE_CONGEST_CHECK CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
#endif
|
||||
|
||||
/* This feature is used to eanble interleaved scan*/
|
||||
#ifndef BTA_HOST_INTERLEAVE_SEARCH
|
||||
#define BTA_HOST_INTERLEAVE_SEARCH FALSE//FALSE
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define HCI_BLE_EVENT 0x3e
|
||||
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
|
||||
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1)
|
||||
extern bool BTU_check_queue_is_congest(void);
|
||||
|
||||
|
||||
static const uint8_t preamble_sizes[] = {
|
||||
@ -105,7 +106,7 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
assert(upper_callbacks != NULL);
|
||||
callbacks = upper_callbacks;
|
||||
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX);
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
|
||||
|
||||
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
|
||||
@ -185,7 +186,6 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
|
||||
evt.par = 0;
|
||||
|
||||
if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) {
|
||||
HCI_TRACE_ERROR("xHciH4Queue failed\n");
|
||||
return TASK_POST_SUCCESS;
|
||||
}
|
||||
|
||||
@ -222,6 +222,14 @@ static void hci_packet_complete(BT_HDR *packet){
|
||||
}
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
@ -276,6 +284,13 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
hci_hal_env.allocator->free(packet);
|
||||
return;
|
||||
}
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
|
||||
HCI_TRACE_ERROR("BtuQueue is congested");
|
||||
hci_hal_env.allocator->free(packet);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
|
||||
callbacks->packet_ready(packet);
|
||||
@ -318,7 +333,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
pkt->layer_specific = 0;
|
||||
memcpy(pkt->data, data, len);
|
||||
fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
|
||||
hci_hal_h4_task_post(TASK_POST_BLOCKING);
|
||||
hci_hal_h4_task_post(100 / portTICK_PERIOD_MS);
|
||||
|
||||
BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);
|
||||
|
||||
|
@ -158,7 +158,7 @@ static int hci_layer_init_env(void)
|
||||
// as per the Bluetooth spec, Volume 2, Part E, 4.4 (Command Flow Control)
|
||||
// This value can change when you get a command complete or command status event.
|
||||
hci_host_env.command_credits = 1;
|
||||
hci_host_env.command_queue = fixed_queue_new(SIZE_MAX);
|
||||
hci_host_env.command_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
if (hci_host_env.command_queue) {
|
||||
fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready);
|
||||
} else {
|
||||
@ -166,7 +166,7 @@ static int hci_layer_init_env(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
hci_host_env.packet_queue = fixed_queue_new(SIZE_MAX);
|
||||
hci_host_env.packet_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
if (hci_host_env.packet_queue) {
|
||||
fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready);
|
||||
} else {
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include <stdbool.h>
|
||||
#include "osi/list.h"
|
||||
|
||||
#ifndef QUEUE_SIZE_MAX
|
||||
#define QUEUE_SIZE_MAX 254
|
||||
#endif
|
||||
|
||||
struct fixed_queue_t;
|
||||
|
||||
typedef struct fixed_queue_t fixed_queue_t;
|
||||
|
@ -69,7 +69,7 @@ typedef enum {
|
||||
#define HCI_H4_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define HCI_H4_TASK_PRIO (configMAX_PRIORITIES - 4)
|
||||
#define HCI_H4_TASK_NAME "hciH4T"
|
||||
#define HCI_H4_QUEUE_LEN 60
|
||||
#define HCI_H4_QUEUE_LEN 1
|
||||
|
||||
#define BTU_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define BTU_TASK_STACK_SIZE (4096 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
|
@ -313,7 +313,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
|
||||
p_lcb->allocated = (UINT8)(i + 1);
|
||||
memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
|
||||
AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
|
||||
p_lcb->tx_q = fixed_queue_new(SIZE_MAX);
|
||||
p_lcb->tx_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -376,8 +376,8 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
|
||||
if (!p_ccb->allocated) {
|
||||
p_ccb->allocated = TRUE;
|
||||
memcpy(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN);
|
||||
p_ccb->cmd_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->rsp_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->cmd_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->timer_entry.param = (UINT32) p_ccb;
|
||||
AVDT_TRACE_DEBUG("avdt_ccb_alloc %d\n", i);
|
||||
break;
|
||||
|
@ -603,7 +603,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
|
||||
memcpy(&p_scb->cs, p_cs, sizeof(tAVDT_CS));
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
/* initialize fragments gueue */
|
||||
p_scb->frag_q = fixed_queue_new(SIZE_MAX);
|
||||
p_scb->frag_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
if (p_cs->cfg.psc_mask & AVDT_PSC_MUX) {
|
||||
p_scb->cs.cfg.mux_tcid_media = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
|
||||
|
@ -3867,7 +3867,7 @@ void btm_ble_init (void)
|
||||
btm_cb.cmn_ble_vsc_cb.values_read = FALSE;
|
||||
p_cb->cur_states = 0;
|
||||
|
||||
p_cb->conn_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
p_cb->conn_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_cb->inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
|
||||
|
@ -56,8 +56,8 @@ void btm_init (void)
|
||||
#endif /* #if BTM_DYNAMIC_MEMORY */
|
||||
/* All fields are cleared; nonzero fields are reinitialized in appropriate function */
|
||||
memset(&btm_cb, 0, sizeof(tBTM_CB));
|
||||
btm_cb.page_queue = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.page_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
#if defined(BTM_INITIAL_TRACE_LEVEL)
|
||||
btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
|
||||
|
@ -113,7 +113,7 @@ void btm_sco_init (void)
|
||||
#endif
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
for (int i = 0; i < BTM_MAX_SCO_LINKS; i++) {
|
||||
btm_cb.sco_cb.sco_db[i].xmit_data_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sco_cb.sco_db[i].xmit_data_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
#endif
|
||||
/* Initialize nonzero defaults */
|
||||
|
@ -2762,7 +2762,7 @@ void btm_sec_check_pending_reqs (void)
|
||||
/* Now, re-submit anything in the mux queue */
|
||||
bq = btm_cb.sec_pending_q;
|
||||
if (!btm_cb.sec_pending_q) {
|
||||
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)fixed_queue_try_dequeue(bq)) != NULL) {
|
||||
|
@ -236,3 +236,13 @@ UINT16 BTU_BleAclPktSize(void)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
bool BTU_check_queue_is_congest(void)
|
||||
{
|
||||
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtuQueue);
|
||||
if(wait_size >= QUEUE_CONGEST_SIZE ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1120,8 +1120,8 @@ static tGAP_CCB *gap_allocate_ccb (void)
|
||||
for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) {
|
||||
if (p_ccb->con_state == GAP_CCB_STATE_IDLE) {
|
||||
memset (p_ccb, 0, sizeof (tGAP_CCB));
|
||||
p_ccb->tx_queue = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->rx_queue = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->tx_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->rx_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_ccb->gap_handle = xx;
|
||||
p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
|
||||
|
@ -64,7 +64,7 @@ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN
|
||||
UINT16 s_hdl, UINT16 num_handle)
|
||||
{
|
||||
if (p_db->svc_buffer == NULL) { //in case already alloc
|
||||
p_db->svc_buffer = fixed_queue_new(SIZE_MAX);
|
||||
p_db->svc_buffer = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
if (!allocate_svc_db_buf(p_db)) {
|
||||
|
@ -108,9 +108,9 @@ void gatt_init (void)
|
||||
gatt_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
|
||||
#endif
|
||||
gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE;
|
||||
gatt_cb.sign_op_queue = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.srv_chg_clt_q = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.pending_new_srv_start_q = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.sign_op_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
gatt_cb.srv_chg_clt_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
gatt_cb.pending_new_srv_start_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
/* First, register fixed L2CAP channel for ATT over BLE */
|
||||
fixed_reg.fixed_chnl_opts.mode = L2CAP_FCR_BASIC_MODE;
|
||||
fixed_reg.fixed_chnl_opts.max_transmit = 0xFF;
|
||||
|
@ -167,7 +167,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
|
||||
GATT_TRACE_DEBUG ("process_read_multi_rsp status=%d mtu=%d", status, mtu);
|
||||
|
||||
if (p_cmd->multi_rsp_q == NULL) {
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(SIZE_MAX);
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
/* Enqueue the response */
|
||||
@ -1290,7 +1290,7 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand
|
||||
queue_data->offset = offset;
|
||||
memcpy(queue_data->value, p, len);
|
||||
if (prepare_record->queue == NULL) {
|
||||
prepare_record->queue = fixed_queue_new(SIZE_MAX);
|
||||
prepare_record->queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
fixed_queue_enqueue(prepare_record->queue, queue_data);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
|
||||
if (!p_cb->hdl_list[i].in_use) {
|
||||
memset(p_elem, 0, sizeof(tGATT_HDL_LIST_ELEM));
|
||||
p_elem->in_use = TRUE;
|
||||
p_elem->svc_db.svc_buffer = fixed_queue_new(SIZE_MAX);
|
||||
p_elem->svc_db.svc_buffer = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
return p_elem;
|
||||
}
|
||||
}
|
||||
@ -1007,8 +1007,8 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
|
||||
|
||||
if (allocated) {
|
||||
memset(p_tcb, 0, sizeof(tGATT_TCB));
|
||||
p_tcb->pending_enc_clcb = fixed_queue_new(SIZE_MAX);
|
||||
p_tcb->pending_ind_q = fixed_queue_new(SIZE_MAX);
|
||||
p_tcb->pending_enc_clcb = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_tcb->pending_ind_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_tcb->in_use = TRUE;
|
||||
p_tcb->tcb_idx = i;
|
||||
p_tcb->transport = transport;
|
||||
|
@ -750,7 +750,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
|
||||
if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) &&
|
||||
(!fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q))) {
|
||||
fixed_queue_t *temp_q = p_ccb->fcrb.srej_rcv_hold_q;
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(temp_q)) != NULL) {
|
||||
if (p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) {
|
||||
|
@ -74,7 +74,7 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
p_lcb->transport = transport;
|
||||
p_lcb->tx_data_len = controller_get_interface()->get_ble_default_data_packet_length();
|
||||
p_lcb->le_sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
p_lcb->le_sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
l2cb.num_ble_links_active++;
|
||||
@ -1519,11 +1519,11 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
|
||||
p_ccb->max_rx_mtu = L2CAP_MTU_SIZE;
|
||||
p_ccb->tx_mps = L2CAP_FCR_TX_BUF_SIZE - 32;
|
||||
|
||||
p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->xmit_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->fcrb.retrans_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
p_ccb->cong_sent = FALSE;
|
||||
|
@ -128,8 +128,8 @@ void port_set_defaults (tPORT *p_port)
|
||||
memset (&p_port->rx, 0, sizeof (p_port->rx));
|
||||
memset (&p_port->tx, 0, sizeof (p_port->tx));
|
||||
|
||||
p_port->tx.queue = fixed_queue_new(SIZE_MAX);
|
||||
p_port->rx.queue = fixed_queue_new(SIZE_MAX);
|
||||
p_port->tx.queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_port->rx.queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -175,7 +175,7 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator)
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, create new p_mcb:%p, index:%d",
|
||||
is_initiator, &rfc_cb.port.rfc_mcb[j], j);
|
||||
|
||||
p_mcb->cmd_q = fixed_queue_new(SIZE_MAX);
|
||||
p_mcb->cmd_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_mcb->is_initiator = is_initiator;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user