Linux Audio

Check our new training course

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