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 			     const 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,
177 		      const char *dev_addr),
178 	     TP_ARGS(iwdev, listener, dev_addr));
179 
180 DEFINE_EVENT(qhash_template, irdma_add_mqh_4,
181 	     TP_PROTO(struct irdma_device *iwdev,
182 		      struct irdma_cm_listener *listener,
183 		      const char *dev_addr),
184 	     TP_ARGS(iwdev, listener, dev_addr));
185 
186 TRACE_EVENT(irdma_addr_resolve,
187 	    TP_PROTO(struct irdma_device *iwdev, char *dev_addr),
188 	    TP_ARGS(iwdev, dev_addr),
189 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
190 		    __dynamic_array(u8, mac, ETH_ALEN)
191 		    ),
192 	    TP_fast_assign(__entry->iwdev = iwdev;
193 		    ether_addr_copy(__get_dynamic_array(mac), dev_addr);
194 		    ),
195 	    TP_printk("iwdev=%p   MAC=%6phC", __entry->iwdev,
196 		      __get_dynamic_array(mac)
197 		    )
198 );
199 
200 TRACE_EVENT(irdma_send_cm_event,
201 	    TP_PROTO(struct irdma_cm_node *cm_node, struct iw_cm_id *cm_id,
202 		     enum iw_cm_event_type type, int status, void *caller),
203 	    TP_ARGS(cm_node, cm_id, type, status, caller),
204 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
205 			     __field(struct irdma_cm_node *, cm_node)
206 			     __field(struct iw_cm_id *, cm_id)
207 			     __field(u32, refcount)
208 			     __field(u16, lport)
209 			     __field(u16, rport)
210 			     __field(enum irdma_cm_node_state, state)
211 			     __field(bool, ipv4)
212 			     __field(u16, vlan_id)
213 			     __field(int, accel)
214 			     __field(enum iw_cm_event_type, type)
215 			     __field(int, status)
216 			     __field(void *, caller)
217 			     __dynamic_array(u32, laddr, 4)
218 			     __dynamic_array(u32, raddr, 4)
219 		    ),
220 	    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
221 			   __entry->cm_node = cm_node;
222 			   __entry->cm_id = cm_id;
223 			   __entry->refcount = refcount_read(&cm_node->refcnt);
224 			   __entry->state = cm_node->state;
225 			   __entry->lport = cm_node->loc_port;
226 			   __entry->rport = cm_node->rem_port;
227 			   __entry->ipv4 = cm_node->ipv4;
228 			   __entry->vlan_id = cm_node->vlan_id;
229 			   __entry->accel = cm_node->accelerated;
230 			   __entry->type = type;
231 			   __entry->status = status;
232 			   __entry->caller = caller;
233 			   memcpy(__get_dynamic_array(laddr),
234 				  cm_node->loc_addr, 4);
235 			   memcpy(__get_dynamic_array(raddr),
236 				  cm_node->rem_addr, 4);
237 		    ),
238 	    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",
239 		      __entry->iwdev,
240 		      __entry->caller,
241 		      __entry->cm_id,
242 		      __entry->cm_node,
243 		      __entry->refcount,
244 		      __entry->vlan_id,
245 		      __entry->accel,
246 		      parse_cm_state(__entry->state),
247 		      parse_iw_event_type(__entry->type),
248 		      __entry->status,
249 		      __print_ip_addr(__get_dynamic_array(laddr),
250 				      __entry->lport, __entry->ipv4),
251 		      __print_ip_addr(__get_dynamic_array(raddr),
252 				      __entry->rport, __entry->ipv4)
253 		    )
254 );
255 
256 TRACE_EVENT(irdma_send_cm_event_no_node,
257 	    TP_PROTO(struct iw_cm_id *cm_id, enum iw_cm_event_type type,
258 		     int status, void *caller),
259 	    TP_ARGS(cm_id, type, status, caller),
260 	    TP_STRUCT__entry(__field(struct iw_cm_id *, cm_id)
261 			     __field(enum iw_cm_event_type, type)
262 			     __field(int, status)
263 			     __field(void *, caller)
264 		    ),
265 	    TP_fast_assign(__entry->cm_id = cm_id;
266 			   __entry->type = type;
267 			   __entry->status = status;
268 			   __entry->caller = caller;
269 		    ),
270 	    TP_printk("cm_id=%p  caller=%pS  event_type=%s  status=%d",
271 		      __entry->cm_id,
272 		      __entry->caller,
273 		      parse_iw_event_type(__entry->type),
274 		      __entry->status
275 		    )
276 );
277 
278 DECLARE_EVENT_CLASS(cm_node_template,
279 		    TP_PROTO(struct irdma_cm_node *cm_node,
280 			     enum irdma_cm_event_type type, void *caller),
281 		    TP_ARGS(cm_node, type, caller),
282 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
283 				     __field(struct irdma_cm_node *, cm_node)
284 				     __field(u32, refcount)
285 				     __field(u16, lport)
286 				     __field(u16, rport)
287 				     __field(enum irdma_cm_node_state, state)
288 				     __field(bool, ipv4)
289 				     __field(u16, vlan_id)
290 				     __field(int, accel)
291 				     __field(enum irdma_cm_event_type, type)
292 				     __field(void *, caller)
293 				     __dynamic_array(u32, laddr, 4)
294 				     __dynamic_array(u32, raddr, 4)
295 			    ),
296 		    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
297 				   __entry->cm_node = cm_node;
298 				   __entry->refcount = refcount_read(&cm_node->refcnt);
299 				   __entry->state = cm_node->state;
300 				   __entry->lport = cm_node->loc_port;
301 				   __entry->rport = cm_node->rem_port;
302 				   __entry->ipv4 = cm_node->ipv4;
303 				   __entry->vlan_id = cm_node->vlan_id;
304 				   __entry->accel = cm_node->accelerated;
305 				   __entry->type = type;
306 				   __entry->caller = caller;
307 				   memcpy(__get_dynamic_array(laddr),
308 					  cm_node->loc_addr, 4);
309 				   memcpy(__get_dynamic_array(raddr),
310 					  cm_node->rem_addr, 4);
311 			    ),
312 		    TP_printk("iwdev=%p  caller=%pS  node=%p  refcnt=%d  vlan_id=%d  accel=%d  state=%s  event_type=%s  loc: %s  rem: %s",
313 			      __entry->iwdev,
314 			      __entry->caller,
315 			      __entry->cm_node,
316 			      __entry->refcount,
317 			      __entry->vlan_id,
318 			      __entry->accel,
319 			      parse_cm_state(__entry->state),
320 			      parse_cm_event_type(__entry->type),
321 			      __print_ip_addr(__get_dynamic_array(laddr),
322 					      __entry->lport, __entry->ipv4),
323 			      __print_ip_addr(__get_dynamic_array(raddr),
324 					      __entry->rport, __entry->ipv4)
325 		    )
326 );
327 
328 DEFINE_EVENT(cm_node_template, irdma_create_event,
329 	     TP_PROTO(struct irdma_cm_node *cm_node,
330 		      enum irdma_cm_event_type type, void *caller),
331 	     TP_ARGS(cm_node, type, caller));
332 
333 DEFINE_EVENT(cm_node_template, irdma_accept,
334 	     TP_PROTO(struct irdma_cm_node *cm_node,
335 		      enum irdma_cm_event_type type, void *caller),
336 	     TP_ARGS(cm_node, type, caller));
337 
338 DEFINE_EVENT(cm_node_template, irdma_connect,
339 	     TP_PROTO(struct irdma_cm_node *cm_node,
340 		      enum irdma_cm_event_type type, void *caller),
341 	     TP_ARGS(cm_node, type, caller));
342 
343 DEFINE_EVENT(cm_node_template, irdma_reject,
344 	     TP_PROTO(struct irdma_cm_node *cm_node,
345 		      enum irdma_cm_event_type type, void *caller),
346 	     TP_ARGS(cm_node, type, caller));
347 
348 DEFINE_EVENT(cm_node_template, irdma_find_node,
349 	     TP_PROTO(struct irdma_cm_node *cm_node,
350 		      enum irdma_cm_event_type type, void *caller),
351 	     TP_ARGS(cm_node, type, caller));
352 
353 DEFINE_EVENT(cm_node_template, irdma_send_reset,
354 	     TP_PROTO(struct irdma_cm_node *cm_node,
355 		      enum irdma_cm_event_type type, void *caller),
356 	     TP_ARGS(cm_node, type, caller));
357 
358 DEFINE_EVENT(cm_node_template, irdma_rem_ref_cm_node,
359 	     TP_PROTO(struct irdma_cm_node *cm_node,
360 		      enum irdma_cm_event_type type, void *caller),
361 	     TP_ARGS(cm_node, type, caller));
362 
363 DEFINE_EVENT(cm_node_template, irdma_cm_event_handler,
364 	     TP_PROTO(struct irdma_cm_node *cm_node,
365 		      enum irdma_cm_event_type type, void *caller),
366 	     TP_ARGS(cm_node, type, caller));
367 
368 TRACE_EVENT(open_err_template,
369 	    TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
370 	    TP_ARGS(cm_node, reset, caller),
371 	    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
372 			     __field(struct irdma_cm_node *, cm_node)
373 			     __field(enum irdma_cm_node_state, state)
374 			     __field(bool, reset)
375 			     __field(void *, caller)
376 		    ),
377 	    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
378 			   __entry->cm_node = cm_node;
379 			   __entry->state = cm_node->state;
380 			   __entry->reset = reset;
381 			   __entry->caller = caller;
382 		    ),
383 	    TP_printk("iwdev=%p  caller=%pS  node%p reset=%d  state=%s",
384 		      __entry->iwdev,
385 		      __entry->caller,
386 		      __entry->cm_node,
387 		      __entry->reset,
388 		      parse_cm_state(__entry->state)
389 		    )
390 );
391 
392 DEFINE_EVENT(open_err_template, irdma_active_open_err,
393 	     TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
394 	     TP_ARGS(cm_node, reset, caller));
395 
396 DEFINE_EVENT(open_err_template, irdma_passive_open_err,
397 	     TP_PROTO(struct irdma_cm_node *cm_node, bool reset, void *caller),
398 	     TP_ARGS(cm_node, reset, caller));
399 
400 DECLARE_EVENT_CLASS(cm_node_ah_template,
401 		    TP_PROTO(struct irdma_cm_node *cm_node),
402 		    TP_ARGS(cm_node),
403 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
404 				     __field(struct irdma_cm_node *, cm_node)
405 				     __field(struct irdma_sc_ah *, ah)
406 				     __field(u32, refcount)
407 				     __field(u16, lport)
408 				     __field(u16, rport)
409 				     __field(enum irdma_cm_node_state, state)
410 				     __field(bool, ipv4)
411 				     __field(u16, vlan_id)
412 				     __field(int, accel)
413 				     __dynamic_array(u32, laddr, 4)
414 				     __dynamic_array(u32, raddr, 4)
415 			    ),
416 		    TP_fast_assign(__entry->iwdev = cm_node->iwdev;
417 				   __entry->cm_node = cm_node;
418 				   __entry->ah = cm_node->ah;
419 				   __entry->refcount = refcount_read(&cm_node->refcnt);
420 				   __entry->lport = cm_node->loc_port;
421 				   __entry->rport = cm_node->rem_port;
422 				   __entry->state = cm_node->state;
423 				   __entry->ipv4 = cm_node->ipv4;
424 				   __entry->vlan_id = cm_node->vlan_id;
425 				   __entry->accel = cm_node->accelerated;
426 				   memcpy(__get_dynamic_array(laddr),
427 					  cm_node->loc_addr, 4);
428 				   memcpy(__get_dynamic_array(raddr),
429 					  cm_node->rem_addr, 4);
430 			    ),
431 		    TP_printk("iwdev=%p  node=%p  ah=%p  refcnt=%d  vlan_id=%d  accel=%d  state=%s loc: %s  rem: %s",
432 			      __entry->iwdev,
433 			      __entry->cm_node,
434 			      __entry->ah,
435 			      __entry->refcount,
436 			      __entry->vlan_id,
437 			      __entry->accel,
438 			      parse_cm_state(__entry->state),
439 			      __print_ip_addr(__get_dynamic_array(laddr),
440 					      __entry->lport, __entry->ipv4),
441 			      __print_ip_addr(__get_dynamic_array(raddr),
442 					      __entry->rport, __entry->ipv4)
443 		    )
444 );
445 
446 DEFINE_EVENT(cm_node_ah_template, irdma_cm_free_ah,
447 	     TP_PROTO(struct irdma_cm_node *cm_node),
448 	     TP_ARGS(cm_node));
449 
450 DEFINE_EVENT(cm_node_ah_template, irdma_create_ah,
451 	     TP_PROTO(struct irdma_cm_node *cm_node),
452 	     TP_ARGS(cm_node));
453 
454 #endif  /* __TRACE_CM_H */
455 
456 #undef TRACE_INCLUDE_PATH
457 #undef TRACE_INCLUDE_FILE
458 #define TRACE_INCLUDE_PATH .
459 #define TRACE_INCLUDE_FILE trace_cm
460 #include <trace/define_trace.h>
461