net-timestamp: TCP timestamping
[linux-block.git] / include / uapi / linux / net_tstamp.h
CommitLineData
cb9eff09
PO
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/socket.h> /* for SO_TIMESTAMPING */
13
14/* SO_TIMESTAMPING gets an integer bit field comprised of these values */
15enum {
16 SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),
17 SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1),
18 SOF_TIMESTAMPING_RX_HARDWARE = (1<<2),
19 SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3),
20 SOF_TIMESTAMPING_SOFTWARE = (1<<4),
21 SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),
22 SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
09c2d251 23 SOF_TIMESTAMPING_OPT_ID = (1<<7),
e7fd2885 24 SOF_TIMESTAMPING_TX_SCHED = (1<<8),
09c2d251 25
e7fd2885 26 SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_SCHED,
09c2d251
WB
27 SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
28 SOF_TIMESTAMPING_LAST
cb9eff09
PO
29};
30
31/**
fd468c74 32 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
cb9eff09 33 *
fd468c74 34 * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP
cb9eff09 35 * @tx_type: one of HWTSTAMP_TX_*
e1bd1dc2 36 * @rx_filter: one of HWTSTAMP_FILTER_*
cb9eff09 37 *
fd468c74
BH
38 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
39 * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
40 * driver or hardware does not support the requested @rx_filter value,
41 * the driver may use a more general filter mode. In this case
42 * @rx_filter will indicate the actual mode on return.
cb9eff09
PO
43 */
44struct hwtstamp_config {
45 int flags;
46 int tx_type;
47 int rx_filter;
48};
49
50/* possible values for hwtstamp_config->tx_type */
4dc360c5 51enum hwtstamp_tx_types {
cb9eff09
PO
52 /*
53 * No outgoing packet will need hardware time stamping;
54 * should a packet arrive which asks for it, no hardware
55 * time stamping will be done.
56 */
57 HWTSTAMP_TX_OFF,
58
59 /*
60 * Enables hardware time stamping for outgoing packets;
61 * the sender of the packet decides which are to be
62 * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE
63 * before sending the packet.
64 */
65 HWTSTAMP_TX_ON,
3ce23fa9
RC
66
67 /*
68 * Enables time stamping for outgoing packets just as
69 * HWTSTAMP_TX_ON does, but also enables time stamp insertion
70 * directly into Sync packets. In this case, transmitted Sync
71 * packets will not received a time stamp via the socket error
72 * queue.
73 */
74 HWTSTAMP_TX_ONESTEP_SYNC,
cb9eff09
PO
75};
76
77/* possible values for hwtstamp_config->rx_filter */
4dc360c5 78enum hwtstamp_rx_filters {
cb9eff09
PO
79 /* time stamp no incoming packet at all */
80 HWTSTAMP_FILTER_NONE,
81
82 /* time stamp any incoming packet */
83 HWTSTAMP_FILTER_ALL,
84
85 /* return value: time stamp all packets requested plus some others */
86 HWTSTAMP_FILTER_SOME,
87
88 /* PTP v1, UDP, any kind of event packet */
89 HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
90 /* PTP v1, UDP, Sync packet */
91 HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
92 /* PTP v1, UDP, Delay_req packet */
93 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
94 /* PTP v2, UDP, any kind of event packet */
95 HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
96 /* PTP v2, UDP, Sync packet */
97 HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
98 /* PTP v2, UDP, Delay_req packet */
99 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
100
101 /* 802.AS1, Ethernet, any kind of event packet */
102 HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
103 /* 802.AS1, Ethernet, Sync packet */
104 HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
105 /* 802.AS1, Ethernet, Delay_req packet */
106 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
107
108 /* PTP v2/802.AS1, any layer, any kind of event packet */
109 HWTSTAMP_FILTER_PTP_V2_EVENT,
110 /* PTP v2/802.AS1, any layer, Sync packet */
111 HWTSTAMP_FILTER_PTP_V2_SYNC,
112 /* PTP v2/802.AS1, any layer, Delay_req packet */
113 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
114};
115
116#endif /* _NET_TIMESTAMPING_H */