xref: /linux/drivers/infiniband/core/cma_trace.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Trace point definitions for the RDMA Connect Manager.
4  *
5  * Author: Chuck Lever <chuck.lever@oracle.com>
6  *
7  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
8  */
9 
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM rdma_cma
12 
13 #if !defined(_TRACE_RDMA_CMA_H) || defined(TRACE_HEADER_MULTI_READ)
14 
15 #define _TRACE_RDMA_CMA_H
16 
17 #include <linux/tracepoint.h>
18 #include <trace/events/rdma.h>
19 
20 
21 DECLARE_EVENT_CLASS(cma_fsm_class,
22 	TP_PROTO(
23 		const struct rdma_id_private *id_priv
24 	),
25 
26 	TP_ARGS(id_priv),
27 
28 	TP_STRUCT__entry(
29 		__field(u32, cm_id)
30 		__field(u32, tos)
31 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
32 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
33 	),
34 
35 	TP_fast_assign(
36 		__entry->cm_id = id_priv->res.id;
37 		__entry->tos = id_priv->tos;
38 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
39 		       sizeof(struct sockaddr_in6));
40 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
41 		       sizeof(struct sockaddr_in6));
42 	),
43 
44 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u",
45 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos
46 	)
47 );
48 
49 #define DEFINE_CMA_FSM_EVENT(name)						\
50 		DEFINE_EVENT(cma_fsm_class, cm_##name,				\
51 				TP_PROTO(					\
52 					const struct rdma_id_private *id_priv	\
53 				),						\
54 				TP_ARGS(id_priv))
55 
56 DEFINE_CMA_FSM_EVENT(send_rtu);
57 DEFINE_CMA_FSM_EVENT(send_rej);
58 DEFINE_CMA_FSM_EVENT(send_mra);
59 DEFINE_CMA_FSM_EVENT(send_sidr_req);
60 DEFINE_CMA_FSM_EVENT(send_sidr_rep);
61 DEFINE_CMA_FSM_EVENT(disconnect);
62 DEFINE_CMA_FSM_EVENT(sent_drep);
63 DEFINE_CMA_FSM_EVENT(sent_dreq);
64 DEFINE_CMA_FSM_EVENT(id_destroy);
65 
66 TRACE_EVENT(cm_id_attach,
67 	TP_PROTO(
68 		const struct rdma_id_private *id_priv,
69 		const struct ib_device *device
70 	),
71 
72 	TP_ARGS(id_priv, device),
73 
74 	TP_STRUCT__entry(
75 		__field(u32, cm_id)
76 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
77 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
78 		__string(devname, device->name)
79 	),
80 
81 	TP_fast_assign(
82 		__entry->cm_id = id_priv->res.id;
83 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
84 		       sizeof(struct sockaddr_in6));
85 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
86 		       sizeof(struct sockaddr_in6));
87 		__assign_str(devname, device->name);
88 	),
89 
90 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc device=%s",
91 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr,
92 		__get_str(devname)
93 	)
94 );
95 
96 DECLARE_EVENT_CLASS(cma_qp_class,
97 	TP_PROTO(
98 		const struct rdma_id_private *id_priv
99 	),
100 
101 	TP_ARGS(id_priv),
102 
103 	TP_STRUCT__entry(
104 		__field(u32, cm_id)
105 		__field(u32, tos)
106 		__field(u32, qp_num)
107 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
108 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
109 	),
110 
111 	TP_fast_assign(
112 		__entry->cm_id = id_priv->res.id;
113 		__entry->tos = id_priv->tos;
114 		__entry->qp_num = id_priv->qp_num;
115 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
116 		       sizeof(struct sockaddr_in6));
117 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
118 		       sizeof(struct sockaddr_in6));
119 	),
120 
121 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u qp_num=%u",
122 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos,
123 		__entry->qp_num
124 	)
125 );
126 
127 #define DEFINE_CMA_QP_EVENT(name)						\
128 		DEFINE_EVENT(cma_qp_class, cm_##name,				\
129 				TP_PROTO(					\
130 					const struct rdma_id_private *id_priv	\
131 				),						\
132 				TP_ARGS(id_priv))
133 
134 DEFINE_CMA_QP_EVENT(send_req);
135 DEFINE_CMA_QP_EVENT(send_rep);
136 DEFINE_CMA_QP_EVENT(qp_destroy);
137 
138 /*
139  * enum ib_wp_type, from include/rdma/ib_verbs.h
140  */
141 #define IB_QP_TYPE_LIST				\
142 	ib_qp_type(SMI)				\
143 	ib_qp_type(GSI)				\
144 	ib_qp_type(RC)				\
145 	ib_qp_type(UC)				\
146 	ib_qp_type(UD)				\
147 	ib_qp_type(RAW_IPV6)			\
148 	ib_qp_type(RAW_ETHERTYPE)		\
149 	ib_qp_type(RAW_PACKET)			\
150 	ib_qp_type(XRC_INI)			\
151 	ib_qp_type_end(XRC_TGT)
152 
153 #undef ib_qp_type
154 #undef ib_qp_type_end
155 
156 #define ib_qp_type(x)		TRACE_DEFINE_ENUM(IB_QPT_##x);
157 #define ib_qp_type_end(x)	TRACE_DEFINE_ENUM(IB_QPT_##x);
158 
159 IB_QP_TYPE_LIST
160 
161 #undef ib_qp_type
162 #undef ib_qp_type_end
163 
164 #define ib_qp_type(x)		{ IB_QPT_##x, #x },
165 #define ib_qp_type_end(x)	{ IB_QPT_##x, #x }
166 
167 #define rdma_show_qp_type(x) \
168 		__print_symbolic(x, IB_QP_TYPE_LIST)
169 
170 
171 TRACE_EVENT(cm_qp_create,
172 	TP_PROTO(
173 		const struct rdma_id_private *id_priv,
174 		const struct ib_pd *pd,
175 		const struct ib_qp_init_attr *qp_init_attr,
176 		int rc
177 	),
178 
179 	TP_ARGS(id_priv, pd, qp_init_attr, rc),
180 
181 	TP_STRUCT__entry(
182 		__field(u32, cm_id)
183 		__field(u32, pd_id)
184 		__field(u32, tos)
185 		__field(u32, qp_num)
186 		__field(u32, send_wr)
187 		__field(u32, recv_wr)
188 		__field(int, rc)
189 		__field(unsigned long, qp_type)
190 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
191 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
192 	),
193 
194 	TP_fast_assign(
195 		__entry->cm_id = id_priv->res.id;
196 		__entry->pd_id = pd->res.id;
197 		__entry->tos = id_priv->tos;
198 		__entry->send_wr = qp_init_attr->cap.max_send_wr;
199 		__entry->recv_wr = qp_init_attr->cap.max_recv_wr;
200 		__entry->rc = rc;
201 		if (!rc) {
202 			__entry->qp_num = id_priv->qp_num;
203 			__entry->qp_type = id_priv->id.qp_type;
204 		} else {
205 			__entry->qp_num = 0;
206 			__entry->qp_type = 0;
207 		}
208 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
209 		       sizeof(struct sockaddr_in6));
210 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
211 		       sizeof(struct sockaddr_in6));
212 	),
213 
214 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u pd.id=%u qp_type=%s"
215 		" send_wr=%u recv_wr=%u qp_num=%u rc=%d",
216 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr,
217 		__entry->tos, __entry->pd_id,
218 		rdma_show_qp_type(__entry->qp_type), __entry->send_wr,
219 		__entry->recv_wr, __entry->qp_num, __entry->rc
220 	)
221 );
222 
223 TRACE_EVENT(cm_req_handler,
224 	TP_PROTO(
225 		const struct rdma_id_private *id_priv,
226 		int event
227 	),
228 
229 	TP_ARGS(id_priv, event),
230 
231 	TP_STRUCT__entry(
232 		__field(u32, cm_id)
233 		__field(u32, tos)
234 		__field(unsigned long, event)
235 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
236 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
237 	),
238 
239 	TP_fast_assign(
240 		__entry->cm_id = id_priv->res.id;
241 		__entry->tos = id_priv->tos;
242 		__entry->event = event;
243 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
244 		       sizeof(struct sockaddr_in6));
245 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
246 		       sizeof(struct sockaddr_in6));
247 	),
248 
249 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu)",
250 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos,
251 		rdma_show_ib_cm_event(__entry->event), __entry->event
252 	)
253 );
254 
255 TRACE_EVENT(cm_event_handler,
256 	TP_PROTO(
257 		const struct rdma_id_private *id_priv,
258 		const struct rdma_cm_event *event
259 	),
260 
261 	TP_ARGS(id_priv, event),
262 
263 	TP_STRUCT__entry(
264 		__field(u32, cm_id)
265 		__field(u32, tos)
266 		__field(unsigned long, event)
267 		__field(int, status)
268 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
269 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
270 	),
271 
272 	TP_fast_assign(
273 		__entry->cm_id = id_priv->res.id;
274 		__entry->tos = id_priv->tos;
275 		__entry->event = event->event;
276 		__entry->status = event->status;
277 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
278 		       sizeof(struct sockaddr_in6));
279 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
280 		       sizeof(struct sockaddr_in6));
281 	),
282 
283 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu/%d)",
284 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos,
285 		rdma_show_cm_event(__entry->event), __entry->event,
286 		__entry->status
287 	)
288 );
289 
290 TRACE_EVENT(cm_event_done,
291 	TP_PROTO(
292 		const struct rdma_id_private *id_priv,
293 		const struct rdma_cm_event *event,
294 		int result
295 	),
296 
297 	TP_ARGS(id_priv, event, result),
298 
299 	TP_STRUCT__entry(
300 		__field(u32, cm_id)
301 		__field(u32, tos)
302 		__field(unsigned long, event)
303 		__field(int, result)
304 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
305 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
306 	),
307 
308 	TP_fast_assign(
309 		__entry->cm_id = id_priv->res.id;
310 		__entry->tos = id_priv->tos;
311 		__entry->event = event->event;
312 		__entry->result = result;
313 		memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr,
314 		       sizeof(struct sockaddr_in6));
315 		memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr,
316 		       sizeof(struct sockaddr_in6));
317 	),
318 
319 	TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s consumer returns %d",
320 		__entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos,
321 		rdma_show_cm_event(__entry->event), __entry->result
322 	)
323 );
324 
325 DECLARE_EVENT_CLASS(cma_client_class,
326 	TP_PROTO(
327 		const struct ib_device *device
328 	),
329 
330 	TP_ARGS(device),
331 
332 	TP_STRUCT__entry(
333 		__string(name, device->name)
334 	),
335 
336 	TP_fast_assign(
337 		__assign_str(name, device->name);
338 	),
339 
340 	TP_printk("device name=%s",
341 		__get_str(name)
342 	)
343 );
344 
345 #define DEFINE_CMA_CLIENT_EVENT(name)						\
346 		DEFINE_EVENT(cma_client_class, cm_##name,			\
347 				TP_PROTO(					\
348 					const struct ib_device *device		\
349 				),						\
350 				TP_ARGS(device))
351 
352 DEFINE_CMA_CLIENT_EVENT(add_one);
353 DEFINE_CMA_CLIENT_EVENT(remove_one);
354 
355 #endif /* _TRACE_RDMA_CMA_H */
356 
357 #undef TRACE_INCLUDE_PATH
358 #define TRACE_INCLUDE_PATH .
359 #define TRACE_INCLUDE_FILE cma_trace
360 
361 #include <trace/define_trace.h>
362