1 /* SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB */
2 /* Copyright (c) 2019 - 2021 Intel Corporation */
3 #if !defined(__TRACE_CM_H) || defined(TRACE_HEADER_MULTI_READ)
4 #define __TRACE_CM_H
5 
6 #include <linux/tracepoint.h>
7 #include <linux/trace_seq.h>
8 
9 #include "main.h"
10 
11 const char *print_ip_addr(struct trace_seq *p, u32 *addr, u16 port, bool ivp4);
12 const char *parse_iw_event_type(enum iw_cm_event_type iw_type);
13 const char *parse_cm_event_type(enum irdma_cm_event_type cm_type);
14 const char *parse_cm_state(enum irdma_cm_node_state);
15 #define __print_ip_addr(addr, port, ipv4) print_ip_addr(p, addr, port, ipv4)
16 
17 #undef TRACE_SYSTEM
18 #define TRACE_SYSTEM irdma_cm
19 
20 TRACE_EVENT(irdma_create_listen,
21 	    TP_PROTO(struct irdma_device *iwdev, struct irdma_cm_info *cm_info),
22 	    TP_ARGS(iwdev, cm_info),
23 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
24 			     __dynamic_array(u32, laddr, 4)
25 			     __field(u16, lport)
26 			     __field(bool, ipv4)
27 		    ),
28 	    TP_fast_assign(__entry->iwdev = iwdev;
29 			   __entry->lport = cm_info->loc_port;
30 			   __entry->ipv4 = cm_info->ipv4;
31 			   memcpy(__get_dynamic_array(laddr),
32 				  cm_info->loc_addr, 4);
33 		    ),
34 	    TP_printk("iwdev=%p  loc: %s",
35 		      __entry->iwdev,
36 		      __print_ip_addr(__get_dynamic_array(laddr),
37 				      __entry->lport, __entry->ipv4)
38 		    )
39 );
40 
41 TRACE_EVENT(irdma_dec_refcnt_listen,
42 	    TP_PROTO(struct irdma_cm_listener *listener, void *caller),
43 	    TP_ARGS(listener, caller),
44 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
45 		    __field(u32, refcnt)
46 		    __dynamic_array(u32, laddr, 4)
47 		    __field(u16, lport)
48 		    __field(bool, ipv4)
49 		    __field(void *, caller)
50 		    ),
51 	    TP_fast_assign(__entry->iwdev = listener->iwdev;
52 			   __entry->lport = listener->loc_port;
53 			   __entry->ipv4 = listener->ipv4;
54 			   memcpy(__get_dynamic_array(laddr),
55 				  listener->loc_addr, 4);
56 		    ),
57 	    TP_printk("iwdev=%p  caller=%pS  loc: %s",
58 		      __entry->iwdev,
59 		      __entry->caller,
60 		      __print_ip_addr(__get_dynamic_array(laddr),
61 				      __entry->lport, __entry->ipv4)
62 		    )
63 );
64 
65 DECLARE_EVENT_CLASS(listener_template,
66 		    TP_PROTO(struct irdma_cm_listener *listener),
67 		    TP_ARGS(listener),
68 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
69 				     __field(u16, lport)
70 				     __field(u16, vlan_id)
71 				     __field(bool, ipv4)
72 				     __field(enum irdma_cm_listener_state,
73 					     state)
74 				     __dynamic_array(u32, laddr, 4)
75 			    ),
76 		    TP_fast_assign(__entry->iwdev = listener->iwdev;
77 				   __entry->lport = listener->loc_port;
78 				   __entry->vlan_id = listener->vlan_id;
79 				   __entry->ipv4 = listener->ipv4;
80 				   __entry->state = listener->listener_state;
81 				   memcpy(__get_dynamic_array(laddr),
82 					  listener->loc_addr, 4);
83 			    ),
84 		    TP_printk("iwdev=%p  vlan=%d  loc: %s",
85 			      __entry->iwdev,
86 			      __entry->vlan_id,
87 			      __print_ip_addr(__get_dynamic_array(laddr),
88 					      __entry->lport, __entry->ipv4)
89 			    )
90 );
91 
92 DEFINE_EVENT(listener_template, irdma_find_listener,
93 	     TP_PROTO(struct irdma_cm_listener *listener),
94 	     TP_ARGS(listener));
95 
96 DEFINE_EVENT(listener_template, irdma_del_multiple_qhash,
97 	     TP_PROTO(struct irdma_cm_listener *listener),
98 	     TP_ARGS(listener));
99 
100 TRACE_EVENT(irdma_negotiate_mpa_v2,
101 	    TP_PROTO(struct irdma_cm_node *cm_node),
102 	    TP_ARGS(cm_node),
103 	    TP_STRUCT__entry(__field(struct irdma_cm_node *, cm_node)
104 			     __field(u16, ord_size)
105 			     __field(u16, ird_size)
106 		    ),
107 	    TP_fast_assign(__entry->cm_node = cm_node;
108 			   __entry->ord_size = cm_node->ord_size;
109 			   __entry->ird_size = cm_node->ird_size;
110 		    ),
111 	    TP_printk("MPVA2 Negotiated cm_node=%p ORD:[%d], IRD:[%d]",
112 		      __entry->cm_node,
113 		      __entry->ord_size,
114 		      __entry->ird_size
115 		    )
116 );
117 
118 DECLARE_EVENT_CLASS(tos_template,
119 		    TP_PROTO(struct irdma_device *iwdev, u8 tos, u8 user_pri),
120 		    TP_ARGS(iwdev, tos, user_pri),
121 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
122 				     __field(u8, tos)
123 				     __field(u8, user_pri)
124 			    ),
125 		    TP_fast_assign(__entry->iwdev = iwdev;
126 				   __entry->tos = tos;
127 				   __entry->user_pri = user_pri;
128 			    ),
129 		    TP_printk("iwdev=%p  TOS:[%d]  UP:[%d]",
130 			      __entry->iwdev,
131 			      __entry->tos,
132 			      __entry->user_pri
133 			    )
134 );
135 
136 DEFINE_EVENT(tos_template, irdma_listener_tos,
137 	     TP_PROTO(struct irdma_device *iwdev, u8 tos, u8 user_pri),
138 	     TP_ARGS(iwdev, tos, user_pri));
139 
140 DEFINE_EVENT(tos_template, irdma_dcb_tos,
141 	     TP_PROTO(struct irdma_device *iwdev, u8 tos, u8 user_pri),
142 	     TP_ARGS(iwdev, tos, user_pri));
143 
144 DECLARE_EVENT_CLASS(qhash_template,
145 		    TP_PROTO(struct irdma_device *iwdev,
146 			     struct irdma_cm_listener *listener,
147 			     char *dev_addr),
148 		    TP_ARGS(iwdev, listener, dev_addr),
149 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
150 				     __field(u16, lport)
151 				     __field(u16, vlan_id)
152 				     __field(bool, ipv4)
153 				     __dynamic_array(u32, laddr, 4)
154 				     __dynamic_array(u32, mac, ETH_ALEN)
155 			    ),
156 		    TP_fast_assign(__entry->iwdev = iwdev;
157 				   __entry->lport = listener->loc_port;
158 				   __entry->vlan_id = listener->vlan_id;
159 				   __entry->ipv4 = listener->ipv4;
160 				   memcpy(__get_dynamic_array(laddr),
161 					  listener->loc_addr, 4);
162 				   ether_addr_copy(__get_dynamic_array(mac),
163 						   dev_addr);
164 			    ),
165 		    TP_printk("iwdev=%p  vlan=%d  MAC=%6phC  loc: %s",
166 			      __entry->iwdev,
167 			      __entry->vlan_id,
168 			      __get_dynamic_array(mac),
169 			      __print_ip_addr(__get_dynamic_array(laddr),
170 					      __entry->lport, __entry->ipv4)
171 		    )
172 );
173 
174 DEFINE_EVENT(qhash_template, irdma_add_mqh_6,
175 	     TP_PROTO(struct irdma_device *iwdev,
176 		      struct irdma_cm_listener *listener, char *dev_addr),
177 	     TP_ARGS(iwdev, listener, dev_addr));
178 
179 DEFINE_EVENT(qhash_template, irdma_add_mqh_4,
180 	     TP_PROTO(struct irdma_device *iwdev,
181 		      struct irdma_cm_listener *listener, char *dev_addr),
182 	     TP_ARGS(iwdev, listener, dev_addr));
183 
184 TRACE_EVENT(irdma_addr_resolve,
185 	    TP_PROTO(struct irdma_device *iwdev, char *dev_addr),
186 	    TP_ARGS(iwdev, dev_addr),
187 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
188 		    __dynamic_array(u8, mac, ETH_ALEN)
189 		    ),
190 	    TP_fast_assign(__entry->iwdev = iwdev;
191 		    ether_addr_copy(__get_dynamic_array(mac), dev_addr);
192 		    ),
193 	    TP_printk("iwdev=%p   MAC=%6phC", __entry->iwdev,
194 		      __get_dynamic_array(mac)
195 		    )
196 );
197 
198 TRACE_EVENT(irdma_send_cm_event,
199 	    TP_PROTO(struct irdma_cm_node *cm_node, struct iw_cm_id *cm_id,
200 		     enum iw_cm_event_type type, int status, void *caller),
201 	    TP_ARGS(cm_node, cm_id, type, status, caller),
202 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
203 			     __field(struct irdma_cm_node *, cm_node)
204 			     __field(struct iw_cm_id *, cm_id)
205 			     __field(u32, refcount)
206 			     __field(u16, lport)
207 			     __field(u16, rport)
208 			     __field(enum irdma_cm_node_state, state)
209 			     __field(bool, ipv4)
210 			     __field(u16, vlan_id)
211 			     __field(int, accel)
212 			     __field(enum iw_cm_event_type, type)
213 			     __field(int, status)
214 			     __field(void *, caller)
215 			     __dynamic_array(u32, laddr, 4)
216 			     __dynamic_array(u32, raddr, 4)
217 		    ),
218 	    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
219 			   __entry->cm_node = cm_node;
220 			   __entry->cm_id = cm_id;
221 			   __entry->refcount = refcount_read(&cm_node->refcnt);
222 			   __entry->state = cm_node->state;
223 			   __entry->lport = cm_node->loc_port;
224 			   __entry->rport = cm_node->rem_port;
225 			   __entry->ipv4 = cm_node->ipv4;
226 			   __entry->vlan_id = cm_node->vlan_id;
227 			   __entry->accel = cm_node->accelerated;
228 			   __entry->type = type;
229 			   __entry->status = status;
230 			   __entry->caller = caller;
231 			   memcpy(__get_dynamic_array(laddr),
232 				  cm_node->loc_addr, 4);
233 			   memcpy(__get_dynamic_array(raddr),
234 				  cm_node->rem_addr, 4);
235 		    ),
236 	    TP_printk("iwdev=%p  caller=%pS  cm_id=%p  node=%p  refcnt=%d  vlan_id=%d  accel=%d  state=%s  event_type=%s  status=%d  loc: %s  rem: %s",
237 		      __entry->iwdev,
238 		      __entry->caller,
239 		      __entry->cm_id,
240 		      __entry->cm_node,
241 		      __entry->refcount,
242 		      __entry->vlan_id,
243 		      __entry->accel,
244 		      parse_cm_state(__entry->state),
245 		      parse_iw_event_type(__entry->type),
246 		      __entry->status,
247 		      __print_ip_addr(__get_dynamic_array(laddr),
248 				      __entry->lport, __entry->ipv4),
249 		      __print_ip_addr(__get_dynamic_array(raddr),
250 				      __entry->rport, __entry->ipv4)
251 		    )
252 );
253 
254 TRACE_EVENT(irdma_send_cm_event_no_node,
255 	    TP_PROTO(struct iw_cm_id *cm_id, enum iw_cm_event_type type,
256 		     int status, void *caller),
257 	    TP_ARGS(cm_id, type, status, caller),
258 	    TP_STRUCT__entry(__field(struct iw_cm_id *, cm_id)
259 			     __field(enum iw_cm_event_type, type)
260 			     __field(int, status)
261 			     __field(void *, caller)
262 		    ),
263 	    TP_fast_assign(__entry->cm_id = cm_id;
264 			   __entry->type = type;
265 			   __entry->status = status;
266 			   __entry->caller = caller;
267 		    ),
268 	    TP_printk("cm_id=%p  caller=%pS  event_type=%s  status=%d",
269 		      __entry->cm_id,
270 		      __entry->caller,
271 		      parse_iw_event_type(__entry->type),
272 		      __entry->status
273 		    )
274 );
275 
276 DECLARE_EVENT_CLASS(cm_node_template,
277 		    TP_PROTO(struct irdma_cm_node *cm_node,
278 			     enum irdma_cm_event_type type, void *caller),
279 		    TP_ARGS(cm_node, type, caller),
280 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
281 				     __field(struct irdma_cm_node *, cm_node)
282 				     __field(u32, refcount)
283 				     __field(u16, lport)
284 				     __field(u16, rport)
285 				     __field(enum irdma_cm_node_state, state)
286 				     __field(bool, ipv4)
287 				     __field(u16, vlan_id)
288 				     __field(int, accel)
289 				     __field(enum irdma_cm_event_type, type)
290 				     __field(void *, caller)
291 				     __dynamic_array(u32, laddr, 4)
292 				     __dynamic_array(u32, raddr, 4)
293 			    ),
294 		    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
295 				   __entry->cm_node = cm_node;
296 				   __entry->refcount = refcount_read(&cm_node->refcnt);
297 				   __entry->state = cm_node->state;
298 				   __entry->lport = cm_node->loc_port;
299 				   __entry->rport = cm_node->rem_port;
300 				   __entry->ipv4 = cm_node->ipv4;
301 				   __entry->vlan_id = cm_node->vlan_id;
302 				   __entry->accel = cm_node->accelerated;
303 				   __entry->type = type;
304 				   __entry->caller = caller;
305 				   memcpy(__get_dynamic_array(laddr),
306 					  cm_node->loc_addr, 4);
307 				   memcpy(__get_dynamic_array(raddr),
308 					  cm_node->rem_addr, 4);
309 			    ),
310 		    TP_printk("iwdev=%p  caller=%pS  node=%p  refcnt=%d  vlan_id=%d  accel=%d  state=%s  event_type=%s  loc: %s  rem: %s",
311 			      __entry->iwdev,
312 			      __entry->caller,
313 			      __entry->cm_node,
314 			      __entry->refcount,
315 			      __entry->vlan_id,
316 			      __entry->accel,
317 			      parse_cm_state(__entry->state),
318 			      parse_cm_event_type(__entry->type),
319 			      __print_ip_addr(__get_dynamic_array(laddr),
320 					      __entry->lport, __entry->ipv4),
321 			      __print_ip_addr(__get_dynamic_array(raddr),
322 					      __entry->rport, __entry->ipv4)
323 		    )
324 );
325 
326 DEFINE_EVENT(cm_node_template, irdma_create_event,
327 	     TP_PROTO(struct irdma_cm_node *cm_node,
328 		      enum irdma_cm_event_type type, void *caller),
329 	     TP_ARGS(cm_node, type, caller));
330 
331 DEFINE_EVENT(cm_node_template, irdma_accept,
332 	     TP_PROTO(struct irdma_cm_node *cm_node,
333 		      enum irdma_cm_event_type type, void *caller),
334 	     TP_ARGS(cm_node, type, caller));
335 
336 DEFINE_EVENT(cm_node_template, irdma_connect,
337 	     TP_PROTO(struct irdma_cm_node *cm_node,
338 		      enum irdma_cm_event_type type, void *caller),
339 	     TP_ARGS(cm_node, type, caller));
340 
341 DEFINE_EVENT(cm_node_template, irdma_reject,
342 	     TP_PROTO(struct irdma_cm_node *cm_node,
343 		      enum irdma_cm_event_type type, void *caller),
344 	     TP_ARGS(cm_node, type, caller));
345 
346 DEFINE_EVENT(cm_node_template, irdma_find_node,
347 	     TP_PROTO(struct irdma_cm_node *cm_node,
348 		      enum irdma_cm_event_type type, void *caller),
349 	     TP_ARGS(cm_node, type, caller));
350 
351 DEFINE_EVENT(cm_node_template, irdma_send_reset,
352 	     TP_PROTO(struct irdma_cm_node *cm_node,
353 		      enum irdma_cm_event_type type, void *caller),
354 	     TP_ARGS(cm_node, type, caller));
355 
356 DEFINE_EVENT(cm_node_template, irdma_rem_ref_cm_node,
357 	     TP_PROTO(struct irdma_cm_node *cm_node,
358 		      enum irdma_cm_event_type type, void *caller),
359 	     TP_ARGS(cm_node, type, caller));
360 
361 DEFINE_EVENT(cm_node_template, irdma_cm_event_handler,
362 	     TP_PROTO(struct irdma_cm_node *cm_node,
363 		      enum irdma_cm_event_type type, void *caller),
364 	     TP_ARGS(cm_node, type, caller));
365 
366 TRACE_EVENT(open_err_template,
367 	    TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
368 	    TP_ARGS(cm_node, reset, caller),
369 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
370 			     __field(struct irdma_cm_node *, cm_node)
371 			     __field(enum irdma_cm_node_state, state)
372 			     __field(bool, reset)
373 			     __field(void *, caller)
374 		    ),
375 	    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
376 			   __entry->cm_node = cm_node;
377 			   __entry->state = cm_node->state;
378 			   __entry->reset = reset;
379 			   __entry->caller = caller;
380 		    ),
381 	    TP_printk("iwdev=%p  caller=%pS  node%p reset=%d  state=%s",
382 		      __entry->iwdev,
383 		      __entry->caller,
384 		      __entry->cm_node,
385 		      __entry->reset,
386 		      parse_cm_state(__entry->state)
387 		    )
388 );
389 
390 DEFINE_EVENT(open_err_template, irdma_active_open_err,
391 	     TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
392 	     TP_ARGS(cm_node, reset, caller));
393 
394 DEFINE_EVENT(open_err_template, irdma_passive_open_err,
395 	     TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
396 	     TP_ARGS(cm_node, reset, caller));
397 
398 DECLARE_EVENT_CLASS(cm_node_ah_template,
399 		    TP_PROTO(struct irdma_cm_node *cm_node),
400 		    TP_ARGS(cm_node),
401 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
402 				     __field(struct irdma_cm_node *, cm_node)
403 				     __field(struct irdma_sc_ah *, ah)
404 				     __field(u32, refcount)
405 				     __field(u16, lport)
406 				     __field(u16, rport)
407 				     __field(enum irdma_cm_node_state, state)
408 				     __field(bool, ipv4)
409 				     __field(u16, vlan_id)
410 				     __field(int, accel)
411 				     __dynamic_array(u32, laddr, 4)
412 				     __dynamic_array(u32, raddr, 4)
413 			    ),
414 		    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
415 				   __entry->cm_node = cm_node;
416 				   __entry->ah = cm_node->ah;
417 				   __entry->refcount = refcount_read(&cm_node->refcnt);
418 				   __entry->lport = cm_node->loc_port;
419 				   __entry->rport = cm_node->rem_port;
420 				   __entry->state = cm_node->state;
421 				   __entry->ipv4 = cm_node->ipv4;
422 				   __entry->vlan_id = cm_node->vlan_id;
423 				   __entry->accel = cm_node->accelerated;
424 				   memcpy(__get_dynamic_array(laddr),
425 					  cm_node->loc_addr, 4);
426 				   memcpy(__get_dynamic_array(raddr),
427 					  cm_node->rem_addr, 4);
428 			    ),
429 		    TP_printk("iwdev=%p  node=%p  ah=%p  refcnt=%d  vlan_id=%d  accel=%d  state=%s loc: %s  rem: %s",
430 			      __entry->iwdev,
431 			      __entry->cm_node,
432 			      __entry->ah,
433 			      __entry->refcount,
434 			      __entry->vlan_id,
435 			      __entry->accel,
436 			      parse_cm_state(__entry->state),
437 			      __print_ip_addr(__get_dynamic_array(laddr),
438 					      __entry->lport, __entry->ipv4),
439 			      __print_ip_addr(__get_dynamic_array(raddr),
440 					      __entry->rport, __entry->ipv4)
441 		    )
442 );
443 
444 DEFINE_EVENT(cm_node_ah_template, irdma_cm_free_ah,
445 	     TP_PROTO(struct irdma_cm_node *cm_node),
446 	     TP_ARGS(cm_node));
447 
448 DEFINE_EVENT(cm_node_ah_template, irdma_create_ah,
449 	     TP_PROTO(struct irdma_cm_node *cm_node),
450 	     TP_ARGS(cm_node));
451 
452 #endif  /* __TRACE_CM_H */
453 
454 #undef TRACE_INCLUDE_PATH
455 #undef TRACE_INCLUDE_FILE
456 #define TRACE_INCLUDE_PATH .
457 #define TRACE_INCLUDE_FILE trace_cm
458 #include <trace/define_trace.h>
459