• Home
  • Raw
  • Download

Lines Matching refs:p_ccb

150   tL2C_CCB* p_ccb;  in l2cu_release_lcb()  local
181 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; in l2cu_release_lcb()
182 p_ccb = p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_lcb()
183 l2cu_release_ccb(p_ccb); in l2cu_release_lcb()
400 void l2cu_send_peer_connect_req(tL2C_CCB* p_ccb) { in l2cu_send_peer_connect_req() argument
405 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_connect_req()
406 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_connect_req()
408 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_connect_req()
410 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_REQ_LEN, in l2cu_send_peer_connect_req()
411 L2CAP_CMD_CONN_REQ, p_ccb->local_id); in l2cu_send_peer_connect_req()
420 UINT16_TO_STREAM(p, p_ccb->p_rcb->real_psm); in l2cu_send_peer_connect_req()
421 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_connect_req()
423 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_connect_req()
436 void l2cu_send_peer_connect_rsp(tL2C_CCB* p_ccb, uint16_t result, in l2cu_send_peer_connect_rsp() argument
440 if (p_ccb->flags & CCB_FLAG_SENT_PENDING) { in l2cu_send_peer_connect_rsp()
444 p_ccb->flags |= CCB_FLAG_SENT_PENDING; in l2cu_send_peer_connect_rsp()
448 BT_HDR* p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_RSP_LEN, in l2cu_send_peer_connect_rsp()
449 L2CAP_CMD_CONN_RSP, p_ccb->remote_id); in l2cu_send_peer_connect_rsp()
458 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_connect_rsp()
459 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_connect_rsp()
463 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_connect_rsp()
510 void l2cu_send_credit_based_reconfig_req(tL2C_CCB* p_ccb, in l2cu_send_credit_based_reconfig_req() argument
515 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2cu_send_credit_based_reconfig_req()
525 p_ccb->local_id = p_lcb->signal_id; in l2cu_send_credit_based_reconfig_req()
563 void l2cu_send_peer_config_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_send_peer_config_req() argument
569 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_config_req()
570 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_config_req()
572 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_config_req()
587 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_req()
589 L2CAP_CMD_CONFIG_REQ, p_ccb->local_id); in l2cu_send_peer_config_req()
598 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_config_req()
651 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_req()
664 void l2cu_send_peer_config_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_send_peer_config_rsp() argument
681 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_rsp()
683 L2CAP_CMD_CONFIG_RSP, p_ccb->remote_id); in l2cu_send_peer_config_rsp()
692 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_config_rsp()
725 UINT16_TO_STREAM(p, p_ccb->our_cfg.fcr.rtrans_tout); in l2cu_send_peer_config_rsp()
726 UINT16_TO_STREAM(p, p_ccb->our_cfg.fcr.mon_tout); in l2cu_send_peer_config_rsp()
741 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_rsp()
754 void l2cu_send_peer_config_rej(tL2C_CCB* p_ccb, uint8_t* p_data, in l2cu_send_peer_config_rej() argument
780 UINT16_TO_STREAM(p, (p_ccb->p_lcb->Handle() | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_send_peer_config_rej()
784 UINT16_TO_STREAM(p, (p_ccb->p_lcb->Handle() | in l2cu_send_peer_config_rej()
798 UINT8_TO_STREAM(p, p_ccb->remote_id); in l2cu_send_peer_config_rej()
802 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_config_rej()
858 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_rej()
871 void l2cu_send_peer_disc_req(tL2C_CCB* p_ccb) { in l2cu_send_peer_disc_req() argument
875 if ((!p_ccb) || (p_ccb->p_lcb == NULL)) { in l2cu_send_peer_disc_req()
881 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_disc_req()
882 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_disc_req()
884 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_disc_req()
886 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_DISC_REQ_LEN, in l2cu_send_peer_disc_req()
887 L2CAP_CMD_DISC_REQ, p_ccb->local_id); in l2cu_send_peer_disc_req()
896 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_disc_req()
897 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_disc_req()
902 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) { in l2cu_send_peer_disc_req()
903 while ((p_buf2 = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->xmit_hold_q)) != in l2cu_send_peer_disc_req()
905 l2cu_set_acl_hci_header(p_buf2, p_ccb); in l2cu_send_peer_disc_req()
906 l2c_link_check_send_pkts(p_ccb->p_lcb, p_ccb->local_cid, p_buf2); in l2cu_send_peer_disc_req()
910 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_disc_req()
1158 void l2cu_enqueue_ccb(tL2C_CCB* p_ccb) { in l2cu_enqueue_ccb() argument
1164 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_enqueue_ccb()
1166 if ((!p_ccb->in_use) || (p_q == NULL)) { in l2cu_enqueue_ccb()
1168 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb); in l2cu_enqueue_ccb()
1173 p_ccb->local_cid, p_ccb->ccb_priority); in l2cu_enqueue_ccb()
1177 p_q->p_first_ccb = p_q->p_last_ccb = p_ccb; in l2cu_enqueue_ccb()
1178 p_ccb->p_next_ccb = p_ccb->p_prev_ccb = NULL; in l2cu_enqueue_ccb()
1185 if (p_ccb->ccb_priority < p_ccb1->ccb_priority) { in l2cu_enqueue_ccb()
1188 p_q->p_first_ccb = p_ccb; in l2cu_enqueue_ccb()
1190 p_ccb1->p_prev_ccb->p_next_ccb = p_ccb; in l2cu_enqueue_ccb()
1192 p_ccb->p_next_ccb = p_ccb1; in l2cu_enqueue_ccb()
1193 p_ccb->p_prev_ccb = p_ccb1->p_prev_ccb; in l2cu_enqueue_ccb()
1194 p_ccb1->p_prev_ccb = p_ccb; in l2cu_enqueue_ccb()
1204 p_q->p_last_ccb->p_next_ccb = p_ccb; in l2cu_enqueue_ccb()
1206 p_ccb->p_next_ccb = NULL; in l2cu_enqueue_ccb()
1207 p_ccb->p_prev_ccb = p_q->p_last_ccb; in l2cu_enqueue_ccb()
1208 p_q->p_last_ccb = p_ccb; in l2cu_enqueue_ccb()
1213 if (p_ccb->p_lcb != NULL) { in l2cu_enqueue_ccb()
1215 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_enqueue_ccb()
1217 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_enqueue_ccb()
1219 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_enqueue_ccb()
1221 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_enqueue_ccb()
1222 L2CAP_GET_PRIORITY_QUOTA(p_ccb->ccb_priority); in l2cu_enqueue_ccb()
1225 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb++; in l2cu_enqueue_ccb()
1238 void l2cu_dequeue_ccb(tL2C_CCB* p_ccb) { in l2cu_dequeue_ccb() argument
1241 L2CAP_TRACE_DEBUG("l2cu_dequeue_ccb CID: 0x%04x", p_ccb->local_cid); in l2cu_dequeue_ccb()
1245 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_dequeue_ccb()
1247 if ((!p_ccb->in_use) || (p_q == NULL) || (p_q->p_first_ccb == NULL)) { in l2cu_dequeue_ccb()
1251 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb, p_q, in l2cu_dequeue_ccb()
1257 if (p_ccb->p_lcb != NULL) { in l2cu_dequeue_ccb()
1259 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb--; in l2cu_dequeue_ccb()
1262 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_dequeue_ccb()
1263 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_dequeue_ccb()
1264 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_dequeue_ccb()
1267 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb == p_ccb) { in l2cu_dequeue_ccb()
1268 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = in l2cu_dequeue_ccb()
1269 p_ccb->p_next_ccb; in l2cu_dequeue_ccb()
1272 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb == p_ccb) { in l2cu_dequeue_ccb()
1274 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = in l2cu_dequeue_ccb()
1275 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb; in l2cu_dequeue_ccb()
1280 if (p_ccb == p_q->p_first_ccb) { in l2cu_dequeue_ccb()
1282 p_q->p_first_ccb = p_ccb->p_next_ccb; in l2cu_dequeue_ccb()
1288 } else if (p_ccb == p_q->p_last_ccb) { in l2cu_dequeue_ccb()
1290 p_q->p_last_ccb = p_ccb->p_prev_ccb; in l2cu_dequeue_ccb()
1294 p_ccb->p_prev_ccb->p_next_ccb = p_ccb->p_next_ccb; in l2cu_dequeue_ccb()
1295 p_ccb->p_next_ccb->p_prev_ccb = p_ccb->p_prev_ccb; in l2cu_dequeue_ccb()
1298 p_ccb->p_next_ccb = p_ccb->p_prev_ccb = NULL; in l2cu_dequeue_ccb()
1310 void l2cu_change_pri_ccb(tL2C_CCB* p_ccb, tL2CAP_CHNL_PRIORITY priority) { in l2cu_change_pri_ccb() argument
1311 if (p_ccb->ccb_priority != priority) { in l2cu_change_pri_ccb()
1313 if ((p_ccb->p_next_ccb != NULL) || (p_ccb->p_prev_ccb != NULL)) { in l2cu_change_pri_ccb()
1317 l2cu_dequeue_ccb(p_ccb); in l2cu_change_pri_ccb()
1319 p_ccb->ccb_priority = priority; in l2cu_change_pri_ccb()
1320 l2cu_enqueue_ccb(p_ccb); in l2cu_change_pri_ccb()
1325 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 0; in l2cu_change_pri_ccb()
1326 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_change_pri_ccb()
1327 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_change_pri_ccb()
1329 p_ccb->ccb_priority = priority; in l2cu_change_pri_ccb()
1331 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_change_pri_ccb()
1332 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_change_pri_ccb()
1333 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_change_pri_ccb()
1334 L2CAP_GET_PRIORITY_QUOTA(p_ccb->ccb_priority); in l2cu_change_pri_ccb()
1335 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 1; in l2cu_change_pri_ccb()
1357 tL2C_CCB* p_ccb; in l2cu_allocate_ccb() local
1360 p_ccb = l2cb.p_free_ccb_first; in l2cu_allocate_ccb()
1361 l2cb.p_free_ccb_first = p_ccb->p_next_ccb; in l2cu_allocate_ccb()
1365 p_ccb = &l2cb.ccb_pool[cid - L2CAP_BASE_APPL_CID]; in l2cu_allocate_ccb()
1367 if (p_ccb == l2cb.p_free_ccb_first) { in l2cu_allocate_ccb()
1368 l2cb.p_free_ccb_first = p_ccb->p_next_ccb; in l2cu_allocate_ccb()
1372 if (p_prev->p_next_ccb == p_ccb) { in l2cu_allocate_ccb()
1373 p_prev->p_next_ccb = p_ccb->p_next_ccb; in l2cu_allocate_ccb()
1375 if (p_ccb == l2cb.p_free_ccb_last) { in l2cu_allocate_ccb()
1389 p_ccb->p_next_ccb = p_ccb->p_prev_ccb = nullptr; in l2cu_allocate_ccb()
1391 p_ccb->in_use = true; in l2cu_allocate_ccb()
1394 p_ccb->local_cid = L2CAP_BASE_APPL_CID + (uint16_t)(p_ccb - l2cb.ccb_pool); in l2cu_allocate_ccb()
1396 p_ccb->p_lcb = p_lcb; in l2cu_allocate_ccb()
1397 p_ccb->p_rcb = nullptr; in l2cu_allocate_ccb()
1400 p_ccb->ccb_priority = L2CAP_CHNL_PRIORITY_LOW; in l2cu_allocate_ccb()
1402 if (p_lcb) l2cu_enqueue_ccb(p_ccb); in l2cu_allocate_ccb()
1405 memset(&p_ccb->our_cfg, 0, sizeof(tL2CAP_CFG_INFO)); in l2cu_allocate_ccb()
1406 memset(&p_ccb->peer_cfg, 0, sizeof(tL2CAP_CFG_INFO)); in l2cu_allocate_ccb()
1409 p_ccb->our_cfg.flush_to = p_ccb->peer_cfg.flush_to = L2CAP_NO_AUTOMATIC_FLUSH; in l2cu_allocate_ccb()
1410 p_ccb->our_cfg.mtu = p_ccb->peer_cfg.mtu = L2CAP_DEFAULT_MTU; in l2cu_allocate_ccb()
1411 p_ccb->our_cfg.qos.service_type = p_ccb->peer_cfg.qos.service_type = in l2cu_allocate_ccb()
1413 p_ccb->our_cfg.qos.token_rate = p_ccb->peer_cfg.qos.token_rate = in l2cu_allocate_ccb()
1415 p_ccb->our_cfg.qos.token_bucket_size = p_ccb->peer_cfg.qos.token_bucket_size = in l2cu_allocate_ccb()
1417 p_ccb->our_cfg.qos.peak_bandwidth = p_ccb->peer_cfg.qos.peak_bandwidth = in l2cu_allocate_ccb()
1419 p_ccb->our_cfg.qos.latency = p_ccb->peer_cfg.qos.latency = in l2cu_allocate_ccb()
1421 p_ccb->our_cfg.qos.delay_variation = p_ccb->peer_cfg.qos.delay_variation = in l2cu_allocate_ccb()
1424 p_ccb->peer_cfg_already_rejected = false; in l2cu_allocate_ccb()
1425 p_ccb->fcr_cfg_tries = L2CAP_MAX_FCR_CFG_TRIES; in l2cu_allocate_ccb()
1427 alarm_free(p_ccb->fcrb.ack_timer); in l2cu_allocate_ccb()
1428 p_ccb->fcrb.ack_timer = alarm_new("l2c_fcrb.ack_timer"); in l2cu_allocate_ccb()
1434 alarm_free(p_ccb->fcrb.mon_retrans_timer); in l2cu_allocate_ccb()
1435 p_ccb->fcrb.mon_retrans_timer = alarm_new("l2c_fcrb.mon_retrans_timer"); in l2cu_allocate_ccb()
1437 p_ccb->max_rx_mtu = BT_DEFAULT_BUFFER_SIZE - in l2cu_allocate_ccb()
1439 p_ccb->tx_mps = BT_DEFAULT_BUFFER_SIZE - 32; in l2cu_allocate_ccb()
1441 p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_ccb()
1442 p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_ccb()
1443 p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_ccb()
1444 p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_ccb()
1446 p_ccb->cong_sent = false; in l2cu_allocate_ccb()
1447 p_ccb->buff_quota = 2; /* This gets set after config */ in l2cu_allocate_ccb()
1451 p_ccb->config_done = 0; in l2cu_allocate_ccb()
1453 LOG_DEBUG("cid 0x%04x config_done:0x%x", cid, p_ccb->config_done); in l2cu_allocate_ccb()
1456 p_ccb->chnl_state = CST_CLOSED; in l2cu_allocate_ccb()
1457 p_ccb->flags = 0; in l2cu_allocate_ccb()
1458 p_ccb->tx_data_rate = L2CAP_CHNL_DATA_RATE_LOW; in l2cu_allocate_ccb()
1459 p_ccb->rx_data_rate = L2CAP_CHNL_DATA_RATE_LOW; in l2cu_allocate_ccb()
1461 p_ccb->is_flushable = false; in l2cu_allocate_ccb()
1462 p_ccb->ecoc = false; in l2cu_allocate_ccb()
1464 alarm_free(p_ccb->l2c_ccb_timer); in l2cu_allocate_ccb()
1465 p_ccb->l2c_ccb_timer = alarm_new("l2c.l2c_ccb_timer"); in l2cu_allocate_ccb()
1469 return p_ccb; in l2cu_allocate_ccb()
1529 void l2cu_release_ccb(tL2C_CCB* p_ccb) { in l2cu_release_ccb() argument
1530 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2cu_release_ccb()
1531 tL2C_RCB* p_rcb = p_ccb->p_rcb; in l2cu_release_ccb()
1534 p_ccb->local_cid, p_ccb->in_use); in l2cu_release_ccb()
1537 if (!p_ccb->in_use) return; in l2cu_release_ccb()
1540 p_lcb->Handle(), p_ccb->local_cid, p_ccb->remote_cid); in l2cu_release_ccb()
1547 alarm_free(p_ccb->l2c_ccb_timer); in l2cu_release_ccb()
1548 p_ccb->l2c_ccb_timer = NULL; in l2cu_release_ccb()
1550 fixed_queue_free(p_ccb->xmit_hold_q, osi_free); in l2cu_release_ccb()
1551 p_ccb->xmit_hold_q = NULL; in l2cu_release_ccb()
1553 l2c_fcr_cleanup(p_ccb); in l2cu_release_ccb()
1556 if ((p_lcb) && ((p_ccb->local_cid >= L2CAP_BASE_APPL_CID))) { in l2cu_release_ccb()
1557 l2cu_dequeue_ccb(p_ccb); in l2cu_release_ccb()
1560 p_ccb->p_lcb = NULL; in l2cu_release_ccb()
1565 l2cb.p_free_ccb_first = p_ccb; in l2cu_release_ccb()
1566 l2cb.p_free_ccb_last = p_ccb; in l2cu_release_ccb()
1567 p_ccb->p_next_ccb = NULL; in l2cu_release_ccb()
1568 p_ccb->p_prev_ccb = NULL; in l2cu_release_ccb()
1570 p_ccb->p_next_ccb = NULL; in l2cu_release_ccb()
1571 p_ccb->p_prev_ccb = l2cb.p_free_ccb_last; in l2cu_release_ccb()
1572 l2cb.p_free_ccb_last->p_next_ccb = p_ccb; in l2cu_release_ccb()
1573 l2cb.p_free_ccb_last = p_ccb; in l2cu_release_ccb()
1577 p_ccb->in_use = false; in l2cu_release_ccb()
1586 p_ccb->local_cid == L2CAP_SMP_CID) in l2cu_release_ccb()
1597 p_ccb->local_cid == L2CAP_ATT_CID) { in l2cu_release_ccb()
1617 tL2C_CCB* p_ccb; in l2cu_find_ccb_by_remote_cid() local
1623 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()
1624 if ((p_ccb->in_use) && (p_ccb->remote_cid == remote_cid)) return (p_ccb); in l2cu_find_ccb_by_remote_cid()
1721 void l2cu_disconnect_chnl(tL2C_CCB* p_ccb) { in l2cu_disconnect_chnl() argument
1722 uint16_t local_cid = p_ccb->local_cid; in l2cu_disconnect_chnl()
1726 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2cu_disconnect_chnl()
1730 l2cu_send_peer_disc_req(p_ccb); in l2cu_disconnect_chnl()
1732 l2cu_release_ccb(p_ccb); in l2cu_disconnect_chnl()
1806 uint8_t l2cu_process_peer_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_process_peer_cfg_req() argument
1813 std::max<uint16_t>(L2CAP_MIN_MTU, p_ccb->p_rcb->required_remote_mtu); in l2cu_process_peer_cfg_req()
1830 p_ccb->peer_cfg.mtu = p_cfg->mtu; in l2cu_process_peer_cfg_req()
1831 p_ccb->peer_cfg.mtu_present = true; in l2cu_process_peer_cfg_req()
1839 else if (p_ccb->peer_cfg.mtu_present && !(p_ccb->config_done & IB_CFG_DONE)) { in l2cu_process_peer_cfg_req()
1841 p_cfg->mtu = p_ccb->peer_cfg.mtu; in l2cu_process_peer_cfg_req()
1851 p_ccb->peer_cfg.flush_to_present = true; in l2cu_process_peer_cfg_req()
1852 p_ccb->peer_cfg.flush_to = p_cfg->flush_to; in l2cu_process_peer_cfg_req()
1856 else if (p_ccb->peer_cfg.flush_to_present && in l2cu_process_peer_cfg_req()
1857 !(p_ccb->config_done & IB_CFG_DONE)) { in l2cu_process_peer_cfg_req()
1859 p_cfg->flush_to = p_ccb->peer_cfg.flush_to; in l2cu_process_peer_cfg_req()
1868 p_ccb->peer_cfg.qos = p_cfg->qos; in l2cu_process_peer_cfg_req()
1869 p_ccb->peer_cfg.qos_present = true; in l2cu_process_peer_cfg_req()
1877 else if (p_ccb->peer_cfg.qos_present && !(p_ccb->config_done & IB_CFG_DONE)) { in l2cu_process_peer_cfg_req()
1879 p_cfg->qos = p_ccb->peer_cfg.qos; in l2cu_process_peer_cfg_req()
1882 fcr_status = l2c_fcr_process_peer_cfg_req(p_ccb, p_cfg); in l2cu_process_peer_cfg_req()
1895 l2cu_adjust_out_mps(p_ccb); in l2cu_process_peer_cfg_req()
1920 void l2cu_process_peer_cfg_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_process_peer_cfg_rsp() argument
1923 if ((p_cfg->qos_present) && (p_ccb->our_cfg.qos_present)) in l2cu_process_peer_cfg_rsp()
1924 p_ccb->our_cfg.qos = p_cfg->qos; in l2cu_process_peer_cfg_rsp()
1929 p_ccb->peer_cfg.fcr.rtrans_tout = p_cfg->fcr.rtrans_tout; in l2cu_process_peer_cfg_rsp()
1930 p_ccb->peer_cfg.fcr.mon_tout = p_cfg->fcr.mon_tout; in l2cu_process_peer_cfg_rsp()
1935 if (p_cfg->fcr.tx_win_sz < p_ccb->our_cfg.fcr.tx_win_sz) in l2cu_process_peer_cfg_rsp()
1936 p_ccb->fcrb.max_held_acks = p_cfg->fcr.tx_win_sz / 3; in l2cu_process_peer_cfg_rsp()
1938 p_ccb->fcrb.max_held_acks = p_ccb->our_cfg.fcr.tx_win_sz / 3; in l2cu_process_peer_cfg_rsp()
1943 p_cfg->fcr.tx_win_sz, p_ccb->our_cfg.fcr.tx_win_sz, in l2cu_process_peer_cfg_rsp()
1944 p_ccb->fcrb.max_held_acks); in l2cu_process_peer_cfg_rsp()
1959 void l2cu_process_our_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_process_our_cfg_req() argument
1962 p_ccb->our_cfg.qos_present = true; in l2cu_process_our_cfg_req()
1963 p_ccb->our_cfg.qos = p_cfg->qos; in l2cu_process_our_cfg_req()
1980 p_ccb->fcrb.max_held_acks = p_cfg->fcr.tx_win_sz / 3; in l2cu_process_our_cfg_req()
1983 if ((p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_NO_CRC) == 0) { in l2cu_process_our_cfg_req()
1990 p_ccb->our_cfg.fcr.mode = p_cfg->fcr.mode; in l2cu_process_our_cfg_req()
1991 p_ccb->our_cfg.fcr_present = p_cfg->fcr_present; in l2cu_process_our_cfg_req()
2005 void l2cu_process_our_cfg_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2cu_process_our_cfg_rsp() argument
2008 if ((p_cfg->qos_present) && (p_ccb->peer_cfg.qos_present)) in l2cu_process_our_cfg_rsp()
2009 p_ccb->peer_cfg.qos = p_cfg->qos; in l2cu_process_our_cfg_rsp()
2013 l2c_fcr_adj_our_rsp_options(p_ccb, p_cfg); in l2cu_process_our_cfg_rsp()
2173 tL2C_CCB* p_ccb; in l2cu_lcb_disconnecting() local
2189 p_ccb = p_lcb->ccb_queue.p_first_ccb; in l2cu_lcb_disconnecting()
2191 if ((p_ccb->in_use) && in l2cu_lcb_disconnecting()
2192 ((p_ccb->chnl_state == CST_W4_L2CAP_DISCONNECT_RSP) || in l2cu_lcb_disconnecting()
2193 (p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP))) { in l2cu_lcb_disconnecting()
2298 tL2C_CCB* p_ccb; in l2cu_resubmit_pending_sec_req() local
2311 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2312 p_next_ccb = p_ccb->p_next_ccb; in l2cu_resubmit_pending_sec_req()
2313 l2c_csm_execute(p_ccb, L2CEVT_SEC_RE_SEND_CMD, NULL); in l2cu_resubmit_pending_sec_req()
2324 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2325 p_next_ccb = p_ccb->p_next_ccb; in l2cu_resubmit_pending_sec_req()
2326 l2c_csm_execute(p_ccb, L2CEVT_SEC_RE_SEND_CMD, NULL); in l2cu_resubmit_pending_sec_req()
2356 void l2cu_adjust_out_mps(tL2C_CCB* p_ccb) { in l2cu_adjust_out_mps() argument
2360 packet_size = BTM_GetMaxPacketSize(p_ccb->p_lcb->remote_bd_addr); in l2cu_adjust_out_mps()
2367 packet_size, p_ccb->peer_cfg.fcr.mps); in l2cu_adjust_out_mps()
2368 p_ccb->tx_mps = p_ccb->peer_cfg.fcr.mps; in l2cu_adjust_out_mps()
2384 if (p_ccb->peer_cfg.fcr.mps >= packet_size) in l2cu_adjust_out_mps()
2385 p_ccb->tx_mps = p_ccb->peer_cfg.fcr.mps / packet_size * packet_size; in l2cu_adjust_out_mps()
2387 p_ccb->tx_mps = p_ccb->peer_cfg.fcr.mps; in l2cu_adjust_out_mps()
2392 p_ccb->tx_mps, p_ccb->peer_cfg.fcr.mps, packet_size); in l2cu_adjust_out_mps()
2406 tL2C_CCB* p_ccb; in l2cu_initialize_fixed_ccb() local
2409 p_ccb = p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]; in l2cu_initialize_fixed_ccb()
2410 if ((p_ccb != NULL) && p_ccb->in_use) { in l2cu_initialize_fixed_ccb()
2418 p_ccb = l2cu_allocate_ccb(NULL, 0); in l2cu_initialize_fixed_ccb()
2419 if (p_ccb == NULL) return (false); in l2cu_initialize_fixed_ccb()
2424 p_ccb->local_cid = fixed_cid; in l2cu_initialize_fixed_ccb()
2425 p_ccb->remote_cid = fixed_cid; in l2cu_initialize_fixed_ccb()
2427 p_ccb->is_flushable = false; in l2cu_initialize_fixed_ccb()
2430 p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = p_ccb; in l2cu_initialize_fixed_ccb()
2431 p_ccb->p_lcb = p_lcb; in l2cu_initialize_fixed_ccb()
2434 if (p_lcb->link_state == LST_CONNECTED) p_ccb->chnl_state = CST_OPEN; in l2cu_initialize_fixed_ccb()
2437 p_ccb->fixed_chnl_idle_tout = in l2cu_initialize_fixed_ccb()
2680 void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb) { in l2cu_send_peer_ble_credit_based_conn_req() argument
2688 if (!p_ccb) return; in l2cu_send_peer_ble_credit_based_conn_req()
2689 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_conn_req()
2692 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_credit_based_conn_req()
2693 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_credit_based_conn_req()
2695 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_credit_based_conn_req()
2708 mtu = p_ccb->local_conn_cfg.mtu; in l2cu_send_peer_ble_credit_based_conn_req()
2709 mps = p_ccb->local_conn_cfg.mps; in l2cu_send_peer_ble_credit_based_conn_req()
2710 initial_credit = p_ccb->local_conn_cfg.credits; in l2cu_send_peer_ble_credit_based_conn_req()
2715 p_ccb->p_rcb->real_psm, p_ccb->local_cid, mtu, mps, initial_credit); in l2cu_send_peer_ble_credit_based_conn_req()
2717 UINT16_TO_STREAM(p, p_ccb->p_rcb->real_psm); in l2cu_send_peer_ble_credit_based_conn_req()
2718 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_ble_credit_based_conn_req()
2736 void l2cu_send_peer_credit_based_conn_req(tL2C_CCB* p_ccb) { in l2cu_send_peer_credit_based_conn_req() argument
2744 if (!p_ccb) return; in l2cu_send_peer_credit_based_conn_req()
2746 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_credit_based_conn_req()
2749 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_credit_based_conn_req()
2750 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_credit_based_conn_req()
2752 p_ccb->local_id = p_lcb->signal_id; in l2cu_send_peer_credit_based_conn_req()
2757 L2CAP_CMD_CREDIT_BASED_CONN_REQ, p_ccb->local_id); in l2cu_send_peer_credit_based_conn_req()
2766 mtu = p_ccb->local_conn_cfg.mtu; in l2cu_send_peer_credit_based_conn_req()
2767 mps = p_ccb->local_conn_cfg.mps; in l2cu_send_peer_credit_based_conn_req()
2768 initial_credit = p_ccb->local_conn_cfg.credits; in l2cu_send_peer_credit_based_conn_req()
2772 p_ccb->p_rcb->real_psm, mtu, mps, initial_credit, in l2cu_send_peer_credit_based_conn_req()
2775 UINT16_TO_STREAM(p, p_ccb->p_rcb->real_psm); in l2cu_send_peer_credit_based_conn_req()
2872 void l2cu_send_peer_credit_based_conn_res(tL2C_CCB* p_ccb, in l2cu_send_peer_credit_based_conn_res() argument
2880 p_ccb->p_lcb->pending_ecoc_conn_cnt * sizeof(uint16_t); in l2cu_send_peer_credit_based_conn_res()
2882 p_buf = l2cu_build_header(p_ccb->p_lcb, rsp_len, in l2cu_send_peer_credit_based_conn_res()
2883 L2CAP_CMD_CREDIT_BASED_CONN_RES, p_ccb->remote_id); in l2cu_send_peer_credit_based_conn_res()
2893 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.mtu); /* MTU */ in l2cu_send_peer_credit_based_conn_res()
2894 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.mps); /* MPS */ in l2cu_send_peer_credit_based_conn_res()
2895 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.credits); /* initial credit */ in l2cu_send_peer_credit_based_conn_res()
2903 result = p_ccb->p_lcb->pending_l2cap_result; in l2cu_send_peer_credit_based_conn_res()
2913 for (int i = 0; i < p_ccb->p_lcb->pending_ecoc_conn_cnt; i++) { in l2cu_send_peer_credit_based_conn_res()
2914 uint16_t cid = p_ccb->p_lcb->pending_ecoc_connection_cids[i]; in l2cu_send_peer_credit_based_conn_res()
2927 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_credit_based_conn_res()
2941 void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id, in l2cu_reject_ble_connection() argument
2943 if (p_ccb->ecoc) in l2cu_reject_ble_connection()
2945 p_ccb->p_lcb, rem_id, p_ccb->p_lcb->pending_ecoc_reconfig_cnt, result); in l2cu_reject_ble_connection()
2947 l2cu_reject_ble_coc_connection(p_ccb->p_lcb, rem_id, result); in l2cu_reject_ble_connection()
2996 void l2cu_send_peer_ble_credit_based_conn_res(tL2C_CCB* p_ccb, in l2cu_send_peer_ble_credit_based_conn_res() argument
3003 l2cu_build_header(p_ccb->p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN, in l2cu_send_peer_ble_credit_based_conn_res()
3004 L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES, p_ccb->remote_id); in l2cu_send_peer_ble_credit_based_conn_res()
3013 UINT16_TO_STREAM(p, p_ccb->local_cid); /* Local CID */ in l2cu_send_peer_ble_credit_based_conn_res()
3014 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.mtu); /* MTU */ in l2cu_send_peer_ble_credit_based_conn_res()
3015 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.mps); /* MPS */ in l2cu_send_peer_ble_credit_based_conn_res()
3016 UINT16_TO_STREAM(p, p_ccb->local_conn_cfg.credits); /* initial credit */ in l2cu_send_peer_ble_credit_based_conn_res()
3019 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_ble_credit_based_conn_res()
3032 void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB* p_ccb, in l2cu_send_peer_ble_flow_control_credit() argument
3038 if (!p_ccb) return; in l2cu_send_peer_ble_flow_control_credit()
3039 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_flow_control_credit()
3042 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_flow_control_credit()
3043 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_flow_control_credit()
3045 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_flow_control_credit()
3057 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_ble_flow_control_credit()
3073 void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB* p_ccb) { in l2cu_send_peer_ble_credit_based_disconn_req() argument
3079 if (!p_ccb) return; in l2cu_send_peer_ble_credit_based_disconn_req()
3080 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_disconn_req()
3083 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_credit_based_disconn_req()
3084 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_credit_based_disconn_req()
3086 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_credit_based_disconn_req()
3098 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2cu_send_peer_ble_credit_based_disconn_req()
3099 UINT16_TO_STREAM(p, p_ccb->local_cid); in l2cu_send_peer_ble_credit_based_disconn_req()
3144 tL2C_CCB* p_ccb = NULL; in l2cu_find_ccb_by_cid() local
3151 p_ccb = l2cb.ccb_pool + local_cid; in l2cu_find_ccb_by_cid()
3154 if (!p_ccb->in_use) { in l2cu_find_ccb_by_cid()
3155 p_ccb = NULL; in l2cu_find_ccb_by_cid()
3158 else if (p_lcb && p_lcb != p_ccb->p_lcb) { in l2cu_find_ccb_by_cid()
3159 p_ccb = NULL; in l2cu_find_ccb_by_cid()
3162 return (p_ccb); in l2cu_find_ccb_by_cid()
3174 void l2cu_set_acl_hci_header(BT_HDR* p_buf, tL2C_CCB* p_ccb) { in l2cu_set_acl_hci_header() argument
3181 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_set_acl_hci_header()
3182 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_set_acl_hci_header()
3196 (p_ccb->is_flushable)) { in l2cu_set_acl_hci_header()
3197 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | in l2cu_set_acl_hci_header()
3200 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | l2cb.non_flushable_pbf); in l2cu_set_acl_hci_header()
3216 static void send_congestion_status_to_all_clients(tL2C_CCB* p_ccb, in send_congestion_status_to_all_clients() argument
3218 p_ccb->cong_sent = status; in send_congestion_status_to_all_clients()
3220 if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb) { in send_congestion_status_to_all_clients()
3224 status, p_ccb->local_cid, fixed_queue_length(p_ccb->xmit_hold_q), in send_congestion_status_to_all_clients()
3225 p_ccb->buff_quota); in send_congestion_status_to_all_clients()
3230 (*p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)(p_ccb->local_cid, status); in send_congestion_status_to_all_clients()
3236 if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb) { in send_congestion_status_to_all_clients()
3238 (*l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, in send_congestion_status_to_all_clients()
3247 void l2cu_check_channel_congestion(tL2C_CCB* p_ccb) { in l2cu_check_channel_congestion() argument
3250 if (p_ccb->buff_quota == 0) return; in l2cu_check_channel_congestion()
3252 size_t q_count = fixed_queue_length(p_ccb->xmit_hold_q); in l2cu_check_channel_congestion()
3254 if (p_ccb->cong_sent) { in l2cu_check_channel_congestion()
3256 if (q_count <= (p_ccb->buff_quota / 2)) in l2cu_check_channel_congestion()
3257 send_congestion_status_to_all_clients(p_ccb, false); in l2cu_check_channel_congestion()
3260 if (q_count > p_ccb->buff_quota) in l2cu_check_channel_congestion()
3261 send_congestion_status_to_all_clients(p_ccb, true); in l2cu_check_channel_congestion()
3275 bool l2cu_is_ccb_active(tL2C_CCB* p_ccb) { return (p_ccb && p_ccb->in_use); } in l2cu_is_ccb_active() argument