Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[sfrench/cifs-2.6.git] / include / uapi / linux / net_tstamp.h
1 /*
2  * Userspace API for hardware time stamping of network packets
3  *
4  * Copyright (C) 2008,2009 Intel Corporation
5  * Author: Patrick Ohly <patrick.ohly@intel.com>
6  *
7  */
8
9 #ifndef _NET_TIMESTAMPING_H
10 #define _NET_TIMESTAMPING_H
11
12 #include <linux/types.h>
13 #include <linux/socket.h>   /* for SO_TIMESTAMPING */
14
15 /* SO_TIMESTAMPING gets an integer bit field comprised of these values */
16 enum {
17         SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),
18         SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1),
19         SOF_TIMESTAMPING_RX_HARDWARE = (1<<2),
20         SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3),
21         SOF_TIMESTAMPING_SOFTWARE = (1<<4),
22         SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),
23         SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
24         SOF_TIMESTAMPING_OPT_ID = (1<<7),
25         SOF_TIMESTAMPING_TX_SCHED = (1<<8),
26         SOF_TIMESTAMPING_TX_ACK = (1<<9),
27         SOF_TIMESTAMPING_OPT_CMSG = (1<<10),
28         SOF_TIMESTAMPING_OPT_TSONLY = (1<<11),
29         SOF_TIMESTAMPING_OPT_STATS = (1<<12),
30         SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
31         SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),
32
33         SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TX_SWHW,
34         SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
35                                  SOF_TIMESTAMPING_LAST
36 };
37
38 /*
39  * SO_TIMESTAMPING flags are either for recording a packet timestamp or for
40  * reporting the timestamp to user space.
41  * Recording flags can be set both via socket options and control messages.
42  */
43 #define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | \
44                                          SOF_TIMESTAMPING_TX_SOFTWARE | \
45                                          SOF_TIMESTAMPING_TX_SCHED | \
46                                          SOF_TIMESTAMPING_TX_ACK)
47
48 /**
49  * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
50  *
51  * @flags:      no flags defined right now, must be zero for %SIOCSHWTSTAMP
52  * @tx_type:    one of HWTSTAMP_TX_*
53  * @rx_filter:  one of HWTSTAMP_FILTER_*
54  *
55  * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
56  * ifr_data pointer to this structure.  For %SIOCSHWTSTAMP, if the
57  * driver or hardware does not support the requested @rx_filter value,
58  * the driver may use a more general filter mode.  In this case
59  * @rx_filter will indicate the actual mode on return.
60  */
61 struct hwtstamp_config {
62         int flags;
63         int tx_type;
64         int rx_filter;
65 };
66
67 /* possible values for hwtstamp_config->tx_type */
68 enum hwtstamp_tx_types {
69         /*
70          * No outgoing packet will need hardware time stamping;
71          * should a packet arrive which asks for it, no hardware
72          * time stamping will be done.
73          */
74         HWTSTAMP_TX_OFF,
75
76         /*
77          * Enables hardware time stamping for outgoing packets;
78          * the sender of the packet decides which are to be
79          * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE
80          * before sending the packet.
81          */
82         HWTSTAMP_TX_ON,
83
84         /*
85          * Enables time stamping for outgoing packets just as
86          * HWTSTAMP_TX_ON does, but also enables time stamp insertion
87          * directly into Sync packets. In this case, transmitted Sync
88          * packets will not received a time stamp via the socket error
89          * queue.
90          */
91         HWTSTAMP_TX_ONESTEP_SYNC,
92 };
93
94 /* possible values for hwtstamp_config->rx_filter */
95 enum hwtstamp_rx_filters {
96         /* time stamp no incoming packet at all */
97         HWTSTAMP_FILTER_NONE,
98
99         /* time stamp any incoming packet */
100         HWTSTAMP_FILTER_ALL,
101
102         /* return value: time stamp all packets requested plus some others */
103         HWTSTAMP_FILTER_SOME,
104
105         /* PTP v1, UDP, any kind of event packet */
106         HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
107         /* PTP v1, UDP, Sync packet */
108         HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
109         /* PTP v1, UDP, Delay_req packet */
110         HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
111         /* PTP v2, UDP, any kind of event packet */
112         HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
113         /* PTP v2, UDP, Sync packet */
114         HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
115         /* PTP v2, UDP, Delay_req packet */
116         HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
117
118         /* 802.AS1, Ethernet, any kind of event packet */
119         HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
120         /* 802.AS1, Ethernet, Sync packet */
121         HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
122         /* 802.AS1, Ethernet, Delay_req packet */
123         HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
124
125         /* PTP v2/802.AS1, any layer, any kind of event packet */
126         HWTSTAMP_FILTER_PTP_V2_EVENT,
127         /* PTP v2/802.AS1, any layer, Sync packet */
128         HWTSTAMP_FILTER_PTP_V2_SYNC,
129         /* PTP v2/802.AS1, any layer, Delay_req packet */
130         HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
131
132         /* NTP, UDP, all versions and packet modes */
133         HWTSTAMP_FILTER_NTP_ALL,
134 };
135
136 /* SCM_TIMESTAMPING_PKTINFO control message */
137 struct scm_ts_pktinfo {
138         __u32 if_index;
139         __u32 pkt_length;
140         __u32 reserved[2];
141 };
142
143 #endif /* _NET_TIMESTAMPING_H */