![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * Userspace API for hardware time stamping of network packets 0004 * 0005 * Copyright (C) 2008,2009 Intel Corporation 0006 * Author: Patrick Ohly <patrick.ohly@intel.com> 0007 * 0008 */ 0009 0010 #ifndef _NET_TIMESTAMPING_H 0011 #define _NET_TIMESTAMPING_H 0012 0013 #include <linux/types.h> 0014 #include <linux/socket.h> /* for SO_TIMESTAMPING */ 0015 0016 /* SO_TIMESTAMPING flags */ 0017 enum { 0018 SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), 0019 SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1), 0020 SOF_TIMESTAMPING_RX_HARDWARE = (1<<2), 0021 SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3), 0022 SOF_TIMESTAMPING_SOFTWARE = (1<<4), 0023 SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5), 0024 SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6), 0025 SOF_TIMESTAMPING_OPT_ID = (1<<7), 0026 SOF_TIMESTAMPING_TX_SCHED = (1<<8), 0027 SOF_TIMESTAMPING_TX_ACK = (1<<9), 0028 SOF_TIMESTAMPING_OPT_CMSG = (1<<10), 0029 SOF_TIMESTAMPING_OPT_TSONLY = (1<<11), 0030 SOF_TIMESTAMPING_OPT_STATS = (1<<12), 0031 SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13), 0032 SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14), 0033 SOF_TIMESTAMPING_BIND_PHC = (1 << 15), 0034 0035 SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_BIND_PHC, 0036 SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) | 0037 SOF_TIMESTAMPING_LAST 0038 }; 0039 0040 /* 0041 * SO_TIMESTAMPING flags are either for recording a packet timestamp or for 0042 * reporting the timestamp to user space. 0043 * Recording flags can be set both via socket options and control messages. 0044 */ 0045 #define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | \ 0046 SOF_TIMESTAMPING_TX_SOFTWARE | \ 0047 SOF_TIMESTAMPING_TX_SCHED | \ 0048 SOF_TIMESTAMPING_TX_ACK) 0049 0050 /** 0051 * struct so_timestamping - SO_TIMESTAMPING parameter 0052 * 0053 * @flags: SO_TIMESTAMPING flags 0054 * @bind_phc: Index of PTP virtual clock bound to sock. This is available 0055 * if flag SOF_TIMESTAMPING_BIND_PHC is set. 0056 */ 0057 struct so_timestamping { 0058 int flags; 0059 int bind_phc; 0060 }; 0061 0062 /** 0063 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter 0064 * 0065 * @flags: one of HWTSTAMP_FLAG_* 0066 * @tx_type: one of HWTSTAMP_TX_* 0067 * @rx_filter: one of HWTSTAMP_FILTER_* 0068 * 0069 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a 0070 * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the 0071 * driver or hardware does not support the requested @rx_filter value, 0072 * the driver may use a more general filter mode. In this case 0073 * @rx_filter will indicate the actual mode on return. 0074 */ 0075 struct hwtstamp_config { 0076 int flags; 0077 int tx_type; 0078 int rx_filter; 0079 }; 0080 0081 /* possible values for hwtstamp_config->flags */ 0082 enum hwtstamp_flags { 0083 /* 0084 * With this flag, the user could get bond active interface's 0085 * PHC index. Note this PHC index is not stable as when there 0086 * is a failover, the bond active interface will be changed, so 0087 * will be the PHC index. 0088 */ 0089 HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0), 0090 #define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTAMP_FLAG_BONDED_PHC_INDEX 0091 0092 HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX, 0093 HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST 0094 }; 0095 0096 /* possible values for hwtstamp_config->tx_type */ 0097 enum hwtstamp_tx_types { 0098 /* 0099 * No outgoing packet will need hardware time stamping; 0100 * should a packet arrive which asks for it, no hardware 0101 * time stamping will be done. 0102 */ 0103 HWTSTAMP_TX_OFF, 0104 0105 /* 0106 * Enables hardware time stamping for outgoing packets; 0107 * the sender of the packet decides which are to be 0108 * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE 0109 * before sending the packet. 0110 */ 0111 HWTSTAMP_TX_ON, 0112 0113 /* 0114 * Enables time stamping for outgoing packets just as 0115 * HWTSTAMP_TX_ON does, but also enables time stamp insertion 0116 * directly into Sync packets. In this case, transmitted Sync 0117 * packets will not received a time stamp via the socket error 0118 * queue. 0119 */ 0120 HWTSTAMP_TX_ONESTEP_SYNC, 0121 0122 /* 0123 * Same as HWTSTAMP_TX_ONESTEP_SYNC, but also enables time 0124 * stamp insertion directly into PDelay_Resp packets. In this 0125 * case, neither transmitted Sync nor PDelay_Resp packets will 0126 * receive a time stamp via the socket error queue. 0127 */ 0128 HWTSTAMP_TX_ONESTEP_P2P, 0129 0130 /* add new constants above here */ 0131 __HWTSTAMP_TX_CNT 0132 }; 0133 0134 /* possible values for hwtstamp_config->rx_filter */ 0135 enum hwtstamp_rx_filters { 0136 /* time stamp no incoming packet at all */ 0137 HWTSTAMP_FILTER_NONE, 0138 0139 /* time stamp any incoming packet */ 0140 HWTSTAMP_FILTER_ALL, 0141 0142 /* return value: time stamp all packets requested plus some others */ 0143 HWTSTAMP_FILTER_SOME, 0144 0145 /* PTP v1, UDP, any kind of event packet */ 0146 HWTSTAMP_FILTER_PTP_V1_L4_EVENT, 0147 /* PTP v1, UDP, Sync packet */ 0148 HWTSTAMP_FILTER_PTP_V1_L4_SYNC, 0149 /* PTP v1, UDP, Delay_req packet */ 0150 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ, 0151 /* PTP v2, UDP, any kind of event packet */ 0152 HWTSTAMP_FILTER_PTP_V2_L4_EVENT, 0153 /* PTP v2, UDP, Sync packet */ 0154 HWTSTAMP_FILTER_PTP_V2_L4_SYNC, 0155 /* PTP v2, UDP, Delay_req packet */ 0156 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ, 0157 0158 /* 802.AS1, Ethernet, any kind of event packet */ 0159 HWTSTAMP_FILTER_PTP_V2_L2_EVENT, 0160 /* 802.AS1, Ethernet, Sync packet */ 0161 HWTSTAMP_FILTER_PTP_V2_L2_SYNC, 0162 /* 802.AS1, Ethernet, Delay_req packet */ 0163 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ, 0164 0165 /* PTP v2/802.AS1, any layer, any kind of event packet */ 0166 HWTSTAMP_FILTER_PTP_V2_EVENT, 0167 /* PTP v2/802.AS1, any layer, Sync packet */ 0168 HWTSTAMP_FILTER_PTP_V2_SYNC, 0169 /* PTP v2/802.AS1, any layer, Delay_req packet */ 0170 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, 0171 0172 /* NTP, UDP, all versions and packet modes */ 0173 HWTSTAMP_FILTER_NTP_ALL, 0174 0175 /* add new constants above here */ 0176 __HWTSTAMP_FILTER_CNT 0177 }; 0178 0179 /* SCM_TIMESTAMPING_PKTINFO control message */ 0180 struct scm_ts_pktinfo { 0181 __u32 if_index; 0182 __u32 pkt_length; 0183 __u32 reserved[2]; 0184 }; 0185 0186 /* 0187 * SO_TXTIME gets a struct sock_txtime with flags being an integer bit 0188 * field comprised of these values. 0189 */ 0190 enum txtime_flags { 0191 SOF_TXTIME_DEADLINE_MODE = (1 << 0), 0192 SOF_TXTIME_REPORT_ERRORS = (1 << 1), 0193 0194 SOF_TXTIME_FLAGS_LAST = SOF_TXTIME_REPORT_ERRORS, 0195 SOF_TXTIME_FLAGS_MASK = (SOF_TXTIME_FLAGS_LAST - 1) | 0196 SOF_TXTIME_FLAGS_LAST 0197 }; 0198 0199 struct sock_txtime { 0200 __kernel_clockid_t clockid;/* reference clockid */ 0201 __u32 flags; /* as defined by enum txtime_flags */ 0202 }; 0203 0204 #endif /* _NET_TIMESTAMPING_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |