net_tstamp.h 3.9 KB

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