net_tstamp.h 3.3 KB

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