port_net_events.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * If TRACE_SYSTEM is defined, that will be the directory created
  3. * in the ftrace directory under /sys/kernel/debug/tracing/events/<system>
  4. *
  5. * The define_trace.h below will also look for a file name of
  6. * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here.
  7. * In this case, it would look for sample.h
  8. *
  9. * If the header name will be different than the system name
  10. * (as in this case), then you can override the header name that
  11. * define_trace.h will look up by defining TRACE_INCLUDE_FILE
  12. *
  13. * This file is called trace-events-sample.h but we want the system
  14. * to be called "sample". Therefore we must define the name of this
  15. * file:
  16. *
  17. * #define TRACE_INCLUDE_FILE trace-events-sample
  18. *
  19. * As we do an the bottom of this file.
  20. *
  21. * Notice that TRACE_SYSTEM should be defined outside of #if
  22. * protection, just like TRACE_INCLUDE_FILE.
  23. */
  24. #undef TRACE_SYSTEM
  25. #define TRACE_SYSTEM ccci
  26. /*
  27. * Notice that this file is not protected like a normal header.
  28. * We also must allow for rereading of this file. The
  29. *
  30. * || defined(TRACE_HEADER_MULTI_READ)
  31. *
  32. * serves this purpose.
  33. */
  34. #if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ)
  35. #define _TRACE_EVENT_SAMPLE_H
  36. /*
  37. * All trace headers should include tracepoint.h, until we finally
  38. * make it into a standard header.
  39. */
  40. #include <linux/tracepoint.h>
  41. /*
  42. * The TRACE_EVENT macro is broken up into 5 parts.
  43. *
  44. * name: name of the trace point. This is also how to enable the tracepoint.
  45. * A function called trace_foo_bar() will be created.
  46. *
  47. * proto: the prototype of the function trace_foo_bar()
  48. * Here it is trace_foo_bar(char *foo, int bar).
  49. *
  50. * args: must match the arguments in the prototype.
  51. * Here it is simply "foo, bar".
  52. *
  53. * struct: This defines the way the data will be stored in the ring buffer.
  54. * There are currently two types of elements. __field and __array.
  55. * a __field is broken up into (type, name). Where type can be any
  56. * type but an array.
  57. * For an array. there are three fields. (type, name, size). The
  58. * type of elements in the array, the name of the field and the size
  59. * of the array.
  60. *
  61. * __array( char, foo, 10) is the same as saying char foo[10].
  62. *
  63. * fast_assign: This is a C like function that is used to store the items
  64. * into the ring buffer.
  65. *
  66. * printk: This is a way to print out the data in pretty print. This is
  67. * useful if the system crashes and you are logging via a serial line,
  68. * the data can be printed to the console using this "printk" method.
  69. *
  70. * Note, that for both the assign and the printk, __entry is the handler
  71. * to the data structure in the ring buffer, and is defined by the
  72. * TP_STRUCT__entry.
  73. */
  74. TRACE_EVENT(port_net_rx,
  75. TP_PROTO(unsigned int md_id, unsigned int queue_no, unsigned int ccci_ch, unsigned int rx_cb_time,
  76. unsigned int rx_total_time), TP_ARGS(md_id, queue_no, ccci_ch, rx_cb_time, rx_total_time),
  77. TP_STRUCT__entry(__field(unsigned int, md_id)
  78. __field(unsigned int, queue_no)
  79. __field(unsigned int, ccci_ch)
  80. __field(unsigned int, rx_cb_time)
  81. __field(unsigned int, rx_total_time)
  82. ),
  83. TP_fast_assign(__entry->md_id = md_id;
  84. __entry->queue_no = queue_no;
  85. __entry->ccci_ch = ccci_ch;
  86. __entry->rx_cb_time = rx_cb_time; __entry->rx_total_time = rx_total_time;
  87. ),
  88. TP_printk("md%u q%d ch%u %u %u", __entry->md_id + 1, __entry->queue_no, __entry->ccci_ch,
  89. __entry->rx_cb_time, __entry->rx_total_time)
  90. );
  91. TRACE_EVENT(port_net_tx,
  92. TP_PROTO(int md_id, unsigned int queue_no, unsigned int ccci_ch, unsigned int req_alloc_time,
  93. unsigned int send_req_time, unsigned int tx_total_time), TP_ARGS(md_id, queue_no, ccci_ch,
  94. req_alloc_time, send_req_time,
  95. tx_total_time),
  96. TP_STRUCT__entry(__field(unsigned int, md_id)
  97. __field(unsigned int, queue_no)
  98. __field(unsigned int, ccci_ch)
  99. __field(unsigned int, req_alloc_time)
  100. __field(unsigned int, send_req_time)
  101. __field(unsigned int, tx_total_time)
  102. ),
  103. TP_fast_assign(__entry->md_id = md_id;
  104. __entry->queue_no = queue_no;
  105. __entry->ccci_ch = ccci_ch;
  106. __entry->req_alloc_time = req_alloc_time;
  107. __entry->send_req_time = send_req_time; __entry->tx_total_time = tx_total_time;
  108. ),
  109. TP_printk("md%d q%u ch%u %u %u %u", __entry->md_id + 1, __entry->queue_no,
  110. __entry->ccci_ch, __entry->req_alloc_time, __entry->send_req_time, __entry->tx_total_time)
  111. );
  112. TRACE_EVENT(port_net_error,
  113. TP_PROTO(int md_id, int queue_no, unsigned int ccci_ch, unsigned int error_no, unsigned int line_no),
  114. TP_ARGS(md_id, queue_no, ccci_ch, error_no, line_no), TP_STRUCT__entry(__field(int, md_id)
  115. __field(int, queue_no)
  116. __field(int, ccci_ch)
  117. __field(unsigned int, error_no)
  118. __field(unsigned int, line_no)
  119. ),
  120. TP_fast_assign(__entry->md_id = md_id;
  121. __entry->queue_no = queue_no;
  122. __entry->ccci_ch = ccci_ch; __entry->error_no = error_no; __entry->line_no = line_no;
  123. ),
  124. TP_printk("md%d q%d ch=%d err=%u line_no=%u", (__entry->md_id + 1), __entry->queue_no,
  125. __entry->ccci_ch, __entry->error_no, __entry->line_no)
  126. );
  127. #endif
  128. /***** NOTICE! The #if protection ends here. *****/
  129. /*
  130. * There are several ways I could have done this. If I left out the
  131. * TRACE_INCLUDE_PATH, then it would default to the kernel source
  132. * include/trace/events directory.
  133. *
  134. * I could specify a path from the define_trace.h file back to this
  135. * file.
  136. *
  137. * #define TRACE_INCLUDE_PATH ../../samples/trace_events
  138. *
  139. * But the safest and easiest way to simply make it use the directory
  140. * that the file is in is to add in the Makefile:
  141. *
  142. * CFLAGS_trace-events-sample.o := -I$(src)
  143. *
  144. * This will make sure the current path is part of the include
  145. * structure for our file so that define_trace.h can find it.
  146. *
  147. * I could have made only the top level directory the include:
  148. *
  149. * CFLAGS_trace-events-sample.o := -I$(PWD)
  150. *
  151. * And then let the path to this directory be the TRACE_INCLUDE_PATH:
  152. *
  153. * #define TRACE_INCLUDE_PATH samples/trace_events
  154. *
  155. * But then if something defines "samples" or "trace_events" as a macro
  156. * then we could risk that being converted too, and give us an unexpected
  157. * result.
  158. */
  159. #undef TRACE_INCLUDE_PATH
  160. #undef TRACE_INCLUDE_FILE
  161. #define TRACE_INCLUDE_PATH .
  162. /*
  163. * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
  164. */
  165. #define TRACE_INCLUDE_FILE port_net_events
  166. #include <trace/define_trace.h>