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()
61 if (hc->tx_seqbufc == 0) in ccid2_hc_tx_alloc_seq()
62 hc->tx_seqh = hc->tx_seqt = seqp; in ccid2_hc_tx_alloc_seq()
65 hc->tx_seqh->ccid2s_next = seqp; in ccid2_hc_tx_alloc_seq()
66 seqp->ccid2s_prev = hc->tx_seqh; in ccid2_hc_tx_alloc_seq()
68 hc->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; in ccid2_hc_tx_alloc_seq()
69 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hc->tx_seqt; in ccid2_hc_tx_alloc_seq()
73 hc->tx_seqbuf[hc->tx_seqbufc] = seqp; in ccid2_hc_tx_alloc_seq()
74 hc->tx_seqbufc++; in ccid2_hc_tx_alloc_seq()
106 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_check_l_ack_ratio() local
118 if (dccp_feat_nn_get(sk, DCCPF_ACK_RATIO) > hc->tx_cwnd) in ccid2_check_l_ack_ratio()
119 ccid2_change_l_ack_ratio(sk, hc->tx_cwnd/2 ? : 1U); in ccid2_check_l_ack_ratio()
132 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_rto_expire() local
133 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_rto_expire()
137 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + HZ / 5); in ccid2_hc_tx_rto_expire()
144 hc->tx_rto <<= 1; in ccid2_hc_tx_rto_expire()
145 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_hc_tx_rto_expire()
146 hc->tx_rto = DCCP_RTO_MAX; in ccid2_hc_tx_rto_expire()
149 hc->tx_ssthresh = hc->tx_cwnd / 2; in ccid2_hc_tx_rto_expire()
150 if (hc->tx_ssthresh < 2) in ccid2_hc_tx_rto_expire()
151 hc->tx_ssthresh = 2; in ccid2_hc_tx_rto_expire()
152 hc->tx_cwnd = 1; in ccid2_hc_tx_rto_expire()
153 hc->tx_pipe = 0; in ccid2_hc_tx_rto_expire()
156 hc->tx_seqt = hc->tx_seqh; in ccid2_hc_tx_rto_expire()
157 hc->tx_packets_acked = 0; in ccid2_hc_tx_rto_expire()
160 hc->tx_rpseq = 0; in ccid2_hc_tx_rto_expire()
161 hc->tx_rpdupack = -1; in ccid2_hc_tx_rto_expire()
168 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_rto_expire()
188 static void ccid2_update_used_window(struct ccid2_hc_tx_sock *hc, u32 new_wnd) in ccid2_update_used_window() argument
190 hc->tx_expected_wnd = (3 * hc->tx_expected_wnd + new_wnd) / 4; in ccid2_update_used_window()
196 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_application_limited() local
199 win_used = max(hc->tx_cwnd_used, init_win); in ccid2_cwnd_application_limited()
201 if (win_used < hc->tx_cwnd) { in ccid2_cwnd_application_limited()
202 hc->tx_ssthresh = max(hc->tx_ssthresh, in ccid2_cwnd_application_limited()
203 (hc->tx_cwnd >> 1) + (hc->tx_cwnd >> 2)); in ccid2_cwnd_application_limited()
204 hc->tx_cwnd = (hc->tx_cwnd + win_used) >> 1; in ccid2_cwnd_application_limited()
206 hc->tx_cwnd_used = 0; in ccid2_cwnd_application_limited()
207 hc->tx_cwnd_stamp = now; in ccid2_cwnd_application_limited()
215 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_cwnd_restart() local
216 u32 cwnd = hc->tx_cwnd, restart_cwnd, in ccid2_cwnd_restart()
219 hc->tx_ssthresh = max(hc->tx_ssthresh, (cwnd >> 1) + (cwnd >> 2)); in ccid2_cwnd_restart()
223 cwnd >>= (now - hc->tx_lsndtime) / hc->tx_rto; in ccid2_cwnd_restart()
224 hc->tx_cwnd = max(cwnd, restart_cwnd); in ccid2_cwnd_restart()
226 hc->tx_cwnd_stamp = now; in ccid2_cwnd_restart()
227 hc->tx_cwnd_used = 0; in ccid2_cwnd_restart()
235 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_sent() local
240 if (ccid2_do_cwv && !hc->tx_pipe && in ccid2_hc_tx_packet_sent()
241 (s32)(now - hc->tx_lsndtime) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
244 hc->tx_lsndtime = now; in ccid2_hc_tx_packet_sent()
245 hc->tx_pipe += 1; in ccid2_hc_tx_packet_sent()
248 if (ccid2_cwnd_network_limited(hc)) { in ccid2_hc_tx_packet_sent()
249 ccid2_update_used_window(hc, hc->tx_cwnd); in ccid2_hc_tx_packet_sent()
250 hc->tx_cwnd_used = 0; in ccid2_hc_tx_packet_sent()
251 hc->tx_cwnd_stamp = now; in ccid2_hc_tx_packet_sent()
253 if (hc->tx_pipe > hc->tx_cwnd_used) in ccid2_hc_tx_packet_sent()
254 hc->tx_cwnd_used = hc->tx_pipe; in ccid2_hc_tx_packet_sent()
256 ccid2_update_used_window(hc, hc->tx_cwnd_used); in ccid2_hc_tx_packet_sent()
258 if (ccid2_do_cwv && (s32)(now - hc->tx_cwnd_stamp) >= hc->tx_rto) in ccid2_hc_tx_packet_sent()
262 hc->tx_seqh->ccid2s_seq = dp->dccps_gss; in ccid2_hc_tx_packet_sent()
263 hc->tx_seqh->ccid2s_acked = 0; in ccid2_hc_tx_packet_sent()
264 hc->tx_seqh->ccid2s_sent = now; in ccid2_hc_tx_packet_sent()
266 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
268 if (next == hc->tx_seqt) { in ccid2_hc_tx_packet_sent()
269 if (ccid2_hc_tx_alloc_seq(hc)) { in ccid2_hc_tx_packet_sent()
274 next = hc->tx_seqh->ccid2s_next; in ccid2_hc_tx_packet_sent()
275 BUG_ON(next == hc->tx_seqt); in ccid2_hc_tx_packet_sent()
277 hc->tx_seqh = next; in ccid2_hc_tx_packet_sent()
279 ccid2_pr_debug("cwnd=%d pipe=%d\n", hc->tx_cwnd, hc->tx_pipe); in ccid2_hc_tx_packet_sent()
302 hc->tx_arsent++; in ccid2_hc_tx_packet_sent()
304 if (hc->tx_ackloss) { in ccid2_hc_tx_packet_sent()
305 if (hc->tx_arsent >= hc->tx_cwnd) { in ccid2_hc_tx_packet_sent()
306 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
307 hc->tx_ackloss = 0; in ccid2_hc_tx_packet_sent()
317 denom = hc->tx_cwnd * hc->tx_cwnd / denom; in ccid2_hc_tx_packet_sent()
319 if (hc->tx_arsent >= denom) { in ccid2_hc_tx_packet_sent()
321 hc->tx_arsent = 0; in ccid2_hc_tx_packet_sent()
325 hc->tx_arsent = 0; /* or maybe set it to cwnd*/ in ccid2_hc_tx_packet_sent()
330 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_sent()
334 struct ccid2_seq *seqp = hc->tx_seqt; in ccid2_hc_tx_packet_sent()
336 while (seqp != hc->tx_seqh) { in ccid2_hc_tx_packet_sent()
358 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_rtt_estimator() local
361 if (hc->tx_srtt == 0) { in ccid2_rtt_estimator()
363 hc->tx_srtt = m << 3; in ccid2_rtt_estimator()
364 hc->tx_mdev = m << 1; in ccid2_rtt_estimator()
366 hc->tx_mdev_max = max(hc->tx_mdev, tcp_rto_min(sk)); in ccid2_rtt_estimator()
367 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
369 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
372 m -= (hc->tx_srtt >> 3); in ccid2_rtt_estimator()
373 hc->tx_srtt += m; in ccid2_rtt_estimator()
378 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
387 m -= (hc->tx_mdev >> 2); in ccid2_rtt_estimator()
389 hc->tx_mdev += m; in ccid2_rtt_estimator()
391 if (hc->tx_mdev > hc->tx_mdev_max) { in ccid2_rtt_estimator()
392 hc->tx_mdev_max = hc->tx_mdev; in ccid2_rtt_estimator()
393 if (hc->tx_mdev_max > hc->tx_rttvar) in ccid2_rtt_estimator()
394 hc->tx_rttvar = hc->tx_mdev_max; in ccid2_rtt_estimator()
404 if (after48(dccp_sk(sk)->dccps_gar, hc->tx_rtt_seq)) { in ccid2_rtt_estimator()
405 if (hc->tx_mdev_max < hc->tx_rttvar) in ccid2_rtt_estimator()
406 hc->tx_rttvar -= (hc->tx_rttvar - in ccid2_rtt_estimator()
407 hc->tx_mdev_max) >> 2; in ccid2_rtt_estimator()
408 hc->tx_rtt_seq = dccp_sk(sk)->dccps_gss; in ccid2_rtt_estimator()
409 hc->tx_mdev_max = tcp_rto_min(sk); in ccid2_rtt_estimator()
420 hc->tx_rto = (hc->tx_srtt >> 3) + hc->tx_rttvar; in ccid2_rtt_estimator()
422 if (hc->tx_rto > DCCP_RTO_MAX) in ccid2_rtt_estimator()
423 hc->tx_rto = DCCP_RTO_MAX; in ccid2_rtt_estimator()
429 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_new_ack() local
431 int r_seq_used = hc->tx_cwnd / dp->dccps_l_ack_ratio; in ccid2_new_ack()
433 if (hc->tx_cwnd < dp->dccps_l_seq_win && in ccid2_new_ack()
435 if (hc->tx_cwnd < hc->tx_ssthresh) { in ccid2_new_ack()
436 if (*maxincr > 0 && ++hc->tx_packets_acked >= 2) { in ccid2_new_ack()
437 hc->tx_cwnd += 1; in ccid2_new_ack()
439 hc->tx_packets_acked = 0; in ccid2_new_ack()
441 } else if (++hc->tx_packets_acked >= hc->tx_cwnd) { in ccid2_new_ack()
442 hc->tx_cwnd += 1; in ccid2_new_ack()
443 hc->tx_packets_acked = 0; in ccid2_new_ack()
456 if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR >= dp->dccps_l_seq_win) in ccid2_new_ack()
458 else if (hc->tx_cwnd * CCID2_WIN_CHANGE_FACTOR < dp->dccps_l_seq_win/2) in ccid2_new_ack()
474 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_congestion_event() local
476 if ((s32)(seqp->ccid2s_sent - hc->tx_last_cong) < 0) { in ccid2_congestion_event()
481 hc->tx_last_cong = ccid2_time_stamp; in ccid2_congestion_event()
483 hc->tx_cwnd = hc->tx_cwnd / 2 ? : 1U; in ccid2_congestion_event()
484 hc->tx_ssthresh = max(hc->tx_cwnd, 2U); in ccid2_congestion_event()
492 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_parse_options() local
497 return dccp_ackvec_parsed_add(&hc->tx_av_chunks, optval, optlen, in ccid2_hc_tx_parse_options()
506 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_packet_recv() local
507 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); in ccid2_hc_tx_packet_recv()
522 if (hc->tx_rpdupack == -1) { in ccid2_hc_tx_packet_recv()
523 hc->tx_rpdupack = 0; in ccid2_hc_tx_packet_recv()
524 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
527 if (dccp_delta_seqno(hc->tx_rpseq, seqno) == 1) in ccid2_hc_tx_packet_recv()
528 hc->tx_rpseq = seqno; in ccid2_hc_tx_packet_recv()
530 else if (after48(seqno, hc->tx_rpseq)) { in ccid2_hc_tx_packet_recv()
531 hc->tx_rpdupack++; in ccid2_hc_tx_packet_recv()
534 if (hc->tx_rpdupack >= NUMDUPACK) { in ccid2_hc_tx_packet_recv()
535 hc->tx_rpdupack = -1; /* XXX lame */ in ccid2_hc_tx_packet_recv()
536 hc->tx_rpseq = 0; in ccid2_hc_tx_packet_recv()
556 if (hc->tx_seqh == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
560 if (after48(ackno, hc->tx_high_ack)) in ccid2_hc_tx_packet_recv()
561 hc->tx_high_ack = ackno; in ccid2_hc_tx_packet_recv()
563 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
566 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
567 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
577 if (hc->tx_cwnd < hc->tx_ssthresh) in ccid2_hc_tx_packet_recv()
581 list_for_each_entry(avp, &hc->tx_av_chunks, node) { in ccid2_hc_tx_packet_recv()
596 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
624 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
626 if (seqp == hc->tx_seqt) { in ccid2_hc_tx_packet_recv()
644 seqp = hc->tx_seqt; in ccid2_hc_tx_packet_recv()
645 while (before48(seqp->ccid2s_seq, hc->tx_high_ack)) { in ccid2_hc_tx_packet_recv()
647 if (seqp == hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
648 seqp = hc->tx_seqh->ccid2s_prev; in ccid2_hc_tx_packet_recv()
659 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
680 hc->tx_pipe--; in ccid2_hc_tx_packet_recv()
682 if (seqp == hc->tx_seqt) in ccid2_hc_tx_packet_recv()
687 hc->tx_seqt = last_acked; in ccid2_hc_tx_packet_recv()
691 while (hc->tx_seqt != hc->tx_seqh) { in ccid2_hc_tx_packet_recv()
692 if (!hc->tx_seqt->ccid2s_acked) in ccid2_hc_tx_packet_recv()
695 hc->tx_seqt = hc->tx_seqt->ccid2s_next; in ccid2_hc_tx_packet_recv()
699 if (hc->tx_pipe == 0) in ccid2_hc_tx_packet_recv()
700 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_packet_recv()
702 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto); in ccid2_hc_tx_packet_recv()
705 if (sender_was_blocked && !ccid2_cwnd_network_limited(hc)) in ccid2_hc_tx_packet_recv()
707 dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); in ccid2_hc_tx_packet_recv()
712 struct ccid2_hc_tx_sock *hc = ccid_priv(ccid); in ccid2_hc_tx_init() local
717 hc->tx_ssthresh = ~0U; in ccid2_hc_tx_init()
720 hc->tx_cwnd = rfc3390_bytes_to_packets(dp->dccps_mss_cache); in ccid2_hc_tx_init()
721 hc->tx_expected_wnd = hc->tx_cwnd; in ccid2_hc_tx_init()
724 max_ratio = DIV_ROUND_UP(hc->tx_cwnd, 2); in ccid2_hc_tx_init()
729 if (ccid2_hc_tx_alloc_seq(hc)) in ccid2_hc_tx_init()
732 hc->tx_rto = DCCP_TIMEOUT_INIT; in ccid2_hc_tx_init()
733 hc->tx_rpdupack = -1; in ccid2_hc_tx_init()
734 hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_time_stamp; in ccid2_hc_tx_init()
735 hc->tx_cwnd_used = 0; in ccid2_hc_tx_init()
736 setup_timer(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire, in ccid2_hc_tx_init()
738 INIT_LIST_HEAD(&hc->tx_av_chunks); in ccid2_hc_tx_init()
744 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); in ccid2_hc_tx_exit() local
747 sk_stop_timer(sk, &hc->tx_rtotimer); in ccid2_hc_tx_exit()
749 for (i = 0; i < hc->tx_seqbufc; i++) in ccid2_hc_tx_exit()
750 kfree(hc->tx_seqbuf[i]); in ccid2_hc_tx_exit()
751 hc->tx_seqbufc = 0; in ccid2_hc_tx_exit()
756 struct ccid2_hc_rx_sock *hc = ccid2_hc_rx_sk(sk); in ccid2_hc_rx_packet_recv() local
761 if (++hc->rx_num_data_pkts >= dccp_sk(sk)->dccps_r_ack_ratio) { in ccid2_hc_rx_packet_recv()
763 hc->rx_num_data_pkts = 0; in ccid2_hc_rx_packet_recv()