• Home
  • Raw
  • Download

Lines Matching refs:p_lcb

71   tL2C_LCB* p_lcb = &l2cb.lcb_pool[0];  in l2cu_allocate_lcb()  local
73 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_allocate_lcb()
74 if (!p_lcb->in_use) { in l2cu_allocate_lcb()
75 alarm_free(p_lcb->l2c_lcb_timer); in l2cu_allocate_lcb()
76 alarm_free(p_lcb->info_resp_timer); in l2cu_allocate_lcb()
77 memset(p_lcb, 0, sizeof(tL2C_LCB)); in l2cu_allocate_lcb()
79 p_lcb->remote_bd_addr = p_bd_addr; in l2cu_allocate_lcb()
81 p_lcb->in_use = true; in l2cu_allocate_lcb()
82 p_lcb->link_state = LST_DISCONNECTED; in l2cu_allocate_lcb()
83 p_lcb->handle = HCI_INVALID_HANDLE; in l2cu_allocate_lcb()
84 p_lcb->link_flush_tout = 0xFFFF; in l2cu_allocate_lcb()
85 p_lcb->l2c_lcb_timer = alarm_new("l2c_lcb.l2c_lcb_timer"); in l2cu_allocate_lcb()
86 p_lcb->info_resp_timer = alarm_new("l2c_lcb.info_resp_timer"); in l2cu_allocate_lcb()
87 p_lcb->idle_timeout = l2cb.idle_timeout; in l2cu_allocate_lcb()
88 p_lcb->id = 1; /* spec does not allow '0' */ in l2cu_allocate_lcb()
89 p_lcb->is_bonding = is_bonding; in l2cu_allocate_lcb()
90 p_lcb->transport = transport; in l2cu_allocate_lcb()
91 p_lcb->tx_data_len = in l2cu_allocate_lcb()
93 p_lcb->le_sec_pending_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_lcb()
102 p_lcb->link_xmit_data_q = list_new(NULL); in l2cu_allocate_lcb()
103 return (p_lcb); in l2cu_allocate_lcb()
122 tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_BR_EDR); in l2cu_update_lcb_4_bonding() local
124 if (p_lcb) { in l2cu_update_lcb_4_bonding()
127 p_lcb->is_bonding = is_bonding; in l2cu_update_lcb_4_bonding()
141 void l2cu_release_lcb(tL2C_LCB* p_lcb) { in l2cu_release_lcb() argument
144 p_lcb->in_use = false; in l2cu_release_lcb()
145 p_lcb->is_bonding = false; in l2cu_release_lcb()
148 alarm_free(p_lcb->l2c_lcb_timer); in l2cu_release_lcb()
149 p_lcb->l2c_lcb_timer = NULL; in l2cu_release_lcb()
150 alarm_free(p_lcb->info_resp_timer); in l2cu_release_lcb()
151 p_lcb->info_resp_timer = NULL; in l2cu_release_lcb()
154 osi_free_and_reset((void**)&p_lcb->p_hcit_rcv_acl); in l2cu_release_lcb()
156 if (p_lcb->transport == BT_TRANSPORT_BR_EDR) /* Release all SCO links */ in l2cu_release_lcb()
157 btm_remove_sco_links(p_lcb->remote_bd_addr); in l2cu_release_lcb()
159 if (p_lcb->sent_not_acked > 0) { in l2cu_release_lcb()
160 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_release_lcb()
161 l2cb.controller_le_xmit_window += p_lcb->sent_not_acked; in l2cu_release_lcb()
166 l2cb.controller_xmit_window += p_lcb->sent_not_acked; in l2cu_release_lcb()
174 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_release_lcb()
178 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; in l2cu_release_lcb()
179 p_ccb = p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_lcb()
184 if ((p_lcb->link_state == LST_CONNECTED) || in l2cu_release_lcb()
185 (p_lcb->link_state == LST_DISCONNECTING)) in l2cu_release_lcb()
186 btm_acl_removed(p_lcb->remote_bd_addr, p_lcb->transport); in l2cu_release_lcb()
189 if (p_lcb->link_xmit_data_q) { in l2cu_release_lcb()
190 while (!list_is_empty(p_lcb->link_xmit_data_q)) { in l2cu_release_lcb()
191 BT_HDR* p_buf = static_cast<BT_HDR*>(list_front(p_lcb->link_xmit_data_q)); in l2cu_release_lcb()
192 list_remove(p_lcb->link_xmit_data_q, p_buf); in l2cu_release_lcb()
195 list_free(p_lcb->link_xmit_data_q); in l2cu_release_lcb()
196 p_lcb->link_xmit_data_q = NULL; in l2cu_release_lcb()
200 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_release_lcb()
211 if (p_lcb->p_echo_rsp_cb) { in l2cu_release_lcb()
212 tL2CA_ECHO_RSP_CB* p_cb = p_lcb->p_echo_rsp_cb; in l2cu_release_lcb()
215 p_lcb->p_echo_rsp_cb = NULL; in l2cu_release_lcb()
221 if (p_lcb->le_sec_pending_q) { in l2cu_release_lcb()
222 while (!fixed_queue_is_empty(p_lcb->le_sec_pending_q)) { in l2cu_release_lcb()
224 (tL2CAP_SEC_DATA*)fixed_queue_try_dequeue(p_lcb->le_sec_pending_q); in l2cu_release_lcb()
226 p_buf->p_callback(p_lcb->remote_bd_addr, p_lcb->transport, in l2cu_release_lcb()
230 fixed_queue_free(p_lcb->le_sec_pending_q, NULL); in l2cu_release_lcb()
231 p_lcb->le_sec_pending_q = NULL; in l2cu_release_lcb()
248 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_bd_addr() local
250 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_find_lcb_by_bd_addr()
251 if ((p_lcb->in_use) && p_lcb->transport == transport && in l2cu_find_lcb_by_bd_addr()
252 (p_lcb->remote_bd_addr == p_bd_addr)) { in l2cu_find_lcb_by_bd_addr()
253 return (p_lcb); in l2cu_find_lcb_by_bd_addr()
288 bool l2c_is_cmd_rejected(uint8_t cmd_code, uint8_t id, tL2C_LCB* p_lcb) { in l2c_is_cmd_rejected() argument
298 l2cu_send_peer_cmd_reject(p_lcb, L2CAP_CMD_REJ_MTU_EXCEEDED, id, in l2c_is_cmd_rejected()
317 BT_HDR* l2cu_build_header(tL2C_LCB* p_lcb, uint16_t len, uint8_t cmd, in l2cu_build_header() argument
328 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_build_header()
329 UINT16_TO_STREAM(p, (p_lcb->handle | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_build_header()
333 UINT16_TO_STREAM(p, p_lcb->handle | l2cb.non_flushable_pbf); in l2cu_build_header()
336 p, (p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT))); in l2cu_build_header()
343 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_build_header()
367 void l2cu_adj_id(tL2C_LCB* p_lcb, uint8_t adj_mask) { in l2cu_adj_id() argument
368 if ((adj_mask & L2CAP_ADJ_ZERO_ID) && !p_lcb->id) { in l2cu_adj_id()
369 p_lcb->id++; in l2cu_adj_id()
383 void l2cu_send_peer_cmd_reject(tL2C_LCB* p_lcb, uint16_t reason, uint8_t rem_id, in l2cu_send_peer_cmd_reject() argument
397 p_buf = l2cu_build_header(p_lcb, (uint16_t)(L2CAP_CMD_REJECT_LEN + param_len), in l2cu_send_peer_cmd_reject()
413 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_cmd_reject()
431 p_ccb->p_lcb->id++; in l2cu_send_peer_connect_req()
432 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_connect_req()
434 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_connect_req()
436 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_REQ_LEN, in l2cu_send_peer_connect_req()
449 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_connect_req()
475 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_RSP_LEN, in l2cu_send_peer_connect_rsp()
490 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_connect_rsp()
504 void l2cu_reject_connection(tL2C_LCB* p_lcb, uint16_t remote_cid, in l2cu_reject_connection() argument
510 l2cu_build_header(p_lcb, L2CAP_CONN_RSP_LEN, L2CAP_CMD_CONN_RSP, rem_id); in l2cu_reject_connection()
524 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_reject_connection()
543 p_ccb->p_lcb->id++; in l2cu_send_peer_config_req()
544 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_config_req()
546 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_config_req()
561 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_req()
625 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_config_req()
655 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_rsp()
715 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_config_rsp()
753 UINT16_TO_STREAM(p, (p_ccb->p_lcb->handle | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_send_peer_config_rej()
759 p, (p_ccb->p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT))); in l2cu_send_peer_config_rej()
832 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_config_rej()
849 if ((!p_ccb) || (p_ccb->p_lcb == NULL)) { in l2cu_send_peer_disc_req()
855 p_ccb->p_lcb->id++; in l2cu_send_peer_disc_req()
856 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_disc_req()
858 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_disc_req()
860 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_DISC_REQ_LEN, in l2cu_send_peer_disc_req()
880 l2c_link_check_send_pkts(p_ccb->p_lcb, p_ccb, p_buf2); in l2cu_send_peer_disc_req()
884 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_disc_req()
901 void l2cu_send_peer_disc_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, in l2cu_send_peer_disc_rsp() argument
906 p_buf = l2cu_build_header(p_lcb, L2CAP_DISC_RSP_LEN, L2CAP_CMD_DISC_RSP, in l2cu_send_peer_disc_rsp()
919 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_disc_rsp()
933 void l2cu_send_peer_echo_req(tL2C_LCB* p_lcb, uint8_t* p_data, in l2cu_send_peer_echo_req() argument
938 p_lcb->id++; in l2cu_send_peer_echo_req()
939 l2cu_adj_id(p_lcb, L2CAP_ADJ_ZERO_ID); /* check for wrap to '0' */ in l2cu_send_peer_echo_req()
941 p_buf = l2cu_build_header(p_lcb, (uint16_t)(L2CAP_ECHO_REQ_LEN + data_len), in l2cu_send_peer_echo_req()
942 L2CAP_CMD_ECHO_REQ, p_lcb->id); in l2cu_send_peer_echo_req()
955 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_echo_req()
968 void l2cu_send_peer_echo_rsp(tL2C_LCB* p_lcb, uint8_t id, uint8_t* p_data, in l2cu_send_peer_echo_rsp() argument
975 if (!id || id == p_lcb->cur_echo_id) { in l2cu_send_peer_echo_rsp()
980 p_lcb->cur_echo_id = id; in l2cu_send_peer_echo_rsp()
996 p_buf = l2cu_build_header(p_lcb, (uint16_t)(L2CAP_ECHO_RSP_LEN + data_len), in l2cu_send_peer_echo_rsp()
1010 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_echo_rsp()
1022 void l2cu_send_peer_info_req(tL2C_LCB* p_lcb, uint16_t info_type) { in l2cu_send_peer_info_req() argument
1027 p_lcb->id++; in l2cu_send_peer_info_req()
1028 l2cu_adj_id(p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_info_req()
1030 p_buf = l2cu_build_header(p_lcb, 2, L2CAP_CMD_INFO_REQ, p_lcb->id); in l2cu_send_peer_info_req()
1043 p_lcb->w4_info_rsp = true; in l2cu_send_peer_info_req()
1044 alarm_set_on_mloop(p_lcb->info_resp_timer, L2CAP_WAIT_INFO_RSP_TIMEOUT_MS, in l2cu_send_peer_info_req()
1045 l2c_info_resp_timer_timeout, p_lcb); in l2cu_send_peer_info_req()
1047 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_info_req()
1060 void l2cu_send_peer_info_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, in l2cu_send_peer_info_rsp() argument
1088 p_buf = l2cu_build_header(p_lcb, len, L2CAP_CMD_INFO_RSP, remote_id); in l2cu_send_peer_info_rsp()
1112 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_send_peer_info_rsp()
1160 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_info_rsp()
1179 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_enqueue_ccb()
1183 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb); in l2cu_enqueue_ccb()
1229 if (p_ccb->p_lcb != NULL) { in l2cu_enqueue_ccb()
1231 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_enqueue_ccb()
1233 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_enqueue_ccb()
1235 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_enqueue_ccb()
1237 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_enqueue_ccb()
1241 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb++; in l2cu_enqueue_ccb()
1262 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_dequeue_ccb()
1268 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb, p_q, in l2cu_dequeue_ccb()
1275 if (p_ccb->p_lcb != NULL) { in l2cu_dequeue_ccb()
1277 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb--; in l2cu_dequeue_ccb()
1280 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_dequeue_ccb()
1281 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_dequeue_ccb()
1282 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_dequeue_ccb()
1285 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb == p_ccb) { in l2cu_dequeue_ccb()
1286 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = in l2cu_dequeue_ccb()
1290 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb == p_ccb) { in l2cu_dequeue_ccb()
1292 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = in l2cu_dequeue_ccb()
1293 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb; in l2cu_dequeue_ccb()
1345 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 0; in l2cu_change_pri_ccb()
1346 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_change_pri_ccb()
1347 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_change_pri_ccb()
1351 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_change_pri_ccb()
1352 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_change_pri_ccb()
1353 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_change_pri_ccb()
1355 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 1; in l2cu_change_pri_ccb()
1372 tL2C_CCB* l2cu_allocate_ccb(tL2C_LCB* p_lcb, uint16_t cid) { in l2cu_allocate_ccb() argument
1419 p_ccb->p_lcb = p_lcb; in l2cu_allocate_ccb()
1426 if (p_lcb) l2cu_enqueue_ccb(p_ccb); in l2cu_allocate_ccb()
1524 tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle); in l2cu_start_post_bond_timer() local
1526 if (!p_lcb) return (true); in l2cu_start_post_bond_timer()
1528 p_lcb->is_bonding = false; in l2cu_start_post_bond_timer()
1531 if (p_lcb->ccb_queue.p_first_ccb != NULL) return (false); in l2cu_start_post_bond_timer()
1534 if ((p_lcb->link_state == LST_CONNECTED) || in l2cu_start_post_bond_timer()
1535 (p_lcb->link_state == LST_CONNECTING) || in l2cu_start_post_bond_timer()
1536 (p_lcb->link_state == LST_DISCONNECTING)) { in l2cu_start_post_bond_timer()
1539 if (p_lcb->idle_timeout == 0) { in l2cu_start_post_bond_timer()
1540 btsnd_hcic_disconnect(p_lcb->handle, HCI_ERR_PEER_USER); in l2cu_start_post_bond_timer()
1541 p_lcb->link_state = LST_DISCONNECTING; in l2cu_start_post_bond_timer()
1544 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, in l2cu_start_post_bond_timer()
1545 p_lcb); in l2cu_start_post_bond_timer()
1564 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2cu_release_ccb() local
1574 p_lcb->handle, p_ccb->local_cid, p_ccb->remote_cid); in l2cu_release_ccb()
1586 btm_sec_clr_temp_auth_service(p_lcb->remote_bd_addr); in l2cu_release_ccb()
1598 if ((p_lcb) && ((p_ccb->local_cid >= L2CAP_BASE_APPL_CID))) { in l2cu_release_ccb()
1602 p_ccb->p_lcb = NULL; in l2cu_release_ccb()
1622 if ((p_lcb) && p_lcb->in_use) { in l2cu_release_ccb()
1623 if (p_lcb->link_state == LST_CONNECTED) { in l2cu_release_ccb()
1624 if (!p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_ccb()
1627 if (p_lcb->transport == BT_TRANSPORT_LE && in l2cu_release_ccb()
1631 l2cu_no_dynamic_ccbs(p_lcb); in l2cu_release_ccb()
1636 } else if (p_lcb->link_state == LST_CONNECTING) { in l2cu_release_ccb()
1637 if (!p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_ccb()
1638 if (p_lcb->transport == BT_TRANSPORT_LE && in l2cu_release_ccb()
1641 l2cu_no_dynamic_ccbs(p_lcb); in l2cu_release_ccb()
1658 tL2C_CCB* l2cu_find_ccb_by_remote_cid(tL2C_LCB* p_lcb, uint16_t remote_cid) { in l2cu_find_ccb_by_remote_cid() argument
1662 if (!p_lcb) { in l2cu_find_ccb_by_remote_cid()
1665 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) in l2cu_find_ccb_by_remote_cid()
1999 tL2C_LCB* p_lcb; in l2cu_process_our_cfg_req() local
2028 if (p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_NO_CRC) { in l2cu_process_our_cfg_req()
2053 p_lcb = p_ccb->p_lcb; in l2cu_process_our_cfg_req()
2055 if (p_cfg->flush_to < p_lcb->link_flush_tout) { in l2cu_process_our_cfg_req()
2056 p_lcb->link_flush_tout = p_cfg->flush_to; in l2cu_process_our_cfg_req()
2062 btsnd_hcic_write_auto_flush_tout(p_lcb->handle, hci_flush_to); in l2cu_process_our_cfg_req()
2103 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_device_reset() local
2105 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_device_reset()
2106 if ((p_lcb->in_use) && (p_lcb->handle != HCI_INVALID_HANDLE)) { in l2cu_device_reset()
2107 l2c_link_hci_disc_comp(p_lcb->handle, (uint8_t)-1); in l2cu_device_reset()
2112 bool l2cu_create_conn_le(tL2C_LCB* p_lcb) { in l2cu_create_conn_le() argument
2114 return l2cu_create_conn_le(p_lcb, phy); in l2cu_create_conn_le()
2119 bool l2cu_create_conn_le(tL2C_LCB* p_lcb, uint8_t initiating_phys) { in l2cu_create_conn_le() argument
2123 BTM_ReadDevInfo(p_lcb->remote_bd_addr, &dev_type, &addr_type); in l2cu_create_conn_le()
2127 p_lcb->ble_addr_type = addr_type; in l2cu_create_conn_le()
2128 p_lcb->transport = BT_TRANSPORT_LE; in l2cu_create_conn_le()
2129 p_lcb->initiating_phys = initiating_phys; in l2cu_create_conn_le()
2131 return (l2cble_create_conn(p_lcb)); in l2cu_create_conn_le()
2136 bool l2cu_create_conn_br_edr(tL2C_LCB* p_lcb) { in l2cu_create_conn_br_edr() argument
2145 if (p_lcb_cur == p_lcb) continue; in l2cu_create_conn_br_edr()
2165 p_lcb->link_state = LST_CONNECTING_WAIT_SWITCH; in l2cu_create_conn_br_edr()
2166 p_lcb->link_role = HCI_ROLE_MASTER; in l2cu_create_conn_br_edr()
2170 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, in l2cu_create_conn_br_edr()
2172 l2c_lcb_timer_timeout, p_lcb); in l2cu_create_conn_br_edr()
2179 p_lcb->link_state = LST_CONNECTING; in l2cu_create_conn_br_edr()
2181 return (l2cu_create_conn_after_switch(p_lcb)); in l2cu_create_conn_br_edr()
2196 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_get_num_hi_priority() local
2198 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_get_num_hi_priority()
2199 if ((p_lcb->in_use) && (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)) { in l2cu_get_num_hi_priority()
2217 bool l2cu_create_conn_after_switch(tL2C_LCB* p_lcb) { in l2cu_create_conn_after_switch() argument
2225 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(p_lcb->remote_bd_addr); in l2cu_create_conn_after_switch()
2232 l2cb.disallow_switch, num_acl, no_hi_prio_chs, p_lcb->is_bonding); in l2cu_create_conn_after_switch()
2237 (p_lcb->is_bonding && (no_hi_prio_chs == 0))) && in l2cu_create_conn_after_switch()
2243 p_lcb->link_state = LST_CONNECTING; in l2cu_create_conn_after_switch()
2246 p_inq_info = BTM_InqDbRead(p_lcb->remote_bd_addr); in l2cu_create_conn_after_switch()
2260 p_lcb->remote_bd_addr, (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 | in l2cu_create_conn_after_switch()
2267 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS, in l2cu_create_conn_after_switch()
2268 l2c_lcb_timer_timeout, p_lcb); in l2cu_create_conn_after_switch()
2285 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_state() local
2287 for (i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) { in l2cu_find_lcb_by_state()
2288 if ((p_lcb->in_use) && (p_lcb->link_state == state)) { in l2cu_find_lcb_by_state()
2289 return (p_lcb); in l2cu_find_lcb_by_state()
2310 tL2C_LCB* p_lcb; in l2cu_lcb_disconnecting() local
2315 p_lcb = &l2cb.lcb_pool[0]; in l2cu_lcb_disconnecting()
2317 for (i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) { in l2cu_lcb_disconnecting()
2318 if (p_lcb->in_use) { in l2cu_lcb_disconnecting()
2320 if ((!p_lcb->ccb_queue.p_first_ccb) || in l2cu_lcb_disconnecting()
2321 (p_lcb->link_state == LST_DISCONNECTING)) { in l2cu_lcb_disconnecting()
2326 else if (p_lcb->ccb_queue.p_first_ccb == p_lcb->ccb_queue.p_last_ccb) { in l2cu_lcb_disconnecting()
2327 p_ccb = p_lcb->ccb_queue.p_first_ccb; in l2cu_lcb_disconnecting()
2355 tL2C_LCB* p_lcb; in l2cu_set_acl_priority() local
2363 p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR); in l2cu_set_acl_priority()
2364 if (p_lcb == NULL) { in l2cu_set_acl_priority()
2371 if ((!reset_after_rs && (priority != p_lcb->acl_priority)) || in l2cu_set_acl_priority()
2373 (reset_after_rs && p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)) { in l2cu_set_acl_priority()
2379 UINT16_TO_STREAM(pp, p_lcb->handle); in l2cu_set_acl_priority()
2389 if (p_lcb->acl_priority != priority) { in l2cu_set_acl_priority()
2390 p_lcb->acl_priority = priority; in l2cu_set_acl_priority()
2426 tL2C_LCB* p_lcb; in l2cu_resubmit_pending_sec_req() local
2435 p_lcb = l2cu_find_lcb_by_bd_addr(*p_bda, BT_TRANSPORT_BR_EDR); in l2cu_resubmit_pending_sec_req()
2438 if (p_lcb) { in l2cu_resubmit_pending_sec_req()
2440 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2449 for (xx = 0, p_lcb = &l2cb.lcb_pool[0]; xx < MAX_L2CAP_LINKS; in l2cu_resubmit_pending_sec_req()
2450 xx++, p_lcb++) { in l2cu_resubmit_pending_sec_req()
2451 if (p_lcb->in_use) { in l2cu_resubmit_pending_sec_req()
2453 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2489 packet_size = btm_get_max_packet_size(p_ccb->p_lcb->remote_bd_addr); in l2cu_adjust_out_mps()
2534 bool l2cu_initialize_fixed_ccb(tL2C_LCB* p_lcb, uint16_t fixed_cid, in l2cu_initialize_fixed_ccb() argument
2540 p_ccb = p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]; in l2cu_initialize_fixed_ccb()
2552 alarm_cancel(p_lcb->l2c_lcb_timer); in l2cu_initialize_fixed_ccb()
2573 p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = p_ccb; in l2cu_initialize_fixed_ccb()
2574 p_ccb->p_lcb = p_lcb; in l2cu_initialize_fixed_ccb()
2577 if (p_lcb->link_state == LST_CONNECTED) p_ccb->chnl_state = CST_OPEN; in l2cu_initialize_fixed_ccb()
2598 void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) { in l2cu_no_dynamic_ccbs() argument
2600 uint64_t timeout_ms = p_lcb->idle_timeout * 1000; in l2cu_no_dynamic_ccbs()
2607 if ((p_lcb->p_fixed_ccbs[xx] != NULL) && in l2cu_no_dynamic_ccbs()
2608 (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000 > timeout_ms)) { in l2cu_no_dynamic_ccbs()
2610 if (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout == L2CAP_NO_IDLE_TIMEOUT) { in l2cu_no_dynamic_ccbs()
2612 p_lcb->p_fixed_ccbs[xx]->local_cid); in l2cu_no_dynamic_ccbs()
2615 timeout_ms = p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000; in l2cu_no_dynamic_ccbs()
2621 if (p_lcb->is_bonding) return; in l2cu_no_dynamic_ccbs()
2627 rc = btm_sec_disconnect(p_lcb->handle, HCI_ERR_PEER_USER); in l2cu_no_dynamic_ccbs()
2629 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2630 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2633 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2636 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2638 } else if (p_lcb->is_bonding) { in l2cu_no_dynamic_ccbs()
2639 btsnd_hcic_disconnect(p_lcb->handle, HCI_ERR_PEER_USER); in l2cu_no_dynamic_ccbs()
2640 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2641 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2651 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, in l2cu_no_dynamic_ccbs()
2652 p_lcb); in l2cu_no_dynamic_ccbs()
2654 alarm_cancel(p_lcb->l2c_lcb_timer); in l2cu_no_dynamic_ccbs()
2668 void l2cu_process_fixed_chnl_resp(tL2C_LCB* p_lcb) { in l2cu_process_fixed_chnl_resp() argument
2669 if (p_lcb->transport == BT_TRANSPORT_BR_EDR) { in l2cu_process_fixed_chnl_resp()
2671 p_lcb->peer_chnl_mask[0] &= in l2cu_process_fixed_chnl_resp()
2675 p_lcb->peer_chnl_mask[0] = l2cb.l2c_ble_fixed_chnls_mask; in l2cu_process_fixed_chnl_resp()
2684 if (p_lcb->transport == BT_TRANSPORT_BR_EDR && in l2cu_process_fixed_chnl_resp()
2689 if (p_lcb->transport == BT_TRANSPORT_LE && channel_id == L2CAP_SMP_BR_CID) in l2cu_process_fixed_chnl_resp()
2694 if (p_lcb->peer_chnl_mask[(channel_id) / 8] & (1 << ((channel_id) % 8))) { in l2cu_process_fixed_chnl_resp()
2695 if (p_lcb->p_fixed_ccbs[xx]) in l2cu_process_fixed_chnl_resp()
2696 p_lcb->p_fixed_ccbs[xx]->chnl_state = CST_OPEN; in l2cu_process_fixed_chnl_resp()
2698 channel_id, p_lcb->remote_bd_addr, true, 0, p_lcb->transport); in l2cu_process_fixed_chnl_resp()
2701 channel_id, p_lcb->remote_bd_addr, false, p_lcb->disc_reason, in l2cu_process_fixed_chnl_resp()
2702 p_lcb->transport); in l2cu_process_fixed_chnl_resp()
2704 if (p_lcb->p_fixed_ccbs[xx]) { in l2cu_process_fixed_chnl_resp()
2705 l2cu_release_ccb(p_lcb->p_fixed_ccbs[xx]); in l2cu_process_fixed_chnl_resp()
2706 p_lcb->p_fixed_ccbs[xx] = NULL; in l2cu_process_fixed_chnl_resp()
2723 void l2cu_process_fixed_disc_cback(tL2C_LCB* p_lcb) { in l2cu_process_fixed_disc_cback() argument
2727 uint8_t peer_channel_mask = p_lcb->peer_chnl_mask[0]; in l2cu_process_fixed_disc_cback()
2730 if (p_lcb->transport == BT_TRANSPORT_LE) p_lcb->peer_chnl_mask[0] = 0; in l2cu_process_fixed_disc_cback()
2733 if (p_lcb->p_fixed_ccbs[xx]) { in l2cu_process_fixed_disc_cback()
2734 if (p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) { in l2cu_process_fixed_disc_cback()
2736 p_l2c_chnl_ctrl_block = p_lcb->p_fixed_ccbs[xx]; in l2cu_process_fixed_disc_cback()
2737 p_lcb->p_fixed_ccbs[xx] = NULL; in l2cu_process_fixed_disc_cback()
2740 xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false, in l2cu_process_fixed_disc_cback()
2741 p_lcb->disc_reason, p_lcb->transport); in l2cu_process_fixed_disc_cback()
2746 xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false, in l2cu_process_fixed_disc_cback()
2747 p_lcb->disc_reason, p_lcb->transport); in l2cu_process_fixed_disc_cback()
2762 void l2cu_send_peer_ble_par_req(tL2C_LCB* p_lcb, uint16_t min_int, in l2cu_send_peer_ble_par_req() argument
2769 p_lcb->id++; in l2cu_send_peer_ble_par_req()
2770 l2cu_adj_id(p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_ble_par_req()
2772 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_UPD_REQ_LEN, in l2cu_send_peer_ble_par_req()
2773 L2CAP_CMD_BLE_UPDATE_REQ, p_lcb->id); in l2cu_send_peer_ble_par_req()
2787 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_ble_par_req()
2800 void l2cu_send_peer_ble_par_rsp(tL2C_LCB* p_lcb, uint16_t reason, in l2cu_send_peer_ble_par_rsp() argument
2805 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_UPD_RSP_LEN, in l2cu_send_peer_ble_par_rsp()
2817 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_ble_par_rsp()
2833 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_credit_based_conn_req() local
2839 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_conn_req()
2842 p_ccb->p_lcb->id++; in l2cu_send_peer_ble_credit_based_conn_req()
2843 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_ble_credit_based_conn_req()
2845 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_ble_credit_based_conn_req()
2847 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN, in l2cu_send_peer_ble_credit_based_conn_req()
2848 L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ, p_lcb->id); in l2cu_send_peer_ble_credit_based_conn_req()
2872 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_ble_credit_based_conn_req()
2886 void l2cu_reject_ble_connection(tL2C_LCB* p_lcb, uint8_t rem_id, in l2cu_reject_ble_connection() argument
2891 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN, in l2cu_reject_ble_connection()
2907 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_reject_ble_connection()
2928 l2cu_build_header(p_ccb->p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN, in l2cu_send_peer_ble_credit_based_conn_res()
2944 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2cu_send_peer_ble_credit_based_conn_res()
2961 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_flow_control_credit() local
2964 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_flow_control_credit()
2967 p_ccb->p_lcb->id++; in l2cu_send_peer_ble_flow_control_credit()
2968 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_ble_flow_control_credit()
2970 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_ble_flow_control_credit()
2972 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN, in l2cu_send_peer_ble_flow_control_credit()
2973 L2CAP_CMD_BLE_FLOW_CTRL_CREDIT, p_lcb->id); in l2cu_send_peer_ble_flow_control_credit()
2985 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_ble_flow_control_credit()
3001 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_credit_based_disconn_req() local
3005 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_disconn_req()
3008 p_ccb->p_lcb->id++; in l2cu_send_peer_ble_credit_based_disconn_req()
3009 l2cu_adj_id(p_ccb->p_lcb, L2CAP_ADJ_ID); in l2cu_send_peer_ble_credit_based_disconn_req()
3011 p_ccb->local_id = p_ccb->p_lcb->id; in l2cu_send_peer_ble_credit_based_disconn_req()
3012 p_buf = l2cu_build_header(p_lcb, L2CAP_DISC_REQ_LEN, L2CAP_CMD_DISC_REQ, in l2cu_send_peer_ble_credit_based_disconn_req()
3013 p_lcb->id); in l2cu_send_peer_ble_credit_based_disconn_req()
3026 l2c_link_check_send_pkts(p_lcb, NULL, p_buf); in l2cu_send_peer_ble_credit_based_disconn_req()
3045 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_handle() local
3047 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_find_lcb_by_handle()
3048 if ((p_lcb->in_use) && (p_lcb->handle == handle)) { in l2cu_find_lcb_by_handle()
3049 return (p_lcb); in l2cu_find_lcb_by_handle()
3068 tL2C_CCB* l2cu_find_ccb_by_cid(tL2C_LCB* p_lcb, uint16_t local_cid) { in l2cu_find_ccb_by_cid() argument
3083 else if (p_lcb && p_lcb != p_ccb->p_lcb) { in l2cu_find_ccb_by_cid()
3102 static tL2C_CCB* l2cu_get_next_channel_in_rr(tL2C_LCB* p_lcb) { in l2cu_get_next_channel_in_rr() argument
3112 for (j = 0; (j < p_lcb->rr_serv[p_lcb->rr_pri].num_ccb) && (!p_serve_ccb); in l2cu_get_next_channel_in_rr()
3115 p_ccb = p_lcb->rr_serv[p_lcb->rr_pri].p_serve_ccb; in l2cu_get_next_channel_in_rr()
3118 L2CAP_TRACE_ERROR("p_serve_ccb is NULL, rr_pri=%d", p_lcb->rr_pri); in l2cu_get_next_channel_in_rr()
3131 p_lcb->rr_serv[p_lcb->rr_pri].p_serve_ccb = in l2cu_get_next_channel_in_rr()
3132 p_lcb->rr_serv[p_lcb->rr_pri].p_first_ccb; in l2cu_get_next_channel_in_rr()
3135 p_lcb->rr_serv[p_lcb->rr_pri].p_serve_ccb = p_ccb->p_next_ccb; in l2cu_get_next_channel_in_rr()
3140 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_get_next_channel_in_rr()
3165 p_lcb->rr_serv[p_lcb->rr_pri].quota--; in l2cu_get_next_channel_in_rr()
3170 if ((p_lcb->rr_serv[p_lcb->rr_pri].quota == 0) || (!p_serve_ccb)) { in l2cu_get_next_channel_in_rr()
3172 p_lcb->rr_pri = (p_lcb->rr_pri + 1) % L2CAP_NUM_CHNL_PRIORITY; in l2cu_get_next_channel_in_rr()
3174 p_lcb->rr_serv[p_lcb->rr_pri].quota = in l2cu_get_next_channel_in_rr()
3175 L2CAP_GET_PRIORITY_QUOTA(p_lcb->rr_pri); in l2cu_get_next_channel_in_rr()
3182 p_lcb->rr_serv[p_serve_ccb->ccb_priority].quota, in l2cu_get_next_channel_in_rr()
3201 static tL2C_CCB* l2cu_get_next_channel(tL2C_LCB* p_lcb) { in l2cu_get_next_channel() argument
3206 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) { in l2cu_get_next_channel()
3242 BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb, in l2cu_get_next_buffer_to_send() argument
3254 p_ccb = p_lcb->p_fixed_ccbs[xx]; in l2cu_get_next_buffer_to_send()
3300 p_ccb = l2cu_get_next_channel_in_rr(p_lcb); in l2cu_get_next_buffer_to_send()
3302 p_ccb = l2cu_get_next_channel(p_lcb); in l2cu_get_next_buffer_to_send()
3308 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_get_next_buffer_to_send()
3364 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_set_acl_hci_header()
3365 UINT16_TO_STREAM(p, p_ccb->p_lcb->handle | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_set_acl_hci_header()
3384 p, p_ccb->p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT)); in l2cu_set_acl_hci_header()
3386 UINT16_TO_STREAM(p, p_ccb->p_lcb->handle | l2cb.non_flushable_pbf); in l2cu_set_acl_hci_header()
3390 p, p_ccb->p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT)); in l2cu_set_acl_hci_header()
3427 if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb) { in send_congestion_status_to_all_clients()
3429 (*l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, in send_congestion_status_to_all_clients()