cc_cubic.c (b8d60729deefa0bd13e6a395fcab4928e6e10445) | cc_cubic.c (a9696510f5caef4a7c525fcf4359597798829350) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008-2010 Lawrence Stewart <lstewart@freebsd.org> 5 * Copyright (c) 2010 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * This software was developed by Lawrence Stewart while studying at the Centre --- 56 unchanged lines hidden (view full) --- 65#include <net/route.h> 66#include <net/route/nhop.h> 67 68#include <netinet/in_pcb.h> 69#include <netinet/tcp.h> 70#include <netinet/tcp_seq.h> 71#include <netinet/tcp_timer.h> 72#include <netinet/tcp_var.h> | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008-2010 Lawrence Stewart <lstewart@freebsd.org> 5 * Copyright (c) 2010 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * This software was developed by Lawrence Stewart while studying at the Centre --- 56 unchanged lines hidden (view full) --- 65#include <net/route.h> 66#include <net/route/nhop.h> 67 68#include <netinet/in_pcb.h> 69#include <netinet/tcp.h> 70#include <netinet/tcp_seq.h> 71#include <netinet/tcp_timer.h> 72#include <netinet/tcp_var.h> |
73#include <netinet/tcp_log_buf.h> 74#include <netinet/tcp_hpts.h> |
|
73#include <netinet/cc/cc.h> 74#include <netinet/cc/cc_cubic.h> 75#include <netinet/cc/cc_module.h> 76 77static void cubic_ack_received(struct cc_var *ccv, uint16_t type); 78static void cubic_cb_destroy(struct cc_var *ccv); 79static int cubic_cb_init(struct cc_var *ccv, void *ptr); 80static void cubic_cong_signal(struct cc_var *ccv, uint32_t type); 81static void cubic_conn_init(struct cc_var *ccv); 82static int cubic_mod_init(void); 83static void cubic_post_recovery(struct cc_var *ccv); 84static void cubic_record_rtt(struct cc_var *ccv); 85static void cubic_ssthresh_update(struct cc_var *ccv, uint32_t maxseg); 86static void cubic_after_idle(struct cc_var *ccv); 87static size_t cubic_data_sz(void); | 75#include <netinet/cc/cc.h> 76#include <netinet/cc/cc_cubic.h> 77#include <netinet/cc/cc_module.h> 78 79static void cubic_ack_received(struct cc_var *ccv, uint16_t type); 80static void cubic_cb_destroy(struct cc_var *ccv); 81static int cubic_cb_init(struct cc_var *ccv, void *ptr); 82static void cubic_cong_signal(struct cc_var *ccv, uint32_t type); 83static void cubic_conn_init(struct cc_var *ccv); 84static int cubic_mod_init(void); 85static void cubic_post_recovery(struct cc_var *ccv); 86static void cubic_record_rtt(struct cc_var *ccv); 87static void cubic_ssthresh_update(struct cc_var *ccv, uint32_t maxseg); 88static void cubic_after_idle(struct cc_var *ccv); 89static size_t cubic_data_sz(void); |
90static void cubic_newround(struct cc_var *ccv, uint32_t round_cnt); 91static void cubic_rttsample(struct cc_var *ccv, uint32_t usec_rtt, 92 uint32_t rxtcnt, uint32_t fas); |
|
88 | 93 |
89struct cubic { 90 /* Cubic K in fixed point form with CUBIC_SHIFT worth of precision. */ 91 int64_t K; 92 /* Sum of RTT samples across an epoch in ticks. */ 93 int64_t sum_rtt_ticks; 94 /* cwnd at the most recent congestion event. */ 95 unsigned long max_cwnd; 96 /* cwnd at the previous congestion event. */ 97 unsigned long prev_max_cwnd; 98 /* A copy of prev_max_cwnd. Used for CC_RTO_ERR */ 99 unsigned long prev_max_cwnd_cp; 100 /* various flags */ 101 uint32_t flags; 102#define CUBICFLAG_CONG_EVENT 0x00000001 /* congestion experienced */ 103#define CUBICFLAG_IN_SLOWSTART 0x00000002 /* in slow start */ 104#define CUBICFLAG_IN_APPLIMIT 0x00000004 /* application limited */ 105#define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */ 106 /* Minimum observed rtt in ticks. */ 107 int min_rtt_ticks; 108 /* Mean observed rtt between congestion epochs. */ 109 int mean_rtt_ticks; 110 /* ACKs since last congestion event. */ 111 int epoch_ack_count; 112 /* Timestamp (in ticks) of arriving in congestion avoidance from last 113 * congestion event. 114 */ 115 int t_last_cong; 116 /* Timestamp (in ticks) of a previous congestion event. Used for 117 * CC_RTO_ERR. 118 */ 119 int t_last_cong_prev; 120}; 121 | |
122struct cc_algo cubic_cc_algo = { 123 .name = "cubic", 124 .ack_received = cubic_ack_received, 125 .cb_destroy = cubic_cb_destroy, 126 .cb_init = cubic_cb_init, 127 .cong_signal = cubic_cong_signal, 128 .conn_init = cubic_conn_init, 129 .mod_init = cubic_mod_init, 130 .post_recovery = cubic_post_recovery, 131 .after_idle = cubic_after_idle, | 94struct cc_algo cubic_cc_algo = { 95 .name = "cubic", 96 .ack_received = cubic_ack_received, 97 .cb_destroy = cubic_cb_destroy, 98 .cb_init = cubic_cb_init, 99 .cong_signal = cubic_cong_signal, 100 .conn_init = cubic_conn_init, 101 .mod_init = cubic_mod_init, 102 .post_recovery = cubic_post_recovery, 103 .after_idle = cubic_after_idle, |
132 .cc_data_sz = cubic_data_sz | 104 .cc_data_sz = cubic_data_sz, 105 .rttsample = cubic_rttsample, 106 .newround = cubic_newround |
133}; 134 135static void | 107}; 108 109static void |
110cubic_log_hystart_event(struct cc_var *ccv, struct cubic *cubicd, uint8_t mod, uint32_t flex1) 111{ 112 /* 113 * Types of logs (mod value) 114 * 1 - rtt_thresh in flex1, checking to see if RTT is to great. 115 * 2 - rtt is too great, rtt_thresh in flex1. 116 * 3 - CSS is active incr in flex1 117 * 4 - A new round is beginning flex1 is round count 118 * 5 - A new RTT measurement flex1 is the new measurement. 119 * 6 - We enter CA ssthresh is also in flex1. 120 * 7 - Socket option to change hystart executed opt.val in flex1. 121 * 8 - Back out of CSS into SS, flex1 is the css_baseline_minrtt 122 * 9 - We enter CA, via an ECN mark. 123 * 10 - We enter CA, via a loss. 124 * 11 - We have slipped out of SS into CA via cwnd growth. 125 * 12 - After idle has re-enabled hystart++ 126 */ 127 struct tcpcb *tp; 128 129 if (hystart_bblogs == 0) 130 return; 131 tp = ccv->ccvc.tcp; 132 if (tp->t_logstate != TCP_LOG_STATE_OFF) { 133 union tcp_log_stackspecific log; 134 struct timeval tv; 135 136 memset(&log, 0, sizeof(log)); 137 log.u_bbr.flex1 = flex1; 138 log.u_bbr.flex2 = cubicd->css_current_round_minrtt; 139 log.u_bbr.flex3 = cubicd->css_lastround_minrtt; 140 log.u_bbr.flex4 = cubicd->css_rttsample_count; 141 log.u_bbr.flex5 = cubicd->css_entered_at_round; 142 log.u_bbr.flex6 = cubicd->css_baseline_minrtt; 143 /* We only need bottom 16 bits of flags */ 144 log.u_bbr.flex7 = cubicd->flags & 0x0000ffff; 145 log.u_bbr.flex8 = mod; 146 log.u_bbr.epoch = cubicd->css_current_round; 147 log.u_bbr.timeStamp = tcp_get_usecs(&tv); 148 log.u_bbr.lt_epoch = cubicd->css_fas_at_css_entry; 149 log.u_bbr.pkts_out = cubicd->css_last_fas; 150 log.u_bbr.delivered = cubicd->css_lowrtt_fas; 151 log.u_bbr.pkt_epoch = ccv->flags; 152 TCP_LOG_EVENTP(tp, NULL, 153 &tp->t_inpcb->inp_socket->so_rcv, 154 &tp->t_inpcb->inp_socket->so_snd, 155 TCP_HYSTART, 0, 156 0, &log, false, &tv); 157 } 158} 159 160static void 161cubic_does_slow_start(struct cc_var *ccv, struct cubic *cubicd) 162{ 163 /* 164 * In slow-start with ABC enabled and no RTO in sight? 165 * (Must not use abc_l_var > 1 if slow starting after 166 * an RTO. On RTO, snd_nxt = snd_una, so the 167 * snd_nxt == snd_max check is sufficient to 168 * handle this). 169 * 170 * XXXLAS: Find a way to signal SS after RTO that 171 * doesn't rely on tcpcb vars. 172 */ 173 u_int cw = CCV(ccv, snd_cwnd); 174 u_int incr = CCV(ccv, t_maxseg); 175 uint16_t abc_val; 176 177 cubicd->flags |= CUBICFLAG_IN_SLOWSTART; 178 if (ccv->flags & CCF_USE_LOCAL_ABC) 179 abc_val = ccv->labc; 180 else 181 abc_val = V_tcp_abc_l_var; 182 if ((ccv->flags & CCF_HYSTART_ALLOWED) && 183 (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) && 184 ((cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) == 0)) { 185 /* 186 * Hystart is allowed and still enabled and we are not yet 187 * in CSS. Lets check to see if we can make a decision on 188 * if we need to go into CSS. 189 */ 190 if ((cubicd->css_rttsample_count >= hystart_n_rttsamples) && 191 (cubicd->css_current_round_minrtt != 0xffffffff) && 192 (cubicd->css_lastround_minrtt != 0xffffffff)) { 193 uint32_t rtt_thresh; 194 195 /* Clamp (minrtt_thresh, lastround/8, maxrtt_thresh) */ 196 rtt_thresh = (cubicd->css_lastround_minrtt >> 3); 197 if (rtt_thresh < hystart_minrtt_thresh) 198 rtt_thresh = hystart_minrtt_thresh; 199 if (rtt_thresh > hystart_maxrtt_thresh) 200 rtt_thresh = hystart_maxrtt_thresh; 201 cubic_log_hystart_event(ccv, cubicd, 1, rtt_thresh); 202 203 if (cubicd->css_current_round_minrtt >= (cubicd->css_lastround_minrtt + rtt_thresh)) { 204 /* Enter CSS */ 205 cubicd->flags |= CUBICFLAG_HYSTART_IN_CSS; 206 cubicd->css_fas_at_css_entry = cubicd->css_lowrtt_fas; 207 /* 208 * The draft (v4) calls for us to set baseline to css_current_round_min 209 * but that can cause an oscillation. We probably shoudl be using 210 * css_lastround_minrtt, but the authors insist that will cause 211 * issues on exiting early. We will leave the draft version for now 212 * but I suspect this is incorrect. 213 */ 214 cubicd->css_baseline_minrtt = cubicd->css_current_round_minrtt; 215 cubicd->css_entered_at_round = cubicd->css_current_round; 216 cubic_log_hystart_event(ccv, cubicd, 2, rtt_thresh); 217 } 218 } 219 } 220 if (CCV(ccv, snd_nxt) == CCV(ccv, snd_max)) 221 incr = min(ccv->bytes_this_ack, 222 ccv->nsegs * abc_val * 223 CCV(ccv, t_maxseg)); 224 else 225 incr = min(ccv->bytes_this_ack, CCV(ccv, t_maxseg)); 226 227 /* Only if Hystart is enabled will the flag get set */ 228 if (cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) { 229 incr /= hystart_css_growth_div; 230 cubic_log_hystart_event(ccv, cubicd, 3, incr); 231 } 232 /* ABC is on by default, so incr equals 0 frequently. */ 233 if (incr > 0) 234 CCV(ccv, snd_cwnd) = min((cw + incr), 235 TCP_MAXWIN << CCV(ccv, snd_scale)); 236} 237 238static void |
|
136cubic_ack_received(struct cc_var *ccv, uint16_t type) 137{ 138 struct cubic *cubic_data; 139 unsigned long w_tf, w_cubic_next; 140 int ticks_since_cong; 141 142 cubic_data = ccv->cc_data; 143 cubic_record_rtt(ccv); 144 145 /* 146 * For a regular ACK and we're not in cong/fast recovery and 147 * we're cwnd limited, always recalculate cwnd. 148 */ 149 if (type == CC_ACK && !IN_RECOVERY(CCV(ccv, t_flags)) && 150 (ccv->flags & CCF_CWND_LIMITED)) { 151 /* Use the logic in NewReno ack_received() for slow start. */ 152 if (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || 153 cubic_data->min_rtt_ticks == TCPTV_SRTTBASE) { | 239cubic_ack_received(struct cc_var *ccv, uint16_t type) 240{ 241 struct cubic *cubic_data; 242 unsigned long w_tf, w_cubic_next; 243 int ticks_since_cong; 244 245 cubic_data = ccv->cc_data; 246 cubic_record_rtt(ccv); 247 248 /* 249 * For a regular ACK and we're not in cong/fast recovery and 250 * we're cwnd limited, always recalculate cwnd. 251 */ 252 if (type == CC_ACK && !IN_RECOVERY(CCV(ccv, t_flags)) && 253 (ccv->flags & CCF_CWND_LIMITED)) { 254 /* Use the logic in NewReno ack_received() for slow start. */ 255 if (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || 256 cubic_data->min_rtt_ticks == TCPTV_SRTTBASE) { |
154 cubic_data->flags |= CUBICFLAG_IN_SLOWSTART; 155 newreno_cc_ack_received(ccv, type); | 257 cubic_does_slow_start(ccv, cubic_data); |
156 } else { | 258 } else { |
259 if (cubic_data->flags & CUBICFLAG_HYSTART_IN_CSS) { 260 /* 261 * We have slipped into CA with 262 * CSS active. Deactivate all. 263 */ 264 /* Turn off the CSS flag */ 265 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 266 /* Disable use of CSS in the future except long idle */ 267 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; 268 cubic_log_hystart_event(ccv, cubic_data, 11, CCV(ccv, snd_ssthresh)); 269 } |
|
157 if ((cubic_data->flags & CUBICFLAG_RTO_EVENT) && 158 (cubic_data->flags & CUBICFLAG_IN_SLOWSTART)) { 159 /* RFC8312 Section 4.7 */ 160 cubic_data->flags &= ~(CUBICFLAG_RTO_EVENT | 161 CUBICFLAG_IN_SLOWSTART); 162 cubic_data->max_cwnd = CCV(ccv, snd_cwnd); 163 cubic_data->K = 0; 164 } else if (cubic_data->flags & (CUBICFLAG_IN_SLOWSTART | --- 75 unchanged lines hidden (view full) --- 240cubic_after_idle(struct cc_var *ccv) 241{ 242 struct cubic *cubic_data; 243 244 cubic_data = ccv->cc_data; 245 246 cubic_data->max_cwnd = ulmax(cubic_data->max_cwnd, CCV(ccv, snd_cwnd)); 247 cubic_data->K = cubic_k(cubic_data->max_cwnd / CCV(ccv, t_maxseg)); | 270 if ((cubic_data->flags & CUBICFLAG_RTO_EVENT) && 271 (cubic_data->flags & CUBICFLAG_IN_SLOWSTART)) { 272 /* RFC8312 Section 4.7 */ 273 cubic_data->flags &= ~(CUBICFLAG_RTO_EVENT | 274 CUBICFLAG_IN_SLOWSTART); 275 cubic_data->max_cwnd = CCV(ccv, snd_cwnd); 276 cubic_data->K = 0; 277 } else if (cubic_data->flags & (CUBICFLAG_IN_SLOWSTART | --- 75 unchanged lines hidden (view full) --- 353cubic_after_idle(struct cc_var *ccv) 354{ 355 struct cubic *cubic_data; 356 357 cubic_data = ccv->cc_data; 358 359 cubic_data->max_cwnd = ulmax(cubic_data->max_cwnd, CCV(ccv, snd_cwnd)); 360 cubic_data->K = cubic_k(cubic_data->max_cwnd / CCV(ccv, t_maxseg)); |
248 | 361 if ((cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) == 0) { 362 /* 363 * Re-enable hystart if we have been idle. 364 */ 365 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 366 cubic_data->flags |= CUBICFLAG_HYSTART_ENABLED; 367 cubic_log_hystart_event(ccv, cubic_data, 12, CCV(ccv, snd_ssthresh)); 368 } |
249 newreno_cc_after_idle(ccv); 250 cubic_data->t_last_cong = ticks; 251} 252 253static void 254cubic_cb_destroy(struct cc_var *ccv) 255{ 256 free(ccv->cc_data, M_CC_MEM); --- 19 unchanged lines hidden (view full) --- 276 cubic_data = ptr; 277 278 /* Init some key variables with sensible defaults. */ 279 cubic_data->t_last_cong = ticks; 280 cubic_data->min_rtt_ticks = TCPTV_SRTTBASE; 281 cubic_data->mean_rtt_ticks = 1; 282 283 ccv->cc_data = cubic_data; | 369 newreno_cc_after_idle(ccv); 370 cubic_data->t_last_cong = ticks; 371} 372 373static void 374cubic_cb_destroy(struct cc_var *ccv) 375{ 376 free(ccv->cc_data, M_CC_MEM); --- 19 unchanged lines hidden (view full) --- 396 cubic_data = ptr; 397 398 /* Init some key variables with sensible defaults. */ 399 cubic_data->t_last_cong = ticks; 400 cubic_data->min_rtt_ticks = TCPTV_SRTTBASE; 401 cubic_data->mean_rtt_ticks = 1; 402 403 ccv->cc_data = cubic_data; |
404 cubic_data->flags = CUBICFLAG_HYSTART_ENABLED; 405 /* At init set both to infinity */ 406 cubic_data->css_lastround_minrtt = 0xffffffff; 407 cubic_data->css_current_round_minrtt = 0xffffffff; 408 cubic_data->css_current_round = 0; 409 cubic_data->css_baseline_minrtt = 0xffffffff; 410 cubic_data->css_rttsample_count = 0; 411 cubic_data->css_entered_at_round = 0; 412 cubic_data->css_fas_at_css_entry = 0; 413 cubic_data->css_lowrtt_fas = 0; 414 cubic_data->css_last_fas = 0; |
|
284 285 return (0); 286} 287 288/* 289 * Perform any necessary tasks before we enter congestion recovery. 290 */ 291static void 292cubic_cong_signal(struct cc_var *ccv, uint32_t type) 293{ 294 struct cubic *cubic_data; 295 u_int mss; 296 297 cubic_data = ccv->cc_data; 298 mss = tcp_maxseg(ccv->ccvc.tcp); 299 300 switch (type) { 301 case CC_NDUPACK: | 415 416 return (0); 417} 418 419/* 420 * Perform any necessary tasks before we enter congestion recovery. 421 */ 422static void 423cubic_cong_signal(struct cc_var *ccv, uint32_t type) 424{ 425 struct cubic *cubic_data; 426 u_int mss; 427 428 cubic_data = ccv->cc_data; 429 mss = tcp_maxseg(ccv->ccvc.tcp); 430 431 switch (type) { 432 case CC_NDUPACK: |
433 if (cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) { 434 /* Make sure the flags are all off we had a loss */ 435 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; 436 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 437 cubic_log_hystart_event(ccv, cubic_data, 10, CCV(ccv, snd_ssthresh)); 438 } |
|
302 if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { 303 if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { 304 cubic_ssthresh_update(ccv, mss); 305 cubic_data->flags |= CUBICFLAG_CONG_EVENT; 306 cubic_data->t_last_cong = ticks; 307 cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); 308 } 309 ENTER_RECOVERY(CCV(ccv, t_flags)); 310 } 311 break; 312 313 case CC_ECN: | 439 if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { 440 if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { 441 cubic_ssthresh_update(ccv, mss); 442 cubic_data->flags |= CUBICFLAG_CONG_EVENT; 443 cubic_data->t_last_cong = ticks; 444 cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); 445 } 446 ENTER_RECOVERY(CCV(ccv, t_flags)); 447 } 448 break; 449 450 case CC_ECN: |
451 if (cubic_data->flags & CUBICFLAG_HYSTART_ENABLED) { 452 /* Make sure the flags are all off we had a loss */ 453 cubic_data->flags &= ~CUBICFLAG_HYSTART_ENABLED; 454 cubic_data->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 455 cubic_log_hystart_event(ccv, cubic_data, 9, CCV(ccv, snd_ssthresh)); 456 } |
|
314 if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { 315 cubic_ssthresh_update(ccv, mss); 316 cubic_data->flags |= CUBICFLAG_CONG_EVENT; 317 cubic_data->t_last_cong = ticks; 318 cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); 319 CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); 320 ENTER_CONGRECOVERY(CCV(ccv, t_flags)); 321 } --- 168 unchanged lines hidden (view full) --- 490 CUBIC_BETA) >> CUBIC_SHIFT; 491 } else { 492 ssthresh = ((uint64_t)cwnd * 493 CUBIC_BETA) >> CUBIC_SHIFT; 494 } 495 CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * maxseg); 496} 497 | 457 if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { 458 cubic_ssthresh_update(ccv, mss); 459 cubic_data->flags |= CUBICFLAG_CONG_EVENT; 460 cubic_data->t_last_cong = ticks; 461 cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); 462 CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); 463 ENTER_CONGRECOVERY(CCV(ccv, t_flags)); 464 } --- 168 unchanged lines hidden (view full) --- 633 CUBIC_BETA) >> CUBIC_SHIFT; 634 } else { 635 ssthresh = ((uint64_t)cwnd * 636 CUBIC_BETA) >> CUBIC_SHIFT; 637 } 638 CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * maxseg); 639} 640 |
641static void 642cubic_rttsample(struct cc_var *ccv, uint32_t usec_rtt, uint32_t rxtcnt, uint32_t fas) 643{ 644 struct cubic *cubicd; 645 646 cubicd = ccv->cc_data; 647 if (rxtcnt > 1) { 648 /* 649 * Only look at RTT's that are non-ambiguous. 650 */ 651 return; 652 } 653 cubicd->css_rttsample_count++; 654 cubicd->css_last_fas = fas; 655 if (cubicd->css_current_round_minrtt > usec_rtt) { 656 cubicd->css_current_round_minrtt = usec_rtt; 657 cubicd->css_lowrtt_fas = cubicd->css_last_fas; 658 } 659 if ((cubicd->css_rttsample_count >= hystart_n_rttsamples) && 660 (cubicd->css_current_round_minrtt != 0xffffffff) && 661 (cubicd->css_lastround_minrtt != 0xffffffff)) { 662 /* 663 * We were in CSS and the RTT is now less, we 664 * entered CSS erroneously. 665 */ 666 cubicd->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 667 cubic_log_hystart_event(ccv, cubicd, 8, cubicd->css_baseline_minrtt); 668 cubicd->css_baseline_minrtt = 0xffffffff; 669 } 670 if (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) 671 cubic_log_hystart_event(ccv, cubicd, 5, usec_rtt); 672} 673 674static void 675cubic_newround(struct cc_var *ccv, uint32_t round_cnt) 676{ 677 struct cubic *cubicd; 678 679 cubicd = ccv->cc_data; 680 /* We have entered a new round */ 681 cubicd->css_lastround_minrtt = cubicd->css_current_round_minrtt; 682 cubicd->css_current_round_minrtt = 0xffffffff; 683 cubicd->css_rttsample_count = 0; 684 cubicd->css_current_round = round_cnt; 685 if ((cubicd->flags & CUBICFLAG_HYSTART_IN_CSS) && 686 ((round_cnt - cubicd->css_entered_at_round) >= hystart_css_rounds)) { 687 /* Enter CA */ 688 if (ccv->flags & CCF_HYSTART_CAN_SH_CWND) { 689 /* 690 * We engage more than snd_ssthresh, engage 691 * the brakes!! Though we will stay in SS to 692 * creep back up again, so lets leave CSS active 693 * and give us hystart_css_rounds more rounds. 694 */ 695 if (ccv->flags & CCF_HYSTART_CONS_SSTH) { 696 CCV(ccv, snd_ssthresh) = ((cubicd->css_lowrtt_fas + cubicd->css_fas_at_css_entry) / 2); 697 } else { 698 CCV(ccv, snd_ssthresh) = cubicd->css_lowrtt_fas; 699 } 700 CCV(ccv, snd_cwnd) = cubicd->css_fas_at_css_entry; 701 cubicd->css_entered_at_round = round_cnt; 702 } else { 703 CCV(ccv, snd_ssthresh) = CCV(ccv, snd_cwnd); 704 /* Turn off the CSS flag */ 705 cubicd->flags &= ~CUBICFLAG_HYSTART_IN_CSS; 706 /* Disable use of CSS in the future except long idle */ 707 cubicd->flags &= ~CUBICFLAG_HYSTART_ENABLED; 708 } 709 cubic_log_hystart_event(ccv, cubicd, 6, CCV(ccv, snd_ssthresh)); 710 } 711 if (cubicd->flags & CUBICFLAG_HYSTART_ENABLED) 712 cubic_log_hystart_event(ccv, cubicd, 4, round_cnt); 713} 714 |
|
498DECLARE_CC_MODULE(cubic, &cubic_cc_algo); 499MODULE_VERSION(cubic, 2); | 715DECLARE_CC_MODULE(cubic, &cubic_cc_algo); 716MODULE_VERSION(cubic, 2); |