Skip to content

Commit 9799ccb

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp: add tcp_wstamp_ns socket field
TCP will soon provide earliest departure time on TX skbs. It needs to track this in a new variable. tcp_mstamp_refresh() needs to update this variable, and became too big to stay an inline. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 142537e commit 9799ccb

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

include/linux/tcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ struct tcp_sock {
248248
syn_smc:1; /* SYN includes SMC */
249249
u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
250250

251+
u64 tcp_wstamp_ns; /* departure time for next sent data packet */
252+
251253
/* RTT measurement */
252254
u64 tcp_mstamp; /* most recent packet received/sent */
253255
u32 srtt_us; /* smoothed round trip time << 3 in usecs */

include/net/tcp.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -752,17 +752,7 @@ static inline u32 tcp_time_stamp_raw(void)
752752
return div_u64(tcp_clock_ns(), NSEC_PER_SEC / TCP_TS_HZ);
753753
}
754754

755-
756-
/* Refresh 1us clock of a TCP socket,
757-
* ensuring monotically increasing values.
758-
*/
759-
static inline void tcp_mstamp_refresh(struct tcp_sock *tp)
760-
{
761-
u64 val = tcp_clock_us();
762-
763-
if (val > tp->tcp_mstamp)
764-
tp->tcp_mstamp = val;
765-
}
755+
void tcp_mstamp_refresh(struct tcp_sock *tp);
766756

767757
static inline u32 tcp_stamp_us_delta(u64 t1, u64 t0)
768758
{

net/ipv4/tcp_output.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@
4545

4646
#include <trace/events/tcp.h>
4747

48+
/* Refresh clocks of a TCP socket,
49+
* ensuring monotically increasing values.
50+
*/
51+
void tcp_mstamp_refresh(struct tcp_sock *tp)
52+
{
53+
u64 val = tcp_clock_ns();
54+
55+
/* departure time for next data packet */
56+
if (val > tp->tcp_wstamp_ns)
57+
tp->tcp_wstamp_ns = val;
58+
59+
val = div_u64(val, NSEC_PER_USEC);
60+
if (val > tp->tcp_mstamp)
61+
tp->tcp_mstamp = val;
62+
}
63+
4864
static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
4965
int push_one, gfp_t gfp);
5066

0 commit comments

Comments
 (0)