Lines Matching +full:no +full:- +full:idle +full:- +full:on +full:- +full:init

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2008-2010 Lawrence Stewart <lstewart@freebsd.org>
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * based on the Internet RFC9438 by Xu, Ha, Rhee, Goel, and Eggert.
111 * 1 - rtt_thresh in flex1, checking to see if RTT is to great. in cubic_log_hystart_event()
112 * 2 - rtt is too great, rtt_thresh in flex1. in cubic_log_hystart_event()
113 * 3 - CSS is active incr in flex1 in cubic_log_hystart_event()
114 * 4 - A new round is beginning flex1 is round count in cubic_log_hystart_event()
115 * 5 - A new RTT measurement flex1 is the new measurement. in cubic_log_hystart_event()
116 * 6 - We enter CA ssthresh is also in flex1. in cubic_log_hystart_event()
117 * 7 - Socket option to change hystart executed opt.val in flex1. in cubic_log_hystart_event()
118 * 8 - Back out of CSS into SS, flex1 is the css_baseline_minrtt in cubic_log_hystart_event()
119 * 9 - We enter CA, via an ECN mark. in cubic_log_hystart_event()
120 * 10 - We enter CA, via a loss. in cubic_log_hystart_event()
121 * 11 - We have slipped out of SS into CA via cwnd growth. in cubic_log_hystart_event()
122 * 12 - After idle has re-enabled hystart++ in cubic_log_hystart_event()
128 tp = ccv->tp; in cubic_log_hystart_event()
135 log.u_bbr.flex2 = cubicd->css_current_round_minrtt; in cubic_log_hystart_event()
136 log.u_bbr.flex3 = cubicd->css_lastround_minrtt; in cubic_log_hystart_event()
137 log.u_bbr.flex4 = cubicd->css_rttsample_count; in cubic_log_hystart_event()
138 log.u_bbr.flex5 = cubicd->css_entered_at_round; in cubic_log_hystart_event()
139 log.u_bbr.flex6 = cubicd->css_baseline_minrtt; in cubic_log_hystart_event()
141 log.u_bbr.flex7 = cubicd->flags & 0x0000ffff; in cubic_log_hystart_event()
143 log.u_bbr.epoch = cubicd->css_current_round; in cubic_log_hystart_event()
145 log.u_bbr.lt_epoch = cubicd->css_fas_at_css_entry; in cubic_log_hystart_event()
146 log.u_bbr.pkts_out = cubicd->css_last_fas; in cubic_log_hystart_event()
147 log.u_bbr.delivered = cubicd->css_lowrtt_fas; in cubic_log_hystart_event()
148 log.u_bbr.pkt_epoch = ccv->flags; in cubic_log_hystart_event()
150 &tptosocket(tp)->so_rcv, in cubic_log_hystart_event()
151 &tptosocket(tp)->so_snd, in cubic_log_hystart_event()
161 * In slow-start with ABC enabled and no RTO in sight? in cubic_does_slow_start()
163 * an RTO. On RTO, snd_nxt = snd_una, so the in cubic_does_slow_start()
168 * doesn't rely on tcpcb vars. in cubic_does_slow_start()
171 uint32_t mss = tcp_fixed_maxseg(ccv->tp); in cubic_does_slow_start()
175 cubicd->flags |= CUBICFLAG_IN_SLOWSTART; in cubic_does_slow_start()
176 if (ccv->flags & CCF_USE_LOCAL_ABC) in cubic_does_slow_start()
177 abc_val = ccv->labc; in cubic_does_slow_start()
180 if ((ccv->flags & CCF_HYSTART_ALLOWED) && in cubic_does_slow_start()
181 (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) && in cubic_does_slow_start()
182 ((cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) == 0)) { in cubic_does_slow_start()
185 * in CSS. Lets check to see if we can make a decision on in cubic_does_slow_start()
188 if ((cubicd->css_rttsample_count >= hystart_n_rttsamples) && in cubic_does_slow_start()
189 (cubicd->css_current_round_minrtt != 0xffffffff) && in cubic_does_slow_start()
190 (cubicd->css_lastround_minrtt != 0xffffffff)) { in cubic_does_slow_start()
194 rtt_thresh = (cubicd->css_lastround_minrtt >> 3); in cubic_does_slow_start()
201 if (cubicd->css_current_round_minrtt >= (cubicd->css_lastround_minrtt + rtt_thresh)) { in cubic_does_slow_start()
203 cubicd->flags |= CUBICFLAG_HYSTART_IN_CSS; in cubic_does_slow_start()
204 cubicd->css_fas_at_css_entry = cubicd->css_lowrtt_fas; in cubic_does_slow_start()
209 * issues on exiting early. We will leave the draft version for now in cubic_does_slow_start()
212 cubicd->css_baseline_minrtt = cubicd->css_current_round_minrtt; in cubic_does_slow_start()
213 cubicd->css_entered_at_round = cubicd->css_current_round; in cubic_does_slow_start()
219 incr = min(ccv->bytes_this_ack, in cubic_does_slow_start()
220 ccv->nsegs * abc_val * mss); in cubic_does_slow_start()
222 incr = min(ccv->bytes_this_ack, mss); in cubic_does_slow_start()
225 if (cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) { in cubic_does_slow_start()
229 /* ABC is on by default, so incr equals 0 frequently. */ in cubic_does_slow_start()
241 uint32_t mss = tcp_fixed_maxseg(ccv->tp); in cubic_ack_received()
244 cubic_data = ccv->cc_data; in cubic_ack_received()
252 (ccv->flags & CCF_CWND_LIMITED)) { in cubic_ack_received()
255 cubic_data->min_rtt_usecs == TCPTV_SRTTBASE) { in cubic_ack_received()
258 if (cubic_data->flags & CUBICFLAG_HYSTART_IN_CSS) { in cubic_ack_received()
264 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_ack_received()
265 /* Disable use of CSS in the future except long idle */ in cubic_ack_received()
266 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; in cubic_ack_received()
269 if (cubic_data->flags & (CUBICFLAG_IN_SLOWSTART | in cubic_ack_received()
279 * 3) application-limited in cubic_ack_received()
281 cubic_data->t_epoch = ticks; in cubic_ack_received()
282 cubic_data->cwnd_epoch = cwin; in cubic_ack_received()
283 cubic_data->K = cubic_k(cubic_data->W_max / mss, in cubic_ack_received()
284 cubic_data->cwnd_epoch / mss); in cubic_ack_received()
285 cubic_data->flags &= ~(CUBICFLAG_IN_SLOWSTART | in cubic_ack_received()
289 if (cubic_data->flags & CUBICFLAG_RTO_EVENT) { in cubic_ack_received()
291 cubic_data->flags &= ~CUBICFLAG_RTO_EVENT; in cubic_ack_received()
292 cubic_data->W_max = cwin; in cubic_ack_received()
293 cubic_data->K = 0; in cubic_ack_received()
296 usecs_since_epoch = (ticks - cubic_data->t_epoch) * tick; in cubic_ack_received()
302 cubic_data->t_epoch = ticks - INT_MAX; in cubic_ack_received()
309 cubic_data->mean_rtt_usecs, in cubic_ack_received()
310 cubic_data->W_max, in cubic_ack_received()
312 cubic_data->K); in cubic_ack_received()
315 /* RFC9438 Section 4.3: Reno-friendly region */ in cubic_ack_received()
317 cubic_data->flags |= CUBICFLAG_IN_TF; in cubic_ack_received()
330 incr = (((target - cwin) << CUBIC_SHIFT) / in cubic_ack_received()
336 !(ccv->flags & CCF_CWND_LIMITED)) { in cubic_ack_received()
337 cubic_data->flags |= CUBICFLAG_IN_APPLIMIT; in cubic_ack_received()
343 * - Reset cwnd by calling New Reno implementation of after_idle.
344 * - Reset t_epoch.
349 struct cubic *cubic_data = ccv->cc_data; in cubic_after_idle()
350 uint32_t mss = tcp_fixed_maxseg(ccv->tp); in cubic_after_idle()
352 cubic_data->W_max = ulmax(cubic_data->W_max, CCV(ccv, snd_cwnd)); in cubic_after_idle()
353 cubic_data->K = cubic_k(cubic_data->W_max / mss, cubic_data->cwnd_epoch / mss); in cubic_after_idle()
354 if ((cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) == 0) { in cubic_after_idle()
356 * Re-enable hystart if we have been idle. in cubic_after_idle()
358 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_after_idle()
359 cubic_data->flags |= CUBICFLAG_HYSTART_ENABLED; in cubic_after_idle()
363 cubic_data->t_epoch = ticks; in cubic_after_idle()
369 free(ccv->cc_data, M_CC_MEM); in cubic_cb_destroy()
383 INP_WLOCK_ASSERT(tptoinpcb(ccv->tp)); in cubic_cb_init()
391 /* Init some key variables with sensible defaults. */ in cubic_cb_init()
392 cubic_data->t_epoch = 0; in cubic_cb_init()
393 cubic_data->cwnd_epoch = 0; in cubic_cb_init()
394 cubic_data->K = 0; in cubic_cb_init()
395 cubic_data->min_rtt_usecs = TCPTV_SRTTBASE; in cubic_cb_init()
396 cubic_data->mean_rtt_usecs = 1; in cubic_cb_init()
398 ccv->cc_data = cubic_data; in cubic_cb_init()
399 cubic_data->flags = CUBICFLAG_HYSTART_ENABLED; in cubic_cb_init()
400 /* At init set both to infinity */ in cubic_cb_init()
401 cubic_data->css_lastround_minrtt = 0xffffffff; in cubic_cb_init()
402 cubic_data->css_current_round_minrtt = 0xffffffff; in cubic_cb_init()
403 cubic_data->css_current_round = 0; in cubic_cb_init()
404 cubic_data->css_baseline_minrtt = 0xffffffff; in cubic_cb_init()
405 cubic_data->css_rttsample_count = 0; in cubic_cb_init()
406 cubic_data->css_entered_at_round = 0; in cubic_cb_init()
407 cubic_data->css_fas_at_css_entry = 0; in cubic_cb_init()
408 cubic_data->css_lowrtt_fas = 0; in cubic_cb_init()
409 cubic_data->css_last_fas = 0; in cubic_cb_init()
423 cubic_data = ccv->cc_data; in cubic_cong_signal()
424 mss = tcp_fixed_maxseg(ccv->tp); in cubic_cong_signal()
428 if (cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) { in cubic_cong_signal()
430 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; in cubic_cong_signal()
431 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_cong_signal()
442 cubic_data->flags |= CUBICFLAG_CONG_EVENT; in cubic_cong_signal()
449 if (cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) { in cubic_cong_signal()
451 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; in cubic_cong_signal()
452 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_cong_signal()
463 cubic_data->flags |= CUBICFLAG_CONG_EVENT; in cubic_cong_signal()
477 cubic_data->undo_t_epoch = cubic_data->t_epoch; in cubic_cong_signal()
478 cubic_data->undo_cwnd_epoch = cubic_data->cwnd_epoch; in cubic_cong_signal()
479 cubic_data->undo_W_max = cubic_data->W_max; in cubic_cong_signal()
480 cubic_data->undo_K = cubic_data->K; in cubic_cong_signal()
481 pipe = tcp_compute_pipe(ccv->tp); in cubic_cong_signal()
490 cubic_data->flags |= CUBICFLAG_RTO_EVENT; in cubic_cong_signal()
495 cubic_data->flags &= ~CUBICFLAG_RTO_EVENT; in cubic_cong_signal()
496 cubic_data->K = cubic_data->undo_K; in cubic_cong_signal()
497 cubic_data->W_max = cubic_data->undo_W_max; in cubic_cong_signal()
498 cubic_data->cwnd_epoch = cubic_data->undo_cwnd_epoch; in cubic_cong_signal()
499 cubic_data->t_epoch = cubic_data->undo_t_epoch; in cubic_cong_signal()
511 cubic_data = ccv->cc_data; in cubic_conn_init()
518 cubic_data->W_max = UINT_MAX; in cubic_conn_init()
535 uint32_t mss = tcp_fixed_maxseg(ccv->tp); in cubic_post_recovery()
537 cubic_data = ccv->cc_data; in cubic_post_recovery()
546 pipe = tcp_compute_pipe(ccv->tp); in cubic_post_recovery()
554 /* Update cwnd based on beta and adjusted W_max. */ in cubic_post_recovery()
555 CCV(ccv, snd_cwnd) = max(((uint64_t)cubic_data->W_max * in cubic_post_recovery()
561 if (cubic_data->epoch_ack_count > 0 && in cubic_post_recovery()
562 cubic_data->sum_rtt_usecs >= cubic_data->epoch_ack_count) { in cubic_post_recovery()
563 cubic_data->mean_rtt_usecs = (int)(cubic_data->sum_rtt_usecs / in cubic_post_recovery()
564 cubic_data->epoch_ack_count); in cubic_post_recovery()
567 cubic_data->epoch_ack_count = 0; in cubic_post_recovery()
568 cubic_data->sum_rtt_usecs = 0; in cubic_post_recovery()
582 cubic_data = ccv->cc_data; in cubic_record_rtt()
583 t_srtt_usecs = tcp_get_srtt(ccv->tp, in cubic_record_rtt()
592 if ((t_srtt_usecs < cubic_data->min_rtt_usecs || in cubic_record_rtt()
593 cubic_data->min_rtt_usecs == TCPTV_SRTTBASE)) { in cubic_record_rtt()
596 cubic_data->min_rtt_usecs = max(tick >> TCP_RTT_SHIFT, in cubic_record_rtt()
605 if (cubic_data->min_rtt_usecs > in cubic_record_rtt()
606 cubic_data->mean_rtt_usecs) in cubic_record_rtt()
607 cubic_data->mean_rtt_usecs = in cubic_record_rtt()
608 cubic_data->min_rtt_usecs; in cubic_record_rtt()
612 cubic_data->sum_rtt_usecs += t_srtt_usecs; in cubic_record_rtt()
613 cubic_data->epoch_ack_count++; in cubic_record_rtt()
626 cubic_data = ccv->cc_data; in cubic_get_ssthresh()
630 if (cwnd < cubic_data->W_max) { in cubic_get_ssthresh()
633 cubic_data->W_max = cwnd; in cubic_get_ssthresh()
635 if (cubic_data->flags & CUBICFLAG_IN_TF) { in cubic_get_ssthresh()
645 pipe = tcp_compute_pipe(ccv->tp); in cubic_get_ssthresh()
655 cubicd = ccv->cc_data; in cubic_rttsample()
658 * Only look at RTT's that are non-ambiguous. in cubic_rttsample()
662 cubicd->css_rttsample_count++; in cubic_rttsample()
663 cubicd->css_last_fas = fas; in cubic_rttsample()
664 if (cubicd->css_current_round_minrtt > usec_rtt) { in cubic_rttsample()
665 cubicd->css_current_round_minrtt = usec_rtt; in cubic_rttsample()
666 cubicd->css_lowrtt_fas = cubicd->css_last_fas; in cubic_rttsample()
668 if ((cubicd->css_rttsample_count >= hystart_n_rttsamples) && in cubic_rttsample()
669 (cubicd->css_current_round_minrtt != 0xffffffff) && in cubic_rttsample()
670 (cubicd->css_current_round_minrtt < cubicd->css_baseline_minrtt) && in cubic_rttsample()
671 (cubicd->css_lastround_minrtt != 0xffffffff)) { in cubic_rttsample()
676 cubicd->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_rttsample()
677 cubic_log_hystart_event(ccv, cubicd, 8, cubicd->css_baseline_minrtt); in cubic_rttsample()
678 cubicd->css_baseline_minrtt = 0xffffffff; in cubic_rttsample()
680 if (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) in cubic_rttsample()
689 cubicd = ccv->cc_data; in cubic_newround()
691 cubicd->css_lastround_minrtt = cubicd->css_current_round_minrtt; in cubic_newround()
692 cubicd->css_current_round_minrtt = 0xffffffff; in cubic_newround()
693 cubicd->css_rttsample_count = 0; in cubic_newround()
694 cubicd->css_current_round = round_cnt; in cubic_newround()
695 if ((cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) && in cubic_newround()
696 ((round_cnt - cubicd->css_entered_at_round) >= hystart_css_rounds)) { in cubic_newround()
698 if (ccv->flags & CCF_HYSTART_CAN_SH_CWND) { in cubic_newround()
705 if (ccv->flags & CCF_HYSTART_CONS_SSTH) { in cubic_newround()
706 CCV(ccv, snd_ssthresh) = ((cubicd->css_lowrtt_fas + cubicd->css_fas_at_css_entry) / 2); in cubic_newround()
708 CCV(ccv, snd_ssthresh) = cubicd->css_lowrtt_fas; in cubic_newround()
710 CCV(ccv, snd_cwnd) = cubicd->css_fas_at_css_entry; in cubic_newround()
711 cubicd->css_entered_at_round = round_cnt; in cubic_newround()
715 cubicd->flags &= ~CUBICFLAG_HYSTART_IN_CSS; in cubic_newround()
716 /* Disable use of CSS in the future except long idle */ in cubic_newround()
717 cubicd->flags &= ~CUBICFLAG_HYSTART_ENABLED; in cubic_newround()
721 if (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) in cubic_newround()