Lines Matching +full:0 +full:- +full:987
1 // SPDX-License-Identifier: GPL-2.0-only
3 * CAIA Delay-Gradient (CDG) congestion control
7 * delay gradients." In IFIP Networking, pages 328-341. Springer, 2011.
9 * Scavenger traffic (Less-than-Best-Effort) should disable coexistence
10 * heuristics using parameters use_shadow=0 and use_ineff=0.
22 * o Add toggle for non-congestion loss tolerance.
26 * o More accurate e^-x.
49 MODULE_PARM_DESC(backoff_beta, "backoff beta (0-1024)");
54 "(0: disabled, 1: ACK train, 2: delay threshold, 3: both)");
73 CDG_UNKNOWN = 0,
98 * nexp_u32 - negative base-e exponential
101 * Returns exp(ux * -1e-6) * U32_MAX.
106 /* exp(-x)*65536-1 for x = 0, 0.000256, 0.000512, ... */ in nexp_u32()
109 61378, 57484, 50423, 38795, 22965, 8047, 987, 14, in nexp_u32()
117 return 0; in nexp_u32()
120 res = U32_MAX - (ux & 0xff) * (U32_MAX / 1000000); in nexp_u32()
124 u32 y = v[i & -(msb & 1)] + U32_C(1); in nexp_u32()
145 ca->delay_min = min_not_zero(ca->delay_min, ca->rtt.min); in tcp_cdg_hystart_update()
146 if (ca->delay_min == 0) in tcp_cdg_hystart_update()
150 u32 now_us = tp->tcp_mstamp; in tcp_cdg_hystart_update()
152 if (ca->last_ack == 0 || !tcp_is_cwnd_limited(sk)) { in tcp_cdg_hystart_update()
153 ca->last_ack = now_us; in tcp_cdg_hystart_update()
154 ca->round_start = now_us; in tcp_cdg_hystart_update()
155 } else if (before(now_us, ca->last_ack + 3000)) { in tcp_cdg_hystart_update()
156 u32 base_owd = max(ca->delay_min / 2U, 125U); in tcp_cdg_hystart_update()
158 ca->last_ack = now_us; in tcp_cdg_hystart_update()
159 if (after(now_us, ca->round_start + base_owd)) { in tcp_cdg_hystart_update()
164 tp->snd_cwnd); in tcp_cdg_hystart_update()
165 tp->snd_ssthresh = tp->snd_cwnd; in tcp_cdg_hystart_update()
172 if (ca->sample_cnt < 8) { in tcp_cdg_hystart_update()
173 ca->sample_cnt++; in tcp_cdg_hystart_update()
175 s32 thresh = max(ca->delay_min + ca->delay_min / 8U, in tcp_cdg_hystart_update()
178 if (ca->rtt.min > thresh) { in tcp_cdg_hystart_update()
183 tp->snd_cwnd); in tcp_cdg_hystart_update()
184 tp->snd_ssthresh = tp->snd_cwnd; in tcp_cdg_hystart_update()
192 s32 gmin = ca->rtt.min - ca->rtt_prev.min; in tcp_cdg_grad()
193 s32 gmax = ca->rtt.max - ca->rtt_prev.max; in tcp_cdg_grad()
196 if (ca->gradients) { in tcp_cdg_grad()
197 ca->gsum.min += gmin - ca->gradients[ca->tail].min; in tcp_cdg_grad()
198 ca->gsum.max += gmax - ca->gradients[ca->tail].max; in tcp_cdg_grad()
199 ca->gradients[ca->tail].min = gmin; in tcp_cdg_grad()
200 ca->gradients[ca->tail].max = gmax; in tcp_cdg_grad()
201 ca->tail = (ca->tail + 1) & (window - 1); in tcp_cdg_grad()
202 gmin = ca->gsum.min; in tcp_cdg_grad()
203 gmax = ca->gsum.max; in tcp_cdg_grad()
208 * (rtt_latest - rtt_oldest) / window. in tcp_cdg_grad()
212 grad = gmin > 0 ? gmin : gmax; in tcp_cdg_grad()
215 if (!ca->gfilled) { in tcp_cdg_grad()
216 if (!ca->gradients && window > 1) in tcp_cdg_grad()
218 else if (ca->tail == 0) in tcp_cdg_grad()
219 ca->gfilled = true; in tcp_cdg_grad()
221 grad = (grad * window) / (int)ca->tail; in tcp_cdg_grad()
225 if (gmin <= -32 || gmax <= -32) in tcp_cdg_grad()
226 ca->backoff_cnt = 0; in tcp_cdg_grad()
233 if (gmin > 0 && gmax <= 0) in tcp_cdg_grad()
234 ca->state = CDG_FULL; in tcp_cdg_grad()
235 else if ((gmin > 0 && gmax > 0) || gmax < 0) in tcp_cdg_grad()
236 ca->state = CDG_NONFULL; in tcp_cdg_grad()
250 ca->backoff_cnt++; in tcp_cdg_backoff()
251 if (ca->backoff_cnt > use_ineff) in tcp_cdg_backoff()
255 ca->shadow_wnd = max(ca->shadow_wnd, tp->snd_cwnd); in tcp_cdg_backoff()
256 ca->state = CDG_BACKOFF; in tcp_cdg_backoff()
272 if (after(ack, ca->rtt_seq) && ca->rtt.v64) { in tcp_cdg_cong_avoid()
273 s32 grad = 0; in tcp_cdg_cong_avoid()
275 if (ca->rtt_prev.v64) in tcp_cdg_cong_avoid()
277 ca->rtt_seq = tp->snd_nxt; in tcp_cdg_cong_avoid()
278 ca->rtt_prev = ca->rtt; in tcp_cdg_cong_avoid()
279 ca->rtt.v64 = 0; in tcp_cdg_cong_avoid()
280 ca->last_ack = 0; in tcp_cdg_cong_avoid()
281 ca->sample_cnt = 0; in tcp_cdg_cong_avoid()
283 if (grad > 0 && tcp_cdg_backoff(sk, grad)) in tcp_cdg_cong_avoid()
288 ca->shadow_wnd = min(ca->shadow_wnd, tp->snd_cwnd); in tcp_cdg_cong_avoid()
292 prior_snd_cwnd = tp->snd_cwnd; in tcp_cdg_cong_avoid()
295 incr = tp->snd_cwnd - prior_snd_cwnd; in tcp_cdg_cong_avoid()
296 ca->shadow_wnd = max(ca->shadow_wnd, ca->shadow_wnd + incr); in tcp_cdg_cong_avoid()
304 if (sample->rtt_us <= 0) in tcp_cdg_acked()
311 if (tp->sacked_out == 0) { in tcp_cdg_acked()
312 if (sample->pkts_acked == 1 && ca->delack) { in tcp_cdg_acked()
314 * provenly lower than an existing non-zero minimum. in tcp_cdg_acked()
316 ca->rtt.min = min(ca->rtt.min, sample->rtt_us); in tcp_cdg_acked()
317 ca->delack--; in tcp_cdg_acked()
319 } else if (sample->pkts_acked > 1 && ca->delack < 5) { in tcp_cdg_acked()
320 ca->delack++; in tcp_cdg_acked()
324 ca->rtt.min = min_not_zero(ca->rtt.min, sample->rtt_us); in tcp_cdg_acked()
325 ca->rtt.max = max(ca->rtt.max, sample->rtt_us); in tcp_cdg_acked()
333 if (ca->state == CDG_BACKOFF) in tcp_cdg_ssthresh()
334 return max(2U, (tp->snd_cwnd * min(1024U, backoff_beta)) >> 10); in tcp_cdg_ssthresh()
336 if (ca->state == CDG_NONFULL && use_tolerance) in tcp_cdg_ssthresh()
337 return tp->snd_cwnd; in tcp_cdg_ssthresh()
339 ca->shadow_wnd = min(ca->shadow_wnd >> 1, tp->snd_cwnd); in tcp_cdg_ssthresh()
341 return max3(2U, ca->shadow_wnd, tp->snd_cwnd >> 1); in tcp_cdg_ssthresh()
342 return max(2U, tp->snd_cwnd >> 1); in tcp_cdg_ssthresh()
353 gradients = ca->gradients; in tcp_cdg_cwnd_event()
355 memset(gradients, 0, window * sizeof(gradients[0])); in tcp_cdg_cwnd_event()
356 memset(ca, 0, sizeof(*ca)); in tcp_cdg_cwnd_event()
358 ca->gradients = gradients; in tcp_cdg_cwnd_event()
359 ca->rtt_seq = tp->snd_nxt; in tcp_cdg_cwnd_event()
360 ca->shadow_wnd = tp->snd_cwnd; in tcp_cdg_cwnd_event()
363 ca->state = CDG_UNKNOWN; in tcp_cdg_cwnd_event()
364 ca->rtt_seq = tp->snd_nxt; in tcp_cdg_cwnd_event()
365 ca->rtt_prev = ca->rtt; in tcp_cdg_cwnd_event()
366 ca->rtt.v64 = 0; in tcp_cdg_cwnd_event()
380 ca->gradients = kcalloc(window, sizeof(ca->gradients[0]), in tcp_cdg_init()
382 ca->rtt_seq = tp->snd_nxt; in tcp_cdg_init()
383 ca->shadow_wnd = tp->snd_cwnd; in tcp_cdg_init()
390 kfree(ca->gradients); in tcp_cdg_release()
408 return -ERANGE; in tcp_cdg_register()
410 return -EINVAL; in tcp_cdg_register()
414 return 0; in tcp_cdg_register()