Lines Matching +full:ideal +full:- +full:factor +full:- +full:value

1 // SPDX-License-Identifier: GPL-2.0-only
5 * TCP-NV is a successor of TCP-Vegas that has been developed to
7 * Like TCP-Vegas, TCP-NV supports true congestion avoidance,
9 * When congestion (queue buildup) starts to occur, TCP-NV
22 * seen issues with rx-frames values greater than 8.
41 * nv_rtt_factor RTT averaging factor
46 * slow-start due to congestion
47 * nv_stop_rtt_cnt Only grow cwnd for this many RTTs after non-congestion
52 * congested. One value (nv_cwnd_growth_rate_neg) for when
78 MODULE_PARM_DESC(nv_min_cwnd, "NV will not decrease cwnd below this value"
85 s8 cwnd_growth_factor; /* Current cwnd growth factor,
104 u32 nv_base_rtt; /* If non-zero it represents the threshold for
112 u32 nv_last_snd_una; /* Previous value of tp->snd_una. It is
127 ca->nv_reset = 0; in tcpnv_reset()
128 ca->nv_no_cong_cnt = 0; in tcpnv_reset()
129 ca->nv_rtt_cnt = 0; in tcpnv_reset()
130 ca->nv_last_rtt = 0; in tcpnv_reset()
131 ca->nv_rtt_max_rate = 0; in tcpnv_reset()
132 ca->nv_rtt_start_seq = tp->snd_una; in tcpnv_reset()
133 ca->nv_eval_call_cnt = 0; in tcpnv_reset()
134 ca->nv_last_snd_una = tp->snd_una; in tcpnv_reset()
151 ca->nv_base_rtt = base_rtt; in tcpnv_init()
152 ca->nv_lower_bound_rtt = (base_rtt * 205) >> 8; /* 80% */ in tcpnv_init()
154 ca->nv_base_rtt = 0; in tcpnv_init()
155 ca->nv_lower_bound_rtt = 0; in tcpnv_init()
158 ca->nv_allow_cwnd_growth = 1; in tcpnv_init()
159 ca->nv_min_rtt_reset_jiffies = jiffies + 2 * HZ; in tcpnv_init()
160 ca->nv_min_rtt = NV_INIT_RTT; in tcpnv_init()
161 ca->nv_min_rtt_new = NV_INIT_RTT; in tcpnv_init()
162 ca->nv_min_cwnd = NV_MIN_CWND; in tcpnv_init()
163 ca->nv_catchup = 0; in tcpnv_init()
164 ca->cwnd_growth_factor = 0; in tcpnv_init()
172 if (ca->nv_lower_bound_rtt > 0 && val < ca->nv_lower_bound_rtt) in nv_get_bounded_rtt()
173 return ca->nv_lower_bound_rtt; in nv_get_bounded_rtt()
174 else if (ca->nv_base_rtt > 0 && val > ca->nv_base_rtt) in nv_get_bounded_rtt()
175 return ca->nv_base_rtt; in nv_get_bounded_rtt()
190 if (!ca->nv_allow_cwnd_growth) in tcpnv_cong_avoid()
199 if (ca->cwnd_growth_factor < 0) { in tcpnv_cong_avoid()
200 cnt = tcp_snd_cwnd(tp) << -ca->cwnd_growth_factor; in tcpnv_cong_avoid()
203 cnt = max(4U, tcp_snd_cwnd(tp) >> ca->cwnd_growth_factor); in tcpnv_cong_avoid()
219 if (new_state == TCP_CA_Open && ca->nv_reset) { in tcpnv_state()
223 ca->nv_reset = 1; in tcpnv_state()
224 ca->nv_allow_cwnd_growth = 0; in tcpnv_state()
226 /* Reset cwnd growth factor to Reno value */ in tcpnv_state()
227 if (ca->cwnd_growth_factor > 0) in tcpnv_state()
228 ca->cwnd_growth_factor = 0; in tcpnv_state()
231 ca->cwnd_growth_factor > -8) in tcpnv_state()
232 ca->cwnd_growth_factor--; in tcpnv_state()
237 /* Do congestion avoidance calculations for TCP-NV
251 if (sample->rtt_us < 0) in tcpnv_acked()
255 if (icsk->icsk_ca_state != TCP_CA_Open && in tcpnv_acked()
256 icsk->icsk_ca_state != TCP_CA_Disorder) in tcpnv_acked()
260 if (ca->nv_catchup && tcp_snd_cwnd(tp) >= nv_min_cwnd) { in tcpnv_acked()
261 ca->nv_catchup = 0; in tcpnv_acked()
262 ca->nv_allow_cwnd_growth = 0; in tcpnv_acked()
265 bytes_acked = tp->snd_una - ca->nv_last_snd_una; in tcpnv_acked()
266 ca->nv_last_snd_una = tp->snd_una; in tcpnv_acked()
268 if (sample->in_flight == 0) in tcpnv_acked()
273 if (ca->nv_last_rtt > 0) { in tcpnv_acked()
274 avg_rtt = (((u64)sample->rtt_us) * nv_rtt_factor + in tcpnv_acked()
275 ((u64)ca->nv_last_rtt) in tcpnv_acked()
276 * (256 - nv_rtt_factor)) >> 8; in tcpnv_acked()
278 avg_rtt = sample->rtt_us; in tcpnv_acked()
279 ca->nv_min_rtt = avg_rtt << 1; in tcpnv_acked()
281 ca->nv_last_rtt = avg_rtt; in tcpnv_acked()
283 avg_rtt = sample->rtt_us; in tcpnv_acked()
287 rate64 = ((u64)sample->in_flight) * 80000; in tcpnv_acked()
295 if (ca->nv_rtt_max_rate < rate) in tcpnv_acked()
296 ca->nv_rtt_max_rate = rate; in tcpnv_acked()
299 if (ca->nv_eval_call_cnt < 255) in tcpnv_acked()
300 ca->nv_eval_call_cnt++; in tcpnv_acked()
306 if (avg_rtt < ca->nv_min_rtt) in tcpnv_acked()
307 ca->nv_min_rtt = avg_rtt; in tcpnv_acked()
310 if (avg_rtt < ca->nv_min_rtt_new) in tcpnv_acked()
311 ca->nv_min_rtt_new = avg_rtt; in tcpnv_acked()
322 if (time_after_eq(now, ca->nv_min_rtt_reset_jiffies)) { in tcpnv_acked()
325 ca->nv_min_rtt = ca->nv_min_rtt_new; in tcpnv_acked()
326 ca->nv_min_rtt_new = NV_INIT_RTT; in tcpnv_acked()
328 ca->nv_min_rtt_reset_jiffies = in tcpnv_acked()
330 /* Every so often we decrease ca->nv_min_cwnd in case previous in tcpnv_acked()
331 * value is no longer accurate. in tcpnv_acked()
333 ca->nv_min_cwnd = max(ca->nv_min_cwnd / 2, NV_MIN_CWND); in tcpnv_acked()
337 if (before(ca->nv_rtt_start_seq, tp->snd_una)) { in tcpnv_acked()
338 ca->nv_rtt_start_seq = tp->snd_nxt; in tcpnv_acked()
339 if (ca->nv_rtt_cnt < 0xff) in tcpnv_acked()
341 ca->nv_rtt_cnt++; in tcpnv_acked()
346 * ca->nv_min_cwnd. in tcpnv_acked()
348 if (ca->nv_eval_call_cnt == 1 && in tcpnv_acked()
349 bytes_acked >= (ca->nv_min_cwnd - 1) * tp->mss_cache && in tcpnv_acked()
350 ca->nv_min_cwnd < (NV_TSO_CWND_BOUND + 1)) { in tcpnv_acked()
351 ca->nv_min_cwnd = min(ca->nv_min_cwnd in tcpnv_acked()
354 ca->nv_rtt_start_seq = tp->snd_nxt + in tcpnv_acked()
355 ca->nv_min_cwnd * tp->mss_cache; in tcpnv_acked()
356 ca->nv_eval_call_cnt = 0; in tcpnv_acked()
357 ca->nv_allow_cwnd_growth = 1; in tcpnv_acked()
361 /* Find the ideal cwnd for current rate from slope in tcpnv_acked()
366 div64_u64(((u64)ca->nv_rtt_max_rate) * ca->nv_min_rtt, in tcpnv_acked()
367 80000ULL * tp->mss_cache); in tcpnv_acked()
382 if (ca->nv_rtt_cnt < nv_rtt_min_cnt) { in tcpnv_acked()
384 } else if (tp->snd_ssthresh == TCP_INFINITE_SSTHRESH) { in tcpnv_acked()
385 if (ca->nv_eval_call_cnt < in tcpnv_acked()
389 } else if (ca->nv_eval_call_cnt < in tcpnv_acked()
391 if (ca->nv_allow_cwnd_growth && in tcpnv_acked()
392 ca->nv_rtt_cnt > nv_stop_rtt_cnt) in tcpnv_acked()
393 ca->nv_allow_cwnd_growth = 0; in tcpnv_acked()
398 ca->nv_allow_cwnd_growth = 0; in tcpnv_acked()
399 tp->snd_ssthresh = in tcpnv_acked()
401 if (tcp_snd_cwnd(tp) - max_win > 2) { in tcpnv_acked()
405 dec = max(2U, ((tcp_snd_cwnd(tp) - max_win) * in tcpnv_acked()
407 tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - dec); in tcpnv_acked()
411 if (ca->cwnd_growth_factor > 0) in tcpnv_acked()
412 ca->cwnd_growth_factor = 0; in tcpnv_acked()
413 ca->nv_no_cong_cnt = 0; in tcpnv_acked()
414 } else if (tcp_snd_cwnd(tp) <= max_win - nv_pad_buffer) { in tcpnv_acked()
416 if (ca->nv_eval_call_cnt < nv_inc_eval_min_calls) in tcpnv_acked()
419 ca->nv_allow_cwnd_growth = 1; in tcpnv_acked()
420 ca->nv_no_cong_cnt++; in tcpnv_acked()
421 if (ca->cwnd_growth_factor < 0 && in tcpnv_acked()
423 ca->nv_no_cong_cnt > nv_cwnd_growth_rate_neg) { in tcpnv_acked()
424 ca->cwnd_growth_factor++; in tcpnv_acked()
425 ca->nv_no_cong_cnt = 0; in tcpnv_acked()
426 } else if (ca->cwnd_growth_factor >= 0 && in tcpnv_acked()
428 ca->nv_no_cong_cnt > in tcpnv_acked()
430 ca->cwnd_growth_factor++; in tcpnv_acked()
431 ca->nv_no_cong_cnt = 0; in tcpnv_acked()
434 /* cwnd is in-between, so do nothing */ in tcpnv_acked()
439 ca->nv_eval_call_cnt = 0; in tcpnv_acked()
440 ca->nv_rtt_cnt = 0; in tcpnv_acked()
441 ca->nv_rtt_max_rate = 0; in tcpnv_acked()
458 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { in tcpnv_get_info()
459 info->vegas.tcpv_enabled = 1; in tcpnv_get_info()
460 info->vegas.tcpv_rttcnt = ca->nv_rtt_cnt; in tcpnv_get_info()
461 info->vegas.tcpv_rtt = ca->nv_last_rtt; in tcpnv_get_info()
462 info->vegas.tcpv_minrtt = ca->nv_min_rtt; in tcpnv_get_info()