Lines Matching refs:p_ccb
90 static bool process_reqseq(tL2C_CCB* p_ccb, uint16_t ctrl_word);
91 static void process_s_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word);
92 static void process_i_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word,
94 static bool retransmit_i_frames(tL2C_CCB* p_ccb, uint8_t tx_seq);
95 static void prepare_I_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf,
97 static void process_stream_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf);
98 static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf,
102 static void l2c_fcr_collect_ack_delay(tL2C_CCB* p_ccb, uint8_t num_bufs_acked);
170 void l2c_fcr_start_timer(tL2C_CCB* p_ccb) { in l2c_fcr_start_timer() argument
171 CHECK(p_ccb != NULL); in l2c_fcr_start_timer()
175 if (p_ccb->fcrb.wait_ack) { in l2c_fcr_start_timer()
176 tout = (uint32_t)p_ccb->our_cfg.fcr.mon_tout; in l2c_fcr_start_timer()
178 tout = (uint32_t)p_ccb->our_cfg.fcr.rtrans_tout; in l2c_fcr_start_timer()
182 if (!alarm_is_scheduled(p_ccb->fcrb.mon_retrans_timer)) { in l2c_fcr_start_timer()
183 alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, tout, in l2c_fcr_start_timer()
184 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_start_timer()
197 void l2c_fcr_stop_timer(tL2C_CCB* p_ccb) { in l2c_fcr_stop_timer() argument
198 CHECK(p_ccb != NULL); in l2c_fcr_stop_timer()
199 alarm_cancel(p_ccb->fcrb.mon_retrans_timer); in l2c_fcr_stop_timer()
212 void l2c_fcr_cleanup(tL2C_CCB* p_ccb) { in l2c_fcr_cleanup() argument
213 CHECK(p_ccb != NULL); in l2c_fcr_cleanup()
214 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in l2c_fcr_cleanup()
233 if ((p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && in l2c_fcr_cleanup()
234 (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)) { in l2c_fcr_cleanup()
236 p_ccb->fcrb.connect_tick_count; in l2c_fcr_cleanup()
245 p_ccb->local_cid, dur); in l2c_fcr_cleanup()
250 p_ccb->fcrb.pkts_retransmitted, p_ccb->fcrb.xmit_window_closed, in l2c_fcr_cleanup()
251 p_ccb->fcrb.retrans_touts, p_ccb->fcrb.xmit_ack_touts); in l2c_fcr_cleanup()
256 p_ccb->fcrb.controller_idle); in l2c_fcr_cleanup()
260 p_ccb->fcrb.max_held_acks, p_ccb->peer_cfg.fcr.tx_win_sz); in l2c_fcr_cleanup()
266 p_ccb->fcrb.ertm_pkt_counts[0], p_ccb->fcrb.ertm_byte_counts[0], in l2c_fcr_cleanup()
267 (dur >= 10 ? (p_ccb->fcrb.ertm_byte_counts[0] * 100) / (dur / 10) : 0), in l2c_fcr_cleanup()
268 p_ccb->fcrb.s_frames_sent[0], p_ccb->fcrb.s_frames_sent[1], in l2c_fcr_cleanup()
269 p_ccb->fcrb.s_frames_sent[2], p_ccb->fcrb.s_frames_sent[3]); in l2c_fcr_cleanup()
278 p_ccb->fcrb.ertm_pkt_counts[1], p_ccb->fcrb.ertm_byte_counts[1], in l2c_fcr_cleanup()
279 (dur >= 10 ? (p_ccb->fcrb.ertm_byte_counts[1] * 100) / (dur / 10) : 0), in l2c_fcr_cleanup()
280 p_ccb->fcrb.s_frames_rcvd[0], p_ccb->fcrb.s_frames_rcvd[1], in l2c_fcr_cleanup()
281 p_ccb->fcrb.s_frames_rcvd[2], p_ccb->fcrb.s_frames_rcvd[3]); in l2c_fcr_cleanup()
291 if (i == p_ccb->fcrb.ack_delay_avg_index) { in l2c_fcr_cleanup()
300 i, p_ccb->fcrb.throughput[i], p_ccb->fcrb.ack_delay_avg[i], in l2c_fcr_cleanup()
301 p_ccb->fcrb.ack_delay_min[i], p_ccb->fcrb.ack_delay_max[i], in l2c_fcr_cleanup()
302 p_ccb->fcrb.ack_q_count_avg[i], p_ccb->fcrb.ack_q_count_min[i], in l2c_fcr_cleanup()
303 p_ccb->fcrb.ack_q_count_max[i]); in l2c_fcr_cleanup()
308 throughput_avg += p_ccb->fcrb.throughput[i]; in l2c_fcr_cleanup()
309 ack_delay_avg += p_ccb->fcrb.ack_delay_avg[i]; in l2c_fcr_cleanup()
310 ack_q_count_avg += p_ccb->fcrb.ack_q_count_avg[i]; in l2c_fcr_cleanup()
377 bool l2c_fcr_is_flow_controlled(tL2C_CCB* p_ccb) { in l2c_fcr_is_flow_controlled() argument
378 CHECK(p_ccb != NULL); in l2c_fcr_is_flow_controlled()
379 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in l2c_fcr_is_flow_controlled()
381 if ((p_ccb->fcrb.remote_busy) || in l2c_fcr_is_flow_controlled()
382 (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) >= in l2c_fcr_is_flow_controlled()
383 p_ccb->peer_cfg.fcr.tx_win_sz)) { in l2c_fcr_is_flow_controlled()
385 if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) { in l2c_fcr_is_flow_controlled()
386 p_ccb->fcrb.xmit_window_closed++; in l2c_fcr_is_flow_controlled()
388 if ((p_ccb->p_lcb->sent_not_acked < 2) && in l2c_fcr_is_flow_controlled()
390 p_ccb->fcrb.controller_idle++; in l2c_fcr_is_flow_controlled()
410 static void prepare_I_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in prepare_I_frame() argument
412 CHECK(p_ccb != NULL); in prepare_I_frame()
414 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in prepare_I_frame()
438 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in prepare_I_frame()
443 p_fcrb->last_ack_sent = p_ccb->fcrb.next_seq_expected; in prepare_I_frame()
445 alarm_cancel(p_ccb->fcrb.ack_timer); in prepare_I_frame()
454 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { in prepare_I_frame()
478 p_ccb->local_cid, p_buf->len, in prepare_I_frame()
487 p_ccb->local_cid, p_buf->len, in prepare_I_frame()
495 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) in prepare_I_frame()
496 l2c_fcr_start_timer(p_ccb); in prepare_I_frame()
508 void l2c_fcr_send_S_frame(tL2C_CCB* p_ccb, uint16_t function_code, in l2c_fcr_send_S_frame() argument
510 CHECK(p_ccb != NULL); in l2c_fcr_send_S_frame()
515 if ((!p_ccb->in_use) || (p_ccb->chnl_state != CST_OPEN)) return; in l2c_fcr_send_S_frame()
518 p_ccb->fcrb.s_frames_sent[function_code]++; in l2c_fcr_send_S_frame()
522 p_ccb->fcrb.wait_ack = true; in l2c_fcr_send_S_frame()
524 l2c_fcr_stop_timer(p_ccb); /* Restart the monitor timer */ in l2c_fcr_send_S_frame()
525 l2c_fcr_start_timer(p_ccb); in l2c_fcr_send_S_frame()
530 ctrl_word |= (p_ccb->fcrb.next_seq_expected << L2CAP_FCR_REQ_SEQ_BITS_SHIFT); in l2c_fcr_send_S_frame()
542 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_fcr_send_S_frame()
546 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { in l2c_fcr_send_S_frame()
559 l2cu_set_acl_hci_header(p_buf, p_ccb); in l2c_fcr_send_S_frame()
566 p_ccb->local_cid, ctrl_word, in l2c_fcr_send_S_frame()
576 p_ccb->local_cid, ctrl_word, in l2c_fcr_send_S_frame()
584 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf); in l2c_fcr_send_S_frame()
586 p_ccb->fcrb.last_ack_sent = p_ccb->fcrb.next_seq_expected; in l2c_fcr_send_S_frame()
588 alarm_cancel(p_ccb->fcrb.ack_timer); in l2c_fcr_send_S_frame()
602 void l2c_fcr_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_fcr_proc_pdu() argument
603 CHECK(p_ccb != NULL); in l2c_fcr_proc_pdu()
611 min_pdu_len = (p_ccb->bypass_fcs == L2CAP_BYPASS_FCS) in l2c_fcr_proc_pdu()
617 p_ccb->local_cid, p_buf->len); in l2c_fcr_proc_pdu()
622 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_STREAM_MODE) { in l2c_fcr_proc_pdu()
623 process_stream_frame(p_ccb, p_buf); in l2c_fcr_proc_pdu()
638 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
647 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
657 p_ccb->local_cid, p_buf->len, in l2c_fcr_proc_pdu()
667 p_ccb->fcrb.next_tx_seq, p_ccb->fcrb.last_rx_ack, in l2c_fcr_proc_pdu()
668 p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent, in l2c_fcr_proc_pdu()
669 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q), p_ccb->fcrb.num_tries); in l2c_fcr_proc_pdu()
672 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { in l2c_fcr_proc_pdu()
681 p_ccb->local_cid); in l2c_fcr_proc_pdu()
696 if (p_ccb->fcrb.wait_ack) { in l2c_fcr_proc_pdu()
701 if (p_ccb->fcrb.srej_sent) in l2c_fcr_proc_pdu()
702 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, L2CAP_FCR_F_BIT); in l2c_fcr_proc_pdu()
703 else if (p_ccb->fcrb.local_busy) in l2c_fcr_proc_pdu()
704 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, L2CAP_FCR_F_BIT); in l2c_fcr_proc_pdu()
706 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_F_BIT); in l2c_fcr_proc_pdu()
716 alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, BT_1SEC_TIMEOUT_MS, in l2c_fcr_proc_pdu()
717 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_proc_pdu()
723 p_ccb->fcrb.wait_ack = false; in l2c_fcr_proc_pdu()
728 if (fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) in l2c_fcr_proc_pdu()
729 p_ccb->fcrb.num_tries = 0; in l2c_fcr_proc_pdu()
731 l2c_fcr_stop_timer(p_ccb); in l2c_fcr_proc_pdu()
738 if (!process_reqseq(p_ccb, ctrl_word)) { in l2c_fcr_proc_pdu()
745 process_s_frame(p_ccb, p_buf, ctrl_word); in l2c_fcr_proc_pdu()
747 process_i_frame(p_ccb, p_buf, ctrl_word, false); in l2c_fcr_proc_pdu()
751 if ((!p_ccb->in_use) || (p_ccb->chnl_state != CST_OPEN)) return; in l2c_fcr_proc_pdu()
755 if ((!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) && in l2c_fcr_proc_pdu()
756 (!fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q))) { in l2c_fcr_proc_pdu()
757 fixed_queue_t* temp_q = p_ccb->fcrb.srej_rcv_hold_q; in l2c_fcr_proc_pdu()
758 p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX); in l2c_fcr_proc_pdu()
761 if (p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) { in l2c_fcr_proc_pdu()
770 p_ccb->local_cid, in l2c_fcr_proc_pdu()
772 p_ccb->fcrb.next_seq_expected); in l2c_fcr_proc_pdu()
776 process_i_frame(p_ccb, p_buf, ctrl_word, true); in l2c_fcr_proc_pdu()
781 if (p_ccb->fcrb.rej_after_srej) { in l2c_fcr_proc_pdu()
782 p_ccb->fcrb.rej_after_srej = false; in l2c_fcr_proc_pdu()
783 p_ccb->fcrb.rej_sent = true; in l2c_fcr_proc_pdu()
785 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_REJ, 0); in l2c_fcr_proc_pdu()
791 if ((!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.rej_sent) && in l2c_fcr_proc_pdu()
792 (!p_ccb->fcrb.srej_sent) && in l2c_fcr_proc_pdu()
793 (p_ccb->fcrb.next_seq_expected != p_ccb->fcrb.last_ack_sent)) in l2c_fcr_proc_pdu()
794 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in l2c_fcr_proc_pdu()
799 p_ccb->local_cid, p_ccb->fcrb.local_busy, p_ccb->fcrb.rej_sent, in l2c_fcr_proc_pdu()
800 p_ccb->fcrb.srej_sent, p_ccb->fcrb.next_seq_expected, in l2c_fcr_proc_pdu()
801 p_ccb->fcrb.last_ack_sent); in l2c_fcr_proc_pdu()
806 if ((!fixed_queue_is_empty(p_ccb->fcrb.retrans_q) || in l2c_fcr_proc_pdu()
807 !fixed_queue_is_empty(p_ccb->xmit_hold_q)) && in l2c_fcr_proc_pdu()
808 (!p_ccb->fcrb.wait_ack) && (!l2c_fcr_is_flow_controlled(p_ccb))) { in l2c_fcr_proc_pdu()
809 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in l2c_fcr_proc_pdu()
823 void l2c_lcc_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_lcc_proc_pdu() argument
824 CHECK(p_ccb != NULL); in l2c_lcc_proc_pdu()
831 if (p_buf->len > p_ccb->local_conn_cfg.mps) { in l2c_lcc_proc_pdu()
837 if (p_ccb->is_first_seg) { in l2c_lcc_proc_pdu()
849 if (sdu_length > p_ccb->local_conn_cfg.mtu) { in l2c_lcc_proc_pdu()
872 p_ccb->ble_sdu = p_data; in l2c_lcc_proc_pdu()
874 p_ccb->ble_sdu_length = sdu_length; in l2c_lcc_proc_pdu()
879 p_data = p_ccb->ble_sdu; in l2c_lcc_proc_pdu()
880 if (p_buf->len > (p_ccb->ble_sdu_length - p_data->len)) { in l2c_lcc_proc_pdu()
883 (p_ccb->ble_sdu_length - p_data->len)); in l2c_lcc_proc_pdu()
888 p_ccb->is_first_seg = true; in l2c_lcc_proc_pdu()
889 osi_free(p_ccb->ble_sdu); in l2c_lcc_proc_pdu()
890 p_ccb->ble_sdu = NULL; in l2c_lcc_proc_pdu()
891 p_ccb->ble_sdu_length = 0; in l2c_lcc_proc_pdu()
892 l2cu_disconnect_chnl(p_ccb); in l2c_lcc_proc_pdu()
901 if (p_data->len == p_ccb->ble_sdu_length) { in l2c_lcc_proc_pdu()
902 l2c_csm_execute(p_ccb, L2CEVT_L2CAP_DATA, p_data); in l2c_lcc_proc_pdu()
903 p_ccb->is_first_seg = true; in l2c_lcc_proc_pdu()
904 p_ccb->ble_sdu = NULL; in l2c_lcc_proc_pdu()
905 p_ccb->ble_sdu_length = 0; in l2c_lcc_proc_pdu()
906 } else if (p_data->len < p_ccb->ble_sdu_length) { in l2c_lcc_proc_pdu()
907 p_ccb->is_first_seg = false; in l2c_lcc_proc_pdu()
923 void l2c_fcr_proc_tout(tL2C_CCB* p_ccb) { in l2c_fcr_proc_tout() argument
924 CHECK(p_ccb != NULL); in l2c_fcr_proc_tout()
928 p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit, in l2c_fcr_proc_tout()
929 p_ccb->fcrb.wait_ack, fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in l2c_fcr_proc_tout()
932 p_ccb->fcrb.retrans_touts++; in l2c_fcr_proc_tout()
935 if ((p_ccb->peer_cfg.fcr.max_transmit != 0) && in l2c_fcr_proc_tout()
936 (++p_ccb->fcrb.num_tries > p_ccb->peer_cfg.fcr.max_transmit)) { in l2c_fcr_proc_tout()
937 l2cu_disconnect_chnl(p_ccb); in l2c_fcr_proc_tout()
939 if (!p_ccb->fcrb.srej_sent && !p_ccb->fcrb.rej_sent) { in l2c_fcr_proc_tout()
940 if (p_ccb->fcrb.local_busy) in l2c_fcr_proc_tout()
941 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, L2CAP_FCR_P_BIT); in l2c_fcr_proc_tout()
943 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_P_BIT); in l2c_fcr_proc_tout()
957 void l2c_fcr_proc_ack_tout(tL2C_CCB* p_ccb) { in l2c_fcr_proc_ack_tout() argument
958 CHECK(p_ccb != NULL); in l2c_fcr_proc_ack_tout()
961 p_ccb->local_cid, p_ccb->chnl_state, p_ccb->fcrb.wait_ack, in l2c_fcr_proc_ack_tout()
962 p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent); in l2c_fcr_proc_ack_tout()
964 if ((p_ccb->chnl_state == CST_OPEN) && (!p_ccb->fcrb.wait_ack) && in l2c_fcr_proc_ack_tout()
965 (p_ccb->fcrb.last_ack_sent != p_ccb->fcrb.next_seq_expected)) { in l2c_fcr_proc_ack_tout()
967 p_ccb->fcrb.xmit_ack_touts++; in l2c_fcr_proc_ack_tout()
969 if (p_ccb->fcrb.local_busy) in l2c_fcr_proc_ack_tout()
970 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, 0); in l2c_fcr_proc_ack_tout()
972 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in l2c_fcr_proc_ack_tout()
985 static bool process_reqseq(tL2C_CCB* p_ccb, uint16_t ctrl_word) { in process_reqseq() argument
986 CHECK(p_ccb != NULL); in process_reqseq()
987 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_reqseq()
1000 l2c_fcr_start_timer(p_ccb); in process_reqseq()
1020 l2cu_disconnect_chnl(p_ccb); in process_reqseq()
1033 l2c_fcr_collect_ack_delay(p_ccb, num_bufs_acked); in process_reqseq()
1048 if (!p_ccb->fcrb.wait_ack) l2c_fcr_stop_timer(p_ccb); in process_reqseq()
1051 if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_TxComplete_Cb) && in process_reqseq()
1055 fixed_queue_is_empty(p_ccb->xmit_hold_q)) { in process_reqseq()
1059 (*p_ccb->p_rcb->api.pL2CA_TxComplete_Cb)(p_ccb->local_cid, in process_reqseq()
1066 l2c_fcr_start_timer(p_ccb); in process_reqseq()
1079 static void process_s_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, in process_s_frame() argument
1081 CHECK(p_ccb != NULL); in process_s_frame()
1084 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_s_frame()
1098 p_ccb->fcrb.s_frames_rcvd[s_frame_type]++; in process_s_frame()
1112 all_ok = retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS); in process_s_frame()
1117 all_ok = retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS); in process_s_frame()
1122 l2c_fcr_stop_timer(p_ccb); in process_s_frame()
1128 p_ccb, (uint8_t)((ctrl_word & L2CAP_FCR_REQ_SEQ_BITS) >> in process_s_frame()
1138 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, L2CAP_FCR_F_BIT); in process_s_frame()
1140 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, L2CAP_FCR_F_BIT); in process_s_frame()
1142 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_F_BIT); in process_s_frame()
1162 static void process_i_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word, in process_i_frame() argument
1164 CHECK(p_ccb != NULL); in process_i_frame()
1167 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in process_i_frame()
1173 if (!retransmit_i_frames(p_ccb, L2C_FCR_RETX_ALL_PKTS)) { in process_i_frame()
1180 p_ccb->fcrb.ertm_pkt_counts[1]++; in process_i_frame()
1181 p_ccb->fcrb.ertm_byte_counts[1] += p_buf->len; in process_i_frame()
1191 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, 0); in process_i_frame()
1201 if (num_lost >= p_ccb->our_cfg.fcr.tx_win_sz) { in process_i_frame()
1212 p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1226 p_ccb->our_cfg.fcr.tx_win_sz)) { in process_i_frame()
1229 if (p_ccb->ertm_info.fcr_rx_buf_size != L2CAP_FCR_RX_BUF_SIZE) { in process_i_frame()
1256 p_ccb->local_cid, next_srej, in process_i_frame()
1258 p_ccb->our_cfg.fcr.tx_win_sz); in process_i_frame()
1267 p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1275 p_ccb->local_cid, tx_seq, p_fcrb->next_seq_expected, in process_i_frame()
1282 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_REJ, 0); in process_i_frame()
1288 p_ccb->local_cid, tx_seq, in process_i_frame()
1294 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_SREJ, 0); in process_i_frame()
1296 alarm_cancel(p_ccb->fcrb.ack_timer); in process_i_frame()
1312 if (!do_sar_reassembly(p_ccb, p_buf, ctrl_word)) { in process_i_frame()
1314 p_ccb->local_cid); in process_i_frame()
1315 l2cu_disconnect_chnl(p_ccb); in process_i_frame()
1324 if ((num_to_ack < p_ccb->fcrb.max_held_acks) && (!p_fcrb->local_busy)) in process_i_frame()
1328 if ((num_to_ack != 0) && p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) { in process_i_frame()
1333 if (!alarm_is_scheduled(p_ccb->fcrb.ack_timer)) { in process_i_frame()
1334 alarm_set_on_mloop(p_ccb->fcrb.ack_timer, L2CAP_FCR_ACK_TIMEOUT_MS, in process_i_frame()
1335 l2c_fcrb_ack_timer_timeout, p_ccb); in process_i_frame()
1337 } else if ((fixed_queue_is_empty(p_ccb->xmit_hold_q) || in process_i_frame()
1338 l2c_fcr_is_flow_controlled(p_ccb)) && in process_i_frame()
1339 fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q)) { in process_i_frame()
1341 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, 0); in process_i_frame()
1343 l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, 0); in process_i_frame()
1357 static void process_stream_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in process_stream_frame() argument
1358 CHECK(p_ccb != NULL); in process_stream_frame()
1367 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { in process_stream_frame()
1376 p_ccb->local_cid); in process_stream_frame()
1395 p_ccb->local_cid, ctrl_word); in process_stream_frame()
1403 p_ccb->local_cid, p_buf->len, in process_stream_frame()
1413 if (tx_seq != p_ccb->fcrb.next_seq_expected) { in process_stream_frame()
1417 p_ccb->local_cid, p_ccb->fcrb.next_seq_expected, tx_seq, in process_stream_frame()
1418 p_ccb->fcrb.p_rx_sdu); in process_stream_frame()
1421 osi_free_and_reset((void**)&p_ccb->fcrb.p_rx_sdu); in process_stream_frame()
1424 p_ccb->fcrb.next_seq_expected = (tx_seq + 1) & L2CAP_FCR_SEQ_MODULO; in process_stream_frame()
1426 if (!do_sar_reassembly(p_ccb, p_buf, ctrl_word)) { in process_stream_frame()
1428 osi_free_and_reset((void**)&p_ccb->fcrb.p_rx_sdu); in process_stream_frame()
1441 static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf, in do_sar_reassembly() argument
1443 CHECK(p_ccb != NULL); in do_sar_reassembly()
1446 tL2C_FCRB* p_fcrb = &p_ccb->fcrb; in do_sar_reassembly()
1484 if (p_fcrb->rx_sdu_len > p_ccb->max_rx_mtu) { in do_sar_reassembly()
1530 if (p_ccb->local_cid < L2CAP_BASE_APPL_CID && in do_sar_reassembly()
1531 (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && in do_sar_reassembly()
1532 p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL)) { in do_sar_reassembly()
1533 if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in do_sar_reassembly()
1535 (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in do_sar_reassembly()
1536 .pL2CA_FixedData_Cb)(p_ccb->local_cid, in do_sar_reassembly()
1537 p_ccb->p_lcb->remote_bd_addr, p_buf); in do_sar_reassembly()
1540 l2c_csm_execute(p_ccb, L2CEVT_L2CAP_DATA, p_buf); in do_sar_reassembly()
1555 static bool retransmit_i_frames(tL2C_CCB* p_ccb, uint8_t tx_seq) { in retransmit_i_frames() argument
1556 CHECK(p_ccb != NULL); in retransmit_i_frames()
1563 if ((!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) && in retransmit_i_frames()
1564 (p_ccb->peer_cfg.fcr.max_transmit != 0) && in retransmit_i_frames()
1565 (p_ccb->fcrb.num_tries >= p_ccb->peer_cfg.fcr.max_transmit)) { in retransmit_i_frames()
1569 p_ccb->fcrb.last_rx_ack, p_ccb->local_cid, p_ccb->fcrb.num_tries, in retransmit_i_frames()
1570 p_ccb->peer_cfg.fcr.max_transmit, in retransmit_i_frames()
1571 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in retransmit_i_frames()
1573 l2cu_disconnect_chnl(p_ccb); in retransmit_i_frames()
1581 if (!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) { in retransmit_i_frames()
1582 list_ack = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q); in retransmit_i_frames()
1610 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)); in retransmit_i_frames()
1616 for (list_node_t* node_tmp = list_begin(p_ccb->p_lcb->link_xmit_data_q); in retransmit_i_frames()
1617 node_tmp != list_end(p_ccb->p_lcb->link_xmit_data_q);) { in retransmit_i_frames()
1622 if ((p_tmp->layer_specific == 0) && (p_tmp->event == p_ccb->local_cid)) { in retransmit_i_frames()
1623 list_remove(p_ccb->p_lcb->link_xmit_data_q, p_tmp); in retransmit_i_frames()
1629 while (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q)) in retransmit_i_frames()
1630 osi_free(fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q)); in retransmit_i_frames()
1644 fixed_queue_enqueue(p_ccb->fcrb.retrans_q, p_buf2); in retransmit_i_frames()
1651 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in retransmit_i_frames()
1653 if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)) { in retransmit_i_frames()
1654 p_ccb->fcrb.num_tries++; in retransmit_i_frames()
1655 l2c_fcr_start_timer(p_ccb); in retransmit_i_frames()
1670 BT_HDR* l2c_fcr_get_next_xmit_sdu_seg(tL2C_CCB* p_ccb, in l2c_fcr_get_next_xmit_sdu_seg() argument
1672 CHECK(p_ccb != NULL); in l2c_fcr_get_next_xmit_sdu_seg()
1680 uint16_t max_pdu = p_ccb->tx_mps /* Needed? - L2CAP_MAX_HEADER_FCS*/; in l2c_fcr_get_next_xmit_sdu_seg()
1684 p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q); in l2c_fcr_get_next_xmit_sdu_seg()
1688 prepare_I_frame(p_ccb, p_buf, true); in l2c_fcr_get_next_xmit_sdu_seg()
1690 p_buf->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1693 p_ccb->fcrb.pkts_retransmitted++; in l2c_fcr_get_next_xmit_sdu_seg()
1694 p_ccb->fcrb.ertm_pkt_counts[0]++; in l2c_fcr_get_next_xmit_sdu_seg()
1695 p_ccb->fcrb.ertm_byte_counts[0] += (p_buf->len - 8); in l2c_fcr_get_next_xmit_sdu_seg()
1707 p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->xmit_hold_q); in l2c_fcr_get_next_xmit_sdu_seg()
1724 p_buf->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1725 p_xmit->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1741 p_xmit = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->xmit_hold_q); in l2c_fcr_get_next_xmit_sdu_seg()
1745 p_xmit->event = p_ccb->local_cid; in l2c_fcr_get_next_xmit_sdu_seg()
1765 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_fcr_get_next_xmit_sdu_seg()
1784 prepare_I_frame(p_ccb, p_xmit, false); in l2c_fcr_get_next_xmit_sdu_seg()
1786 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in l2c_fcr_get_next_xmit_sdu_seg()
1793 p_ccb->local_cid, p_xmit->len); in l2c_fcr_get_next_xmit_sdu_seg()
1796 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) p_xmit->len -= L2CAP_FCS_LEN; in l2c_fcr_get_next_xmit_sdu_seg()
1799 fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_xmit); in l2c_fcr_get_next_xmit_sdu_seg()
1814 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) p_wack->len -= L2CAP_FCS_LEN; in l2c_fcr_get_next_xmit_sdu_seg()
1817 fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_wack); in l2c_fcr_get_next_xmit_sdu_seg()
1821 p_ccb->fcrb.ertm_pkt_counts[0]++; in l2c_fcr_get_next_xmit_sdu_seg()
1822 p_ccb->fcrb.ertm_byte_counts[0] += (p_xmit->len - 8); in l2c_fcr_get_next_xmit_sdu_seg()
1832 BT_HDR* l2c_lcc_get_next_xmit_sdu_seg(tL2C_CCB* p_ccb, in l2c_lcc_get_next_xmit_sdu_seg() argument
1834 uint16_t max_pdu = p_ccb->peer_conn_cfg.mps - 4 /* Length and CID */; in l2c_lcc_get_next_xmit_sdu_seg()
1836 BT_HDR* p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->xmit_hold_q); in l2c_lcc_get_next_xmit_sdu_seg()
1849 p_buf->event = p_ccb->local_cid; in l2c_lcc_get_next_xmit_sdu_seg()
1850 p_xmit->event = p_ccb->local_cid; in l2c_lcc_get_next_xmit_sdu_seg()
1868 p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->xmit_hold_q); in l2c_lcc_get_next_xmit_sdu_seg()
1881 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_lcc_get_next_xmit_sdu_seg()
1906 uint8_t l2c_fcr_chk_chan_modes(tL2C_CCB* p_ccb) { in l2c_fcr_chk_chan_modes() argument
1907 CHECK(p_ccb != NULL); in l2c_fcr_chk_chan_modes()
1910 if (!(p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_ENH_RETRANS)) in l2c_fcr_chk_chan_modes()
1911 p_ccb->ertm_info.allowed_modes &= ~L2CAP_FCR_CHAN_OPT_ERTM; in l2c_fcr_chk_chan_modes()
1913 if (!(p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_STREAM_MODE)) in l2c_fcr_chk_chan_modes()
1914 p_ccb->ertm_info.allowed_modes &= ~L2CAP_FCR_CHAN_OPT_STREAM; in l2c_fcr_chk_chan_modes()
1917 if (!p_ccb->ertm_info.allowed_modes) { in l2c_fcr_chk_chan_modes()
1922 return (p_ccb->ertm_info.allowed_modes); in l2c_fcr_chk_chan_modes()
1935 bool l2c_fcr_adj_our_req_options(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_adj_our_req_options() argument
1936 CHECK(p_ccb != NULL); in l2c_fcr_adj_our_req_options()
1941 if (p_fcr->mode != p_ccb->ertm_info.preferred_mode) { in l2c_fcr_adj_our_req_options()
1945 p_ccb->ertm_info.preferred_mode, p_fcr->mode); in l2c_fcr_adj_our_req_options()
1949 p_fcr->mode = p_ccb->ertm_info.preferred_mode; in l2c_fcr_adj_our_req_options()
1953 if (p_ccb->ertm_info.allowed_modes == L2CAP_FCR_CHAN_OPT_BASIC) { in l2c_fcr_adj_our_req_options()
1968 if (p_cfg->fcr_present && !(p_ccb->config_done & RECONFIG_FLAG)) { in l2c_fcr_adj_our_req_options()
1970 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_fcr_adj_our_req_options()
1972 l2cu_disconnect_chnl(p_ccb); in l2c_fcr_adj_our_req_options()
1977 else if (p_ccb->ertm_info.allowed_modes == L2CAP_FCR_CHAN_OPT_BASIC) { in l2c_fcr_adj_our_req_options()
1992 !(p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_STREAM)) { in l2c_fcr_adj_our_req_options()
2001 !(p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_ERTM)) { in l2c_fcr_adj_our_req_options()
2010 if ((p_cfg->mtu_present) && (p_cfg->mtu > p_ccb->max_rx_mtu)) { in l2c_fcr_adj_our_req_options()
2012 p_cfg->mtu, p_ccb->max_rx_mtu); in l2c_fcr_adj_our_req_options()
2021 else if (p_fcr->mps > p_ccb->max_rx_mtu) { in l2c_fcr_adj_our_req_options()
2023 p_ccb->max_rx_mtu); in l2c_fcr_adj_our_req_options()
2037 p_ccb->our_cfg.fcr = *p_fcr; in l2c_fcr_adj_our_req_options()
2041 p_ccb->our_cfg.fcr_present = false; in l2c_fcr_adj_our_req_options()
2056 void l2c_fcr_adj_monitor_retran_timeout(tL2C_CCB* p_ccb) { in l2c_fcr_adj_monitor_retran_timeout() argument
2057 CHECK(p_ccb != NULL); in l2c_fcr_adj_monitor_retran_timeout()
2060 if (p_ccb->out_cfg_fcr_present) { in l2c_fcr_adj_monitor_retran_timeout()
2066 if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) || in l2c_fcr_adj_monitor_retran_timeout()
2067 (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)) { in l2c_fcr_adj_monitor_retran_timeout()
2069 p_ccb->our_cfg.fcr.mon_tout = L2CAP_MIN_MONITOR_TOUT; in l2c_fcr_adj_monitor_retran_timeout()
2070 p_ccb->our_cfg.fcr.rtrans_tout = L2CAP_MIN_RETRANS_TOUT; in l2c_fcr_adj_monitor_retran_timeout()
2072 p_ccb->our_cfg.fcr.mon_tout = 0; in l2c_fcr_adj_monitor_retran_timeout()
2073 p_ccb->our_cfg.fcr.rtrans_tout = 0; in l2c_fcr_adj_monitor_retran_timeout()
2078 p_ccb->our_cfg.fcr.mon_tout, p_ccb->our_cfg.fcr.rtrans_tout); in l2c_fcr_adj_monitor_retran_timeout()
2092 void l2c_fcr_adj_our_rsp_options(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_adj_our_rsp_options() argument
2093 CHECK(p_ccb != NULL); in l2c_fcr_adj_our_rsp_options()
2097 l2c_fcr_adj_monitor_retran_timeout(p_ccb); in l2c_fcr_adj_our_rsp_options()
2099 p_cfg->fcr_present = p_ccb->out_cfg_fcr_present; in l2c_fcr_adj_our_rsp_options()
2106 if (p_ccb->peer_cfg.fcr.tx_win_sz > p_ccb->our_cfg.fcr.tx_win_sz) { in l2c_fcr_adj_our_rsp_options()
2108 __func__, p_ccb->peer_cfg.fcr.tx_win_sz, in l2c_fcr_adj_our_rsp_options()
2109 p_ccb->our_cfg.fcr.tx_win_sz); in l2c_fcr_adj_our_rsp_options()
2110 p_ccb->peer_cfg.fcr.tx_win_sz = p_ccb->our_cfg.fcr.tx_win_sz; in l2c_fcr_adj_our_rsp_options()
2113 p_cfg->fcr.mode = p_ccb->peer_cfg.fcr.mode; in l2c_fcr_adj_our_rsp_options()
2114 p_cfg->fcr.tx_win_sz = p_ccb->peer_cfg.fcr.tx_win_sz; in l2c_fcr_adj_our_rsp_options()
2115 p_cfg->fcr.max_transmit = p_ccb->peer_cfg.fcr.max_transmit; in l2c_fcr_adj_our_rsp_options()
2116 p_cfg->fcr.mps = p_ccb->peer_cfg.fcr.mps; in l2c_fcr_adj_our_rsp_options()
2117 p_cfg->fcr.rtrans_tout = p_ccb->our_cfg.fcr.rtrans_tout; in l2c_fcr_adj_our_rsp_options()
2118 p_cfg->fcr.mon_tout = p_ccb->our_cfg.fcr.mon_tout; in l2c_fcr_adj_our_rsp_options()
2134 bool l2c_fcr_renegotiate_chan(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { in l2c_fcr_renegotiate_chan() argument
2135 CHECK(p_ccb != NULL); in l2c_fcr_renegotiate_chan()
2138 uint8_t peer_mode = p_ccb->our_cfg.fcr.mode; in l2c_fcr_renegotiate_chan()
2143 if (!p_cfg->fcr_present || (p_ccb->config_done & RECONFIG_FLAG)) in l2c_fcr_renegotiate_chan()
2150 if (p_ccb->our_cfg.fcr.mode != peer_mode) { in l2c_fcr_renegotiate_chan()
2151 if ((--p_ccb->fcr_cfg_tries) == 0) { in l2c_fcr_renegotiate_chan()
2160 switch (p_ccb->our_cfg.fcr.mode) { in l2c_fcr_renegotiate_chan()
2165 (p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_ERTM)) { in l2c_fcr_renegotiate_chan()
2167 p_ccb->our_cfg.fcr.mode = L2CAP_FCR_ERTM_MODE; in l2c_fcr_renegotiate_chan()
2173 if (p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_BASIC) { in l2c_fcr_renegotiate_chan()
2176 p_ccb->our_cfg.fcr.mode = L2CAP_FCR_BASIC_MODE; in l2c_fcr_renegotiate_chan()
2186 p_ccb->our_cfg.fcr_present = true; in l2c_fcr_renegotiate_chan()
2188 if (p_ccb->our_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) { in l2c_fcr_renegotiate_chan()
2189 p_ccb->our_cfg.fcs_present = false; in l2c_fcr_renegotiate_chan()
2190 p_ccb->our_cfg.ext_flow_spec_present = false; in l2c_fcr_renegotiate_chan()
2199 l2cu_process_our_cfg_req(p_ccb, &p_ccb->our_cfg); in l2c_fcr_renegotiate_chan()
2200 l2cu_send_peer_config_req(p_ccb, &p_ccb->our_cfg); in l2c_fcr_renegotiate_chan()
2201 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_fcr_renegotiate_chan()
2202 l2c_ccb_timer_timeout, p_ccb); in l2c_fcr_renegotiate_chan()
2209 if (p_ccb->our_cfg.fcr.mode != peer_mode) { in l2c_fcr_renegotiate_chan()
2211 p_ccb->our_cfg.fcr.mode, peer_mode); in l2c_fcr_renegotiate_chan()
2212 l2cu_disconnect_chnl(p_ccb); in l2c_fcr_renegotiate_chan()
2229 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
2230 CHECK(p_ccb != NULL); in l2c_fcr_process_peer_cfg_req()
2236 p_ccb->p_lcb->w4_info_rsp = in l2c_fcr_process_peer_cfg_req()
2242 p_cfg->fcr_present, p_cfg->fcr.mode, p_ccb->our_cfg.fcr.mode, in l2c_fcr_process_peer_cfg_req()
2243 p_ccb->ertm_info.preferred_mode, p_ccb->ertm_info.allowed_modes); in l2c_fcr_process_peer_cfg_req()
2248 if (!(p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_BASIC)) in l2c_fcr_process_peer_cfg_req()
2253 else if (p_cfg->fcr.mode != p_ccb->ertm_info.preferred_mode) { in l2c_fcr_process_peer_cfg_req()
2261 (p_ccb->ertm_info.preferred_mode == L2CAP_FCR_ERTM_MODE)) { in l2c_fcr_process_peer_cfg_req()
2262 p_cfg->fcr.mode = p_ccb->our_cfg.fcr.mode; in l2c_fcr_process_peer_cfg_req()
2263 p_cfg->fcr.tx_win_sz = p_ccb->our_cfg.fcr.tx_win_sz; in l2c_fcr_process_peer_cfg_req()
2264 p_cfg->fcr.max_transmit = p_ccb->our_cfg.fcr.max_transmit; in l2c_fcr_process_peer_cfg_req()
2269 else if (p_ccb->ertm_info.preferred_mode == L2CAP_FCR_BASIC_MODE) { in l2c_fcr_process_peer_cfg_req()
2273 p_ccb->our_cfg.fcr.rtrans_tout = p_ccb->our_cfg.fcr.mon_tout = in l2c_fcr_process_peer_cfg_req()
2274 p_ccb->our_cfg.fcr.mps = 0; in l2c_fcr_process_peer_cfg_req()
2283 !(p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_ERTM)) { in l2c_fcr_process_peer_cfg_req()
2292 p_ccb->out_cfg_fcr_present = false; in l2c_fcr_process_peer_cfg_req()
2298 p_ccb->peer_cfg.fcs = p_cfg->fcs; in l2c_fcr_process_peer_cfg_req()
2299 p_ccb->peer_cfg_bits |= L2CAP_CH_CFG_MASK_FCS; in l2c_fcr_process_peer_cfg_req()
2301 p_ccb->bypass_fcs |= L2CAP_CFG_FCS_PEER; in l2c_fcr_process_peer_cfg_req()
2304 max_retrans_size = p_ccb->ertm_info.fcr_tx_buf_size - sizeof(BT_HDR) - in l2c_fcr_process_peer_cfg_req()
2309 if ((p_cfg->fcr.mps == 0) || (p_cfg->fcr.mps > p_ccb->peer_cfg.mtu)) { in l2c_fcr_process_peer_cfg_req()
2310 p_cfg->fcr.mps = p_ccb->peer_cfg.mtu; in l2c_fcr_process_peer_cfg_req()
2311 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
2320 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
2326 p_ccb->out_cfg_fcr_present = true; in l2c_fcr_process_peer_cfg_req()
2331 p_ccb->peer_cfg.fcr = p_cfg->fcr; in l2c_fcr_process_peer_cfg_req()
2333 if (p_cfg->fcr_present) p_ccb->peer_cfg_bits |= L2CAP_CH_CFG_MASK_FCR; in l2c_fcr_process_peer_cfg_req()
2336 if (p_ccb->peer_cfg_already_rejected) in l2c_fcr_process_peer_cfg_req()
2339 p_ccb->peer_cfg_already_rejected = true; in l2c_fcr_process_peer_cfg_req()
2358 static void l2c_fcr_collect_ack_delay(tL2C_CCB* p_ccb, uint8_t num_bufs_acked) { in l2c_fcr_collect_ack_delay() argument
2366 index = p_ccb->fcrb.ack_delay_avg_index; in l2c_fcr_collect_ack_delay()
2369 p_ccb->fcrb.ack_q_count_avg[index] += in l2c_fcr_collect_ack_delay()
2370 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q); in l2c_fcr_collect_ack_delay()
2372 if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) > in l2c_fcr_collect_ack_delay()
2373 p_ccb->fcrb.ack_q_count_max[index]) in l2c_fcr_collect_ack_delay()
2374 p_ccb->fcrb.ack_q_count_max[index] = in l2c_fcr_collect_ack_delay()
2375 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q); in l2c_fcr_collect_ack_delay()
2377 if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) < in l2c_fcr_collect_ack_delay()
2378 p_ccb->fcrb.ack_q_count_min[index]) in l2c_fcr_collect_ack_delay()
2379 p_ccb->fcrb.ack_q_count_min[index] = in l2c_fcr_collect_ack_delay()
2380 fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q); in l2c_fcr_collect_ack_delay()
2384 if (!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) in l2c_fcr_collect_ack_delay()
2385 list = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q); in l2c_fcr_collect_ack_delay()
2392 p_ccb->fcrb.throughput[index] += p_buf->len - 8; in l2c_fcr_collect_ack_delay()
2397 if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { in l2c_fcr_collect_ack_delay()
2406 p_ccb->fcrb.ack_delay_avg[index] += delay; in l2c_fcr_collect_ack_delay()
2407 if (delay > p_ccb->fcrb.ack_delay_max[index]) in l2c_fcr_collect_ack_delay()
2408 p_ccb->fcrb.ack_delay_max[index] = delay; in l2c_fcr_collect_ack_delay()
2409 if (delay < p_ccb->fcrb.ack_delay_min[index]) in l2c_fcr_collect_ack_delay()
2410 p_ccb->fcrb.ack_delay_min[index] = delay; in l2c_fcr_collect_ack_delay()
2415 p_ccb->fcrb.ack_delay_avg_count++; in l2c_fcr_collect_ack_delay()
2418 if (p_ccb->fcrb.ack_delay_avg_count > L2CAP_ERTM_STATS_AVG_NUM_SAMPLES) { in l2c_fcr_collect_ack_delay()
2419 p_ccb->fcrb.ack_delay_avg_count = 0; in l2c_fcr_collect_ack_delay()
2421 p_ccb->fcrb.ack_q_count_avg[index] /= L2CAP_ERTM_STATS_AVG_NUM_SAMPLES; in l2c_fcr_collect_ack_delay()
2422 p_ccb->fcrb.ack_delay_avg[index] /= L2CAP_ERTM_STATS_AVG_NUM_SAMPLES; in l2c_fcr_collect_ack_delay()
2426 if (timestamp - p_ccb->fcrb.throughput_start > 0) in l2c_fcr_collect_ack_delay()
2427 p_ccb->fcrb.throughput[index] /= in l2c_fcr_collect_ack_delay()
2428 (timestamp - p_ccb->fcrb.throughput_start); in l2c_fcr_collect_ack_delay()
2430 p_ccb->fcrb.throughput_start = timestamp; in l2c_fcr_collect_ack_delay()
2436 index, p_ccb->fcrb.throughput[index], p_ccb->fcrb.ack_delay_avg[index], in l2c_fcr_collect_ack_delay()
2437 p_ccb->fcrb.ack_delay_min[index], p_ccb->fcrb.ack_delay_max[index], in l2c_fcr_collect_ack_delay()
2438 p_ccb->fcrb.ack_q_count_avg[index], p_ccb->fcrb.ack_q_count_min[index], in l2c_fcr_collect_ack_delay()
2439 p_ccb->fcrb.ack_q_count_max[index]); in l2c_fcr_collect_ack_delay()
2445 p_ccb->fcrb.ack_delay_avg_index = index; in l2c_fcr_collect_ack_delay()
2447 p_ccb->fcrb.ack_q_count_max[index] = 0; in l2c_fcr_collect_ack_delay()
2448 p_ccb->fcrb.ack_q_count_min[index] = 0xFFFFFFFF; in l2c_fcr_collect_ack_delay()
2449 p_ccb->fcrb.ack_q_count_avg[index] = 0; in l2c_fcr_collect_ack_delay()
2451 p_ccb->fcrb.ack_delay_max[index] = 0; in l2c_fcr_collect_ack_delay()
2452 p_ccb->fcrb.ack_delay_min[index] = 0xFFFFFFFF; in l2c_fcr_collect_ack_delay()
2453 p_ccb->fcrb.ack_delay_avg[index] = 0; in l2c_fcr_collect_ack_delay()
2455 p_ccb->fcrb.throughput[index] = 0; in l2c_fcr_collect_ack_delay()