Lines Matching refs:p_buf
90 static void process_s_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word);
91 static void process_i_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word,
94 static void prepare_I_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf,
96 static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf,
130 static uint16_t l2c_fcr_tx_get_fcs(BT_HDR* p_buf) { in l2c_fcr_tx_get_fcs() argument
131 uint8_t* p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in l2c_fcr_tx_get_fcs()
133 return (l2c_fcr_updcrc(L2CAP_FCR_INIT_CRC, p, p_buf->len)); in l2c_fcr_tx_get_fcs()
145 static uint16_t l2c_fcr_rx_get_fcs(BT_HDR* p_buf) { in l2c_fcr_rx_get_fcs() argument
146 uint8_t* p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in l2c_fcr_rx_get_fcs()
152 l2c_fcr_updcrc(L2CAP_FCR_INIT_CRC, p, p_buf->len + L2CAP_PKT_OVERHEAD)); in l2c_fcr_rx_get_fcs()
239 BT_HDR* l2c_fcr_clone_buf(BT_HDR* p_buf, uint16_t new_offset, in l2c_fcr_clone_buf() argument
241 CHECK(p_buf != NULL); in l2c_fcr_clone_buf()
252 ((uint8_t*)(p_buf + 1)) + p_buf->offset, no_of_bytes); in l2c_fcr_clone_buf()
290 static void prepare_I_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in prepare_I_frame() argument
293 CHECK(p_buf != NULL); in prepare_I_frame()
304 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset + L2CAP_PKT_OVERHEAD; in prepare_I_frame()
310 ctrl_word = p_buf->layer_specific & L2CAP_FCR_SEG_BITS; /* SAR bits */ in prepare_I_frame()
329 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset + L2CAP_PKT_OVERHEAD; in prepare_I_frame()
335 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in prepare_I_frame()
336 UINT16_TO_STREAM(p, p_buf->len + L2CAP_FCS_LEN - L2CAP_PKT_OVERHEAD); in prepare_I_frame()
339 fcs = l2c_fcr_tx_get_fcs(p_buf); in prepare_I_frame()
346 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset + p_buf->len; in prepare_I_frame()
350 p_buf->len += L2CAP_FCS_LEN; in prepare_I_frame()
356 p_ccb->local_cid, p_buf->len, in prepare_I_frame()
365 p_ccb->local_cid, p_buf->len, in prepare_I_frame()
407 BT_HDR* p_buf = (BT_HDR*)osi_malloc(L2CAP_CMD_BUF_SIZE); in l2c_fcr_send_S_frame() local
408 p_buf->offset = HCI_DATA_PREAMBLE_SIZE; in l2c_fcr_send_S_frame()
409 p_buf->len = L2CAP_PKT_OVERHEAD + L2CAP_FCR_OVERHEAD; in l2c_fcr_send_S_frame()
412 p = (uint8_t*)(p_buf + 1) + p_buf->offset; in l2c_fcr_send_S_frame()
420 fcs = l2c_fcr_tx_get_fcs(p_buf); in l2c_fcr_send_S_frame()
423 p_buf->len += L2CAP_FCS_LEN; in l2c_fcr_send_S_frame()
426 p_buf->layer_specific = L2CAP_NON_FLUSHABLE_PKT; in l2c_fcr_send_S_frame()
427 l2cu_set_acl_hci_header(p_buf, p_ccb); in l2c_fcr_send_S_frame()
439 L2CAP_TRACE_WARNING(" Buf Len: %u", p_buf->len); in l2c_fcr_send_S_frame()
449 L2CAP_TRACE_EVENT(" Buf Len: %u", p_buf->len); in l2c_fcr_send_S_frame()
452 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2c_fcr_send_S_frame()
470 void l2c_fcr_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_fcr_proc_pdu() argument
472 CHECK(p_buf != NULL); in l2c_fcr_proc_pdu()
481 if (p_buf->len < min_pdu_len) { in l2c_fcr_proc_pdu()
483 p_ccb->local_cid, p_buf->len); in l2c_fcr_proc_pdu()
484 osi_free(p_buf); in l2c_fcr_proc_pdu()
489 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in l2c_fcr_proc_pdu()
499 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
508 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
518 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
533 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset + p_buf->len - L2CAP_FCS_LEN; in l2c_fcr_proc_pdu()
537 p_buf->len -= L2CAP_FCS_LEN; in l2c_fcr_proc_pdu()
539 if (l2c_fcr_rx_get_fcs(p_buf) != fcs) { in l2c_fcr_proc_pdu()
541 osi_free(p_buf); in l2c_fcr_proc_pdu()
546 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in l2c_fcr_proc_pdu()
550 p_buf->len -= L2CAP_FCR_OVERHEAD; in l2c_fcr_proc_pdu()
551 p_buf->offset += L2CAP_FCR_OVERHEAD; in l2c_fcr_proc_pdu()
575 osi_free(p_buf); in l2c_fcr_proc_pdu()
595 osi_free(p_buf); in l2c_fcr_proc_pdu()
601 process_s_frame(p_ccb, p_buf, ctrl_word); in l2c_fcr_proc_pdu()
603 process_i_frame(p_ccb, p_buf, ctrl_word, false); in l2c_fcr_proc_pdu()
616 while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(temp_q)) != NULL) { in l2c_fcr_proc_pdu()
619 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset - L2CAP_FCR_OVERHEAD; in l2c_fcr_proc_pdu()
632 process_i_frame(p_ccb, p_buf, ctrl_word, true); in l2c_fcr_proc_pdu()
634 osi_free(p_buf); in l2c_fcr_proc_pdu()
677 void l2c_lcc_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_lcc_proc_pdu() argument
679 CHECK(p_buf != NULL); in l2c_lcc_proc_pdu()
680 uint8_t* p = (uint8_t*)(p_buf + 1) + p_buf->offset; in l2c_lcc_proc_pdu()
685 if (p_buf->len > p_ccb->local_conn_cfg.mps) { in l2c_lcc_proc_pdu()
687 osi_free(p_buf); in l2c_lcc_proc_pdu()
692 if (p_buf->len < sizeof(sdu_length)) { in l2c_lcc_proc_pdu()
694 __func__, p_buf->len); in l2c_lcc_proc_pdu()
697 osi_free(p_buf); in l2c_lcc_proc_pdu()
705 osi_free(p_buf); in l2c_lcc_proc_pdu()
709 p_buf->len -= sizeof(sdu_length); in l2c_lcc_proc_pdu()
710 p_buf->offset += sizeof(sdu_length); in l2c_lcc_proc_pdu()
712 if (sdu_length < p_buf->len) { in l2c_lcc_proc_pdu()
716 osi_free(p_buf); in l2c_lcc_proc_pdu()
722 osi_free(p_buf); in l2c_lcc_proc_pdu()
734 if (p_buf->len > (p_ccb->ble_sdu_length - p_data->len)) { in l2c_lcc_proc_pdu()
739 osi_free(p_buf); in l2c_lcc_proc_pdu()
752 (uint8_t*)(p_buf + 1) + p_buf->offset, p_buf->len); in l2c_lcc_proc_pdu()
753 p_data->len += p_buf->len; in l2c_lcc_proc_pdu()
764 osi_free(p_buf); in l2c_lcc_proc_pdu()
916 static void process_s_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in process_s_frame() argument
919 CHECK(p_buf != NULL); in process_s_frame()
927 if (p_buf->len != 0) { in process_s_frame()
928 L2CAP_TRACE_WARNING("Incorrect S-frame Length (%d)", p_buf->len); in process_s_frame()
981 osi_free(p_buf); in process_s_frame()
993 static void process_i_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word, in process_i_frame() argument
996 CHECK(p_buf != NULL); in process_i_frame()
1005 osi_free(p_buf); in process_i_frame()
1024 osi_free(p_buf); in process_i_frame()
1049 p_buf->layer_specific = tx_seq; in process_i_frame()
1050 fixed_queue_enqueue(p_fcrb->srej_rcv_hold_q, p_buf); in process_i_frame()
1060 osi_free(p_buf); in process_i_frame()
1070 osi_free(p_buf); in process_i_frame()
1079 osi_free(p_buf); in process_i_frame()
1090 p_buf->layer_specific = tx_seq; in process_i_frame()
1091 fixed_queue_enqueue(p_fcrb->srej_rcv_hold_q, p_buf); in process_i_frame()
1111 if (!do_sar_reassembly(p_ccb, p_buf, ctrl_word)) { in process_i_frame()
1152 static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf, in do_sar_reassembly() argument
1155 CHECK(p_buf != NULL); in do_sar_reassembly()
1174 (p_buf->len < L2CAP_SDU_LEN_OVERHEAD)) { in do_sar_reassembly()
1175 L2CAP_TRACE_WARNING("SAR start packet too short: %u", p_buf->len); in do_sar_reassembly()
1186 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset; in do_sar_reassembly()
1192 p_buf->offset += 2; in do_sar_reassembly()
1193 p_buf->len -= 2; in do_sar_reassembly()
1208 if ((p_fcrb->p_rx_sdu->len + p_buf->len) > p_fcrb->rx_sdu_len) { in do_sar_reassembly()
1211 p_fcrb->p_rx_sdu->len, p_buf->len, p_fcrb->rx_sdu_len); in do_sar_reassembly()
1214 ((p_fcrb->p_rx_sdu->len + p_buf->len) != p_fcrb->rx_sdu_len)) { in do_sar_reassembly()
1216 p_fcrb->p_rx_sdu->len, p_buf->len, in do_sar_reassembly()
1222 p, p_buf->len); in do_sar_reassembly()
1224 p_fcrb->p_rx_sdu->len += p_buf->len; in do_sar_reassembly()
1226 osi_free(p_buf); in do_sar_reassembly()
1227 p_buf = NULL; in do_sar_reassembly()
1230 p_buf = p_fcrb->p_rx_sdu; in do_sar_reassembly()
1238 osi_free(p_buf); in do_sar_reassembly()
1239 } else if (p_buf != NULL) { in do_sar_reassembly()
1247 p_ccb->p_lcb->remote_bd_addr, p_buf); in do_sar_reassembly()
1249 l2c_csm_execute(p_ccb, L2CEVT_L2CAP_DATA, p_buf); in do_sar_reassembly()
1267 BT_HDR* p_buf = NULL; in retransmit_i_frames() local
1299 p_buf = (BT_HDR*)list_node(node_ack); in retransmit_i_frames()
1301 p = ((uint8_t*)(p_buf + 1)) + p_buf->offset + L2CAP_PKT_OVERHEAD; in retransmit_i_frames()
1316 if (!p_buf) { in retransmit_i_frames()
1346 p_buf = (BT_HDR*)list_node(node_ack); in retransmit_i_frames()
1349 BT_HDR* p_buf2 = l2c_fcr_clone_buf(p_buf, p_buf->offset, p_buf->len); in retransmit_i_frames()
1351 p_buf2->layer_specific = p_buf->layer_specific; in retransmit_i_frames()
1387 BT_HDR *p_buf, *p_xmit; in l2c_fcr_get_next_xmit_sdu_seg() local
1393 p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q); in l2c_fcr_get_next_xmit_sdu_seg()
1394 if (p_buf != NULL) { in l2c_fcr_get_next_xmit_sdu_seg()
1397 prepare_I_frame(p_ccb, p_buf, true); in l2c_fcr_get_next_xmit_sdu_seg()
1399 p_buf->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1401 return (p_buf); in l2c_fcr_get_next_xmit_sdu_seg()
1411 p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->xmit_hold_q); in l2c_fcr_get_next_xmit_sdu_seg()
1414 if (p_buf->len > max_pdu) { in l2c_fcr_get_next_xmit_sdu_seg()
1417 if (p_buf->event == 0) { in l2c_fcr_get_next_xmit_sdu_seg()
1419 sdu_len = p_buf->len; in l2c_fcr_get_next_xmit_sdu_seg()
1424 p_xmit = l2c_fcr_clone_buf(p_buf, L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET, in l2c_fcr_get_next_xmit_sdu_seg()
1428 p_buf->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1431 p_buf->len -= max_pdu; in l2c_fcr_get_next_xmit_sdu_seg()
1432 p_buf->offset += max_pdu; in l2c_fcr_get_next_xmit_sdu_seg()
1435 p_xmit->layer_specific = p_buf->layer_specific; in l2c_fcr_get_next_xmit_sdu_seg()
1525 BT_HDR* p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->xmit_hold_q); in l2c_lcc_get_next_xmit_sdu_seg() local
1526 bool first_pdu = (p_buf->event == 0) ? true : false; in l2c_lcc_get_next_xmit_sdu_seg()
1529 p_buf->len, in l2c_lcc_get_next_xmit_sdu_seg()
1531 bool last_pdu = (no_of_bytes_to_send == p_buf->len); in l2c_lcc_get_next_xmit_sdu_seg()
1535 l2c_fcr_clone_buf(p_buf, first_pdu ? L2CAP_LCC_OFFSET : L2CAP_MIN_OFFSET, in l2c_lcc_get_next_xmit_sdu_seg()
1538 p_buf->event = p_ccb->local_cid; in l2c_lcc_get_next_xmit_sdu_seg()
1544 UINT16_TO_STREAM(p, p_buf->len); in l2c_lcc_get_next_xmit_sdu_seg()
1548 p_buf->len -= no_of_bytes_to_send; in l2c_lcc_get_next_xmit_sdu_seg()
1549 p_buf->offset += no_of_bytes_to_send; in l2c_lcc_get_next_xmit_sdu_seg()
1552 p_xmit->layer_specific = p_buf->layer_specific; in l2c_lcc_get_next_xmit_sdu_seg()
1557 p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->xmit_hold_q); in l2c_lcc_get_next_xmit_sdu_seg()
1558 osi_free(p_buf); in l2c_lcc_get_next_xmit_sdu_seg()