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