i40e_trace.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2013 - 2018 Intel Corporation. */
  3. /* Modeled on trace-events-sample.h */
  4. /* The trace subsystem name for i40e will be "i40e".
  5. *
  6. * This file is named i40e_trace.h.
  7. *
  8. * Since this include file's name is different from the trace
  9. * subsystem name, we'll have to define TRACE_INCLUDE_FILE at the end
  10. * of this file.
  11. */
  12. #undef TRACE_SYSTEM
  13. #define TRACE_SYSTEM i40e
  14. /* See trace-events-sample.h for a detailed description of why this
  15. * guard clause is different from most normal include files.
  16. */
  17. #if !defined(_I40E_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
  18. #define _I40E_TRACE_H_
  19. #include <linux/tracepoint.h>
  20. /*
  21. * i40e_trace() macro enables shared code to refer to trace points
  22. * like:
  23. *
  24. * trace_i40e{,vf}_example(args...)
  25. *
  26. * ... as:
  27. *
  28. * i40e_trace(example, args...)
  29. *
  30. * ... to resolve to the PF or VF version of the tracepoint without
  31. * ifdefs, and to allow tracepoints to be disabled entirely at build
  32. * time.
  33. *
  34. * Trace point should always be referred to in the driver via this
  35. * macro.
  36. *
  37. * Similarly, i40e_trace_enabled(trace_name) wraps references to
  38. * trace_i40e{,vf}_<trace_name>_enabled() functions.
  39. */
  40. #define _I40E_TRACE_NAME(trace_name) (trace_ ## i40e ## _ ## trace_name)
  41. #define I40E_TRACE_NAME(trace_name) _I40E_TRACE_NAME(trace_name)
  42. #define i40e_trace(trace_name, args...) I40E_TRACE_NAME(trace_name)(args)
  43. #define i40e_trace_enabled(trace_name) I40E_TRACE_NAME(trace_name##_enabled)()
  44. /* Events common to PF and VF. Corresponding versions will be defined
  45. * for both, named trace_i40e_* and trace_i40evf_*. The i40e_trace()
  46. * macro above will select the right trace point name for the driver
  47. * being built from shared code.
  48. */
  49. #define NO_DEV "(i40e no_device)"
  50. TRACE_EVENT(i40e_napi_poll,
  51. TP_PROTO(struct napi_struct *napi, struct i40e_q_vector *q, int budget,
  52. int budget_per_ring, unsigned int rx_cleaned, unsigned int tx_cleaned,
  53. bool rx_clean_complete, bool tx_clean_complete),
  54. TP_ARGS(napi, q, budget, budget_per_ring, rx_cleaned, tx_cleaned,
  55. rx_clean_complete, tx_clean_complete),
  56. TP_STRUCT__entry(
  57. __field(int, budget)
  58. __field(int, budget_per_ring)
  59. __field(unsigned int, rx_cleaned)
  60. __field(unsigned int, tx_cleaned)
  61. __field(int, rx_clean_complete)
  62. __field(int, tx_clean_complete)
  63. __field(int, irq_num)
  64. __field(int, curr_cpu)
  65. __string(qname, q->name)
  66. __string(dev_name, napi->dev ? napi->dev->name : NO_DEV)
  67. __bitmask(irq_affinity, nr_cpumask_bits)
  68. ),
  69. TP_fast_assign(
  70. __entry->budget = budget;
  71. __entry->budget_per_ring = budget_per_ring;
  72. __entry->rx_cleaned = rx_cleaned;
  73. __entry->tx_cleaned = tx_cleaned;
  74. __entry->rx_clean_complete = rx_clean_complete;
  75. __entry->tx_clean_complete = tx_clean_complete;
  76. __entry->irq_num = q->irq_num;
  77. __entry->curr_cpu = get_cpu();
  78. __assign_str(qname);
  79. __assign_str(dev_name);
  80. __assign_bitmask(irq_affinity, cpumask_bits(&q->affinity_mask),
  81. nr_cpumask_bits);
  82. ),
  83. TP_printk("i40e_napi_poll on dev %s q %s irq %d irq_mask %s curr_cpu %d "
  84. "budget %d bpr %d rx_cleaned %u tx_cleaned %u "
  85. "rx_clean_complete %d tx_clean_complete %d",
  86. __get_str(dev_name), __get_str(qname), __entry->irq_num,
  87. __get_bitmask(irq_affinity), __entry->curr_cpu, __entry->budget,
  88. __entry->budget_per_ring, __entry->rx_cleaned, __entry->tx_cleaned,
  89. __entry->rx_clean_complete, __entry->tx_clean_complete)
  90. );
  91. /* Events related to a vsi & ring */
  92. DECLARE_EVENT_CLASS(
  93. i40e_tx_template,
  94. TP_PROTO(struct i40e_ring *ring,
  95. struct i40e_tx_desc *desc,
  96. struct i40e_tx_buffer *buf),
  97. TP_ARGS(ring, desc, buf),
  98. /* The convention here is to make the first fields in the
  99. * TP_STRUCT match the TP_PROTO exactly. This enables the use
  100. * of the args struct generated by the tplist tool (from the
  101. * bcc-tools package) to be used for those fields. To access
  102. * fields other than the tracepoint args will require the
  103. * tplist output to be adjusted.
  104. */
  105. TP_STRUCT__entry(
  106. __field(void*, ring)
  107. __field(void*, desc)
  108. __field(void*, buf)
  109. __string(devname, ring->netdev->name)
  110. ),
  111. TP_fast_assign(
  112. __entry->ring = ring;
  113. __entry->desc = desc;
  114. __entry->buf = buf;
  115. __assign_str(devname);
  116. ),
  117. TP_printk(
  118. "netdev: %s ring: %p desc: %p buf %p",
  119. __get_str(devname), __entry->ring,
  120. __entry->desc, __entry->buf)
  121. );
  122. DEFINE_EVENT(
  123. i40e_tx_template, i40e_clean_tx_irq,
  124. TP_PROTO(struct i40e_ring *ring,
  125. struct i40e_tx_desc *desc,
  126. struct i40e_tx_buffer *buf),
  127. TP_ARGS(ring, desc, buf));
  128. DEFINE_EVENT(
  129. i40e_tx_template, i40e_clean_tx_irq_unmap,
  130. TP_PROTO(struct i40e_ring *ring,
  131. struct i40e_tx_desc *desc,
  132. struct i40e_tx_buffer *buf),
  133. TP_ARGS(ring, desc, buf));
  134. DECLARE_EVENT_CLASS(
  135. i40e_rx_template,
  136. TP_PROTO(struct i40e_ring *ring,
  137. union i40e_16byte_rx_desc *desc,
  138. struct xdp_buff *xdp),
  139. TP_ARGS(ring, desc, xdp),
  140. TP_STRUCT__entry(
  141. __field(void*, ring)
  142. __field(void*, desc)
  143. __field(void*, xdp)
  144. __string(devname, ring->netdev->name)
  145. ),
  146. TP_fast_assign(
  147. __entry->ring = ring;
  148. __entry->desc = desc;
  149. __entry->xdp = xdp;
  150. __assign_str(devname);
  151. ),
  152. TP_printk(
  153. "netdev: %s ring: %p desc: %p xdp %p",
  154. __get_str(devname), __entry->ring,
  155. __entry->desc, __entry->xdp)
  156. );
  157. DEFINE_EVENT(
  158. i40e_rx_template, i40e_clean_rx_irq,
  159. TP_PROTO(struct i40e_ring *ring,
  160. union i40e_16byte_rx_desc *desc,
  161. struct xdp_buff *xdp),
  162. TP_ARGS(ring, desc, xdp));
  163. DEFINE_EVENT(
  164. i40e_rx_template, i40e_clean_rx_irq_rx,
  165. TP_PROTO(struct i40e_ring *ring,
  166. union i40e_16byte_rx_desc *desc,
  167. struct xdp_buff *xdp),
  168. TP_ARGS(ring, desc, xdp));
  169. DECLARE_EVENT_CLASS(
  170. i40e_xmit_template,
  171. TP_PROTO(struct sk_buff *skb,
  172. struct i40e_ring *ring),
  173. TP_ARGS(skb, ring),
  174. TP_STRUCT__entry(
  175. __field(void*, skb)
  176. __field(void*, ring)
  177. __string(devname, ring->netdev->name)
  178. ),
  179. TP_fast_assign(
  180. __entry->skb = skb;
  181. __entry->ring = ring;
  182. __assign_str(devname);
  183. ),
  184. TP_printk(
  185. "netdev: %s skb: %p ring: %p",
  186. __get_str(devname), __entry->skb,
  187. __entry->ring)
  188. );
  189. DEFINE_EVENT(
  190. i40e_xmit_template, i40e_xmit_frame_ring,
  191. TP_PROTO(struct sk_buff *skb,
  192. struct i40e_ring *ring),
  193. TP_ARGS(skb, ring));
  194. DEFINE_EVENT(
  195. i40e_xmit_template, i40e_xmit_frame_ring_drop,
  196. TP_PROTO(struct sk_buff *skb,
  197. struct i40e_ring *ring),
  198. TP_ARGS(skb, ring));
  199. /* Events unique to the PF. */
  200. #endif /* _I40E_TRACE_H_ */
  201. /* This must be outside ifdef _I40E_TRACE_H */
  202. /* This trace include file is not located in the .../include/trace
  203. * with the kernel tracepoint definitions, because we're a loadable
  204. * module.
  205. */
  206. #undef TRACE_INCLUDE_PATH
  207. #define TRACE_INCLUDE_PATH .
  208. #undef TRACE_INCLUDE_FILE
  209. #define TRACE_INCLUDE_FILE i40e_trace
  210. #include <trace/define_trace.h>