Lines Matching +full:delta +full:- +full:x +full:- +full:threshold

1 // SPDX-License-Identifier: GPL-2.0-only
3 * TCP Low Priority (TCP-LP)
11 * the original TCP-LP implementation:
16 * o Handling calculation of One-Way-Delay (OWD) within rtt_sample, since
26 * http://www.ece.rice.edu/~akuzma/Doc/akuzma/TCP-LP.pdf
28 * http://www-ece.rice.edu/networks/TCP-LP/
30 * 2.6.x module Authors:
34 * http://tcp-lp-mod.sourceforge.net/
47 * @LP_WITHIN_THR: are we within threshold?
50 * TCP-LP's state flags.
62 * @flag: TCP-LP state flag
73 * TCP-LP's private struct.
74 * We get the idea from original TCP-LP implementation where only left those we
101 lp->flag = 0; in tcp_lp_init()
102 lp->sowd = 0; in tcp_lp_init()
103 lp->owd_min = 0xffffffff; in tcp_lp_init()
104 lp->owd_max = 0; in tcp_lp_init()
105 lp->owd_max_rsv = 0; in tcp_lp_init()
106 lp->remote_hz = 0; in tcp_lp_init()
107 lp->remote_ref_time = 0; in tcp_lp_init()
108 lp->local_ref_time = 0; in tcp_lp_init()
109 lp->last_drop = 0; in tcp_lp_init()
110 lp->inference = 0; in tcp_lp_init()
119 * From TCP-LP's paper, this will be handled in additive increasement.
125 if (!(lp->flag & LP_WITHIN_INF)) in tcp_lp_cong_avoid()
134 * We keep on updating the estimated value, where original TCP-LP
141 s64 rhz = lp->remote_hz << 6; /* remote HZ << 6 */ in tcp_lp_remote_hz_estimator()
146 if (lp->remote_ref_time == 0 || lp->local_ref_time == 0) in tcp_lp_remote_hz_estimator()
150 if (tp->rx_opt.rcv_tsval == lp->remote_ref_time || in tcp_lp_remote_hz_estimator()
151 tp->rx_opt.rcv_tsecr == lp->local_ref_time) in tcp_lp_remote_hz_estimator()
155 (tp->rx_opt.rcv_tsval - lp->remote_ref_time) / in tcp_lp_remote_hz_estimator()
156 (tp->rx_opt.rcv_tsecr - lp->local_ref_time); in tcp_lp_remote_hz_estimator()
158 m = -m; in tcp_lp_remote_hz_estimator()
161 m -= rhz >> 6; /* m is now error in remote HZ est */ in tcp_lp_remote_hz_estimator()
169 lp->flag |= LP_VALID_RHZ; in tcp_lp_remote_hz_estimator()
171 lp->flag &= ~LP_VALID_RHZ; in tcp_lp_remote_hz_estimator()
174 lp->remote_ref_time = tp->rx_opt.rcv_tsval; in tcp_lp_remote_hz_estimator()
175 lp->local_ref_time = tp->rx_opt.rcv_tsecr; in tcp_lp_remote_hz_estimator()
197 lp->remote_hz = tcp_lp_remote_hz_estimator(sk); in tcp_lp_owd_calculator()
199 if (lp->flag & LP_VALID_RHZ) { in tcp_lp_owd_calculator()
201 tp->rx_opt.rcv_tsval * (LP_RESOL / lp->remote_hz) - in tcp_lp_owd_calculator()
202 tp->rx_opt.rcv_tsecr * (LP_RESOL / TCP_TS_HZ); in tcp_lp_owd_calculator()
204 owd = -owd; in tcp_lp_owd_calculator()
208 lp->flag |= LP_VALID_OWD; in tcp_lp_owd_calculator()
210 lp->flag &= ~LP_VALID_OWD; in tcp_lp_owd_calculator()
225 * Most ideas come from the original TCP-LP implementation.
233 if (!(lp->flag & LP_VALID_RHZ) || !(lp->flag & LP_VALID_OWD)) in tcp_lp_rtt_sample()
237 if (mowd < lp->owd_min) in tcp_lp_rtt_sample()
238 lp->owd_min = mowd; in tcp_lp_rtt_sample()
242 if (mowd > lp->owd_max) { in tcp_lp_rtt_sample()
243 if (mowd > lp->owd_max_rsv) { in tcp_lp_rtt_sample()
244 if (lp->owd_max_rsv == 0) in tcp_lp_rtt_sample()
245 lp->owd_max = mowd; in tcp_lp_rtt_sample()
247 lp->owd_max = lp->owd_max_rsv; in tcp_lp_rtt_sample()
248 lp->owd_max_rsv = mowd; in tcp_lp_rtt_sample()
250 lp->owd_max = mowd; in tcp_lp_rtt_sample()
254 if (lp->sowd != 0) { in tcp_lp_rtt_sample()
255 mowd -= lp->sowd >> 3; /* m is now error in owd est */ in tcp_lp_rtt_sample()
256 lp->sowd += mowd; /* owd = 7/8 owd + 1/8 new */ in tcp_lp_rtt_sample()
258 lp->sowd = mowd << 3; /* take the measured time be owd */ in tcp_lp_rtt_sample()
269 * We work it out by following the idea from TCP-LP's paper directly
276 u32 delta; in tcp_lp_pkts_acked() local
278 if (sample->rtt_us > 0) in tcp_lp_pkts_acked()
279 tcp_lp_rtt_sample(sk, sample->rtt_us); in tcp_lp_pkts_acked()
282 delta = now - tp->rx_opt.rcv_tsecr; in tcp_lp_pkts_acked()
283 if ((s32)delta > 0) in tcp_lp_pkts_acked()
284 lp->inference = 3 * delta; in tcp_lp_pkts_acked()
287 if (lp->last_drop && (now - lp->last_drop < lp->inference)) in tcp_lp_pkts_acked()
288 lp->flag |= LP_WITHIN_INF; in tcp_lp_pkts_acked()
290 lp->flag &= ~LP_WITHIN_INF; in tcp_lp_pkts_acked()
292 /* test if within threshold */ in tcp_lp_pkts_acked()
293 if (lp->sowd >> 3 < in tcp_lp_pkts_acked()
294 lp->owd_min + 15 * (lp->owd_max - lp->owd_min) / 100) in tcp_lp_pkts_acked()
295 lp->flag |= LP_WITHIN_THR; in tcp_lp_pkts_acked()
297 lp->flag &= ~LP_WITHIN_THR; in tcp_lp_pkts_acked()
299 pr_debug("TCP-LP: %05o|%5u|%5u|%15u|%15u|%15u\n", lp->flag, in tcp_lp_pkts_acked()
300 tcp_snd_cwnd(tp), lp->remote_hz, lp->owd_min, lp->owd_max, in tcp_lp_pkts_acked()
301 lp->sowd >> 3); in tcp_lp_pkts_acked()
303 if (lp->flag & LP_WITHIN_THR) in tcp_lp_pkts_acked()
308 * and will usually within threshold when within inference */ in tcp_lp_pkts_acked()
309 lp->owd_min = lp->sowd >> 3; in tcp_lp_pkts_acked()
310 lp->owd_max = lp->sowd >> 2; in tcp_lp_pkts_acked()
311 lp->owd_max_rsv = lp->sowd >> 2; in tcp_lp_pkts_acked()
315 if (lp->flag & LP_WITHIN_INF) in tcp_lp_pkts_acked()
324 lp->last_drop = now; in tcp_lp_pkts_acked()