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