net_tstamp.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_LAST = SOF_TIMESTAMPING_TX_ACK,
  24. SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
  25. SOF_TIMESTAMPING_LAST
  26. };
  27. /**
  28. * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
  29. *
  30. * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP
  31. * @tx_type: one of HWTSTAMP_TX_*
  32. * @rx_filter: one of HWTSTAMP_FILTER_*
  33. *
  34. * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
  35. * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
  36. * driver or hardware does not support the requested @rx_filter value,
  37. * the driver may use a more general filter mode. In this case
  38. * @rx_filter will indicate the actual mode on return.
  39. */
  40. struct hwtstamp_config {
  41. int flags;
  42. int tx_type;
  43. int rx_filter;
  44. };
  45. /* possible values for hwtstamp_config->tx_type */
  46. enum hwtstamp_tx_types {
  47. /*
  48. * No outgoing packet will need hardware time stamping;
  49. * should a packet arrive which asks for it, no hardware
  50. * time stamping will be done.
  51. */
  52. HWTSTAMP_TX_OFF,
  53. /*
  54. * Enables hardware time stamping for outgoing packets;
  55. * the sender of the packet decides which are to be
  56. * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE
  57. * before sending the packet.
  58. */
  59. HWTSTAMP_TX_ON,
  60. /*
  61. * Enables time stamping for outgoing packets just as
  62. * HWTSTAMP_TX_ON does, but also enables time stamp insertion
  63. * directly into Sync packets. In this case, transmitted Sync
  64. * packets will not received a time stamp via the socket error
  65. * queue.
  66. */
  67. HWTSTAMP_TX_ONESTEP_SYNC,
  68. };
  69. /* possible values for hwtstamp_config->rx_filter */
  70. enum hwtstamp_rx_filters {
  71. /* time stamp no incoming packet at all */
  72. HWTSTAMP_FILTER_NONE,
  73. /* time stamp any incoming packet */
  74. HWTSTAMP_FILTER_ALL,
  75. /* return value: time stamp all packets requested plus some others */
  76. HWTSTAMP_FILTER_SOME,
  77. /* PTP v1, UDP, any kind of event packet */
  78. HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
  79. /* PTP v1, UDP, Sync packet */
  80. HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
  81. /* PTP v1, UDP, Delay_req packet */
  82. HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
  83. /* PTP v2, UDP, any kind of event packet */
  84. HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
  85. /* PTP v2, UDP, Sync packet */
  86. HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
  87. /* PTP v2, UDP, Delay_req packet */
  88. HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
  89. /* 802.AS1, Ethernet, any kind of event packet */
  90. HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
  91. /* 802.AS1, Ethernet, Sync packet */
  92. HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
  93. /* 802.AS1, Ethernet, Delay_req packet */
  94. HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
  95. /* PTP v2/802.AS1, any layer, any kind of event packet */
  96. HWTSTAMP_FILTER_PTP_V2_EVENT,
  97. /* PTP v2/802.AS1, any layer, Sync packet */
  98. HWTSTAMP_FILTER_PTP_V2_SYNC,
  99. /* PTP v2/802.AS1, any layer, Delay_req packet */
  100. HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
  101. };
  102. #endif /* _NET_TIMESTAMPING_H */