brintos

brintos / linux-shallow public Read only

0
0
Text · 6.0 KiB · 858339d Raw
207 lines · c
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */2/*3 * Userspace API for hardware time stamping of network packets4 *5 * Copyright (C) 2008,2009 Intel Corporation6 * Author: Patrick Ohly <patrick.ohly@intel.com>7 *8 */9 10#ifndef _NET_TIMESTAMPING_H11#define _NET_TIMESTAMPING_H12 13#include <linux/types.h>14#include <linux/socket.h>   /* for SO_TIMESTAMPING */15 16/* SO_TIMESTAMPING flags */17enum {18	SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),19	SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1),20	SOF_TIMESTAMPING_RX_HARDWARE = (1<<2),21	SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3),22	SOF_TIMESTAMPING_SOFTWARE = (1<<4),23	SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),24	SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),25	SOF_TIMESTAMPING_OPT_ID = (1<<7),26	SOF_TIMESTAMPING_TX_SCHED = (1<<8),27	SOF_TIMESTAMPING_TX_ACK = (1<<9),28	SOF_TIMESTAMPING_OPT_CMSG = (1<<10),29	SOF_TIMESTAMPING_OPT_TSONLY = (1<<11),30	SOF_TIMESTAMPING_OPT_STATS = (1<<12),31	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),32	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),33	SOF_TIMESTAMPING_BIND_PHC = (1 << 15),34	SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16),35	SOF_TIMESTAMPING_OPT_RX_FILTER = (1 << 17),36 37	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_RX_FILTER,38	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |39				 SOF_TIMESTAMPING_LAST40};41 42/*43 * SO_TIMESTAMPING flags are either for recording a packet timestamp or for44 * reporting the timestamp to user space.45 * Recording flags can be set both via socket options and control messages.46 */47#define SOF_TIMESTAMPING_TX_RECORD_MASK	(SOF_TIMESTAMPING_TX_HARDWARE | \48					 SOF_TIMESTAMPING_TX_SOFTWARE | \49					 SOF_TIMESTAMPING_TX_SCHED | \50					 SOF_TIMESTAMPING_TX_ACK)51 52/**53 * struct so_timestamping - SO_TIMESTAMPING parameter54 *55 * @flags:	SO_TIMESTAMPING flags56 * @bind_phc:	Index of PTP virtual clock bound to sock. This is available57 *		if flag SOF_TIMESTAMPING_BIND_PHC is set.58 */59struct so_timestamping {60	int flags;61	int bind_phc;62};63 64/**65 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter66 *67 * @flags:	one of HWTSTAMP_FLAG_*68 * @tx_type:	one of HWTSTAMP_TX_*69 * @rx_filter:	one of HWTSTAMP_FILTER_*70 *71 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a72 * ifr_data pointer to this structure.  For %SIOCSHWTSTAMP, if the73 * driver or hardware does not support the requested @rx_filter value,74 * the driver may use a more general filter mode.  In this case75 * @rx_filter will indicate the actual mode on return.76 */77struct hwtstamp_config {78	int flags;79	int tx_type;80	int rx_filter;81};82 83/* possible values for hwtstamp_config->flags */84enum hwtstamp_flags {85	/*86	 * With this flag, the user could get bond active interface's87	 * PHC index. Note this PHC index is not stable as when there88	 * is a failover, the bond active interface will be changed, so89	 * will be the PHC index.90	 */91	HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),92#define HWTSTAMP_FLAG_BONDED_PHC_INDEX	HWTSTAMP_FLAG_BONDED_PHC_INDEX93 94	HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX,95	HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST96};97 98/* possible values for hwtstamp_config->tx_type */99enum hwtstamp_tx_types {100	/*101	 * No outgoing packet will need hardware time stamping;102	 * should a packet arrive which asks for it, no hardware103	 * time stamping will be done.104	 */105	HWTSTAMP_TX_OFF,106 107	/*108	 * Enables hardware time stamping for outgoing packets;109	 * the sender of the packet decides which are to be110	 * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE111	 * before sending the packet.112	 */113	HWTSTAMP_TX_ON,114 115	/*116	 * Enables time stamping for outgoing packets just as117	 * HWTSTAMP_TX_ON does, but also enables time stamp insertion118	 * directly into Sync packets. In this case, transmitted Sync119	 * packets will not received a time stamp via the socket error120	 * queue.121	 */122	HWTSTAMP_TX_ONESTEP_SYNC,123 124	/*125	 * Same as HWTSTAMP_TX_ONESTEP_SYNC, but also enables time126	 * stamp insertion directly into PDelay_Resp packets. In this127	 * case, neither transmitted Sync nor PDelay_Resp packets will128	 * receive a time stamp via the socket error queue.129	 */130	HWTSTAMP_TX_ONESTEP_P2P,131 132	/* add new constants above here */133	__HWTSTAMP_TX_CNT134};135 136/* possible values for hwtstamp_config->rx_filter */137enum hwtstamp_rx_filters {138	/* time stamp no incoming packet at all */139	HWTSTAMP_FILTER_NONE,140 141	/* time stamp any incoming packet */142	HWTSTAMP_FILTER_ALL,143 144	/* return value: time stamp all packets requested plus some others */145	HWTSTAMP_FILTER_SOME,146 147	/* PTP v1, UDP, any kind of event packet */148	HWTSTAMP_FILTER_PTP_V1_L4_EVENT,149	/* PTP v1, UDP, Sync packet */150	HWTSTAMP_FILTER_PTP_V1_L4_SYNC,151	/* PTP v1, UDP, Delay_req packet */152	HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,153	/* PTP v2, UDP, any kind of event packet */154	HWTSTAMP_FILTER_PTP_V2_L4_EVENT,155	/* PTP v2, UDP, Sync packet */156	HWTSTAMP_FILTER_PTP_V2_L4_SYNC,157	/* PTP v2, UDP, Delay_req packet */158	HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,159 160	/* 802.AS1, Ethernet, any kind of event packet */161	HWTSTAMP_FILTER_PTP_V2_L2_EVENT,162	/* 802.AS1, Ethernet, Sync packet */163	HWTSTAMP_FILTER_PTP_V2_L2_SYNC,164	/* 802.AS1, Ethernet, Delay_req packet */165	HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,166 167	/* PTP v2/802.AS1, any layer, any kind of event packet */168	HWTSTAMP_FILTER_PTP_V2_EVENT,169	/* PTP v2/802.AS1, any layer, Sync packet */170	HWTSTAMP_FILTER_PTP_V2_SYNC,171	/* PTP v2/802.AS1, any layer, Delay_req packet */172	HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,173 174	/* NTP, UDP, all versions and packet modes */175	HWTSTAMP_FILTER_NTP_ALL,176 177	/* add new constants above here */178	__HWTSTAMP_FILTER_CNT179};180 181/* SCM_TIMESTAMPING_PKTINFO control message */182struct scm_ts_pktinfo {183	__u32 if_index;184	__u32 pkt_length;185	__u32 reserved[2];186};187 188/*189 * SO_TXTIME gets a struct sock_txtime with flags being an integer bit190 * field comprised of these values.191 */192enum txtime_flags {193	SOF_TXTIME_DEADLINE_MODE = (1 << 0),194	SOF_TXTIME_REPORT_ERRORS = (1 << 1),195 196	SOF_TXTIME_FLAGS_LAST = SOF_TXTIME_REPORT_ERRORS,197	SOF_TXTIME_FLAGS_MASK = (SOF_TXTIME_FLAGS_LAST - 1) |198				 SOF_TXTIME_FLAGS_LAST199};200 201struct sock_txtime {202	__kernel_clockid_t	clockid;/* reference clockid */203	__u32			flags;	/* as defined by enum txtime_flags */204};205 206#endif /* _NET_TIMESTAMPING_H */207