xref: /linux/drivers/net/ethernet/intel/ice/ice_trace.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2021 Intel Corporation. */
3 
4 /* Modeled on trace-events-sample.h */
5 
6 /* The trace subsystem name for ice will be "ice".
7  *
8  * This file is named ice_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 ice
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(_ICE_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
21 #define _ICE_TRACE_H_
22 
23 #include <linux/tracepoint.h>
24 #include "ice_eswitch_br.h"
25 
26 /* ice_trace() macro enables shared code to refer to trace points
27  * like:
28  *
29  * trace_ice_example(args...)
30  *
31  * ... as:
32  *
33  * ice_trace(example, args...)
34  *
35  * ... to resolve to the PF 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, ice_trace_enabled(trace_name) wraps references to
43  * trace_ice_<trace_name>_enabled() functions.
44  * @trace_name: name of tracepoint
45  */
46 #define _ICE_TRACE_NAME(trace_name) (trace_##ice##_##trace_name)
47 #define ICE_TRACE_NAME(trace_name) _ICE_TRACE_NAME(trace_name)
48 
49 #define ice_trace(trace_name, args...) ICE_TRACE_NAME(trace_name)(args)
50 
51 #define ice_trace_enabled(trace_name) ICE_TRACE_NAME(trace_name##_enabled)()
52 
53 /* This is for events common to PF. Corresponding versions will be named
54  * trace_ice_*. The ice_trace() macro above will select the right trace point
55  * name for the driver.
56  */
57 
58 /* Begin tracepoints */
59 
60 /* Global tracepoints */
61 
62 /* Events related to DIM, q_vectors and ring containers */
63 DECLARE_EVENT_CLASS(ice_rx_dim_template,
64 		    TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
65 		    TP_ARGS(q_vector, dim),
66 		    TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
67 				     __field(struct dim *, dim)
68 				     __string(devname, q_vector->rx.rx_ring->netdev->name)),
69 
70 		    TP_fast_assign(__entry->q_vector = q_vector;
71 				   __entry->dim = dim;
72 				   __assign_str(devname);),
73 
74 		    TP_printk("netdev: %s Rx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
75 			      __get_str(devname),
76 			      __entry->q_vector->rx.rx_ring->q_index,
77 			      __entry->dim->state,
78 			      __entry->dim->profile_ix,
79 			      __entry->dim->tune_state,
80 			      __entry->dim->steps_right,
81 			      __entry->dim->steps_left,
82 			      __entry->dim->tired)
83 );
84 
85 DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work,
86 	     TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
87 	     TP_ARGS(q_vector, dim)
88 );
89 
90 DECLARE_EVENT_CLASS(ice_tx_dim_template,
91 		    TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
92 		    TP_ARGS(q_vector, dim),
93 		    TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
94 				     __field(struct dim *, dim)
95 				     __string(devname, q_vector->tx.tx_ring->netdev->name)),
96 
97 		    TP_fast_assign(__entry->q_vector = q_vector;
98 				   __entry->dim = dim;
99 				   __assign_str(devname);),
100 
101 		    TP_printk("netdev: %s Tx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
102 			      __get_str(devname),
103 			      __entry->q_vector->tx.tx_ring->q_index,
104 			      __entry->dim->state,
105 			      __entry->dim->profile_ix,
106 			      __entry->dim->tune_state,
107 			      __entry->dim->steps_right,
108 			      __entry->dim->steps_left,
109 			      __entry->dim->tired)
110 );
111 
112 DEFINE_EVENT(ice_tx_dim_template, ice_tx_dim_work,
113 	     TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
114 	     TP_ARGS(q_vector, dim)
115 );
116 
117 /* Events related to a vsi & ring */
118 DECLARE_EVENT_CLASS(ice_tx_template,
119 		    TP_PROTO(struct ice_tx_ring *ring, struct ice_tx_desc *desc,
120 			     struct ice_tx_buf *buf),
121 
122 		    TP_ARGS(ring, desc, buf),
123 		    TP_STRUCT__entry(__field(void *, ring)
124 				     __field(void *, desc)
125 				     __field(void *, buf)
126 				     __string(devname, ring->netdev->name)),
127 
128 		    TP_fast_assign(__entry->ring = ring;
129 				   __entry->desc = desc;
130 				   __entry->buf = buf;
131 				   __assign_str(devname);),
132 
133 		    TP_printk("netdev: %s ring: %pK desc: %pK buf %pK", __get_str(devname),
134 			      __entry->ring, __entry->desc, __entry->buf)
135 );
136 
137 #define DEFINE_TX_TEMPLATE_OP_EVENT(name) \
138 DEFINE_EVENT(ice_tx_template, name, \
139 	     TP_PROTO(struct ice_tx_ring *ring, \
140 		      struct ice_tx_desc *desc, \
141 		      struct ice_tx_buf *buf), \
142 	     TP_ARGS(ring, desc, buf))
143 
144 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq);
145 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap);
146 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap_eop);
147 
148 DECLARE_EVENT_CLASS(ice_rx_template,
149 		    TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc),
150 
151 		    TP_ARGS(ring, desc),
152 
153 		    TP_STRUCT__entry(__field(void *, ring)
154 				     __field(void *, desc)
155 				     __string(devname, ring->netdev->name)),
156 
157 		    TP_fast_assign(__entry->ring = ring;
158 				   __entry->desc = desc;
159 				   __assign_str(devname);),
160 
161 		    TP_printk("netdev: %s ring: %pK desc: %pK", __get_str(devname),
162 			      __entry->ring, __entry->desc)
163 );
164 DEFINE_EVENT(ice_rx_template, ice_clean_rx_irq,
165 	     TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc),
166 	     TP_ARGS(ring, desc)
167 );
168 
169 DECLARE_EVENT_CLASS(ice_rx_indicate_template,
170 		    TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc,
171 			     struct sk_buff *skb),
172 
173 		    TP_ARGS(ring, desc, skb),
174 
175 		    TP_STRUCT__entry(__field(void *, ring)
176 				     __field(void *, desc)
177 				     __field(void *, skb)
178 				     __string(devname, ring->netdev->name)),
179 
180 		    TP_fast_assign(__entry->ring = ring;
181 				   __entry->desc = desc;
182 				   __entry->skb = skb;
183 				   __assign_str(devname);),
184 
185 		    TP_printk("netdev: %s ring: %pK desc: %pK skb %pK", __get_str(devname),
186 			      __entry->ring, __entry->desc, __entry->skb)
187 );
188 
189 DEFINE_EVENT(ice_rx_indicate_template, ice_clean_rx_irq_indicate,
190 	     TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc,
191 		      struct sk_buff *skb),
192 	     TP_ARGS(ring, desc, skb)
193 );
194 
195 DECLARE_EVENT_CLASS(ice_xmit_template,
196 		    TP_PROTO(struct ice_tx_ring *ring, struct sk_buff *skb),
197 
198 		    TP_ARGS(ring, skb),
199 
200 		    TP_STRUCT__entry(__field(void *, ring)
201 				     __field(void *, skb)
202 				     __string(devname, ring->netdev->name)),
203 
204 		    TP_fast_assign(__entry->ring = ring;
205 				   __entry->skb = skb;
206 				   __assign_str(devname);),
207 
208 		    TP_printk("netdev: %s skb: %pK ring: %pK", __get_str(devname),
209 			      __entry->skb, __entry->ring)
210 );
211 
212 #define DEFINE_XMIT_TEMPLATE_OP_EVENT(name) \
213 DEFINE_EVENT(ice_xmit_template, name, \
214 	     TP_PROTO(struct ice_tx_ring *ring, struct sk_buff *skb), \
215 	     TP_ARGS(ring, skb))
216 
217 DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring);
218 DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring_drop);
219 
220 DECLARE_EVENT_CLASS(ice_tx_tstamp_template,
221 		    TP_PROTO(struct sk_buff *skb, int idx),
222 
223 		    TP_ARGS(skb, idx),
224 
225 		    TP_STRUCT__entry(__field(void *, skb)
226 				     __field(int, idx)),
227 
228 		    TP_fast_assign(__entry->skb = skb;
229 				   __entry->idx = idx;),
230 
231 		    TP_printk("skb %pK idx %d",
232 			      __entry->skb, __entry->idx)
233 );
234 #define DEFINE_TX_TSTAMP_OP_EVENT(name) \
235 DEFINE_EVENT(ice_tx_tstamp_template, name, \
236 	     TP_PROTO(struct sk_buff *skb, int idx), \
237 	     TP_ARGS(skb, idx))
238 
239 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_request);
240 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_fw_req);
241 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_fw_done);
242 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_complete);
243 
244 DECLARE_EVENT_CLASS(ice_esw_br_fdb_template,
245 		    TP_PROTO(struct ice_esw_br_fdb_entry *fdb),
246 		    TP_ARGS(fdb),
247 		    TP_STRUCT__entry(__array(char, dev_name, IFNAMSIZ)
248 				     __array(unsigned char, addr, ETH_ALEN)
249 				     __field(u16, vid)
250 				     __field(int, flags)),
251 		    TP_fast_assign(strscpy(__entry->dev_name,
252 					   netdev_name(fdb->dev),
253 					   IFNAMSIZ);
254 				   memcpy(__entry->addr, fdb->data.addr, ETH_ALEN);
255 				   __entry->vid = fdb->data.vid;
256 				   __entry->flags = fdb->flags;),
257 		    TP_printk("net_device=%s addr=%pM vid=%u flags=%x",
258 			      __entry->dev_name,
259 			      __entry->addr,
260 			      __entry->vid,
261 			      __entry->flags)
262 );
263 
264 DEFINE_EVENT(ice_esw_br_fdb_template,
265 	     ice_eswitch_br_fdb_entry_create,
266 	     TP_PROTO(struct ice_esw_br_fdb_entry *fdb),
267 	     TP_ARGS(fdb)
268 );
269 
270 DEFINE_EVENT(ice_esw_br_fdb_template,
271 	     ice_eswitch_br_fdb_entry_find_and_delete,
272 	     TP_PROTO(struct ice_esw_br_fdb_entry *fdb),
273 	     TP_ARGS(fdb)
274 );
275 
276 DECLARE_EVENT_CLASS(ice_esw_br_vlan_template,
277 		    TP_PROTO(struct ice_esw_br_vlan *vlan),
278 		    TP_ARGS(vlan),
279 		    TP_STRUCT__entry(__field(u16, vid)
280 				     __field(u16, flags)),
281 		    TP_fast_assign(__entry->vid = vlan->vid;
282 				   __entry->flags = vlan->flags;),
283 		    TP_printk("vid=%u flags=%x",
284 			      __entry->vid,
285 			      __entry->flags)
286 );
287 
288 DEFINE_EVENT(ice_esw_br_vlan_template,
289 	     ice_eswitch_br_vlan_create,
290 	     TP_PROTO(struct ice_esw_br_vlan *vlan),
291 	     TP_ARGS(vlan)
292 );
293 
294 DEFINE_EVENT(ice_esw_br_vlan_template,
295 	     ice_eswitch_br_vlan_cleanup,
296 	     TP_PROTO(struct ice_esw_br_vlan *vlan),
297 	     TP_ARGS(vlan)
298 );
299 
300 #define ICE_ESW_BR_PORT_NAME_L 16
301 
302 DECLARE_EVENT_CLASS(ice_esw_br_port_template,
303 		    TP_PROTO(struct ice_esw_br_port *port),
304 		    TP_ARGS(port),
305 		    TP_STRUCT__entry(__field(u16, vport_num)
306 				     __array(char, port_type, ICE_ESW_BR_PORT_NAME_L)),
307 		    TP_fast_assign(__entry->vport_num = port->vsi_idx;
308 					if (port->type == ICE_ESWITCH_BR_UPLINK_PORT)
309 						strscpy(__entry->port_type,
310 							"Uplink",
311 							ICE_ESW_BR_PORT_NAME_L);
312 					else
313 						strscpy(__entry->port_type,
314 							"VF Representor",
315 							ICE_ESW_BR_PORT_NAME_L);),
316 		    TP_printk("vport_num=%u port type=%s",
317 			      __entry->vport_num,
318 			      __entry->port_type)
319 );
320 
321 DEFINE_EVENT(ice_esw_br_port_template,
322 	     ice_eswitch_br_port_link,
323 	     TP_PROTO(struct ice_esw_br_port *port),
324 	     TP_ARGS(port)
325 );
326 
327 DEFINE_EVENT(ice_esw_br_port_template,
328 	     ice_eswitch_br_port_unlink,
329 	     TP_PROTO(struct ice_esw_br_port *port),
330 	     TP_ARGS(port)
331 );
332 
333 DECLARE_EVENT_CLASS(ice_switch_stats_template,
334 		    TP_PROTO(struct ice_switch_info *sw_info),
335 		    TP_ARGS(sw_info),
336 		    TP_STRUCT__entry(__field(u16, rule_cnt)
337 				     __field(u8, recp_cnt)),
338 		    TP_fast_assign(__entry->rule_cnt = sw_info->rule_cnt;
339 				   __entry->recp_cnt = sw_info->recp_cnt;),
340 		    TP_printk("rules=%u recipes=%u",
341 			      __entry->rule_cnt,
342 			      __entry->recp_cnt)
343 );
344 
345 DEFINE_EVENT(ice_switch_stats_template,
346 	     ice_aq_sw_rules,
347 	     TP_PROTO(struct ice_switch_info *sw_info),
348 	     TP_ARGS(sw_info)
349 );
350 
351 /* End tracepoints */
352 
353 #endif /* _ICE_TRACE_H_ */
354 /* This must be outside ifdef _ICE_TRACE_H */
355 
356 /* This trace include file is not located in the .../include/trace
357  * with the kernel tracepoint definitions, because we're a loadable
358  * module.
359  */
360 #undef TRACE_INCLUDE_PATH
361 #define TRACE_INCLUDE_PATH .
362 #undef TRACE_INCLUDE_FILE
363 #define TRACE_INCLUDE_FILE ../../drivers/net/ethernet/intel/ice/ice_trace
364 #include <trace/define_trace.h>
365