blob: 1e861d2e1a315df6829db23971df02c9e0952bb3 [file] [log] [blame]
Patrick Ohlycb9eff02009-02-12 05:03:36 +00001/*
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),
Willem de Bruijn09c2d252014-08-04 22:11:47 -040023 SOF_TIMESTAMPING_OPT_ID = (1<<7),
24
25 SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_ID,
26 SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
27 SOF_TIMESTAMPING_LAST
Patrick Ohlycb9eff02009-02-12 05:03:36 +000028};
29
30/**
Ben Hutchingsfd468c72013-11-14 01:19:29 +000031 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
Patrick Ohlycb9eff02009-02-12 05:03:36 +000032 *
Ben Hutchingsfd468c72013-11-14 01:19:29 +000033 * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP
Patrick Ohlycb9eff02009-02-12 05:03:36 +000034 * @tx_type: one of HWTSTAMP_TX_*
Ben Hutchingse1bd1dc2013-11-14 01:05:58 +000035 * @rx_filter: one of HWTSTAMP_FILTER_*
Patrick Ohlycb9eff02009-02-12 05:03:36 +000036 *
Ben Hutchingsfd468c72013-11-14 01:19:29 +000037 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
38 * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
39 * driver or hardware does not support the requested @rx_filter value,
40 * the driver may use a more general filter mode. In this case
41 * @rx_filter will indicate the actual mode on return.
Patrick Ohlycb9eff02009-02-12 05:03:36 +000042 */
43struct hwtstamp_config {
44 int flags;
45 int tx_type;
46 int rx_filter;
47};
48
49/* possible values for hwtstamp_config->tx_type */
Richard Cochran4dc360c2011-10-19 17:00:35 -040050enum hwtstamp_tx_types {
Patrick Ohlycb9eff02009-02-12 05:03:36 +000051 /*
52 * No outgoing packet will need hardware time stamping;
53 * should a packet arrive which asks for it, no hardware
54 * time stamping will be done.
55 */
56 HWTSTAMP_TX_OFF,
57
58 /*
59 * Enables hardware time stamping for outgoing packets;
60 * the sender of the packet decides which are to be
61 * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE
62 * before sending the packet.
63 */
64 HWTSTAMP_TX_ON,
Richard Cochran3ce23fa2011-09-20 01:43:15 +000065
66 /*
67 * Enables time stamping for outgoing packets just as
68 * HWTSTAMP_TX_ON does, but also enables time stamp insertion
69 * directly into Sync packets. In this case, transmitted Sync
70 * packets will not received a time stamp via the socket error
71 * queue.
72 */
73 HWTSTAMP_TX_ONESTEP_SYNC,
Patrick Ohlycb9eff02009-02-12 05:03:36 +000074};
75
76/* possible values for hwtstamp_config->rx_filter */
Richard Cochran4dc360c2011-10-19 17:00:35 -040077enum hwtstamp_rx_filters {
Patrick Ohlycb9eff02009-02-12 05:03:36 +000078 /* time stamp no incoming packet at all */
79 HWTSTAMP_FILTER_NONE,
80
81 /* time stamp any incoming packet */
82 HWTSTAMP_FILTER_ALL,
83
84 /* return value: time stamp all packets requested plus some others */
85 HWTSTAMP_FILTER_SOME,
86
87 /* PTP v1, UDP, any kind of event packet */
88 HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
89 /* PTP v1, UDP, Sync packet */
90 HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
91 /* PTP v1, UDP, Delay_req packet */
92 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
93 /* PTP v2, UDP, any kind of event packet */
94 HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
95 /* PTP v2, UDP, Sync packet */
96 HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
97 /* PTP v2, UDP, Delay_req packet */
98 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
99
100 /* 802.AS1, Ethernet, any kind of event packet */
101 HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
102 /* 802.AS1, Ethernet, Sync packet */
103 HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
104 /* 802.AS1, Ethernet, Delay_req packet */
105 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
106
107 /* PTP v2/802.AS1, any layer, any kind of event packet */
108 HWTSTAMP_FILTER_PTP_V2_EVENT,
109 /* PTP v2/802.AS1, any layer, Sync packet */
110 HWTSTAMP_FILTER_PTP_V2_SYNC,
111 /* PTP v2/802.AS1, any layer, Delay_req packet */
112 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
113};
114
115#endif /* _NET_TIMESTAMPING_H */