tcp: add tcp_rtt_tsopt_us()
Before adding usec TS support, add tcp_rtt_tsopt_us() helper to factorize code. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9d0c00f5ca
commit
b04c332088
@ -693,6 +693,21 @@ new_measure:
|
||||
tp->rcv_rtt_est.time = tp->tcp_mstamp;
|
||||
}
|
||||
|
||||
static s32 tcp_rtt_tsopt_us(const struct tcp_sock *tp)
|
||||
{
|
||||
u32 delta, delta_us;
|
||||
|
||||
delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr;
|
||||
|
||||
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
|
||||
if (!delta)
|
||||
delta = 1;
|
||||
delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
|
||||
return delta_us;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
|
||||
const struct sk_buff *skb)
|
||||
{
|
||||
@ -704,15 +719,10 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
|
||||
|
||||
if (TCP_SKB_CB(skb)->end_seq -
|
||||
TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss) {
|
||||
u32 delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr;
|
||||
u32 delta_us;
|
||||
s32 delta = tcp_rtt_tsopt_us(tp);
|
||||
|
||||
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
|
||||
if (!delta)
|
||||
delta = 1;
|
||||
delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
|
||||
tcp_rcv_rtt_update(tp, delta_us, 0);
|
||||
}
|
||||
if (delta >= 0)
|
||||
tcp_rcv_rtt_update(tp, delta, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3146,17 +3156,10 @@ static bool tcp_ack_update_rtt(struct sock *sk, const int flag,
|
||||
* left edge of the send window.
|
||||
* See draft-ietf-tcplw-high-performance-00, section 3.3.
|
||||
*/
|
||||
if (seq_rtt_us < 0 && tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr &&
|
||||
flag & FLAG_ACKED) {
|
||||
u32 delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr;
|
||||
if (seq_rtt_us < 0 && tp->rx_opt.saw_tstamp &&
|
||||
tp->rx_opt.rcv_tsecr && flag & FLAG_ACKED)
|
||||
seq_rtt_us = ca_rtt_us = tcp_rtt_tsopt_us(tp);
|
||||
|
||||
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
|
||||
if (!delta)
|
||||
delta = 1;
|
||||
seq_rtt_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
|
||||
ca_rtt_us = seq_rtt_us;
|
||||
}
|
||||
}
|
||||
rs->rtt_us = ca_rtt_us; /* RTT of last (S)ACKed packet (or -1) */
|
||||
if (seq_rtt_us < 0)
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user