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