1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 2 /* 3 * Userspace API for hardware time stamping of 3 * Userspace API for hardware time stamping of network packets 4 * 4 * 5 * Copyright (C) 2008,2009 Intel Corporation 5 * Copyright (C) 2008,2009 Intel Corporation 6 * Author: Patrick Ohly <patrick.ohly@intel.co 6 * Author: Patrick Ohly <patrick.ohly@intel.com> 7 * 7 * 8 */ 8 */ 9 9 10 #ifndef _NET_TIMESTAMPING_H 10 #ifndef _NET_TIMESTAMPING_H 11 #define _NET_TIMESTAMPING_H 11 #define _NET_TIMESTAMPING_H 12 12 13 #include <linux/types.h> 13 #include <linux/types.h> 14 #include <linux/socket.h> /* for SO_TIMESTAM 14 #include <linux/socket.h> /* for SO_TIMESTAMPING */ 15 15 16 /* SO_TIMESTAMPING flags */ 16 /* SO_TIMESTAMPING flags */ 17 enum { 17 enum { 18 SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), 18 SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), 19 SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1), 19 SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1), 20 SOF_TIMESTAMPING_RX_HARDWARE = (1<<2), 20 SOF_TIMESTAMPING_RX_HARDWARE = (1<<2), 21 SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3), 21 SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3), 22 SOF_TIMESTAMPING_SOFTWARE = (1<<4), 22 SOF_TIMESTAMPING_SOFTWARE = (1<<4), 23 SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5) 23 SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5), 24 SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6) 24 SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6), 25 SOF_TIMESTAMPING_OPT_ID = (1<<7), 25 SOF_TIMESTAMPING_OPT_ID = (1<<7), 26 SOF_TIMESTAMPING_TX_SCHED = (1<<8), 26 SOF_TIMESTAMPING_TX_SCHED = (1<<8), 27 SOF_TIMESTAMPING_TX_ACK = (1<<9), 27 SOF_TIMESTAMPING_TX_ACK = (1<<9), 28 SOF_TIMESTAMPING_OPT_CMSG = (1<<10), 28 SOF_TIMESTAMPING_OPT_CMSG = (1<<10), 29 SOF_TIMESTAMPING_OPT_TSONLY = (1<<11), 29 SOF_TIMESTAMPING_OPT_TSONLY = (1<<11), 30 SOF_TIMESTAMPING_OPT_STATS = (1<<12), 30 SOF_TIMESTAMPING_OPT_STATS = (1<<12), 31 SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13) 31 SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13), 32 SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14) 32 SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14), 33 SOF_TIMESTAMPING_BIND_PHC = (1 << 15), 33 SOF_TIMESTAMPING_BIND_PHC = (1 << 15), 34 SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16 34 SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16), 35 SOF_TIMESTAMPING_OPT_RX_FILTER = (1 << << 36 35 37 SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPI !! 36 SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_ID_TCP, 38 SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMP 37 SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) | 39 SOF_TIMESTAMP 38 SOF_TIMESTAMPING_LAST 40 }; 39 }; 41 40 42 /* 41 /* 43 * SO_TIMESTAMPING flags are either for record 42 * SO_TIMESTAMPING flags are either for recording a packet timestamp or for 44 * reporting the timestamp to user space. 43 * reporting the timestamp to user space. 45 * Recording flags can be set both via socket 44 * Recording flags can be set both via socket options and control messages. 46 */ 45 */ 47 #define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_T 46 #define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | \ 48 SOF_T 47 SOF_TIMESTAMPING_TX_SOFTWARE | \ 49 SOF_T 48 SOF_TIMESTAMPING_TX_SCHED | \ 50 SOF_T 49 SOF_TIMESTAMPING_TX_ACK) 51 50 52 /** 51 /** 53 * struct so_timestamping - SO_TIMESTAMPING pa 52 * struct so_timestamping - SO_TIMESTAMPING parameter 54 * 53 * 55 * @flags: SO_TIMESTAMPING flags 54 * @flags: SO_TIMESTAMPING flags 56 * @bind_phc: Index of PTP virtual clock bou 55 * @bind_phc: Index of PTP virtual clock bound to sock. This is available 57 * if flag SOF_TIMESTAMPING_BIND_ 56 * if flag SOF_TIMESTAMPING_BIND_PHC is set. 58 */ 57 */ 59 struct so_timestamping { 58 struct so_timestamping { 60 int flags; 59 int flags; 61 int bind_phc; 60 int bind_phc; 62 }; 61 }; 63 62 64 /** 63 /** 65 * struct hwtstamp_config - %SIOCGHWTSTAMP and 64 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter 66 * 65 * 67 * @flags: one of HWTSTAMP_FLAG_* 66 * @flags: one of HWTSTAMP_FLAG_* 68 * @tx_type: one of HWTSTAMP_TX_* 67 * @tx_type: one of HWTSTAMP_TX_* 69 * @rx_filter: one of HWTSTAMP_FILTER_* 68 * @rx_filter: one of HWTSTAMP_FILTER_* 70 * 69 * 71 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a 70 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a 72 * ifr_data pointer to this structure. For %S 71 * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the 73 * driver or hardware does not support the req 72 * driver or hardware does not support the requested @rx_filter value, 74 * the driver may use a more general filter mo 73 * the driver may use a more general filter mode. In this case 75 * @rx_filter will indicate the actual mode on 74 * @rx_filter will indicate the actual mode on return. 76 */ 75 */ 77 struct hwtstamp_config { 76 struct hwtstamp_config { 78 int flags; 77 int flags; 79 int tx_type; 78 int tx_type; 80 int rx_filter; 79 int rx_filter; 81 }; 80 }; 82 81 83 /* possible values for hwtstamp_config->flags 82 /* possible values for hwtstamp_config->flags */ 84 enum hwtstamp_flags { 83 enum hwtstamp_flags { 85 /* 84 /* 86 * With this flag, the user could get 85 * With this flag, the user could get bond active interface's 87 * PHC index. Note this PHC index is n 86 * PHC index. Note this PHC index is not stable as when there 88 * is a failover, the bond active inte 87 * is a failover, the bond active interface will be changed, so 89 * will be the PHC index. 88 * will be the PHC index. 90 */ 89 */ 91 HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0 90 HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0), 92 #define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTA 91 #define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTAMP_FLAG_BONDED_PHC_INDEX 93 92 94 HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BON 93 HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX, 95 HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LA 94 HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST 96 }; 95 }; 97 96 98 /* possible values for hwtstamp_config->tx_typ 97 /* possible values for hwtstamp_config->tx_type */ 99 enum hwtstamp_tx_types { 98 enum hwtstamp_tx_types { 100 /* 99 /* 101 * No outgoing packet will need hardwa 100 * No outgoing packet will need hardware time stamping; 102 * should a packet arrive which asks f 101 * should a packet arrive which asks for it, no hardware 103 * time stamping will be done. 102 * time stamping will be done. 104 */ 103 */ 105 HWTSTAMP_TX_OFF, 104 HWTSTAMP_TX_OFF, 106 105 107 /* 106 /* 108 * Enables hardware time stamping for 107 * Enables hardware time stamping for outgoing packets; 109 * the sender of the packet decides wh 108 * the sender of the packet decides which are to be 110 * time stamped by setting %SOF_TIMEST 109 * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE 111 * before sending the packet. 110 * before sending the packet. 112 */ 111 */ 113 HWTSTAMP_TX_ON, 112 HWTSTAMP_TX_ON, 114 113 115 /* 114 /* 116 * Enables time stamping for outgoing 115 * Enables time stamping for outgoing packets just as 117 * HWTSTAMP_TX_ON does, but also enabl 116 * HWTSTAMP_TX_ON does, but also enables time stamp insertion 118 * directly into Sync packets. In this 117 * directly into Sync packets. In this case, transmitted Sync 119 * packets will not received a time st 118 * packets will not received a time stamp via the socket error 120 * queue. 119 * queue. 121 */ 120 */ 122 HWTSTAMP_TX_ONESTEP_SYNC, 121 HWTSTAMP_TX_ONESTEP_SYNC, 123 122 124 /* 123 /* 125 * Same as HWTSTAMP_TX_ONESTEP_SYNC, b 124 * Same as HWTSTAMP_TX_ONESTEP_SYNC, but also enables time 126 * stamp insertion directly into PDela 125 * stamp insertion directly into PDelay_Resp packets. In this 127 * case, neither transmitted Sync nor 126 * case, neither transmitted Sync nor PDelay_Resp packets will 128 * receive a time stamp via the socket 127 * receive a time stamp via the socket error queue. 129 */ 128 */ 130 HWTSTAMP_TX_ONESTEP_P2P, 129 HWTSTAMP_TX_ONESTEP_P2P, 131 130 132 /* add new constants above here */ 131 /* add new constants above here */ 133 __HWTSTAMP_TX_CNT 132 __HWTSTAMP_TX_CNT 134 }; 133 }; 135 134 136 /* possible values for hwtstamp_config->rx_fil 135 /* possible values for hwtstamp_config->rx_filter */ 137 enum hwtstamp_rx_filters { 136 enum hwtstamp_rx_filters { 138 /* time stamp no incoming packet at al 137 /* time stamp no incoming packet at all */ 139 HWTSTAMP_FILTER_NONE, 138 HWTSTAMP_FILTER_NONE, 140 139 141 /* time stamp any incoming packet */ 140 /* time stamp any incoming packet */ 142 HWTSTAMP_FILTER_ALL, 141 HWTSTAMP_FILTER_ALL, 143 142 144 /* return value: time stamp all packet 143 /* return value: time stamp all packets requested plus some others */ 145 HWTSTAMP_FILTER_SOME, 144 HWTSTAMP_FILTER_SOME, 146 145 147 /* PTP v1, UDP, any kind of event pack 146 /* PTP v1, UDP, any kind of event packet */ 148 HWTSTAMP_FILTER_PTP_V1_L4_EVENT, 147 HWTSTAMP_FILTER_PTP_V1_L4_EVENT, 149 /* PTP v1, UDP, Sync packet */ 148 /* PTP v1, UDP, Sync packet */ 150 HWTSTAMP_FILTER_PTP_V1_L4_SYNC, 149 HWTSTAMP_FILTER_PTP_V1_L4_SYNC, 151 /* PTP v1, UDP, Delay_req packet */ 150 /* PTP v1, UDP, Delay_req packet */ 152 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ, 151 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ, 153 /* PTP v2, UDP, any kind of event pack 152 /* PTP v2, UDP, any kind of event packet */ 154 HWTSTAMP_FILTER_PTP_V2_L4_EVENT, 153 HWTSTAMP_FILTER_PTP_V2_L4_EVENT, 155 /* PTP v2, UDP, Sync packet */ 154 /* PTP v2, UDP, Sync packet */ 156 HWTSTAMP_FILTER_PTP_V2_L4_SYNC, 155 HWTSTAMP_FILTER_PTP_V2_L4_SYNC, 157 /* PTP v2, UDP, Delay_req packet */ 156 /* PTP v2, UDP, Delay_req packet */ 158 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ, 157 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ, 159 158 160 /* 802.AS1, Ethernet, any kind of even 159 /* 802.AS1, Ethernet, any kind of event packet */ 161 HWTSTAMP_FILTER_PTP_V2_L2_EVENT, 160 HWTSTAMP_FILTER_PTP_V2_L2_EVENT, 162 /* 802.AS1, Ethernet, Sync packet */ 161 /* 802.AS1, Ethernet, Sync packet */ 163 HWTSTAMP_FILTER_PTP_V2_L2_SYNC, 162 HWTSTAMP_FILTER_PTP_V2_L2_SYNC, 164 /* 802.AS1, Ethernet, Delay_req packet 163 /* 802.AS1, Ethernet, Delay_req packet */ 165 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ, 164 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ, 166 165 167 /* PTP v2/802.AS1, any layer, any kind 166 /* PTP v2/802.AS1, any layer, any kind of event packet */ 168 HWTSTAMP_FILTER_PTP_V2_EVENT, 167 HWTSTAMP_FILTER_PTP_V2_EVENT, 169 /* PTP v2/802.AS1, any layer, Sync pac 168 /* PTP v2/802.AS1, any layer, Sync packet */ 170 HWTSTAMP_FILTER_PTP_V2_SYNC, 169 HWTSTAMP_FILTER_PTP_V2_SYNC, 171 /* PTP v2/802.AS1, any layer, Delay_re 170 /* PTP v2/802.AS1, any layer, Delay_req packet */ 172 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, 171 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, 173 172 174 /* NTP, UDP, all versions and packet m 173 /* NTP, UDP, all versions and packet modes */ 175 HWTSTAMP_FILTER_NTP_ALL, 174 HWTSTAMP_FILTER_NTP_ALL, 176 175 177 /* add new constants above here */ 176 /* add new constants above here */ 178 __HWTSTAMP_FILTER_CNT 177 __HWTSTAMP_FILTER_CNT 179 }; 178 }; 180 179 181 /* SCM_TIMESTAMPING_PKTINFO control message */ 180 /* SCM_TIMESTAMPING_PKTINFO control message */ 182 struct scm_ts_pktinfo { 181 struct scm_ts_pktinfo { 183 __u32 if_index; 182 __u32 if_index; 184 __u32 pkt_length; 183 __u32 pkt_length; 185 __u32 reserved[2]; 184 __u32 reserved[2]; 186 }; 185 }; 187 186 188 /* 187 /* 189 * SO_TXTIME gets a struct sock_txtime with fl 188 * SO_TXTIME gets a struct sock_txtime with flags being an integer bit 190 * field comprised of these values. 189 * field comprised of these values. 191 */ 190 */ 192 enum txtime_flags { 191 enum txtime_flags { 193 SOF_TXTIME_DEADLINE_MODE = (1 << 0), 192 SOF_TXTIME_DEADLINE_MODE = (1 << 0), 194 SOF_TXTIME_REPORT_ERRORS = (1 << 1), 193 SOF_TXTIME_REPORT_ERRORS = (1 << 1), 195 194 196 SOF_TXTIME_FLAGS_LAST = SOF_TXTIME_REP 195 SOF_TXTIME_FLAGS_LAST = SOF_TXTIME_REPORT_ERRORS, 197 SOF_TXTIME_FLAGS_MASK = (SOF_TXTIME_FL 196 SOF_TXTIME_FLAGS_MASK = (SOF_TXTIME_FLAGS_LAST - 1) | 198 SOF_TXTIME_FL 197 SOF_TXTIME_FLAGS_LAST 199 }; 198 }; 200 199 201 struct sock_txtime { 200 struct sock_txtime { 202 __kernel_clockid_t clockid;/* ref 201 __kernel_clockid_t clockid;/* reference clockid */ 203 __u32 flags; /* as 202 __u32 flags; /* as defined by enum txtime_flags */ 204 }; 203 }; 205 204 206 #endif /* _NET_TIMESTAMPING_H */ 205 #endif /* _NET_TIMESTAMPING_H */ 207 206
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.