Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 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), |
Willem de Bruijn | 09c2d25 | 2014-08-04 22:11:47 -0400 | [diff] [blame] | 23 | SOF_TIMESTAMPING_OPT_ID = (1<<7), |
Willem de Bruijn | e7fd288 | 2014-08-04 22:11:48 -0400 | [diff] [blame] | 24 | SOF_TIMESTAMPING_TX_SCHED = (1<<8), |
Willem de Bruijn | e1c8a60 | 2014-08-04 22:11:50 -0400 | [diff] [blame] | 25 | SOF_TIMESTAMPING_TX_ACK = (1<<9), |
Willem de Bruijn | 829ae9d | 2014-11-30 22:22:34 -0500 | [diff] [blame^] | 26 | SOF_TIMESTAMPING_OPT_CMSG = (1<<10), |
Willem de Bruijn | 09c2d25 | 2014-08-04 22:11:47 -0400 | [diff] [blame] | 27 | |
Willem de Bruijn | 829ae9d | 2014-11-30 22:22:34 -0500 | [diff] [blame^] | 28 | SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_CMSG, |
Willem de Bruijn | 09c2d25 | 2014-08-04 22:11:47 -0400 | [diff] [blame] | 29 | SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) | |
| 30 | SOF_TIMESTAMPING_LAST |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /** |
Ben Hutchings | fd468c7 | 2013-11-14 01:19:29 +0000 | [diff] [blame] | 34 | * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 35 | * |
Ben Hutchings | fd468c7 | 2013-11-14 01:19:29 +0000 | [diff] [blame] | 36 | * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 37 | * @tx_type: one of HWTSTAMP_TX_* |
Ben Hutchings | e1bd1dc | 2013-11-14 01:05:58 +0000 | [diff] [blame] | 38 | * @rx_filter: one of HWTSTAMP_FILTER_* |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 39 | * |
Ben Hutchings | fd468c7 | 2013-11-14 01:19:29 +0000 | [diff] [blame] | 40 | * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a |
| 41 | * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the |
| 42 | * driver or hardware does not support the requested @rx_filter value, |
| 43 | * the driver may use a more general filter mode. In this case |
| 44 | * @rx_filter will indicate the actual mode on return. |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 45 | */ |
| 46 | struct hwtstamp_config { |
| 47 | int flags; |
| 48 | int tx_type; |
| 49 | int rx_filter; |
| 50 | }; |
| 51 | |
| 52 | /* possible values for hwtstamp_config->tx_type */ |
Richard Cochran | 4dc360c | 2011-10-19 17:00:35 -0400 | [diff] [blame] | 53 | enum hwtstamp_tx_types { |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 54 | /* |
| 55 | * No outgoing packet will need hardware time stamping; |
| 56 | * should a packet arrive which asks for it, no hardware |
| 57 | * time stamping will be done. |
| 58 | */ |
| 59 | HWTSTAMP_TX_OFF, |
| 60 | |
| 61 | /* |
| 62 | * Enables hardware time stamping for outgoing packets; |
| 63 | * the sender of the packet decides which are to be |
| 64 | * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE |
| 65 | * before sending the packet. |
| 66 | */ |
| 67 | HWTSTAMP_TX_ON, |
Richard Cochran | 3ce23fa | 2011-09-20 01:43:15 +0000 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * Enables time stamping for outgoing packets just as |
| 71 | * HWTSTAMP_TX_ON does, but also enables time stamp insertion |
| 72 | * directly into Sync packets. In this case, transmitted Sync |
| 73 | * packets will not received a time stamp via the socket error |
| 74 | * queue. |
| 75 | */ |
| 76 | HWTSTAMP_TX_ONESTEP_SYNC, |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /* possible values for hwtstamp_config->rx_filter */ |
Richard Cochran | 4dc360c | 2011-10-19 17:00:35 -0400 | [diff] [blame] | 80 | enum hwtstamp_rx_filters { |
Patrick Ohly | cb9eff0 | 2009-02-12 05:03:36 +0000 | [diff] [blame] | 81 | /* time stamp no incoming packet at all */ |
| 82 | HWTSTAMP_FILTER_NONE, |
| 83 | |
| 84 | /* time stamp any incoming packet */ |
| 85 | HWTSTAMP_FILTER_ALL, |
| 86 | |
| 87 | /* return value: time stamp all packets requested plus some others */ |
| 88 | HWTSTAMP_FILTER_SOME, |
| 89 | |
| 90 | /* PTP v1, UDP, any kind of event packet */ |
| 91 | HWTSTAMP_FILTER_PTP_V1_L4_EVENT, |
| 92 | /* PTP v1, UDP, Sync packet */ |
| 93 | HWTSTAMP_FILTER_PTP_V1_L4_SYNC, |
| 94 | /* PTP v1, UDP, Delay_req packet */ |
| 95 | HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ, |
| 96 | /* PTP v2, UDP, any kind of event packet */ |
| 97 | HWTSTAMP_FILTER_PTP_V2_L4_EVENT, |
| 98 | /* PTP v2, UDP, Sync packet */ |
| 99 | HWTSTAMP_FILTER_PTP_V2_L4_SYNC, |
| 100 | /* PTP v2, UDP, Delay_req packet */ |
| 101 | HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ, |
| 102 | |
| 103 | /* 802.AS1, Ethernet, any kind of event packet */ |
| 104 | HWTSTAMP_FILTER_PTP_V2_L2_EVENT, |
| 105 | /* 802.AS1, Ethernet, Sync packet */ |
| 106 | HWTSTAMP_FILTER_PTP_V2_L2_SYNC, |
| 107 | /* 802.AS1, Ethernet, Delay_req packet */ |
| 108 | HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ, |
| 109 | |
| 110 | /* PTP v2/802.AS1, any layer, any kind of event packet */ |
| 111 | HWTSTAMP_FILTER_PTP_V2_EVENT, |
| 112 | /* PTP v2/802.AS1, any layer, Sync packet */ |
| 113 | HWTSTAMP_FILTER_PTP_V2_SYNC, |
| 114 | /* PTP v2/802.AS1, any layer, Delay_req packet */ |
| 115 | HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, |
| 116 | }; |
| 117 | |
| 118 | #endif /* _NET_TIMESTAMPING_H */ |