Lines Matching refs:hc
25 static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc) in ccid2_hc_tx_alloc_seq() argument
31 if (hc->tx_seqbufc >= (sizeof(hc->tx_seqbuf) / in ccid2_hc_tx_alloc_seq()
49 if (hc->tx_seqbufc == 0) in ccid2_hc_tx_alloc_seq()
50 hc->tx_seqh = hc->tx_seqt = seqp; in ccid2_hc_tx_alloc_seq()
53 hc->tx_seqh->ccid2s_next = seqp; in ccid2_hc_tx_alloc_seq()
54 seqp->ccid2s_prev = hc->tx_seqh; in ccid2_hc_tx_alloc_seq()
56 hc->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; in ccid2_hc_tx_alloc_seq()
57 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hc->tx_seqt; in ccid2_hc_tx_alloc_seq()
61 hc->tx_seqbuf[hc->tx_seqbufc] = seqp; in ccid2_hc_tx_alloc_seq()
62 hc->tx_seqbufc++; in ccid2_hc_tx_alloc_seq()
94 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_check_l_ack_ratio() local
106 if (dccp_feat_nn_get(sk, DCCPF_ACK_RATIO) > hc->tx_cwnd) in ccid2_check_l_ack_ratio()
107 ccid2_change_l_ack_ratio(sk, hc->tx_cwnd/2 ? : 1U); in ccid2_check_l_ack_ratio()
129 struct ccid2_hc_tx_sock *hc = from_timer(hc, t, tx_rtotimer); in ccid2_hc_tx_rto_expire() local
130 struct sock *sk = hc->sk; in ccid2_hc_tx_rto_expire()
131 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_rto_expire()
135 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + HZ / 5); in ccid2_hc_tx_rto_expire()
145 hc->tx_rto <<= 1; in ccid2_hc_tx_rto_expire()
146 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_hc_tx_rto_expire()
147 hc->tx_rto = DCCP_RTO_MAX; in ccid2_hc_tx_rto_expire()
150 hc->tx_ssthresh = hc->tx_cwnd / 2; in ccid2_hc_tx_rto_expire()
151 if (hc->tx_ssthresh < 2) in ccid2_hc_tx_rto_expire()
152 hc->tx_ssthresh = 2; in ccid2_hc_tx_rto_expire()
153 hc->tx_cwnd = 1; in ccid2_hc_tx_rto_expire()
154 hc->tx_pipe = 0; in ccid2_hc_tx_rto_expire()
157 hc->tx_seqt = hc->tx_seqh; in ccid2_hc_tx_rto_expire()
158 hc->tx_packets_acked = 0; in ccid2_hc_tx_rto_expire()
161 hc->tx_rpseq = 0; in ccid2_hc_tx_rto_expire()
162 hc->tx_rpdupack = -1; in ccid2_hc_tx_rto_expire()
169 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_rto_expire()
189 static void ccid2_update_used_window(struct ccid2_hc_tx_sock *hc, u32 new_wnd) in ccid2_update_used_window() argument
191 hc->tx_expected_wnd = (3 * hc->tx_expected_wnd + new_wnd) / 4; in ccid2_update_used_window()
197 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_application_limited() local
200 win_used = max(hc->tx_cwnd_used, init_win); in ccid2_cwnd_application_limited()
202 if (win_used < hc->tx_cwnd) { in ccid2_cwnd_application_limited()
203 hc->tx_ssthresh = max(hc->tx_ssthresh, in ccid2_cwnd_application_limited()
204 (hc->tx_cwnd >> 1) + (hc->tx_cwnd >> 2)); in ccid2_cwnd_application_limited()
205 hc->tx_cwnd = (hc->tx_cwnd + win_used) >> 1; in ccid2_cwnd_application_limited()
207 hc->tx_cwnd_used = 0; in ccid2_cwnd_application_limited()
208 hc->tx_cwnd_stamp = now; in ccid2_cwnd_application_limited()
216 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_restart() local
217 u32 cwnd = hc->tx_cwnd, restart_cwnd, in ccid2_cwnd_restart()
219 s32 delta = now - hc->tx_lsndtime; in ccid2_cwnd_restart()
221 hc->tx_ssthresh = max(hc->tx_ssthresh, (cwnd >> 1) + (cwnd >> 2)); in ccid2_cwnd_restart()
226 while ((delta -= hc->tx_rto) >= 0 && cwnd > restart_cwnd) in ccid2_cwnd_restart()
228 hc->tx_cwnd = max(cwnd, restart_cwnd); in ccid2_cwnd_restart()
229 hc->tx_cwnd_stamp = now; in ccid2_cwnd_restart()
230 hc->tx_cwnd_used = 0; in ccid2_cwnd_restart()
238 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_sent() local
243 if (ccid2_do_cwv && !hc->tx_pipe && in ccid2_hc_tx_packet_sent()
244 (s32)(now - hc->tx_lsndtime) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
247 hc->tx_lsndtime = now; in ccid2_hc_tx_packet_sent()
248 hc->tx_pipe += 1; in ccid2_hc_tx_packet_sent()
251 if (ccid2_cwnd_network_limited(hc)) { in ccid2_hc_tx_packet_sent()
252 ccid2_update_used_window(hc, hc->tx_cwnd); in ccid2_hc_tx_packet_sent()
253 hc->tx_cwnd_used = 0; in ccid2_hc_tx_packet_sent()
254 hc->tx_cwnd_stamp = now; in ccid2_hc_tx_packet_sent()
256 if (hc->tx_pipe > hc->tx_cwnd_used) in ccid2_hc_tx_packet_sent()
257 hc->tx_cwnd_used = hc->tx_pipe; in ccid2_hc_tx_packet_sent()
259 ccid2_update_used_window(hc, hc->tx_cwnd_used); in ccid2_hc_tx_packet_sent()
261 if (ccid2_do_cwv && (s32)(now - hc->tx_cwnd_stamp) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
265 hc->tx_seqh->ccid2s_seq = dp->dccps_gss; in ccid2_hc_tx_packet_sent()
266 hc->tx_seqh->ccid2s_acked = 0; in ccid2_hc_tx_packet_sent()
267 hc->tx_seqh->ccid2s_sent = now; in ccid2_hc_tx_packet_sent()
269 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
271 if (next == hc->tx_seqt) { in ccid2_hc_tx_packet_sent()
272 if (ccid2_hc_tx_alloc_seq(hc)) { in ccid2_hc_tx_packet_sent()
277 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
278 BUG_ON(next == hc->tx_seqt); in ccid2_hc_tx_packet_sent()
280 hc->tx_seqh = next; in ccid2_hc_tx_packet_sent()
282 ccid2_pr_debug("cwnd=%d pipe=%d\n", hc->tx_cwnd, hc->tx_pipe); in ccid2_hc_tx_packet_sent()
305 hc->tx_arsent++; in ccid2_hc_tx_packet_sent()
307 if (hc->tx_ackloss) { in ccid2_hc_tx_packet_sent()
308 if (hc->tx_arsent >= hc->tx_cwnd) { in ccid2_hc_tx_packet_sent()
309 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
310 hc->tx_ackloss = 0; in ccid2_hc_tx_packet_sent()
320 denom = hc->tx_cwnd * hc->tx_cwnd / denom; in ccid2_hc_tx_packet_sent()
322 if (hc->tx_arsent >= denom) { in ccid2_hc_tx_packet_sent()
324 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
328 hc->tx_arsent = 0; /* or maybe set it to cwnd*/ in ccid2_hc_tx_packet_sent()
333 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_sent()
337 struct ccid2_seq *seqp = hc->tx_seqt; in ccid2_hc_tx_packet_sent()
339 while (seqp != hc->tx_seqh) { in ccid2_hc_tx_packet_sent()
361 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_rtt_estimator() local
364 if (hc->tx_srtt == 0) { in ccid2_rtt_estimator()
366 hc->tx_srtt = m << 3; in ccid2_rtt_estimator()
367 hc->tx_mdev = m << 1; in ccid2_rtt_estimator()
369 hc->tx_mdev_max = max(hc->tx_mdev, tcp_rto_min(sk)); in ccid2_rtt_estimator()
370 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
372 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
375 m -= (hc->tx_srtt >> 3); in ccid2_rtt_estimator()
376 hc->tx_srtt += m; in ccid2_rtt_estimator()
381 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
390 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
392 hc->tx_mdev += m; in ccid2_rtt_estimator()
394 if (hc->tx_mdev > hc->tx_mdev_max) { in ccid2_rtt_estimator()
395 hc->tx_mdev_max = hc->tx_mdev; in ccid2_rtt_estimator()
396 if (hc->tx_mdev_max > hc->tx_rttvar) in ccid2_rtt_estimator()
397 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
407 if (after48(dccp_sk(sk)->dccps_gar, hc->tx_rtt_seq)) { in ccid2_rtt_estimator()
408 if (hc->tx_mdev_max < hc->tx_rttvar) in ccid2_rtt_estimator()
409 hc->tx_rttvar -= (hc->tx_rttvar - in ccid2_rtt_estimator()
410 hc->tx_mdev_max) >> 2; in ccid2_rtt_estimator()
411 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
412 hc->tx_mdev_max = tcp_rto_min(sk); in ccid2_rtt_estimator()
423 hc->tx_rto = (hc->tx_srtt >> 3) + hc->tx_rttvar; in ccid2_rtt_estimator()
425 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_rtt_estimator()
426 hc->tx_rto = DCCP_RTO_MAX; in ccid2_rtt_estimator()
432 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_new_ack() local
434 int r_seq_used = hc->tx_cwnd / dp->dccps_l_ack_ratio; in ccid2_new_ack()
436 if (hc->tx_cwnd < dp->dccps_l_seq_win && in ccid2_new_ack()
438 if (hc->tx_cwnd < hc->tx_ssthresh) { in ccid2_new_ack()
439 if (*maxincr > 0 && ++hc->tx_packets_acked >= 2) { in ccid2_new_ack()
440 hc->tx_cwnd += 1; in ccid2_new_ack()
442 hc->tx_packets_acked = 0; in ccid2_new_ack()
444 } else if (++hc->tx_packets_acked >= hc->tx_cwnd) { in ccid2_new_ack()
445 hc->tx_cwnd += 1; in ccid2_new_ack()
446 hc->tx_packets_acked = 0; in ccid2_new_ack()
459 if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR >= dp->dccps_l_seq_win) in ccid2_new_ack()
461 else if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR < dp->dccps_l_seq_win/2) in ccid2_new_ack()
477 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_congestion_event() local
479 if ((s32)(seqp->ccid2s_sent - hc->tx_last_cong) < 0) { in ccid2_congestion_event()
484 hc->tx_last_cong = ccid2_jiffies32; in ccid2_congestion_event()
486 hc->tx_cwnd = hc->tx_cwnd / 2 ? : 1U; in ccid2_congestion_event()
487 hc->tx_ssthresh = max(hc->tx_cwnd, 2U); in ccid2_congestion_event()
495 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_parse_options() local
500 return dccp_ackvec_parsed_add(&hc->tx_av_chunks, optval, optlen, in ccid2_hc_tx_parse_options()
509 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_recv() local
510 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_packet_recv()
525 if (hc->tx_rpdupack == -1) { in ccid2_hc_tx_packet_recv()
526 hc->tx_rpdupack = 0; in ccid2_hc_tx_packet_recv()
527 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
530 if (dccp_delta_seqno(hc->tx_rpseq, seqno) == 1) in ccid2_hc_tx_packet_recv()
531 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
533 else if (after48(seqno, hc->tx_rpseq)) { in ccid2_hc_tx_packet_recv()
534 hc->tx_rpdupack++; in ccid2_hc_tx_packet_recv()
537 if (hc->tx_rpdupack >= NUMDUPACK) { in ccid2_hc_tx_packet_recv()
538 hc->tx_rpdupack = -1; /* XXX lame */ in ccid2_hc_tx_packet_recv()
539 hc->tx_rpseq = 0; in ccid2_hc_tx_packet_recv()
559 if (hc->tx_seqh == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
563 if (after48(ackno, hc->tx_high_ack)) in ccid2_hc_tx_packet_recv()
564 hc->tx_high_ack = ackno; in ccid2_hc_tx_packet_recv()
566 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
569 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
570 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
580 if (hc->tx_cwnd < hc->tx_ssthresh) in ccid2_hc_tx_packet_recv()
584 list_for_each_entry(avp, &hc->tx_av_chunks, node) { in ccid2_hc_tx_packet_recv()
599 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
627 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
629 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
647 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
648 while (before48(seqp->ccid2s_seq, hc->tx_high_ack)) { in ccid2_hc_tx_packet_recv()
650 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
651 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
662 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
683 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
685 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
690 hc->tx_seqt = last_acked; in ccid2_hc_tx_packet_recv()
694 while (hc->tx_seqt != hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
695 if (!hc->tx_seqt->ccid2s_acked) in ccid2_hc_tx_packet_recv()
698 hc->tx_seqt = hc->tx_seqt->ccid2s_next; in ccid2_hc_tx_packet_recv()
702 if (hc->tx_pipe == 0) in ccid2_hc_tx_packet_recv()
703 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_packet_recv()
705 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_recv()
708 if (sender_was_blocked && !ccid2_cwnd_network_limited(hc)) in ccid2_hc_tx_packet_recv()
710 dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); in ccid2_hc_tx_packet_recv()
715 struct ccid2_hc_tx_sock *hc = ccid_priv(ccid); in ccid2_hc_tx_init() local
720 hc->tx_ssthresh = ~0U; in ccid2_hc_tx_init()
723 hc->tx_cwnd = rfc3390_bytes_to_packets(dp->dccps_mss_cache); in ccid2_hc_tx_init()
724 hc->tx_expected_wnd = hc->tx_cwnd; in ccid2_hc_tx_init()
727 max_ratio = DIV_ROUND_UP(hc->tx_cwnd, 2); in ccid2_hc_tx_init()
732 if (ccid2_hc_tx_alloc_seq(hc)) in ccid2_hc_tx_init()
735 hc->tx_rto = DCCP_TIMEOUT_INIT; in ccid2_hc_tx_init()
736 hc->tx_rpdupack = -1; in ccid2_hc_tx_init()
737 hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_jiffies32; in ccid2_hc_tx_init()
738 hc->tx_cwnd_used = 0; in ccid2_hc_tx_init()
739 hc->sk = sk; in ccid2_hc_tx_init()
740 timer_setup(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire, 0); in ccid2_hc_tx_init()
741 INIT_LIST_HEAD(&hc->tx_av_chunks); in ccid2_hc_tx_init()
747 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_exit() local
750 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_exit()
752 for (i = 0; i < hc->tx_seqbufc; i++) in ccid2_hc_tx_exit()
753 kfree(hc->tx_seqbuf[i]); in ccid2_hc_tx_exit()
754 hc->tx_seqbufc = 0; in ccid2_hc_tx_exit()
755 dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); in ccid2_hc_tx_exit()
760 struct ccid2_hc_rx_sock *hc = ccid2_hc_rx_sk(sk); in ccid2_hc_rx_packet_recv() local
765 if (++hc->rx_num_data_pkts >= dccp_sk(sk)->dccps_r_ack_ratio) { in ccid2_hc_rx_packet_recv()
767 hc->rx_num_data_pkts = 0; in ccid2_hc_rx_packet_recv()