Lines Matching +full:static +full:- +full:beta

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2007-2008,2010,2014
8 * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org>
53 * Borrowed code fragments from cc_cdg.c to add modifiable beta
86 static void newreno_cb_destroy(struct cc_var *ccv);
87 static void newreno_ack_received(struct cc_var *ccv, ccsignal_t type);
88 static void newreno_after_idle(struct cc_var *ccv);
89 static void newreno_cong_signal(struct cc_var *ccv, ccsignal_t type);
90 static int newreno_ctl_output(struct cc_var *ccv, struct sockopt *sopt, void *buf);
91 static void newreno_newround(struct cc_var *ccv, uint32_t round_cnt);
92 static void newreno_rttsample(struct cc_var *ccv, uint32_t usec_rtt, uint32_t rxtcnt, uint32_t fas);
93 static int newreno_cb_init(struct cc_var *ccv, void *);
94 static size_t newreno_data_sz(void);
116 static void
121 * 1 - rtt_thresh in flex1, checking to see if RTT is to great. in newreno_log_hystart_event()
122 * 2 - rtt is too great, rtt_thresh in flex1. in newreno_log_hystart_event()
123 * 3 - CSS is active incr in flex1 in newreno_log_hystart_event()
124 * 4 - A new round is beginning flex1 is round count in newreno_log_hystart_event()
125 * 5 - A new RTT measurement flex1 is the new measurement. in newreno_log_hystart_event()
126 * 6 - We enter CA ssthresh is also in flex1. in newreno_log_hystart_event()
127 * 7 - Socket option to change hystart executed opt.val in flex1. in newreno_log_hystart_event()
128 * 8 - Back out of CSS into SS, flex1 is the css_baseline_minrtt in newreno_log_hystart_event()
129 * 9 - We enter CA, via an ECN mark. in newreno_log_hystart_event()
130 * 10 - We enter CA, via a loss. in newreno_log_hystart_event()
131 * 11 - We have slipped out of SS into CA via cwnd growth. in newreno_log_hystart_event()
132 * 12 - After idle has re-enabled hystart++ in newreno_log_hystart_event()
138 tp = ccv->tp; in newreno_log_hystart_event()
145 log.u_bbr.flex2 = nreno->css_current_round_minrtt; in newreno_log_hystart_event()
146 log.u_bbr.flex3 = nreno->css_lastround_minrtt; in newreno_log_hystart_event()
147 log.u_bbr.flex4 = nreno->css_rttsample_count; in newreno_log_hystart_event()
148 log.u_bbr.flex5 = nreno->css_entered_at_round; in newreno_log_hystart_event()
149 log.u_bbr.flex6 = nreno->css_baseline_minrtt; in newreno_log_hystart_event()
151 log.u_bbr.flex7 = nreno->newreno_flags & 0x0000ffff; in newreno_log_hystart_event()
153 log.u_bbr.epoch = nreno->css_current_round; in newreno_log_hystart_event()
155 log.u_bbr.lt_epoch = nreno->css_fas_at_css_entry; in newreno_log_hystart_event()
156 log.u_bbr.pkts_out = nreno->css_last_fas; in newreno_log_hystart_event()
157 log.u_bbr.delivered = nreno->css_lowrtt_fas; in newreno_log_hystart_event()
158 log.u_bbr.pkt_epoch = ccv->flags; in newreno_log_hystart_event()
160 &tptosocket(tp)->so_rcv, in newreno_log_hystart_event()
161 &tptosocket(tp)->so_snd, in newreno_log_hystart_event()
167 static size_t
173 static int
178 INP_WLOCK_ASSERT(tptoinpcb(ccv->tp)); in newreno_cb_init()
180 ccv->cc_data = malloc(sizeof(struct newreno), M_CC_MEM, M_NOWAIT); in newreno_cb_init()
181 if (ccv->cc_data == NULL) in newreno_cb_init()
184 ccv->cc_data = ptr; in newreno_cb_init()
185 nreno = (struct newreno *)ccv->cc_data; in newreno_cb_init()
187 nreno->beta = V_newreno_beta; in newreno_cb_init()
188 nreno->beta_ecn = V_newreno_beta_ecn; in newreno_cb_init()
194 nreno->newreno_flags = CC_NEWRENO_HYSTART_ENABLED; in newreno_cb_init()
196 nreno->css_lastround_minrtt = 0xffffffff; in newreno_cb_init()
197 nreno->css_current_round_minrtt = 0xffffffff; in newreno_cb_init()
198 nreno->css_current_round = 0; in newreno_cb_init()
199 nreno->css_baseline_minrtt = 0xffffffff; in newreno_cb_init()
200 nreno->css_rttsample_count = 0; in newreno_cb_init()
201 nreno->css_entered_at_round = 0; in newreno_cb_init()
202 nreno->css_fas_at_css_entry = 0; in newreno_cb_init()
203 nreno->css_lowrtt_fas = 0; in newreno_cb_init()
204 nreno->css_last_fas = 0; in newreno_cb_init()
208 static void
211 free(ccv->cc_data, M_CC_MEM); in newreno_cb_destroy()
214 static void
218 uint32_t mss = tcp_fixed_maxseg(ccv->tp); in newreno_ack_received()
220 nreno = ccv->cc_data; in newreno_ack_received()
222 (ccv->flags & CCF_CWND_LIMITED)) { in newreno_ack_received()
227 * Regular in-order ACK, open the congestion window. in newreno_ack_received()
254 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) { in newreno_ack_received()
260 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_ack_received()
262 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; in newreno_ack_received()
266 if (ccv->flags & CCF_ABC_SENTAWND) in newreno_ack_received()
267 ccv->flags &= ~CCF_ABC_SENTAWND; in newreno_ack_received()
274 * In slow-start with ABC enabled and no RTO in sight? in newreno_ack_received()
285 if (ccv->flags & CCF_USE_LOCAL_ABC) in newreno_ack_received()
286 abc_val = ccv->labc; in newreno_ack_received()
289 if ((ccv->flags & CCF_HYSTART_ALLOWED) && in newreno_ack_received()
290 (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) && in newreno_ack_received()
291 ((nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) == 0)) { in newreno_ack_received()
297 if ((nreno->css_rttsample_count >= hystart_n_rttsamples) && in newreno_ack_received()
298 (nreno->css_current_round_minrtt != 0xffffffff) && in newreno_ack_received()
299 (nreno->css_lastround_minrtt != 0xffffffff)) { in newreno_ack_received()
303 rtt_thresh = (nreno->css_lastround_minrtt >> 3); in newreno_ack_received()
309 if (nreno->css_current_round_minrtt >= (nreno->css_lastround_minrtt + rtt_thresh)) { in newreno_ack_received()
311 nreno->newreno_flags |= CC_NEWRENO_HYSTART_IN_CSS; in newreno_ack_received()
312 nreno->css_fas_at_css_entry = nreno->css_lowrtt_fas; in newreno_ack_received()
320 nreno->css_baseline_minrtt = nreno->css_current_round_minrtt; in newreno_ack_received()
321 nreno->css_entered_at_round = nreno->css_current_round; in newreno_ack_received()
327 incr = min(ccv->bytes_this_ack, in newreno_ack_received()
328 ccv->nsegs * abc_val * mss); in newreno_ack_received()
330 incr = min(ccv->bytes_this_ack, mss); in newreno_ack_received()
333 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) { in newreno_ack_received()
345 static void
350 nreno = ccv->cc_data; in newreno_after_idle()
352 if ((nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) == 0) { in newreno_after_idle()
354 * Re-enable hystart if we have been idle. in newreno_after_idle()
356 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_after_idle()
357 nreno->newreno_flags |= CC_NEWRENO_HYSTART_ENABLED; in newreno_after_idle()
365 static void
369 uint32_t beta, beta_ecn, cwin, factor, mss, pipe; in newreno_cong_signal() local
372 mss = tcp_fixed_maxseg(ccv->tp); in newreno_cong_signal()
373 nreno = ccv->cc_data; in newreno_cong_signal()
374 beta = (nreno == NULL) ? V_newreno_beta : nreno->beta; in newreno_cong_signal()
375 beta_ecn = (nreno == NULL) ? V_newreno_beta_ecn : nreno->beta_ecn; in newreno_cong_signal()
380 * us to use the lower valued back-off. in newreno_cong_signal()
384 ((nreno != NULL) && (nreno->newreno_flags & CC_NEWRENO_BETA_ECN_ENABLED)))) in newreno_cong_signal()
387 factor = beta; in newreno_cong_signal()
398 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) { in newreno_cong_signal()
400 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; in newreno_cong_signal()
401 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_cong_signal()
409 (uint64_t)beta) / (uint64_t)beta_ecn; in newreno_cong_signal()
417 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) { in newreno_cong_signal()
419 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; in newreno_cong_signal()
420 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_cong_signal()
432 pipe = tcp_compute_pipe(ccv->tp); in newreno_cong_signal()
434 pipe = CCV(ccv, snd_max) - in newreno_cong_signal()
450 static int
456 if (sopt->sopt_valsize != sizeof(struct cc_newreno_opts)) in newreno_ctl_output()
459 if (CC_ALGO(ccv->tp) != &newreno_cc_algo) in newreno_ctl_output()
462 nreno = (struct newreno *)ccv->cc_data; in newreno_ctl_output()
464 switch (sopt->sopt_dir) { in newreno_ctl_output()
466 switch (opt->name) { in newreno_ctl_output()
468 nreno->beta = opt->val; in newreno_ctl_output()
471 nreno->beta_ecn = opt->val; in newreno_ctl_output()
472 nreno->newreno_flags |= CC_NEWRENO_BETA_ECN_ENABLED; in newreno_ctl_output()
479 switch (opt->name) { in newreno_ctl_output()
481 opt->val = nreno->beta; in newreno_ctl_output()
484 opt->val = nreno->beta_ecn; in newreno_ctl_output()
497 static int
505 if (error == 0 && req->newptr != NULL ) { in newreno_beta_handler()
517 static void
522 nreno = (struct newreno *)ccv->cc_data; in newreno_newround()
524 nreno->css_lastround_minrtt = nreno->css_current_round_minrtt; in newreno_newround()
525 nreno->css_current_round_minrtt = 0xffffffff; in newreno_newround()
526 nreno->css_rttsample_count = 0; in newreno_newround()
527 nreno->css_current_round = round_cnt; in newreno_newround()
528 if ((nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) && in newreno_newround()
529 ((round_cnt - nreno->css_entered_at_round) >= hystart_css_rounds)) { in newreno_newround()
531 if (ccv->flags & CCF_HYSTART_CAN_SH_CWND) { in newreno_newround()
538 if (ccv->flags & CCF_HYSTART_CONS_SSTH) { in newreno_newround()
539 CCV(ccv, snd_ssthresh) = ((nreno->css_lowrtt_fas + nreno->css_fas_at_css_entry) / 2); in newreno_newround()
541 CCV(ccv, snd_ssthresh) = nreno->css_lowrtt_fas; in newreno_newround()
543 CCV(ccv, snd_cwnd) = nreno->css_fas_at_css_entry; in newreno_newround()
544 nreno->css_entered_at_round = round_cnt; in newreno_newround()
548 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_newround()
550 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; in newreno_newround()
554 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) in newreno_newround()
558 static void
563 nreno = (struct newreno *)ccv->cc_data; in newreno_rttsample()
566 * Only look at RTT's that are non-ambiguous. in newreno_rttsample()
570 nreno->css_rttsample_count++; in newreno_rttsample()
571 nreno->css_last_fas = fas; in newreno_rttsample()
572 if (nreno->css_current_round_minrtt > usec_rtt) { in newreno_rttsample()
573 nreno->css_current_round_minrtt = usec_rtt; in newreno_rttsample()
574 nreno->css_lowrtt_fas = nreno->css_last_fas; in newreno_rttsample()
576 if ((nreno->css_rttsample_count >= hystart_n_rttsamples) && in newreno_rttsample()
577 (nreno->css_current_round_minrtt != 0xffffffff) && in newreno_rttsample()
578 (nreno->css_current_round_minrtt < nreno->css_baseline_minrtt) && in newreno_rttsample()
579 (nreno->css_lastround_minrtt != 0xffffffff)) { in newreno_rttsample()
584 nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; in newreno_rttsample()
585 newreno_log_hystart_event(ccv, nreno, 8, nreno->css_baseline_minrtt); in newreno_rttsample()
586 nreno->css_baseline_minrtt = 0xffffffff; in newreno_rttsample()
588 if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) in newreno_rttsample()
597 SYSCTL_PROC(_net_inet_tcp_cc_newreno, OID_AUTO, beta,
600 "New Reno beta, specified as number between 1 and 100");
605 "New Reno beta ecn, specified as number between 1 and 100");