]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net-timestamp: ACK timestamp for bytestreams
authorWillem de Bruijn <willemb@google.com>
Tue, 5 Aug 2014 02:11:50 +0000 (22:11 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Aug 2014 23:35:54 +0000 (16:35 -0700)
Add SOF_TIMESTAMPING_TX_ACK, a request for a tstamp when the last byte
in the send() call is acknowledged. It implements the feature for TCP.

The timestamp is generated when the TCP socket cumulative ACK is moved
beyond the tracked seqno for the first time. The feature ignores SACK
and FACK, because those acknowledge the specific byte, but not
necessarily the entire contents of the buffer up to that byte.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
include/uapi/linux/errqueue.h
include/uapi/linux/net_tstamp.h
net/ipv4/tcp_input.c
net/socket.c

index 50e1e9b3a5a54ff3039c6cc02d070e56fa249d13..11c270551d25dde53babf59f522a754b278f6dbf 100644 (file)
@@ -250,9 +250,14 @@ enum {
 
        /* generate software time stamp when entering packet scheduling */
        SKBTX_SCHED_TSTAMP = 1 << 6,
+
+       /* generate software timestamp on peer data acknowledgment */
+       SKBTX_ACK_TSTAMP = 1 << 7,
 };
 
-#define SKBTX_ANY_SW_TSTAMP    (SKBTX_SW_TSTAMP | SKBTX_SCHED_TSTAMP)
+#define SKBTX_ANY_SW_TSTAMP    (SKBTX_SW_TSTAMP    | \
+                                SKBTX_SCHED_TSTAMP | \
+                                SKBTX_ACK_TSTAMP)
 #define SKBTX_ANY_TSTAMP       (SKBTX_HW_TSTAMP | SKBTX_ANY_SW_TSTAMP)
 
 /*
index 17437cf297b714f034dd1265beae9dfc196a67c8..07bdce1f444aa892c1c36abe10c87ab9d6003daa 100644 (file)
@@ -40,6 +40,7 @@ struct scm_timestamping {
 enum {
        SCM_TSTAMP_SND,         /* driver passed skb to NIC, or HW */
        SCM_TSTAMP_SCHED,       /* data entered the packet scheduler */
+       SCM_TSTAMP_ACK,         /* data acknowledged by peer */
 };
 
 #endif /* _UAPI_LINUX_ERRQUEUE_H */
index 60733845fcdd0ab835a4ea7872515792ede703f6..ff354021bb691c5e52dde58ec5010061f3ab37b8 100644 (file)
@@ -22,8 +22,9 @@ enum {
        SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
        SOF_TIMESTAMPING_OPT_ID = (1<<7),
        SOF_TIMESTAMPING_TX_SCHED = (1<<8),
+       SOF_TIMESTAMPING_TX_ACK = (1<<9),
 
-       SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_SCHED,
+       SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_ACK,
        SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
                                 SOF_TIMESTAMPING_LAST
 };
index 6a2984507755c889974d7aac93a222940cc59f37..a3d47af01906d4436d01703a499530a4825c4a7b 100644 (file)
@@ -74,6 +74,7 @@
 #include <linux/ipsec.h>
 #include <asm/unaligned.h>
 #include <net/netdma.h>
+#include <linux/errqueue.h>
 
 int sysctl_tcp_timestamps __read_mostly = 1;
 int sysctl_tcp_window_scaling __read_mostly = 1;
@@ -3106,6 +3107,11 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
                        tp->retrans_stamp = 0;
                }
 
+               if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_ACK_TSTAMP) &&
+                   between(skb_shinfo(skb)->tskey, prior_snd_una,
+                           tp->snd_una + 1))
+                       __skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK);
+
                if (!fully_acked)
                        break;
 
index 3a2778d71631d4991cee7016e661e76901b41ab2..ae89569a2db5fe24cafec01570acef55836492db 100644 (file)
@@ -619,6 +619,8 @@ void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags)
                *tx_flags |= SKBTX_SW_TSTAMP;
        if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)
                *tx_flags |= SKBTX_SCHED_TSTAMP;
+       if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)
+               *tx_flags |= SKBTX_ACK_TSTAMP;
 
        if (sock_flag(sk, SOCK_WIFI_STATUS))
                *tx_flags |= SKBTX_WIFI_STATUS;