Lines Matching refs:hc
38 static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc) in ccid2_hc_tx_alloc_seq() argument
44 if (hc->tx_seqbufc >= (sizeof(hc->tx_seqbuf) / in ccid2_hc_tx_alloc_seq()
62 if (hc->tx_seqbufc == 0) in ccid2_hc_tx_alloc_seq()
63 hc->tx_seqh = hc->tx_seqt = seqp; in ccid2_hc_tx_alloc_seq()
66 hc->tx_seqh->ccid2s_next = seqp; in ccid2_hc_tx_alloc_seq()
67 seqp->ccid2s_prev = hc->tx_seqh; in ccid2_hc_tx_alloc_seq()
69 hc->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; in ccid2_hc_tx_alloc_seq()
70 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hc->tx_seqt; in ccid2_hc_tx_alloc_seq()
74 hc->tx_seqbuf[hc->tx_seqbufc] = seqp; in ccid2_hc_tx_alloc_seq()
75 hc->tx_seqbufc++; in ccid2_hc_tx_alloc_seq()
107 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_check_l_ack_ratio() local
119 if (dccp_feat_nn_get(sk, DCCPF_ACK_RATIO) > hc->tx_cwnd) in ccid2_check_l_ack_ratio()
120 ccid2_change_l_ack_ratio(sk, hc->tx_cwnd/2 ? : 1U); in ccid2_check_l_ack_ratio()
142 struct ccid2_hc_tx_sock *hc = from_timer(hc, t, tx_rtotimer); in ccid2_hc_tx_rto_expire() local
143 struct sock *sk = hc->sk; in ccid2_hc_tx_rto_expire()
144 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_rto_expire()
148 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + HZ / 5); in ccid2_hc_tx_rto_expire()
158 hc->tx_rto <<= 1; in ccid2_hc_tx_rto_expire()
159 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_hc_tx_rto_expire()
160 hc->tx_rto = DCCP_RTO_MAX; in ccid2_hc_tx_rto_expire()
163 hc->tx_ssthresh = hc->tx_cwnd / 2; in ccid2_hc_tx_rto_expire()
164 if (hc->tx_ssthresh < 2) in ccid2_hc_tx_rto_expire()
165 hc->tx_ssthresh = 2; in ccid2_hc_tx_rto_expire()
166 hc->tx_cwnd = 1; in ccid2_hc_tx_rto_expire()
167 hc->tx_pipe = 0; in ccid2_hc_tx_rto_expire()
170 hc->tx_seqt = hc->tx_seqh; in ccid2_hc_tx_rto_expire()
171 hc->tx_packets_acked = 0; in ccid2_hc_tx_rto_expire()
174 hc->tx_rpseq = 0; in ccid2_hc_tx_rto_expire()
175 hc->tx_rpdupack = -1; in ccid2_hc_tx_rto_expire()
182 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_rto_expire()
202 static void ccid2_update_used_window(struct ccid2_hc_tx_sock *hc, u32 new_wnd) in ccid2_update_used_window() argument
204 hc->tx_expected_wnd = (3 * hc->tx_expected_wnd + new_wnd) / 4; in ccid2_update_used_window()
210 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_application_limited() local
213 win_used = max(hc->tx_cwnd_used, init_win); in ccid2_cwnd_application_limited()
215 if (win_used < hc->tx_cwnd) { in ccid2_cwnd_application_limited()
216 hc->tx_ssthresh = max(hc->tx_ssthresh, in ccid2_cwnd_application_limited()
217 (hc->tx_cwnd >> 1) + (hc->tx_cwnd >> 2)); in ccid2_cwnd_application_limited()
218 hc->tx_cwnd = (hc->tx_cwnd + win_used) >> 1; in ccid2_cwnd_application_limited()
220 hc->tx_cwnd_used = 0; in ccid2_cwnd_application_limited()
221 hc->tx_cwnd_stamp = now; in ccid2_cwnd_application_limited()
229 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_restart() local
230 u32 cwnd = hc->tx_cwnd, restart_cwnd, in ccid2_cwnd_restart()
232 s32 delta = now - hc->tx_lsndtime; in ccid2_cwnd_restart()
234 hc->tx_ssthresh = max(hc->tx_ssthresh, (cwnd >> 1) + (cwnd >> 2)); in ccid2_cwnd_restart()
239 while ((delta -= hc->tx_rto) >= 0 && cwnd > restart_cwnd) in ccid2_cwnd_restart()
241 hc->tx_cwnd = max(cwnd, restart_cwnd); in ccid2_cwnd_restart()
242 hc->tx_cwnd_stamp = now; in ccid2_cwnd_restart()
243 hc->tx_cwnd_used = 0; in ccid2_cwnd_restart()
251 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_sent() local
256 if (ccid2_do_cwv && !hc->tx_pipe && in ccid2_hc_tx_packet_sent()
257 (s32)(now - hc->tx_lsndtime) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
260 hc->tx_lsndtime = now; in ccid2_hc_tx_packet_sent()
261 hc->tx_pipe += 1; in ccid2_hc_tx_packet_sent()
264 if (ccid2_cwnd_network_limited(hc)) { in ccid2_hc_tx_packet_sent()
265 ccid2_update_used_window(hc, hc->tx_cwnd); in ccid2_hc_tx_packet_sent()
266 hc->tx_cwnd_used = 0; in ccid2_hc_tx_packet_sent()
267 hc->tx_cwnd_stamp = now; in ccid2_hc_tx_packet_sent()
269 if (hc->tx_pipe > hc->tx_cwnd_used) in ccid2_hc_tx_packet_sent()
270 hc->tx_cwnd_used = hc->tx_pipe; in ccid2_hc_tx_packet_sent()
272 ccid2_update_used_window(hc, hc->tx_cwnd_used); in ccid2_hc_tx_packet_sent()
274 if (ccid2_do_cwv && (s32)(now - hc->tx_cwnd_stamp) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
278 hc->tx_seqh->ccid2s_seq = dp->dccps_gss; in ccid2_hc_tx_packet_sent()
279 hc->tx_seqh->ccid2s_acked = 0; in ccid2_hc_tx_packet_sent()
280 hc->tx_seqh->ccid2s_sent = now; in ccid2_hc_tx_packet_sent()
282 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
284 if (next == hc->tx_seqt) { in ccid2_hc_tx_packet_sent()
285 if (ccid2_hc_tx_alloc_seq(hc)) { in ccid2_hc_tx_packet_sent()
290 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
291 BUG_ON(next == hc->tx_seqt); in ccid2_hc_tx_packet_sent()
293 hc->tx_seqh = next; in ccid2_hc_tx_packet_sent()
295 ccid2_pr_debug("cwnd=%d pipe=%d\n", hc->tx_cwnd, hc->tx_pipe); in ccid2_hc_tx_packet_sent()
318 hc->tx_arsent++; in ccid2_hc_tx_packet_sent()
320 if (hc->tx_ackloss) { in ccid2_hc_tx_packet_sent()
321 if (hc->tx_arsent >= hc->tx_cwnd) { in ccid2_hc_tx_packet_sent()
322 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
323 hc->tx_ackloss = 0; in ccid2_hc_tx_packet_sent()
333 denom = hc->tx_cwnd * hc->tx_cwnd / denom; in ccid2_hc_tx_packet_sent()
335 if (hc->tx_arsent >= denom) { in ccid2_hc_tx_packet_sent()
337 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
341 hc->tx_arsent = 0; /* or maybe set it to cwnd*/ in ccid2_hc_tx_packet_sent()
346 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_sent()
350 struct ccid2_seq *seqp = hc->tx_seqt; in ccid2_hc_tx_packet_sent()
352 while (seqp != hc->tx_seqh) { in ccid2_hc_tx_packet_sent()
374 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_rtt_estimator() local
377 if (hc->tx_srtt == 0) { in ccid2_rtt_estimator()
379 hc->tx_srtt = m << 3; in ccid2_rtt_estimator()
380 hc->tx_mdev = m << 1; in ccid2_rtt_estimator()
382 hc->tx_mdev_max = max(hc->tx_mdev, tcp_rto_min(sk)); in ccid2_rtt_estimator()
383 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
385 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
388 m -= (hc->tx_srtt >> 3); in ccid2_rtt_estimator()
389 hc->tx_srtt += m; in ccid2_rtt_estimator()
394 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
403 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
405 hc->tx_mdev += m; in ccid2_rtt_estimator()
407 if (hc->tx_mdev > hc->tx_mdev_max) { in ccid2_rtt_estimator()
408 hc->tx_mdev_max = hc->tx_mdev; in ccid2_rtt_estimator()
409 if (hc->tx_mdev_max > hc->tx_rttvar) in ccid2_rtt_estimator()
410 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
420 if (after48(dccp_sk(sk)->dccps_gar, hc->tx_rtt_seq)) { in ccid2_rtt_estimator()
421 if (hc->tx_mdev_max < hc->tx_rttvar) in ccid2_rtt_estimator()
422 hc->tx_rttvar -= (hc->tx_rttvar - in ccid2_rtt_estimator()
423 hc->tx_mdev_max) >> 2; in ccid2_rtt_estimator()
424 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
425 hc->tx_mdev_max = tcp_rto_min(sk); in ccid2_rtt_estimator()
436 hc->tx_rto = (hc->tx_srtt >> 3) + hc->tx_rttvar; in ccid2_rtt_estimator()
438 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_rtt_estimator()
439 hc->tx_rto = DCCP_RTO_MAX; in ccid2_rtt_estimator()
445 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_new_ack() local
447 int r_seq_used = hc->tx_cwnd / dp->dccps_l_ack_ratio; in ccid2_new_ack()
449 if (hc->tx_cwnd < dp->dccps_l_seq_win && in ccid2_new_ack()
451 if (hc->tx_cwnd < hc->tx_ssthresh) { in ccid2_new_ack()
452 if (*maxincr > 0 && ++hc->tx_packets_acked >= 2) { in ccid2_new_ack()
453 hc->tx_cwnd += 1; in ccid2_new_ack()
455 hc->tx_packets_acked = 0; in ccid2_new_ack()
457 } else if (++hc->tx_packets_acked >= hc->tx_cwnd) { in ccid2_new_ack()
458 hc->tx_cwnd += 1; in ccid2_new_ack()
459 hc->tx_packets_acked = 0; in ccid2_new_ack()
472 if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR >= dp->dccps_l_seq_win) in ccid2_new_ack()
474 else if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR < dp->dccps_l_seq_win/2) in ccid2_new_ack()
490 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_congestion_event() local
492 if ((s32)(seqp->ccid2s_sent - hc->tx_last_cong) < 0) { in ccid2_congestion_event()
497 hc->tx_last_cong = ccid2_jiffies32; in ccid2_congestion_event()
499 hc->tx_cwnd = hc->tx_cwnd / 2 ? : 1U; in ccid2_congestion_event()
500 hc->tx_ssthresh = max(hc->tx_cwnd, 2U); in ccid2_congestion_event()
508 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_parse_options() local
513 return dccp_ackvec_parsed_add(&hc->tx_av_chunks, optval, optlen, in ccid2_hc_tx_parse_options()
522 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_recv() local
523 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_packet_recv()
538 if (hc->tx_rpdupack == -1) { in ccid2_hc_tx_packet_recv()
539 hc->tx_rpdupack = 0; in ccid2_hc_tx_packet_recv()
540 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
543 if (dccp_delta_seqno(hc->tx_rpseq, seqno) == 1) in ccid2_hc_tx_packet_recv()
544 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
546 else if (after48(seqno, hc->tx_rpseq)) { in ccid2_hc_tx_packet_recv()
547 hc->tx_rpdupack++; in ccid2_hc_tx_packet_recv()
550 if (hc->tx_rpdupack >= NUMDUPACK) { in ccid2_hc_tx_packet_recv()
551 hc->tx_rpdupack = -1; /* XXX lame */ in ccid2_hc_tx_packet_recv()
552 hc->tx_rpseq = 0; in ccid2_hc_tx_packet_recv()
572 if (hc->tx_seqh == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
576 if (after48(ackno, hc->tx_high_ack)) in ccid2_hc_tx_packet_recv()
577 hc->tx_high_ack = ackno; in ccid2_hc_tx_packet_recv()
579 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
582 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
583 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
593 if (hc->tx_cwnd < hc->tx_ssthresh) in ccid2_hc_tx_packet_recv()
597 list_for_each_entry(avp, &hc->tx_av_chunks, node) { in ccid2_hc_tx_packet_recv()
612 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
640 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
642 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
660 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
661 while (before48(seqp->ccid2s_seq, hc->tx_high_ack)) { in ccid2_hc_tx_packet_recv()
663 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
664 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
675 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
696 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
698 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
703 hc->tx_seqt = last_acked; in ccid2_hc_tx_packet_recv()
707 while (hc->tx_seqt != hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
708 if (!hc->tx_seqt->ccid2s_acked) in ccid2_hc_tx_packet_recv()
711 hc->tx_seqt = hc->tx_seqt->ccid2s_next; in ccid2_hc_tx_packet_recv()
715 if (hc->tx_pipe == 0) in ccid2_hc_tx_packet_recv()
716 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_packet_recv()
718 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_recv()
721 if (sender_was_blocked && !ccid2_cwnd_network_limited(hc)) in ccid2_hc_tx_packet_recv()
723 dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); in ccid2_hc_tx_packet_recv()
728 struct ccid2_hc_tx_sock *hc = ccid_priv(ccid); in ccid2_hc_tx_init() local
733 hc->tx_ssthresh = ~0U; in ccid2_hc_tx_init()
736 hc->tx_cwnd = rfc3390_bytes_to_packets(dp->dccps_mss_cache); in ccid2_hc_tx_init()
737 hc->tx_expected_wnd = hc->tx_cwnd; in ccid2_hc_tx_init()
740 max_ratio = DIV_ROUND_UP(hc->tx_cwnd, 2); in ccid2_hc_tx_init()
745 if (ccid2_hc_tx_alloc_seq(hc)) in ccid2_hc_tx_init()
748 hc->tx_rto = DCCP_TIMEOUT_INIT; in ccid2_hc_tx_init()
749 hc->tx_rpdupack = -1; in ccid2_hc_tx_init()
750 hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_jiffies32; in ccid2_hc_tx_init()
751 hc->tx_cwnd_used = 0; in ccid2_hc_tx_init()
752 hc->sk = sk; in ccid2_hc_tx_init()
753 timer_setup(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire, 0); in ccid2_hc_tx_init()
754 INIT_LIST_HEAD(&hc->tx_av_chunks); in ccid2_hc_tx_init()
760 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_exit() local
763 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_exit()
765 for (i = 0; i < hc->tx_seqbufc; i++) in ccid2_hc_tx_exit()
766 kfree(hc->tx_seqbuf[i]); in ccid2_hc_tx_exit()
767 hc->tx_seqbufc = 0; in ccid2_hc_tx_exit()
768 dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); in ccid2_hc_tx_exit()
773 struct ccid2_hc_rx_sock *hc = ccid2_hc_rx_sk(sk); in ccid2_hc_rx_packet_recv() local
778 if (++hc->rx_num_data_pkts >= dccp_sk(sk)->dccps_r_ack_ratio) { in ccid2_hc_rx_packet_recv()
780 hc->rx_num_data_pkts = 0; in ccid2_hc_rx_packet_recv()