logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

net_tstamp.h (6163B)


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