Lines Matching +full:min +full:- +full:sample +full:- +full:time
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
20 * o OWD is handled in relative format, where local time stamp will in
26 * http://www.ece.rice.edu/~akuzma/Doc/akuzma/TCP-LP.pdf
28 * http://www-ece.rice.edu/networks/TCP-LP/
34 * http://tcp-lp-mod.sourceforge.net/
50 * TCP-LP's state flags.
62 * @flag: TCP-LP state flag
64 * @owd_min: min OWD
68 * @remote_ref_time: remote reference time
69 * @local_ref_time: local reference time
70 * @last_drop: time for last active drop
73 * TCP-LP's private struct.
74 * We get the idea from original TCP-LP implementation where only left those we
100 lp->flag = 0; in tcp_lp_init()
101 lp->sowd = 0; in tcp_lp_init()
102 lp->owd_min = 0xffffffff; in tcp_lp_init()
103 lp->owd_max = 0; in tcp_lp_init()
104 lp->owd_max_rsv = 0; in tcp_lp_init()
105 lp->remote_hz = 0; in tcp_lp_init()
106 lp->remote_ref_time = 0; in tcp_lp_init()
107 lp->local_ref_time = 0; in tcp_lp_init()
108 lp->last_drop = 0; in tcp_lp_init()
109 lp->inference = 0; in tcp_lp_init()
117 * From TCP-LP's paper, this will be handled in additive increasement.
123 if (!(lp->flag & LP_WITHIN_INF)) in tcp_lp_cong_avoid()
131 * We keep on updating the estimated value, where original TCP-LP
138 s64 rhz = lp->remote_hz << 6; /* remote HZ << 6 */ in tcp_lp_remote_hz_estimator()
141 /* not yet record reference time in tcp_lp_remote_hz_estimator()
143 if (lp->remote_ref_time == 0 || lp->local_ref_time == 0) in tcp_lp_remote_hz_estimator()
147 if (tp->rx_opt.rcv_tsval == lp->remote_ref_time || in tcp_lp_remote_hz_estimator()
148 tp->rx_opt.rcv_tsecr == lp->local_ref_time) in tcp_lp_remote_hz_estimator()
152 (tp->rx_opt.rcv_tsval - lp->remote_ref_time) / in tcp_lp_remote_hz_estimator()
153 (tp->rx_opt.rcv_tsecr - lp->local_ref_time); in tcp_lp_remote_hz_estimator()
155 m = -m; in tcp_lp_remote_hz_estimator()
158 m -= rhz >> 6; /* m is now error in remote HZ est */ in tcp_lp_remote_hz_estimator()
164 /* record time for successful remote HZ calc */ in tcp_lp_remote_hz_estimator()
166 lp->flag |= LP_VALID_RHZ; in tcp_lp_remote_hz_estimator()
168 lp->flag &= ~LP_VALID_RHZ; in tcp_lp_remote_hz_estimator()
170 /* record reference time stamp */ in tcp_lp_remote_hz_estimator()
171 lp->remote_ref_time = tp->rx_opt.rcv_tsval; in tcp_lp_remote_hz_estimator()
172 lp->local_ref_time = tp->rx_opt.rcv_tsecr; in tcp_lp_remote_hz_estimator()
181 * Original implement OWD as minus of remote time difference to local time
182 * difference directly. As this time difference just simply equal to RTT, when
193 lp->remote_hz = tcp_lp_remote_hz_estimator(sk); in tcp_lp_owd_calculator()
195 if (lp->flag & LP_VALID_RHZ) { in tcp_lp_owd_calculator()
197 tp->rx_opt.rcv_tsval * (LP_RESOL / lp->remote_hz) - in tcp_lp_owd_calculator()
198 tp->rx_opt.rcv_tsecr * (LP_RESOL / TCP_TS_HZ); in tcp_lp_owd_calculator()
200 owd = -owd; in tcp_lp_owd_calculator()
204 lp->flag |= LP_VALID_OWD; in tcp_lp_owd_calculator()
206 lp->flag &= ~LP_VALID_OWD; in tcp_lp_owd_calculator()
217 * 2. record the min/max OWD,
219 * Most ideas come from the original TCP-LP implementation.
227 if (!(lp->flag & LP_VALID_RHZ) || !(lp->flag & LP_VALID_OWD)) in tcp_lp_rtt_sample()
230 /* record the next min owd */ in tcp_lp_rtt_sample()
231 if (mowd < lp->owd_min) in tcp_lp_rtt_sample()
232 lp->owd_min = mowd; in tcp_lp_rtt_sample()
236 if (mowd > lp->owd_max) { in tcp_lp_rtt_sample()
237 if (mowd > lp->owd_max_rsv) { in tcp_lp_rtt_sample()
238 if (lp->owd_max_rsv == 0) in tcp_lp_rtt_sample()
239 lp->owd_max = mowd; in tcp_lp_rtt_sample()
241 lp->owd_max = lp->owd_max_rsv; in tcp_lp_rtt_sample()
242 lp->owd_max_rsv = mowd; in tcp_lp_rtt_sample()
244 lp->owd_max = mowd; in tcp_lp_rtt_sample()
248 if (lp->sowd != 0) { in tcp_lp_rtt_sample()
249 mowd -= lp->sowd >> 3; /* m is now error in owd est */ in tcp_lp_rtt_sample()
250 lp->sowd += mowd; /* owd = 7/8 owd + 1/8 new */ in tcp_lp_rtt_sample()
252 lp->sowd = mowd << 3; /* take the measured time be owd */ in tcp_lp_rtt_sample()
262 * We work it out by following the idea from TCP-LP's paper directly
264 static void tcp_lp_pkts_acked(struct sock *sk, const struct ack_sample *sample) in tcp_lp_pkts_acked() argument
271 if (sample->rtt_us > 0) in tcp_lp_pkts_acked()
272 tcp_lp_rtt_sample(sk, sample->rtt_us); in tcp_lp_pkts_acked()
275 delta = now - tp->rx_opt.rcv_tsecr; in tcp_lp_pkts_acked()
277 lp->inference = 3 * delta; in tcp_lp_pkts_acked()
280 if (lp->last_drop && (now - lp->last_drop < lp->inference)) in tcp_lp_pkts_acked()
281 lp->flag |= LP_WITHIN_INF; in tcp_lp_pkts_acked()
283 lp->flag &= ~LP_WITHIN_INF; in tcp_lp_pkts_acked()
286 if (lp->sowd >> 3 < in tcp_lp_pkts_acked()
287 lp->owd_min + 15 * (lp->owd_max - lp->owd_min) / 100) in tcp_lp_pkts_acked()
288 lp->flag |= LP_WITHIN_THR; in tcp_lp_pkts_acked()
290 lp->flag &= ~LP_WITHIN_THR; in tcp_lp_pkts_acked()
292 pr_debug("TCP-LP: %05o|%5u|%5u|%15u|%15u|%15u\n", lp->flag, in tcp_lp_pkts_acked()
293 tp->snd_cwnd, lp->remote_hz, lp->owd_min, lp->owd_max, in tcp_lp_pkts_acked()
294 lp->sowd >> 3); in tcp_lp_pkts_acked()
296 if (lp->flag & LP_WITHIN_THR) in tcp_lp_pkts_acked()
300 * so decrease the chance the min/max is no longer suitable in tcp_lp_pkts_acked()
302 lp->owd_min = lp->sowd >> 3; in tcp_lp_pkts_acked()
303 lp->owd_max = lp->sowd >> 2; in tcp_lp_pkts_acked()
304 lp->owd_max_rsv = lp->sowd >> 2; in tcp_lp_pkts_acked()
308 if (lp->flag & LP_WITHIN_INF) in tcp_lp_pkts_acked()
309 tp->snd_cwnd = 1U; in tcp_lp_pkts_acked()
314 tp->snd_cwnd = max(tp->snd_cwnd >> 1U, 1U); in tcp_lp_pkts_acked()
316 /* record this drop time */ in tcp_lp_pkts_acked()
317 lp->last_drop = now; in tcp_lp_pkts_acked()