qdf_pkt_add_timestamp.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qdf_pkt_add_timestamp.h
  20. * This file defines HLOS agnostic functions providing external interface
  21. * for adding timestamp in packet payload.
  22. */
  23. #if !defined(_QDF_PKT_ADD_TS_H)
  24. #define _QDF_PKT_ADD_TS_H
  25. #include <qdf_nbuf.h>
  26. #include <qdf_types.h>
  27. #include <qdf_trace.h>
  28. /**
  29. * enum qdf_pkt_supported_proto - supported protocol for timestamp
  30. * @QDF_PKT_PROTO_INVAL: invalid
  31. * @QDF_PKT_PROTO_TCP: tcp protocol
  32. * @QDF_PKT_PROTO_UDP: udp protocol
  33. * @QDF_PKT_PROTO_MAX: max, keep it at last
  34. */
  35. enum qdf_pkt_supported_proto {
  36. QDF_PKT_PROTO_INVAL,
  37. QDF_PKT_PROTO_TCP,
  38. QDF_PKT_PROTO_UDP,
  39. QDF_PKT_PROTO_MAX
  40. };
  41. /**
  42. * enum qdf_pkt_timestamp_index - index of different timestamp
  43. * @QDF_PKT_TX_DRIVER_ENTRY: tx driver entry timestamp
  44. * @QDF_PKT_TX_DRIVER_EXIT: tx driver exit timestamp
  45. * @QDF_PKT_RX_DRIVER_ENTRY: rx driver entry timestamp
  46. * @QDF_PKT_RX_DRIVER_EXIT: rx driver exit timestamp
  47. * @QDF_PKT_TIMESTAMP_MAX: maximum index, keep it at last
  48. */
  49. enum qdf_pkt_timestamp_index {
  50. QDF_PKT_TX_DRIVER_ENTRY,
  51. QDF_PKT_TX_DRIVER_EXIT,
  52. QDF_PKT_RX_DRIVER_ENTRY,
  53. QDF_PKT_RX_DRIVER_EXIT,
  54. QDF_PKT_TIMESTAMP_MAX
  55. };
  56. #ifdef CONFIG_DP_PKT_ADD_TIMESTAMP
  57. #define NUM_DP_PKT_TIMESTAMP_SUPPORT 4
  58. struct ts_info {
  59. uint64_t sec;
  60. uint64_t usec;
  61. } qdf_packed;
  62. struct ts {
  63. struct ts_info ts_info[QDF_PKT_TIMESTAMP_MAX];
  64. } qdf_packed;
  65. #define QDF_PKT_PROTO_TCP_BIT (1 << QDF_PKT_PROTO_TCP)
  66. #define QDF_PKT_PROTO_UDP_BIT (1 << QDF_PKT_PROTO_UDP)
  67. struct dp_pkt_proto_info {
  68. enum qdf_pkt_supported_proto proto;
  69. uint16_t port;
  70. uint16_t offset;
  71. };
  72. struct dp_pkt_add_ts_info {
  73. uint8_t current_index;
  74. uint16_t enable_protocol_bitmap;
  75. struct dp_pkt_proto_info proto_info[NUM_DP_PKT_TIMESTAMP_SUPPORT];
  76. };
  77. /**
  78. * qdf_set_dp_pkt_add_ts_info() - set protocol/port and offset info
  79. *
  80. * @proto: protocol to timestamp
  81. * @port: destination port of protocol
  82. * @offset: offset in payload
  83. *
  84. * Return: 0 for success
  85. */
  86. int qdf_set_dp_pkt_add_ts_info(enum qdf_pkt_supported_proto proto,
  87. uint16_t port, uint16_t offset);
  88. /**
  89. * qdf_clear_dp_pkt_add_ts_info() - clear all timestamp info
  90. *
  91. * Return: none
  92. */
  93. void qdf_clear_dp_pkt_add_ts_info(void);
  94. /**
  95. * qdf_show_dp_pkt_add_ts_info() - Update buffer with configured information
  96. *
  97. * @buf: buffer pointer to get information
  98. * @size: size of the buffer
  99. *
  100. * Return: number of bytes update in buffer
  101. */
  102. int qdf_show_dp_pkt_add_ts_info(char *buf, size_t size);
  103. /**
  104. * qdf_add_dp_pkt_timestamp() - add timestamp in data payload
  105. *
  106. * @nbuf: network buffer
  107. * @index: this decides offset in payload
  108. * @time: timestamp to update
  109. *
  110. * Return: none
  111. */
  112. void qdf_add_dp_pkt_timestamp(qdf_nbuf_t nbuf,
  113. enum qdf_pkt_timestamp_index index,
  114. uint64_t time);
  115. /**
  116. * qdf_is_dp_pkt_timestamp_enabled() - check if packet timestamping is enabled
  117. *
  118. * Return: true/false
  119. */
  120. bool qdf_is_dp_pkt_timestamp_enabled(void);
  121. #else
  122. static inline
  123. int qdf_set_dp_pkt_add_ts_info(enum qdf_pkt_supported_proto proto,
  124. uint16_t port, uint16_t offset)
  125. {
  126. return 0;
  127. }
  128. static inline
  129. void qdf_clear_dp_pkt_add_ts_info(void)
  130. {
  131. }
  132. static inline
  133. int qdf_show_dp_pkt_add_ts_info(char *buf, size_t size)
  134. {
  135. return 0;
  136. }
  137. static inline
  138. void qdf_add_dp_pkt_timestamp(qdf_nbuf_t nbuf,
  139. enum qdf_pkt_timestamp_index index, uint64_t time)
  140. {
  141. }
  142. static inline
  143. bool qdf_is_dp_pkt_timestamp_enabled(void)
  144. {
  145. return false;
  146. }
  147. #endif
  148. #endif