4cc9fb
From 13e8c7b8c8537488bc7612c11c429cec274db1f9 Mon Sep 17 00:00:00 2001
4cc9fb
From: Miroslav Lichvar <mlichvar@redhat.com>
4cc9fb
Date: Tue, 23 May 2017 16:29:29 +0200
4cc9fb
Subject: [PATCH 6/7] net_tstamp.h: sync with net-next
4cc9fb
4cc9fb
This covers kernel changes up to:
4cc9fb
4cc9fb
commit b50a5c70ffa4fd6b6da324ab54c84adf48fb17d9
4cc9fb
Author: Miroslav Lichvar <mlichvar@redhat.com>
4cc9fb
Date:   Fri May 19 17:52:40 2017 +0200
4cc9fb
4cc9fb
    net: allow simultaneous SW and HW transmit timestamping
4cc9fb
4cc9fb
    Add SOF_TIMESTAMPING_OPT_TX_SWHW option to allow an outgoing packet to
4cc9fb
    be looped to the socket's error queue with a software timestamp even
4cc9fb
    when a hardware transmit timestamp is expected to be provided by the
4cc9fb
    driver.
4cc9fb
4cc9fb
    Applications using this option will receive two separate messages from
4cc9fb
    the error queue, one with a software timestamp and the other with a
4cc9fb
    hardware timestamp. As the hardware timestamp is saved to the shared skb
4cc9fb
    info, which may happen before the first message with software timestamp
4cc9fb
    is received by the application, the hardware timestamp is copied to the
4cc9fb
    SCM_TIMESTAMPING control message only when the skb has no software
4cc9fb
    timestamp or it is an incoming packet.
4cc9fb
4cc9fb
    While changing sw_tx_timestamp(), inline it in skb_tx_timestamp() as
4cc9fb
    there are no other users.
4cc9fb
4cc9fb
    CC: Richard Cochran <richardcochran@gmail.com>
4cc9fb
    CC: Willem de Bruijn <willemb@google.com>
4cc9fb
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
4cc9fb
    Acked-by: Willem de Bruijn <willemb@google.com>
4cc9fb
    Signed-off-by: David S. Miller <davem@davemloft.net>
4cc9fb
4cc9fb
CC: Richard Cochran <richardcochran@gmail.com>
4cc9fb
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
4cc9fb
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4cc9fb
(cherry picked from commit ba800e3b4acd0692fc16013acbab2c3ac1ecfe66)
4cc9fb
---
4cc9fb
 net_tstamp-copy.h | 52 +++++++++++++++++++++++++++++++++++++++++-----------
4cc9fb
 1 file changed, 41 insertions(+), 11 deletions(-)
4cc9fb
4cc9fb
diff --git a/net_tstamp-copy.h b/net_tstamp-copy.h
4cc9fb
index ae5df12..3d421d9 100644
4cc9fb
--- a/net_tstamp-copy.h
4cc9fb
+++ b/net_tstamp-copy.h
4cc9fb
@@ -9,6 +9,7 @@
4cc9fb
 #ifndef _NET_TIMESTAMPING_H
4cc9fb
 #define _NET_TIMESTAMPING_H
4cc9fb
 
4cc9fb
+#include <linux/types.h>
4cc9fb
 #include <linux/socket.h>   /* for SO_TIMESTAMPING */
4cc9fb
 
4cc9fb
 /* SO_TIMESTAMPING gets an integer bit field comprised of these values */
4cc9fb
@@ -20,23 +21,42 @@ enum {
4cc9fb
 	SOF_TIMESTAMPING_SOFTWARE = (1<<4),
4cc9fb
 	SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),
4cc9fb
 	SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
4cc9fb
-	SOF_TIMESTAMPING_MASK =
4cc9fb
-	(SOF_TIMESTAMPING_RAW_HARDWARE - 1) |
4cc9fb
-	SOF_TIMESTAMPING_RAW_HARDWARE
4cc9fb
+	SOF_TIMESTAMPING_OPT_ID = (1<<7),
4cc9fb
+	SOF_TIMESTAMPING_TX_SCHED = (1<<8),
4cc9fb
+	SOF_TIMESTAMPING_TX_ACK = (1<<9),
4cc9fb
+	SOF_TIMESTAMPING_OPT_CMSG = (1<<10),
4cc9fb
+	SOF_TIMESTAMPING_OPT_TSONLY = (1<<11),
4cc9fb
+	SOF_TIMESTAMPING_OPT_STATS = (1<<12),
4cc9fb
+	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
4cc9fb
+	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),
4cc9fb
+
4cc9fb
+	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TX_SWHW,
4cc9fb
+	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
4cc9fb
+				 SOF_TIMESTAMPING_LAST
4cc9fb
 };
4cc9fb
 
4cc9fb
+/*
4cc9fb
+ * SO_TIMESTAMPING flags are either for recording a packet timestamp or for
4cc9fb
+ * reporting the timestamp to user space.
4cc9fb
+ * Recording flags can be set both via socket options and control messages.
4cc9fb
+ */
4cc9fb
+#define SOF_TIMESTAMPING_TX_RECORD_MASK	(SOF_TIMESTAMPING_TX_HARDWARE | \
4cc9fb
+					 SOF_TIMESTAMPING_TX_SOFTWARE | \
4cc9fb
+					 SOF_TIMESTAMPING_TX_SCHED | \
4cc9fb
+					 SOF_TIMESTAMPING_TX_ACK)
4cc9fb
+
4cc9fb
 /**
4cc9fb
- * struct hwtstamp_config - %SIOCSHWTSTAMP parameter
4cc9fb
+ * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
4cc9fb
  *
4cc9fb
- * @flags:	no flags defined right now, must be zero
4cc9fb
+ * @flags:	no flags defined right now, must be zero for %SIOCSHWTSTAMP
4cc9fb
  * @tx_type:	one of HWTSTAMP_TX_*
4cc9fb
- * @rx_type:	one of one of HWTSTAMP_FILTER_*
4cc9fb
+ * @rx_filter:	one of HWTSTAMP_FILTER_*
4cc9fb
  *
4cc9fb
- * %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to
4cc9fb
- * this structure. dev_ifsioc() in the kernel takes care of the
4cc9fb
- * translation between 32 bit userspace and 64 bit kernel. The
4cc9fb
- * structure is intentionally chosen so that it has the same layout on
4cc9fb
- * 32 and 64 bit systems, don't break this!
4cc9fb
+ * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
4cc9fb
+ * ifr_data pointer to this structure.  For %SIOCSHWTSTAMP, if the
4cc9fb
+ * driver or hardware does not support the requested @rx_filter value,
4cc9fb
+ * the driver may use a more general filter mode.  In this case
4cc9fb
+ * @rx_filter will indicate the actual mode on return.
4cc9fb
  */
4cc9fb
 struct hwtstamp_config {
4cc9fb
 	int flags;
4cc9fb
@@ -108,6 +128,16 @@ enum hwtstamp_rx_filters {
4cc9fb
 	HWTSTAMP_FILTER_PTP_V2_SYNC,
4cc9fb
 	/* PTP v2/802.AS1, any layer, Delay_req packet */
4cc9fb
 	HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
4cc9fb
+
4cc9fb
+	/* NTP, UDP, all versions and packet modes */
4cc9fb
+	HWTSTAMP_FILTER_NTP_ALL,
4cc9fb
+};
4cc9fb
+
4cc9fb
+/* SCM_TIMESTAMPING_PKTINFO control message */
4cc9fb
+struct scm_ts_pktinfo {
4cc9fb
+	__u32 if_index;
4cc9fb
+	__u32 pkt_length;
4cc9fb
+	__u32 reserved[2];
4cc9fb
 };
4cc9fb
 
4cc9fb
 #endif /* _NET_TIMESTAMPING_H */
4cc9fb
-- 
4cc9fb
1.8.3.1
4cc9fb