Lines Matching refs:hc
53 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_set_state() local
54 enum ccid3_hc_tx_states oldstate = hc->tx_state; in ccid3_hc_tx_set_state()
60 hc->tx_state = state; in ccid3_hc_tx_set_state()
74 const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in rfc3390_initial_rate() local
75 const __u32 w_init = clamp_t(__u32, 4380U, 2 * hc->tx_s, 4 * hc->tx_s); in rfc3390_initial_rate()
77 return scaled_div(w_init << 6, hc->tx_rtt); in rfc3390_initial_rate()
84 static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hc) in ccid3_update_send_interval() argument
86 hc->tx_t_ipi = scaled_div32(((u64)hc->tx_s) << 6, hc->tx_x); in ccid3_update_send_interval()
88 DCCP_BUG_ON(hc->tx_t_ipi == 0); in ccid3_update_send_interval()
89 ccid3_pr_debug("t_ipi=%u, s=%u, X=%u\n", hc->tx_t_ipi, in ccid3_update_send_interval()
90 hc->tx_s, (unsigned int)(hc->tx_x >> 6)); in ccid3_update_send_interval()
93 static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hc, ktime_t now) in ccid3_hc_tx_idle_rtt() argument
95 u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count); in ccid3_hc_tx_idle_rtt()
97 return delta / hc->tx_rtt; in ccid3_hc_tx_idle_rtt()
113 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_update_x() local
114 __u64 min_rate = 2 * hc->tx_x_recv; in ccid3_hc_tx_update_x()
115 const __u64 old_x = hc->tx_x; in ccid3_hc_tx_update_x()
124 if (ccid3_hc_tx_idle_rtt(hc, now) >= 2) { in ccid3_hc_tx_update_x()
126 min_rate = max(min_rate, 2 * hc->tx_x_recv); in ccid3_hc_tx_update_x()
129 if (hc->tx_p > 0) { in ccid3_hc_tx_update_x()
131 hc->tx_x = min(((__u64)hc->tx_x_calc) << 6, min_rate); in ccid3_hc_tx_update_x()
132 hc->tx_x = max(hc->tx_x, (((__u64)hc->tx_s) << 6) / TFRC_T_MBI); in ccid3_hc_tx_update_x()
134 } else if (ktime_us_delta(now, hc->tx_t_ld) - (s64)hc->tx_rtt >= 0) { in ccid3_hc_tx_update_x()
136 hc->tx_x = min(2 * hc->tx_x, min_rate); in ccid3_hc_tx_update_x()
137 hc->tx_x = max(hc->tx_x, in ccid3_hc_tx_update_x()
138 scaled_div(((__u64)hc->tx_s) << 6, hc->tx_rtt)); in ccid3_hc_tx_update_x()
139 hc->tx_t_ld = now; in ccid3_hc_tx_update_x()
142 if (hc->tx_x != old_x) { in ccid3_hc_tx_update_x()
145 (unsigned int)(hc->tx_x >> 6), hc->tx_x_calc, in ccid3_hc_tx_update_x()
146 (unsigned int)(hc->tx_x_recv >> 6)); in ccid3_hc_tx_update_x()
148 ccid3_update_send_interval(hc); in ccid3_hc_tx_update_x()
158 static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hc, int len) in ccid3_hc_tx_update_s() argument
160 const u16 old_s = hc->tx_s; in ccid3_hc_tx_update_s()
162 hc->tx_s = tfrc_ewma(hc->tx_s, len, 9); in ccid3_hc_tx_update_s()
164 if (hc->tx_s != old_s) in ccid3_hc_tx_update_s()
165 ccid3_update_send_interval(hc); in ccid3_hc_tx_update_s()
172 static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hc, in ccid3_hc_tx_update_win_count() argument
175 u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count), in ccid3_hc_tx_update_win_count()
176 quarter_rtts = (4 * delta) / hc->tx_rtt; in ccid3_hc_tx_update_win_count()
179 hc->tx_t_last_win_count = now; in ccid3_hc_tx_update_win_count()
180 hc->tx_last_win_count += min(quarter_rtts, 5U); in ccid3_hc_tx_update_win_count()
181 hc->tx_last_win_count &= 0xF; /* mod 16 */ in ccid3_hc_tx_update_win_count()
187 struct ccid3_hc_tx_sock *hc = from_timer(hc, t, tx_no_feedback_timer); in ccid3_hc_tx_no_feedback_timer() local
188 struct sock *sk = hc->sk; in ccid3_hc_tx_no_feedback_timer()
199 ccid3_tx_state_name(hc->tx_state)); in ccid3_hc_tx_no_feedback_timer()
206 if (hc->tx_state == TFRC_SSTATE_FBACK) in ccid3_hc_tx_no_feedback_timer()
213 if (hc->tx_t_rto == 0 || hc->tx_p == 0) { in ccid3_hc_tx_no_feedback_timer()
216 hc->tx_x = max(hc->tx_x / 2, in ccid3_hc_tx_no_feedback_timer()
217 (((__u64)hc->tx_s) << 6) / TFRC_T_MBI); in ccid3_hc_tx_no_feedback_timer()
218 ccid3_update_send_interval(hc); in ccid3_hc_tx_no_feedback_timer()
230 if (hc->tx_x_calc > (hc->tx_x_recv >> 5)) in ccid3_hc_tx_no_feedback_timer()
231 hc->tx_x_recv = in ccid3_hc_tx_no_feedback_timer()
232 max(hc->tx_x_recv / 2, in ccid3_hc_tx_no_feedback_timer()
233 (((__u64)hc->tx_s) << 6) / (2*TFRC_T_MBI)); in ccid3_hc_tx_no_feedback_timer()
235 hc->tx_x_recv = hc->tx_x_calc; in ccid3_hc_tx_no_feedback_timer()
236 hc->tx_x_recv <<= 4; in ccid3_hc_tx_no_feedback_timer()
241 (unsigned long long)hc->tx_x); in ccid3_hc_tx_no_feedback_timer()
247 if (unlikely(hc->tx_t_rto == 0)) /* no feedback received yet */ in ccid3_hc_tx_no_feedback_timer()
250 t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi); in ccid3_hc_tx_no_feedback_timer()
253 sk_reset_timer(sk, &hc->tx_no_feedback_timer, in ccid3_hc_tx_no_feedback_timer()
270 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_send_packet() local
282 if (hc->tx_state == TFRC_SSTATE_NO_SENT) { in ccid3_hc_tx_send_packet()
283 sk_reset_timer(sk, &hc->tx_no_feedback_timer, (jiffies + in ccid3_hc_tx_send_packet()
285 hc->tx_last_win_count = 0; in ccid3_hc_tx_send_packet()
286 hc->tx_t_last_win_count = now; in ccid3_hc_tx_send_packet()
289 hc->tx_t_nom = now; in ccid3_hc_tx_send_packet()
291 hc->tx_s = skb->len; in ccid3_hc_tx_send_packet()
300 hc->tx_rtt = dp->dccps_syn_rtt; in ccid3_hc_tx_send_packet()
301 hc->tx_x = rfc3390_initial_rate(sk); in ccid3_hc_tx_send_packet()
302 hc->tx_t_ld = now; in ccid3_hc_tx_send_packet()
310 hc->tx_rtt = DCCP_FALLBACK_RTT; in ccid3_hc_tx_send_packet()
311 hc->tx_x = hc->tx_s; in ccid3_hc_tx_send_packet()
312 hc->tx_x <<= 6; in ccid3_hc_tx_send_packet()
314 ccid3_update_send_interval(hc); in ccid3_hc_tx_send_packet()
319 delay = ktime_us_delta(hc->tx_t_nom, now); in ccid3_hc_tx_send_packet()
332 ccid3_hc_tx_update_win_count(hc, now); in ccid3_hc_tx_send_packet()
337 DCCP_SKB_CB(skb)->dccpd_ccval = hc->tx_last_win_count; in ccid3_hc_tx_send_packet()
340 hc->tx_t_nom = ktime_add_us(hc->tx_t_nom, hc->tx_t_ipi); in ccid3_hc_tx_send_packet()
346 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_packet_sent() local
348 ccid3_hc_tx_update_s(hc, len); in ccid3_hc_tx_packet_sent()
350 if (tfrc_tx_hist_add(&hc->tx_hist, dccp_sk(sk)->dccps_gss)) in ccid3_hc_tx_packet_sent()
356 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_packet_recv() local
374 acked = tfrc_tx_hist_find_entry(hc->tx_hist, dccp_hdr_ack_seq(skb)); in ccid3_hc_tx_packet_recv()
383 hc->tx_rtt = tfrc_ewma(hc->tx_rtt, r_sample, 9); in ccid3_hc_tx_packet_recv()
388 if (hc->tx_state == TFRC_SSTATE_NO_FBACK) { in ccid3_hc_tx_packet_recv()
391 if (hc->tx_t_rto == 0) { in ccid3_hc_tx_packet_recv()
395 hc->tx_x = rfc3390_initial_rate(sk); in ccid3_hc_tx_packet_recv()
396 hc->tx_t_ld = now; in ccid3_hc_tx_packet_recv()
398 ccid3_update_send_interval(hc); in ccid3_hc_tx_packet_recv()
401 } else if (hc->tx_p == 0) { in ccid3_hc_tx_packet_recv()
410 if (hc->tx_p > 0) in ccid3_hc_tx_packet_recv()
411 hc->tx_x_calc = tfrc_calc_x(hc->tx_s, hc->tx_rtt, hc->tx_p); in ccid3_hc_tx_packet_recv()
417 dccp_role(sk), sk, hc->tx_rtt, r_sample, in ccid3_hc_tx_packet_recv()
418 hc->tx_s, hc->tx_p, hc->tx_x_calc, in ccid3_hc_tx_packet_recv()
419 (unsigned int)(hc->tx_x_recv >> 6), in ccid3_hc_tx_packet_recv()
420 (unsigned int)(hc->tx_x >> 6)); in ccid3_hc_tx_packet_recv()
423 sk_stop_timer(sk, &hc->tx_no_feedback_timer); in ccid3_hc_tx_packet_recv()
436 hc->tx_t_rto = max_t(u32, 4 * hc->tx_rtt, in ccid3_hc_tx_packet_recv()
442 t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi); in ccid3_hc_tx_packet_recv()
448 sk_reset_timer(sk, &hc->tx_no_feedback_timer, in ccid3_hc_tx_packet_recv()
455 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_parse_options() local
473 hc->tx_x_recv = opt_val; in ccid3_hc_tx_parse_options()
474 hc->tx_x_recv <<= 6; in ccid3_hc_tx_parse_options()
480 hc->tx_p = tfrc_invert_loss_event_rate(opt_val); in ccid3_hc_tx_parse_options()
491 struct ccid3_hc_tx_sock *hc = ccid_priv(ccid); in ccid3_hc_tx_init() local
493 hc->tx_state = TFRC_SSTATE_NO_SENT; in ccid3_hc_tx_init()
494 hc->tx_hist = NULL; in ccid3_hc_tx_init()
495 hc->sk = sk; in ccid3_hc_tx_init()
496 timer_setup(&hc->tx_no_feedback_timer, in ccid3_hc_tx_init()
503 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_exit() local
505 sk_stop_timer(sk, &hc->tx_no_feedback_timer); in ccid3_hc_tx_exit()
506 tfrc_tx_hist_purge(&hc->tx_hist); in ccid3_hc_tx_exit()
518 const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); in ccid3_hc_tx_getsockopt() local
527 tfrc.tfrctx_x = hc->tx_x; in ccid3_hc_tx_getsockopt()
528 tfrc.tfrctx_x_recv = hc->tx_x_recv; in ccid3_hc_tx_getsockopt()
529 tfrc.tfrctx_x_calc = hc->tx_x_calc; in ccid3_hc_tx_getsockopt()
530 tfrc.tfrctx_rtt = hc->tx_rtt; in ccid3_hc_tx_getsockopt()
531 tfrc.tfrctx_p = hc->tx_p; in ccid3_hc_tx_getsockopt()
532 tfrc.tfrctx_rto = hc->tx_t_rto; in ccid3_hc_tx_getsockopt()
533 tfrc.tfrctx_ipi = hc->tx_t_ipi; in ccid3_hc_tx_getsockopt()
574 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_set_state() local
575 enum ccid3_hc_rx_states oldstate = hc->rx_state; in ccid3_hc_rx_set_state()
581 hc->rx_state = state; in ccid3_hc_rx_set_state()
588 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_send_feedback() local
595 hc->rx_x_recv = 0; in ccid3_hc_rx_send_feedback()
596 hc->rx_pinv = ~0U; /* see RFC 4342, 8.5 */ in ccid3_hc_rx_send_feedback()
609 if (hc->rx_x_recv > 0) in ccid3_hc_rx_send_feedback()
613 delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback); in ccid3_hc_rx_send_feedback()
616 hc->rx_x_recv = scaled_div32(hc->rx_bytes_recv, delta); in ccid3_hc_rx_send_feedback()
623 hc->rx_x_recv, hc->rx_pinv); in ccid3_hc_rx_send_feedback()
625 hc->rx_tstamp_last_feedback = now; in ccid3_hc_rx_send_feedback()
626 hc->rx_last_counter = dccp_hdr(skb)->dccph_ccval; in ccid3_hc_rx_send_feedback()
627 hc->rx_bytes_recv = 0; in ccid3_hc_rx_send_feedback()
635 const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_insert_options() local
644 x_recv = htonl(hc->rx_x_recv); in ccid3_hc_rx_insert_options()
645 pinv = htonl(hc->rx_pinv); in ccid3_hc_rx_insert_options()
668 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_first_li() local
673 if (hc->rx_rtt == 0) { in ccid3_first_li()
675 hc->rx_rtt = DCCP_FALLBACK_RTT; in ccid3_first_li()
678 delta = ktime_us_delta(ktime_get(), hc->rx_tstamp_last_feedback); in ccid3_first_li()
681 x_recv = scaled_div32(hc->rx_bytes_recv, delta); in ccid3_first_li()
684 if (hc->rx_x_recv == 0) { in ccid3_first_li()
688 x_recv = hc->rx_x_recv; in ccid3_first_li()
691 fval = scaled_div(hc->rx_s, hc->rx_rtt); in ccid3_first_li()
703 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_packet_recv() local
708 if (unlikely(hc->rx_state == TFRC_RSTATE_NO_DATA)) { in ccid3_hc_rx_packet_recv()
713 hc->rx_s = payload; in ccid3_hc_rx_packet_recv()
723 if (tfrc_rx_hist_duplicate(&hc->rx_hist, skb)) in ccid3_hc_rx_packet_recv()
731 hc->rx_s = tfrc_ewma(hc->rx_s, payload, 9); in ccid3_hc_rx_packet_recv()
732 hc->rx_bytes_recv += payload; in ccid3_hc_rx_packet_recv()
738 if (tfrc_rx_handle_loss(&hc->rx_hist, &hc->rx_li_hist, in ccid3_hc_rx_packet_recv()
744 if (tfrc_rx_hist_loss_pending(&hc->rx_hist)) in ccid3_hc_rx_packet_recv()
753 if (!tfrc_lh_is_initialised(&hc->rx_li_hist)) { in ccid3_hc_rx_packet_recv()
754 const u32 sample = tfrc_rx_hist_sample_rtt(&hc->rx_hist, skb); in ccid3_hc_rx_packet_recv()
761 hc->rx_rtt = tfrc_ewma(hc->rx_rtt, sample, 9); in ccid3_hc_rx_packet_recv()
763 } else if (tfrc_lh_update_i_mean(&hc->rx_li_hist, skb)) { in ccid3_hc_rx_packet_recv()
774 if (SUB16(dccp_hdr(skb)->dccph_ccval, hc->rx_last_counter) > 3) in ccid3_hc_rx_packet_recv()
778 tfrc_rx_hist_add_packet(&hc->rx_hist, skb, ndp); in ccid3_hc_rx_packet_recv()
787 struct ccid3_hc_rx_sock *hc = ccid_priv(ccid); in ccid3_hc_rx_init() local
789 hc->rx_state = TFRC_RSTATE_NO_DATA; in ccid3_hc_rx_init()
790 tfrc_lh_init(&hc->rx_li_hist); in ccid3_hc_rx_init()
791 return tfrc_rx_hist_alloc(&hc->rx_hist); in ccid3_hc_rx_init()
796 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_exit() local
798 tfrc_rx_hist_purge(&hc->rx_hist); in ccid3_hc_rx_exit()
799 tfrc_lh_cleanup(&hc->rx_li_hist); in ccid3_hc_rx_exit()
812 const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); in ccid3_hc_rx_getsockopt() local
820 rx_info.tfrcrx_x_recv = hc->rx_x_recv; in ccid3_hc_rx_getsockopt()
821 rx_info.tfrcrx_rtt = hc->rx_rtt; in ccid3_hc_rx_getsockopt()
822 rx_info.tfrcrx_p = tfrc_invert_loss_event_rate(hc->rx_pinv); in ccid3_hc_rx_getsockopt()