Lines Matching refs:p_ccb
89 static bool process_reqseq(tL2C_CCB* p_ccb, uint16_t ctrl_word);
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,
93 static bool retransmit_i_frames(tL2C_CCB* p_ccb, uint8_t tx_seq);
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,
164 void l2c_fcr_start_timer(tL2C_CCB* p_ccb) { in l2c_fcr_start_timer() argument
165 CHECK(p_ccb != NULL); in l2c_fcr_start_timer()
169 if (p_ccb->fcrb.wait_ack) { in l2c_fcr_start_timer()
170 tout = (uint32_t)p_ccb->our_cfg.fcr.mon_tout; in l2c_fcr_start_timer()
172 tout = (uint32_t)p_ccb->our_cfg.fcr.rtrans_tout; in l2c_fcr_start_timer()
176 if (!alarm_is_scheduled(p_ccb->fcrb.mon_retrans_timer)) { in l2c_fcr_start_timer()
177 alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, tout, in l2c_fcr_start_timer()
178 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_start_timer()
191 void l2c_fcr_stop_timer(tL2C_CCB* p_ccb) { in l2c_fcr_stop_timer() argument
192 CHECK(p_ccb != NULL); in l2c_fcr_stop_timer()
193 alarm_cancel(p_ccb->fcrb.mon_retrans_timer); in l2c_fcr_stop_timer()
206 void l2c_fcr_cleanup(tL2C_CCB* p_ccb) { in l2c_fcr_cleanup() argument
207 CHECK(p_ccb != NULL); in l2c_fcr_cleanup()
208 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in l2c_fcr_cleanup()
266 bool l2c_fcr_is_flow_controlled(tL2C_CCB* p_ccb) { in l2c_fcr_is_flow_controlled() argument
267 CHECK(p_ccb != NULL); in l2c_fcr_is_flow_controlled()
268 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in l2c_fcr_is_flow_controlled()
270 if ((p_ccb->fcrb.remote_busy) || in l2c_fcr_is_flow_controlled()
271 (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) >= in l2c_fcr_is_flow_controlled()
272 p_ccb->peer_cfg.fcr.tx_win_sz)) { in l2c_fcr_is_flow_controlled()
290 static void prepare_I_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in prepare_I_frame() argument
292 CHECK(p_ccb != NULL); in prepare_I_frame()
294 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in prepare_I_frame()
318 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in prepare_I_frame()
323 p_fcrb->last_ack_sent = p_ccb->fcrb.next_seq_expected; in prepare_I_frame()
325 alarm_cancel(p_ccb->fcrb.ack_timer); 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()
373 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) in prepare_I_frame()
374 l2c_fcr_start_timer(p_ccb); in prepare_I_frame()
386 void l2c_fcr_send_S_frame(tL2C_CCB* p_ccb, uint16_t function_code, in l2c_fcr_send_S_frame() argument
388 CHECK(p_ccb != NULL); in l2c_fcr_send_S_frame()
393 if ((!p_ccb->in_use) || (p_ccb->chnl_state != CST_OPEN)) return; in l2c_fcr_send_S_frame()
396 p_ccb->fcrb.wait_ack = true; in l2c_fcr_send_S_frame()
398 l2c_fcr_stop_timer(p_ccb); /* Restart the monitor timer */ in l2c_fcr_send_S_frame()
399 l2c_fcr_start_timer(p_ccb); in l2c_fcr_send_S_frame()
404 ctrl_word |= (p_ccb->fcrb.next_seq_expected << L2CAP_FCR_REQ_SEQ_BITS_SHIFT); in l2c_fcr_send_S_frame()
416 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_fcr_send_S_frame()
427 l2cu_set_acl_hci_header(p_buf, p_ccb); in l2c_fcr_send_S_frame()
434 p_ccb->local_cid, ctrl_word, in l2c_fcr_send_S_frame()
444 p_ccb->local_cid, ctrl_word, 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()
454 p_ccb->fcrb.last_ack_sent = p_ccb->fcrb.next_seq_expected; in l2c_fcr_send_S_frame()
456 alarm_cancel(p_ccb->fcrb.ack_timer); 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
471 CHECK(p_ccb != NULL); in l2c_fcr_proc_pdu()
483 p_ccb->local_cid, p_buf->len); 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()
528 p_ccb->fcrb.next_tx_seq, p_ccb->fcrb.last_rx_ack, in l2c_fcr_proc_pdu()
529 p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent, in l2c_fcr_proc_pdu()
530 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q), p_ccb->fcrb.num_tries); in l2c_fcr_proc_pdu()
540 L2CAP_TRACE_WARNING("Rx L2CAP PDU: CID: 0x%04x BAD FCS", p_ccb->local_cid); in l2c_fcr_proc_pdu()
554 if (p_ccb->fcrb.wait_ack) { in l2c_fcr_proc_pdu()
559 if (p_ccb->fcrb.srej_sent) in l2c_fcr_proc_pdu()
560 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, L2CAP_FCR_F_BIT); in l2c_fcr_proc_pdu()
562 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_F_BIT); in l2c_fcr_proc_pdu()
572 alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, BT_1SEC_TIMEOUT_MS, in l2c_fcr_proc_pdu()
573 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_proc_pdu()
579 p_ccb->fcrb.wait_ack = false; in l2c_fcr_proc_pdu()
584 if (fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) in l2c_fcr_proc_pdu()
585 p_ccb->fcrb.num_tries = 0; in l2c_fcr_proc_pdu()
587 l2c_fcr_stop_timer(p_ccb); in l2c_fcr_proc_pdu()
594 if (!process_reqseq(p_ccb, ctrl_word)) { 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()
607 if ((!p_ccb->in_use) || (p_ccb->chnl_state != CST_OPEN)) return; in l2c_fcr_proc_pdu()
611 if ((!p_ccb->fcrb.srej_sent) && in l2c_fcr_proc_pdu()
612 (!fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q))) { in l2c_fcr_proc_pdu()
613 fixed_queue_t* temp_q = p_ccb->fcrb.srej_rcv_hold_q; in l2c_fcr_proc_pdu()
614 p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX); in l2c_fcr_proc_pdu()
617 if (p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) { in l2c_fcr_proc_pdu()
626 p_ccb->local_cid, in l2c_fcr_proc_pdu()
628 p_ccb->fcrb.next_seq_expected); in l2c_fcr_proc_pdu()
632 process_i_frame(p_ccb, p_buf, ctrl_word, true); in l2c_fcr_proc_pdu()
637 if (p_ccb->fcrb.rej_after_srej) { in l2c_fcr_proc_pdu()
638 p_ccb->fcrb.rej_after_srej = false; in l2c_fcr_proc_pdu()
639 p_ccb->fcrb.rej_sent = true; in l2c_fcr_proc_pdu()
641 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_REJ, 0); in l2c_fcr_proc_pdu()
647 if ((!p_ccb->fcrb.rej_sent) && (!p_ccb->fcrb.srej_sent) && in l2c_fcr_proc_pdu()
648 (p_ccb->fcrb.next_seq_expected != p_ccb->fcrb.last_ack_sent)) in l2c_fcr_proc_pdu()
649 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in l2c_fcr_proc_pdu()
654 p_ccb->local_cid, 0, p_ccb->fcrb.rej_sent, p_ccb->fcrb.srej_sent, in l2c_fcr_proc_pdu()
655 p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent); in l2c_fcr_proc_pdu()
660 if ((!fixed_queue_is_empty(p_ccb->fcrb.retrans_q) || in l2c_fcr_proc_pdu()
661 !fixed_queue_is_empty(p_ccb->xmit_hold_q)) && in l2c_fcr_proc_pdu()
662 (!p_ccb->fcrb.wait_ack) && (!l2c_fcr_is_flow_controlled(p_ccb))) { in l2c_fcr_proc_pdu()
663 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); 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
678 CHECK(p_ccb != NULL); in l2c_lcc_proc_pdu()
685 if (p_buf->len > p_ccb->local_conn_cfg.mps) { in l2c_lcc_proc_pdu()
691 if (p_ccb->is_first_seg) { in l2c_lcc_proc_pdu()
703 if (sdu_length > p_ccb->local_conn_cfg.mtu) { in l2c_lcc_proc_pdu()
726 p_ccb->ble_sdu = p_data; in l2c_lcc_proc_pdu()
728 p_ccb->ble_sdu_length = sdu_length; in l2c_lcc_proc_pdu()
733 p_data = p_ccb->ble_sdu; in l2c_lcc_proc_pdu()
734 if (p_buf->len > (p_ccb->ble_sdu_length - p_data->len)) { in l2c_lcc_proc_pdu()
737 (p_ccb->ble_sdu_length - p_data->len)); in l2c_lcc_proc_pdu()
742 p_ccb->is_first_seg = true; in l2c_lcc_proc_pdu()
743 osi_free(p_ccb->ble_sdu); in l2c_lcc_proc_pdu()
744 p_ccb->ble_sdu = NULL; in l2c_lcc_proc_pdu()
745 p_ccb->ble_sdu_length = 0; in l2c_lcc_proc_pdu()
746 l2cu_disconnect_chnl(p_ccb); in l2c_lcc_proc_pdu()
755 if (p_data->len == p_ccb->ble_sdu_length) { in l2c_lcc_proc_pdu()
756 l2c_csm_execute(p_ccb, L2CEVT_L2CAP_DATA, p_data); in l2c_lcc_proc_pdu()
757 p_ccb->is_first_seg = true; in l2c_lcc_proc_pdu()
758 p_ccb->ble_sdu = NULL; in l2c_lcc_proc_pdu()
759 p_ccb->ble_sdu_length = 0; in l2c_lcc_proc_pdu()
760 } else if (p_data->len < p_ccb->ble_sdu_length) { in l2c_lcc_proc_pdu()
761 p_ccb->is_first_seg = false; in l2c_lcc_proc_pdu()
777 void l2c_fcr_proc_tout(tL2C_CCB* p_ccb) { in l2c_fcr_proc_tout() argument
778 CHECK(p_ccb != NULL); in l2c_fcr_proc_tout()
782 p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit, in l2c_fcr_proc_tout()
783 p_ccb->fcrb.wait_ack, fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in l2c_fcr_proc_tout()
785 if ((p_ccb->peer_cfg.fcr.max_transmit != 0) && in l2c_fcr_proc_tout()
786 (++p_ccb->fcrb.num_tries > p_ccb->peer_cfg.fcr.max_transmit)) { in l2c_fcr_proc_tout()
787 l2cu_disconnect_chnl(p_ccb); in l2c_fcr_proc_tout()
789 if (!p_ccb->fcrb.srej_sent && !p_ccb->fcrb.rej_sent) { in l2c_fcr_proc_tout()
790 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_P_BIT); in l2c_fcr_proc_tout()
804 void l2c_fcr_proc_ack_tout(tL2C_CCB* p_ccb) { in l2c_fcr_proc_ack_tout() argument
805 CHECK(p_ccb != NULL); in l2c_fcr_proc_ack_tout()
808 p_ccb->local_cid, p_ccb->chnl_state, p_ccb->fcrb.wait_ack, in l2c_fcr_proc_ack_tout()
809 p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent); in l2c_fcr_proc_ack_tout()
811 if ((p_ccb->chnl_state == CST_OPEN) && (!p_ccb->fcrb.wait_ack) && in l2c_fcr_proc_ack_tout()
812 (p_ccb->fcrb.last_ack_sent != p_ccb->fcrb.next_seq_expected)) { in l2c_fcr_proc_ack_tout()
813 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in l2c_fcr_proc_ack_tout()
826 static bool process_reqseq(tL2C_CCB* p_ccb, uint16_t ctrl_word) { in process_reqseq() argument
827 CHECK(p_ccb != NULL); in process_reqseq()
828 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_reqseq()
841 l2c_fcr_start_timer(p_ccb); in process_reqseq()
861 l2cu_disconnect_chnl(p_ccb); in process_reqseq()
885 if (!p_ccb->fcrb.wait_ack) l2c_fcr_stop_timer(p_ccb); in process_reqseq()
888 if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_TxComplete_Cb) && in process_reqseq()
892 fixed_queue_is_empty(p_ccb->xmit_hold_q)) { in process_reqseq()
896 (*p_ccb->p_rcb->api.pL2CA_TxComplete_Cb)(p_ccb->local_cid, in process_reqseq()
903 l2c_fcr_start_timer(p_ccb); in process_reqseq()
916 static void process_s_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in process_s_frame() argument
918 CHECK(p_ccb != NULL); in process_s_frame()
921 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_s_frame()
945 all_ok = retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS); in process_s_frame()
950 all_ok = retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS); in process_s_frame()
955 l2c_fcr_stop_timer(p_ccb); in process_s_frame()
961 p_ccb, (uint8_t)((ctrl_word & L2CAP_FCR_REQ_SEQ_BITS) >> in process_s_frame()
971 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, L2CAP_FCR_F_BIT); in process_s_frame()
973 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_F_BIT); 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
995 CHECK(p_ccb != NULL); in process_i_frame()
998 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_i_frame()
1004 if (!retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS)) { in process_i_frame()
1018 if (num_lost >= p_ccb->our_cfg.fcr.tx_win_sz) { in process_i_frame()
1029 p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1043 p_ccb->our_cfg.fcr.tx_win_sz)) { in process_i_frame()
1055 p_ccb->local_cid, next_srej, in process_i_frame()
1057 p_ccb->our_cfg.fcr.tx_win_sz); in process_i_frame()
1066 p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1074 p_ccb->local_cid, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1081 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_REJ, 0); in process_i_frame()
1087 p_ccb->local_cid, tx_seq, in process_i_frame()
1093 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, 0); in process_i_frame()
1095 alarm_cancel(p_ccb->fcrb.ack_timer); in process_i_frame()
1111 if (!do_sar_reassembly(p_ccb, p_buf, ctrl_word)) { in process_i_frame()
1113 p_ccb->local_cid); in process_i_frame()
1114 l2cu_disconnect_chnl(p_ccb); in process_i_frame()
1123 if (num_to_ack < p_ccb->fcrb.max_held_acks) delay_ack = true; in process_i_frame()
1126 if ((num_to_ack != 0) && p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) { in process_i_frame()
1131 if (!alarm_is_scheduled(p_ccb->fcrb.ack_timer)) { in process_i_frame()
1132 alarm_set_on_mloop(p_ccb->fcrb.ack_timer, L2CAP_FCR_ACK_TIMEOUT_MS, in process_i_frame()
1133 l2c_fcrb_ack_timer_timeout, p_ccb); in process_i_frame()
1135 } else if ((fixed_queue_is_empty(p_ccb->xmit_hold_q) || in process_i_frame()
1136 l2c_fcr_is_flow_controlled(p_ccb)) && in process_i_frame()
1137 fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q)) { in process_i_frame()
1138 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in process_i_frame()
1152 static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf, in do_sar_reassembly() argument
1154 CHECK(p_ccb != NULL); in do_sar_reassembly()
1157 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in do_sar_reassembly()
1195 if (p_fcrb->rx_sdu_len > p_ccb->max_rx_mtu) { in do_sar_reassembly()
1197 p_fcrb->rx_sdu_len, p_ccb->max_rx_mtu); in do_sar_reassembly()
1240 if (p_ccb->local_cid < L2CAP_BASE_APPL_CID && in do_sar_reassembly()
1241 (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && in do_sar_reassembly()
1242 p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL)) { in do_sar_reassembly()
1243 if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in do_sar_reassembly()
1245 (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in do_sar_reassembly()
1246 .pL2CA_FixedData_Cb)(p_ccb->local_cid, 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()
1264 static bool retransmit_i_frames(tL2C_CCB* p_ccb, uint8_t tx_seq) { in retransmit_i_frames() argument
1265 CHECK(p_ccb != NULL); in retransmit_i_frames()
1272 if ((!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) && in retransmit_i_frames()
1273 (p_ccb->peer_cfg.fcr.max_transmit != 0) && in retransmit_i_frames()
1274 (p_ccb->fcrb.num_tries >= p_ccb->peer_cfg.fcr.max_transmit)) { in retransmit_i_frames()
1278 p_ccb->fcrb.last_rx_ack, p_ccb->local_cid, p_ccb->fcrb.num_tries, in retransmit_i_frames()
1279 p_ccb->peer_cfg.fcr.max_transmit, in retransmit_i_frames()
1280 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in retransmit_i_frames()
1282 l2cu_disconnect_chnl(p_ccb); in retransmit_i_frames()
1290 if (!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) { in retransmit_i_frames()
1291 list_ack = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q); in retransmit_i_frames()
1319 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in retransmit_i_frames()
1325 for (list_node_t* node_tmp = list_begin(p_ccb->p_lcb->link_xmit_data_q); in retransmit_i_frames()
1326 node_tmp != list_end(p_ccb->p_lcb->link_xmit_data_q);) { in retransmit_i_frames()
1331 if ((p_tmp->layer_specific == 0) && (p_tmp->event == p_ccb->local_cid)) { in retransmit_i_frames()
1332 list_remove(p_ccb->p_lcb->link_xmit_data_q, p_tmp); in retransmit_i_frames()
1338 while (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q)) in retransmit_i_frames()
1339 osi_free(fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q)); in retransmit_i_frames()
1353 fixed_queue_enqueue(p_ccb->fcrb.retrans_q, p_buf2); in retransmit_i_frames()
1360 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); in retransmit_i_frames()
1362 if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)) { in retransmit_i_frames()
1363 p_ccb->fcrb.num_tries++; in retransmit_i_frames()
1364 l2c_fcr_start_timer(p_ccb); in retransmit_i_frames()
1379 BT_HDR* l2c_fcr_get_next_xmit_sdu_seg(tL2C_CCB* p_ccb, in l2c_fcr_get_next_xmit_sdu_seg() argument
1381 CHECK(p_ccb != NULL); in l2c_fcr_get_next_xmit_sdu_seg()
1389 uint16_t max_pdu = p_ccb->tx_mps /* Needed? - L2CAP_MAX_HEADER_FCS*/; in l2c_fcr_get_next_xmit_sdu_seg()
1393 p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q); 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()
1411 p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->xmit_hold_q); in l2c_fcr_get_next_xmit_sdu_seg()
1428 p_buf->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1429 p_xmit->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1445 p_xmit = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->xmit_hold_q); in l2c_fcr_get_next_xmit_sdu_seg()
1449 p_xmit->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1469 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_fcr_get_next_xmit_sdu_seg()
1488 prepare_I_frame(p_ccb, p_xmit, false); in l2c_fcr_get_next_xmit_sdu_seg()
1490 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in l2c_fcr_get_next_xmit_sdu_seg()
1497 p_ccb->local_cid, p_xmit->len); in l2c_fcr_get_next_xmit_sdu_seg()
1503 fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_xmit); in l2c_fcr_get_next_xmit_sdu_seg()
1510 fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_wack); in l2c_fcr_get_next_xmit_sdu_seg()
1521 BT_HDR* l2c_lcc_get_next_xmit_sdu_seg(tL2C_CCB* p_ccb, in l2c_lcc_get_next_xmit_sdu_seg() argument
1523 uint16_t max_pdu = p_ccb->peer_conn_cfg.mps - 4 /* Length and CID */; in l2c_lcc_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()
1538 p_buf->event = p_ccb->local_cid; in l2c_lcc_get_next_xmit_sdu_seg()
1539 p_xmit->event = p_ccb->local_cid; 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()
1570 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_lcc_get_next_xmit_sdu_seg()
1595 uint8_t l2c_fcr_chk_chan_modes(tL2C_CCB* p_ccb) { in l2c_fcr_chk_chan_modes() argument
1596 CHECK(p_ccb != NULL); in l2c_fcr_chk_chan_modes()
1599 if (!(p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_ENH_RETRANS) && in l2c_fcr_chk_chan_modes()
1600 p_ccb->p_rcb->ertm_info.preferred_mode == L2CAP_FCR_ERTM_MODE) { in l2c_fcr_chk_chan_modes()
1603 p_ccb->p_rcb->ertm_info.preferred_mode = 0; in l2c_fcr_chk_chan_modes()
1618 void l2c_fcr_adj_monitor_retran_timeout(tL2C_CCB* p_ccb) { in l2c_fcr_adj_monitor_retran_timeout() argument
1619 CHECK(p_ccb != NULL); in l2c_fcr_adj_monitor_retran_timeout()
1622 if (p_ccb->out_cfg_fcr_present) { in l2c_fcr_adj_monitor_retran_timeout()
1628 if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) || in l2c_fcr_adj_monitor_retran_timeout()
1629 (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)) { in l2c_fcr_adj_monitor_retran_timeout()
1631 p_ccb->our_cfg.fcr.mon_tout = L2CAP_MIN_MONITOR_TOUT; in l2c_fcr_adj_monitor_retran_timeout()
1632 p_ccb->our_cfg.fcr.rtrans_tout = L2CAP_MIN_RETRANS_TOUT; in l2c_fcr_adj_monitor_retran_timeout()
1634 p_ccb->our_cfg.fcr.mon_tout = 0; in l2c_fcr_adj_monitor_retran_timeout()
1635 p_ccb->our_cfg.fcr.rtrans_tout = 0; in l2c_fcr_adj_monitor_retran_timeout()
1640 p_ccb->our_cfg.fcr.mon_tout, p_ccb->our_cfg.fcr.rtrans_tout); in l2c_fcr_adj_monitor_retran_timeout()
1654 void l2c_fcr_adj_our_rsp_options(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_adj_our_rsp_options() argument
1655 CHECK(p_ccb != NULL); in l2c_fcr_adj_our_rsp_options()
1659 l2c_fcr_adj_monitor_retran_timeout(p_ccb); in l2c_fcr_adj_our_rsp_options()
1661 p_cfg->fcr_present = p_ccb->out_cfg_fcr_present; in l2c_fcr_adj_our_rsp_options()
1668 if (p_ccb->peer_cfg.fcr.tx_win_sz > p_ccb->our_cfg.fcr.tx_win_sz) { in l2c_fcr_adj_our_rsp_options()
1670 __func__, p_ccb->peer_cfg.fcr.tx_win_sz, in l2c_fcr_adj_our_rsp_options()
1671 p_ccb->our_cfg.fcr.tx_win_sz); in l2c_fcr_adj_our_rsp_options()
1672 p_ccb->peer_cfg.fcr.tx_win_sz = p_ccb->our_cfg.fcr.tx_win_sz; in l2c_fcr_adj_our_rsp_options()
1675 p_cfg->fcr.mode = p_ccb->peer_cfg.fcr.mode; in l2c_fcr_adj_our_rsp_options()
1676 p_cfg->fcr.tx_win_sz = p_ccb->peer_cfg.fcr.tx_win_sz; in l2c_fcr_adj_our_rsp_options()
1677 p_cfg->fcr.max_transmit = p_ccb->peer_cfg.fcr.max_transmit; in l2c_fcr_adj_our_rsp_options()
1678 p_cfg->fcr.mps = p_ccb->peer_cfg.fcr.mps; in l2c_fcr_adj_our_rsp_options()
1679 p_cfg->fcr.rtrans_tout = p_ccb->our_cfg.fcr.rtrans_tout; in l2c_fcr_adj_our_rsp_options()
1680 p_cfg->fcr.mon_tout = p_ccb->our_cfg.fcr.mon_tout; in l2c_fcr_adj_our_rsp_options()
1696 bool l2c_fcr_renegotiate_chan(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_renegotiate_chan() argument
1697 CHECK(p_ccb != NULL); in l2c_fcr_renegotiate_chan()
1700 uint8_t peer_mode = p_ccb->our_cfg.fcr.mode; in l2c_fcr_renegotiate_chan()
1705 if (!p_cfg->fcr_present || (p_ccb->config_done & RECONFIG_FLAG)) in l2c_fcr_renegotiate_chan()
1712 if (p_ccb->our_cfg.fcr.mode != peer_mode) { in l2c_fcr_renegotiate_chan()
1713 if ((--p_ccb->fcr_cfg_tries) == 0) { in l2c_fcr_renegotiate_chan()
1722 switch (p_ccb->our_cfg.fcr.mode) { in l2c_fcr_renegotiate_chan()
1725 if (p_ccb->p_rcb->ertm_info.preferred_mode & L2CAP_FCR_BASIC_MODE) { in l2c_fcr_renegotiate_chan()
1728 p_ccb->our_cfg.fcr.mode = L2CAP_FCR_BASIC_MODE; in l2c_fcr_renegotiate_chan()
1738 p_ccb->our_cfg.fcr_present = true; in l2c_fcr_renegotiate_chan()
1740 if (p_ccb->our_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) { in l2c_fcr_renegotiate_chan()
1741 p_ccb->our_cfg.fcs_present = false; in l2c_fcr_renegotiate_chan()
1742 p_ccb->our_cfg.ext_flow_spec_present = false; in l2c_fcr_renegotiate_chan()
1751 l2cu_process_our_cfg_req(p_ccb, &p_ccb->our_cfg); in l2c_fcr_renegotiate_chan()
1752 l2cu_send_peer_config_req(p_ccb, &p_ccb->our_cfg); in l2c_fcr_renegotiate_chan()
1753 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_fcr_renegotiate_chan()
1754 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_renegotiate_chan()
1761 if (p_ccb->our_cfg.fcr.mode != peer_mode) { in l2c_fcr_renegotiate_chan()
1763 p_ccb->our_cfg.fcr.mode, peer_mode); in l2c_fcr_renegotiate_chan()
1764 l2cu_disconnect_chnl(p_ccb); in l2c_fcr_renegotiate_chan()
1781 uint8_t l2c_fcr_process_peer_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_process_peer_cfg_req() argument
1782 CHECK(p_ccb != NULL); in l2c_fcr_process_peer_cfg_req()
1788 p_ccb->p_lcb->w4_info_rsp = in l2c_fcr_process_peer_cfg_req()
1794 p_cfg->fcr_present, p_cfg->fcr.mode, p_ccb->our_cfg.fcr.mode, in l2c_fcr_process_peer_cfg_req()
1795 p_ccb->p_rcb->ertm_info.preferred_mode); in l2c_fcr_process_peer_cfg_req()
1800 if (p_ccb->p_rcb->ertm_info.preferred_mode != L2CAP_FCR_BASIC_MODE) in l2c_fcr_process_peer_cfg_req()
1805 else if (p_cfg->fcr.mode != p_ccb->p_rcb->ertm_info.preferred_mode) { in l2c_fcr_process_peer_cfg_req()
1813 (p_ccb->p_rcb->ertm_info.preferred_mode == L2CAP_FCR_ERTM_MODE)) { in l2c_fcr_process_peer_cfg_req()
1814 p_cfg->fcr.mode = p_ccb->our_cfg.fcr.mode; in l2c_fcr_process_peer_cfg_req()
1815 p_cfg->fcr.tx_win_sz = p_ccb->our_cfg.fcr.tx_win_sz; in l2c_fcr_process_peer_cfg_req()
1816 p_cfg->fcr.max_transmit = p_ccb->our_cfg.fcr.max_transmit; in l2c_fcr_process_peer_cfg_req()
1821 else if (p_ccb->p_rcb->ertm_info.preferred_mode == L2CAP_FCR_BASIC_MODE) { in l2c_fcr_process_peer_cfg_req()
1825 p_ccb->our_cfg.fcr.rtrans_tout = p_ccb->our_cfg.fcr.mon_tout = in l2c_fcr_process_peer_cfg_req()
1826 p_ccb->our_cfg.fcr.mps = 0; in l2c_fcr_process_peer_cfg_req()
1835 p_ccb->out_cfg_fcr_present = false; in l2c_fcr_process_peer_cfg_req()
1841 p_ccb->peer_cfg.fcs = p_cfg->fcs; in l2c_fcr_process_peer_cfg_req()
1849 if ((p_cfg->fcr.mps == 0) || (p_cfg->fcr.mps > p_ccb->peer_cfg.mtu)) { in l2c_fcr_process_peer_cfg_req()
1850 p_cfg->fcr.mps = p_ccb->peer_cfg.mtu; in l2c_fcr_process_peer_cfg_req()
1851 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
1860 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
1865 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
1870 p_ccb->peer_cfg.fcr = p_cfg->fcr; in l2c_fcr_process_peer_cfg_req()
1874 if (p_ccb->peer_cfg_already_rejected) in l2c_fcr_process_peer_cfg_req()
1877 p_ccb->peer_cfg_already_rejected = true; in l2c_fcr_process_peer_cfg_req()