1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*******************************************************************************
3  *
4  * Intel(R) 40-10 Gigabit Ethernet Connection Network Driver
5  * Copyright(c) 2013 - 2017 Intel Corporation.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms and conditions of the GNU General Public License,
9  * version 2, as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * The full GNU General Public License is included in this distribution in
17  * the file called "COPYING".
18  *
19  * Contact Information:
20  * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
21  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22  *
23  ******************************************************************************/
24 
25 /* Modeled on trace-events-sample.h */
26 
27 /* The trace subsystem name for i40e will be "i40e".
28  *
29  * This file is named i40e_trace.h.
30  *
31  * Since this include file's name is different from the trace
32  * subsystem name, we'll have to define TRACE_INCLUDE_FILE at the end
33  * of this file.
34  */
35 #undef TRACE_SYSTEM
36 #define TRACE_SYSTEM i40e
37 
38 /* See trace-events-sample.h for a detailed description of why this
39  * guard clause is different from most normal include files.
40  */
41 #if !defined(_I40E_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
42 #define _I40E_TRACE_H_
43 
44 #include <linux/tracepoint.h>
45 
46 /**
47  * i40e_trace() macro enables shared code to refer to trace points
48  * like:
49  *
50  * trace_i40e{,vf}_example(args...)
51  *
52  * ... as:
53  *
54  * i40e_trace(example, args...)
55  *
56  * ... to resolve to the PF or VF version of the tracepoint without
57  * ifdefs, and to allow tracepoints to be disabled entirely at build
58  * time.
59  *
60  * Trace point should always be referred to in the driver via this
61  * macro.
62  *
63  * Similarly, i40e_trace_enabled(trace_name) wraps references to
64  * trace_i40e{,vf}_<trace_name>_enabled() functions.
65  */
66 #define _I40E_TRACE_NAME(trace_name) (trace_ ## i40e ## _ ## trace_name)
67 #define I40E_TRACE_NAME(trace_name) _I40E_TRACE_NAME(trace_name)
68 
69 #define i40e_trace(trace_name, args...) I40E_TRACE_NAME(trace_name)(args)
70 
71 #define i40e_trace_enabled(trace_name) I40E_TRACE_NAME(trace_name##_enabled)()
72 
73 /* Events common to PF and VF. Corresponding versions will be defined
74  * for both, named trace_i40e_* and trace_i40evf_*. The i40e_trace()
75  * macro above will select the right trace point name for the driver
76  * being built from shared code.
77  */
78 
79 /* Events related to a vsi & ring */
80 DECLARE_EVENT_CLASS(
81 	i40e_tx_template,
82 
83 	TP_PROTO(struct i40e_ring *ring,
84 		 struct i40e_tx_desc *desc,
85 		 struct i40e_tx_buffer *buf),
86 
87 	TP_ARGS(ring, desc, buf),
88 
89 	/* The convention here is to make the first fields in the
90 	 * TP_STRUCT match the TP_PROTO exactly. This enables the use
91 	 * of the args struct generated by the tplist tool (from the
92 	 * bcc-tools package) to be used for those fields. To access
93 	 * fields other than the tracepoint args will require the
94 	 * tplist output to be adjusted.
95 	 */
96 	TP_STRUCT__entry(
97 		__field(void*, ring)
98 		__field(void*, desc)
99 		__field(void*, buf)
100 		__string(devname, ring->netdev->name)
101 	),
102 
103 	TP_fast_assign(
104 		__entry->ring = ring;
105 		__entry->desc = desc;
106 		__entry->buf = buf;
107 		__assign_str(devname, ring->netdev->name);
108 	),
109 
110 	TP_printk(
111 		"netdev: %s ring: %p desc: %p buf %p",
112 		__get_str(devname), __entry->ring,
113 		__entry->desc, __entry->buf)
114 );
115 
116 DEFINE_EVENT(
117 	i40e_tx_template, i40e_clean_tx_irq,
118 	TP_PROTO(struct i40e_ring *ring,
119 		 struct i40e_tx_desc *desc,
120 		 struct i40e_tx_buffer *buf),
121 
122 	TP_ARGS(ring, desc, buf));
123 
124 DEFINE_EVENT(
125 	i40e_tx_template, i40e_clean_tx_irq_unmap,
126 	TP_PROTO(struct i40e_ring *ring,
127 		 struct i40e_tx_desc *desc,
128 		 struct i40e_tx_buffer *buf),
129 
130 	TP_ARGS(ring, desc, buf));
131 
132 DECLARE_EVENT_CLASS(
133 	i40e_rx_template,
134 
135 	TP_PROTO(struct i40e_ring *ring,
136 		 union i40e_32byte_rx_desc *desc,
137 		 struct sk_buff *skb),
138 
139 	TP_ARGS(ring, desc, skb),
140 
141 	TP_STRUCT__entry(
142 		__field(void*, ring)
143 		__field(void*, desc)
144 		__field(void*, skb)
145 		__string(devname, ring->netdev->name)
146 	),
147 
148 	TP_fast_assign(
149 		__entry->ring = ring;
150 		__entry->desc = desc;
151 		__entry->skb = skb;
152 		__assign_str(devname, ring->netdev->name);
153 	),
154 
155 	TP_printk(
156 		"netdev: %s ring: %p desc: %p skb %p",
157 		__get_str(devname), __entry->ring,
158 		__entry->desc, __entry->skb)
159 );
160 
161 DEFINE_EVENT(
162 	i40e_rx_template, i40e_clean_rx_irq,
163 	TP_PROTO(struct i40e_ring *ring,
164 		 union i40e_32byte_rx_desc *desc,
165 		 struct sk_buff *skb),
166 
167 	TP_ARGS(ring, desc, skb));
168 
169 DEFINE_EVENT(
170 	i40e_rx_template, i40e_clean_rx_irq_rx,
171 	TP_PROTO(struct i40e_ring *ring,
172 		 union i40e_32byte_rx_desc *desc,
173 		 struct sk_buff *skb),
174 
175 	TP_ARGS(ring, desc, skb));
176 
177 DECLARE_EVENT_CLASS(
178 	i40e_xmit_template,
179 
180 	TP_PROTO(struct sk_buff *skb,
181 		 struct i40e_ring *ring),
182 
183 	TP_ARGS(skb, ring),
184 
185 	TP_STRUCT__entry(
186 		__field(void*, skb)
187 		__field(void*, ring)
188 		__string(devname, ring->netdev->name)
189 	),
190 
191 	TP_fast_assign(
192 		__entry->skb = skb;
193 		__entry->ring = ring;
194 		__assign_str(devname, ring->netdev->name);
195 	),
196 
197 	TP_printk(
198 		"netdev: %s skb: %p ring: %p",
199 		__get_str(devname), __entry->skb,
200 		__entry->ring)
201 );
202 
203 DEFINE_EVENT(
204 	i40e_xmit_template, i40e_xmit_frame_ring,
205 	TP_PROTO(struct sk_buff *skb,
206 		 struct i40e_ring *ring),
207 
208 	TP_ARGS(skb, ring));
209 
210 DEFINE_EVENT(
211 	i40e_xmit_template, i40e_xmit_frame_ring_drop,
212 	TP_PROTO(struct sk_buff *skb,
213 		 struct i40e_ring *ring),
214 
215 	TP_ARGS(skb, ring));
216 
217 /* Events unique to the PF. */
218 
219 #endif /* _I40E_TRACE_H_ */
220 /* This must be outside ifdef _I40E_TRACE_H */
221 
222 /* This trace include file is not located in the .../include/trace
223  * with the kernel tracepoint definitions, because we're a loadable
224  * module.
225  */
226 #undef TRACE_INCLUDE_PATH
227 #define TRACE_INCLUDE_PATH .
228 #undef TRACE_INCLUDE_FILE
229 #define TRACE_INCLUDE_FILE i40e_trace
230 #include <trace/define_trace.h>
231