xref: /openbmc/linux/include/trace/events/rpcrdma.h (revision 835fd614)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2017, 2018 Oracle.  All rights reserved.
4  *
5  * Trace point definitions for the "rpcrdma" subsystem.
6  */
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM rpcrdma
9 
10 #if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_RPCRDMA_H
12 
13 #include <linux/scatterlist.h>
14 #include <linux/sunrpc/rpc_rdma_cid.h>
15 #include <linux/tracepoint.h>
16 #include <rdma/ib_cm.h>
17 #include <trace/events/rdma.h>
18 
19 /**
20  ** Event classes
21  **/
22 
23 DECLARE_EVENT_CLASS(rpcrdma_completion_class,
24 	TP_PROTO(
25 		const struct ib_wc *wc,
26 		const struct rpc_rdma_cid *cid
27 	),
28 
29 	TP_ARGS(wc, cid),
30 
31 	TP_STRUCT__entry(
32 		__field(u32, cq_id)
33 		__field(int, completion_id)
34 		__field(unsigned long, status)
35 		__field(unsigned int, vendor_err)
36 	),
37 
38 	TP_fast_assign(
39 		__entry->cq_id = cid->ci_queue_id;
40 		__entry->completion_id = cid->ci_completion_id;
41 		__entry->status = wc->status;
42 		if (wc->status)
43 			__entry->vendor_err = wc->vendor_err;
44 		else
45 			__entry->vendor_err = 0;
46 	),
47 
48 	TP_printk("cq.id=%u cid=%d status=%s (%lu/0x%x)",
49 		__entry->cq_id, __entry->completion_id,
50 		rdma_show_wc_status(__entry->status),
51 		__entry->status, __entry->vendor_err
52 	)
53 );
54 
55 #define DEFINE_COMPLETION_EVENT(name)					\
56 		DEFINE_EVENT(rpcrdma_completion_class, name,		\
57 				TP_PROTO(				\
58 					const struct ib_wc *wc,		\
59 					const struct rpc_rdma_cid *cid	\
60 				),					\
61 				TP_ARGS(wc, cid))
62 
63 DECLARE_EVENT_CLASS(xprtrdma_reply_event,
64 	TP_PROTO(
65 		const struct rpcrdma_rep *rep
66 	),
67 
68 	TP_ARGS(rep),
69 
70 	TP_STRUCT__entry(
71 		__field(const void *, rep)
72 		__field(const void *, r_xprt)
73 		__field(u32, xid)
74 		__field(u32, version)
75 		__field(u32, proc)
76 	),
77 
78 	TP_fast_assign(
79 		__entry->rep = rep;
80 		__entry->r_xprt = rep->rr_rxprt;
81 		__entry->xid = be32_to_cpu(rep->rr_xid);
82 		__entry->version = be32_to_cpu(rep->rr_vers);
83 		__entry->proc = be32_to_cpu(rep->rr_proc);
84 	),
85 
86 	TP_printk("rxprt %p xid=0x%08x rep=%p: version %u proc %u",
87 		__entry->r_xprt, __entry->xid, __entry->rep,
88 		__entry->version, __entry->proc
89 	)
90 );
91 
92 #define DEFINE_REPLY_EVENT(name)					\
93 		DEFINE_EVENT(xprtrdma_reply_event, name,		\
94 				TP_PROTO(				\
95 					const struct rpcrdma_rep *rep	\
96 				),					\
97 				TP_ARGS(rep))
98 
99 DECLARE_EVENT_CLASS(xprtrdma_rxprt,
100 	TP_PROTO(
101 		const struct rpcrdma_xprt *r_xprt
102 	),
103 
104 	TP_ARGS(r_xprt),
105 
106 	TP_STRUCT__entry(
107 		__field(const void *, r_xprt)
108 		__string(addr, rpcrdma_addrstr(r_xprt))
109 		__string(port, rpcrdma_portstr(r_xprt))
110 	),
111 
112 	TP_fast_assign(
113 		__entry->r_xprt = r_xprt;
114 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
115 		__assign_str(port, rpcrdma_portstr(r_xprt));
116 	),
117 
118 	TP_printk("peer=[%s]:%s r_xprt=%p",
119 		__get_str(addr), __get_str(port), __entry->r_xprt
120 	)
121 );
122 
123 #define DEFINE_RXPRT_EVENT(name)					\
124 		DEFINE_EVENT(xprtrdma_rxprt, name,			\
125 				TP_PROTO(				\
126 					const struct rpcrdma_xprt *r_xprt \
127 				),					\
128 				TP_ARGS(r_xprt))
129 
130 DECLARE_EVENT_CLASS(xprtrdma_connect_class,
131 	TP_PROTO(
132 		const struct rpcrdma_xprt *r_xprt,
133 		int rc
134 	),
135 
136 	TP_ARGS(r_xprt, rc),
137 
138 	TP_STRUCT__entry(
139 		__field(const void *, r_xprt)
140 		__field(int, rc)
141 		__field(int, connect_status)
142 		__string(addr, rpcrdma_addrstr(r_xprt))
143 		__string(port, rpcrdma_portstr(r_xprt))
144 	),
145 
146 	TP_fast_assign(
147 		__entry->r_xprt = r_xprt;
148 		__entry->rc = rc;
149 		__entry->connect_status = r_xprt->rx_ep->re_connect_status;
150 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
151 		__assign_str(port, rpcrdma_portstr(r_xprt));
152 	),
153 
154 	TP_printk("peer=[%s]:%s r_xprt=%p: rc=%d connection status=%d",
155 		__get_str(addr), __get_str(port), __entry->r_xprt,
156 		__entry->rc, __entry->connect_status
157 	)
158 );
159 
160 #define DEFINE_CONN_EVENT(name)						\
161 		DEFINE_EVENT(xprtrdma_connect_class, xprtrdma_##name,	\
162 				TP_PROTO(				\
163 					const struct rpcrdma_xprt *r_xprt, \
164 					int rc				\
165 				),					\
166 				TP_ARGS(r_xprt, rc))
167 
168 DECLARE_EVENT_CLASS(xprtrdma_rdch_event,
169 	TP_PROTO(
170 		const struct rpc_task *task,
171 		unsigned int pos,
172 		struct rpcrdma_mr *mr,
173 		int nsegs
174 	),
175 
176 	TP_ARGS(task, pos, mr, nsegs),
177 
178 	TP_STRUCT__entry(
179 		__field(unsigned int, task_id)
180 		__field(unsigned int, client_id)
181 		__field(unsigned int, pos)
182 		__field(int, nents)
183 		__field(u32, handle)
184 		__field(u32, length)
185 		__field(u64, offset)
186 		__field(int, nsegs)
187 	),
188 
189 	TP_fast_assign(
190 		__entry->task_id = task->tk_pid;
191 		__entry->client_id = task->tk_client->cl_clid;
192 		__entry->pos = pos;
193 		__entry->nents = mr->mr_nents;
194 		__entry->handle = mr->mr_handle;
195 		__entry->length = mr->mr_length;
196 		__entry->offset = mr->mr_offset;
197 		__entry->nsegs = nsegs;
198 	),
199 
200 	TP_printk("task:%u@%u pos=%u %u@0x%016llx:0x%08x (%s)",
201 		__entry->task_id, __entry->client_id,
202 		__entry->pos, __entry->length,
203 		(unsigned long long)__entry->offset, __entry->handle,
204 		__entry->nents < __entry->nsegs ? "more" : "last"
205 	)
206 );
207 
208 #define DEFINE_RDCH_EVENT(name)						\
209 		DEFINE_EVENT(xprtrdma_rdch_event, xprtrdma_chunk_##name,\
210 				TP_PROTO(				\
211 					const struct rpc_task *task,	\
212 					unsigned int pos,		\
213 					struct rpcrdma_mr *mr,		\
214 					int nsegs			\
215 				),					\
216 				TP_ARGS(task, pos, mr, nsegs))
217 
218 DECLARE_EVENT_CLASS(xprtrdma_wrch_event,
219 	TP_PROTO(
220 		const struct rpc_task *task,
221 		struct rpcrdma_mr *mr,
222 		int nsegs
223 	),
224 
225 	TP_ARGS(task, mr, nsegs),
226 
227 	TP_STRUCT__entry(
228 		__field(unsigned int, task_id)
229 		__field(unsigned int, client_id)
230 		__field(int, nents)
231 		__field(u32, handle)
232 		__field(u32, length)
233 		__field(u64, offset)
234 		__field(int, nsegs)
235 	),
236 
237 	TP_fast_assign(
238 		__entry->task_id = task->tk_pid;
239 		__entry->client_id = task->tk_client->cl_clid;
240 		__entry->nents = mr->mr_nents;
241 		__entry->handle = mr->mr_handle;
242 		__entry->length = mr->mr_length;
243 		__entry->offset = mr->mr_offset;
244 		__entry->nsegs = nsegs;
245 	),
246 
247 	TP_printk("task:%u@%u %u@0x%016llx:0x%08x (%s)",
248 		__entry->task_id, __entry->client_id,
249 		__entry->length, (unsigned long long)__entry->offset,
250 		__entry->handle,
251 		__entry->nents < __entry->nsegs ? "more" : "last"
252 	)
253 );
254 
255 #define DEFINE_WRCH_EVENT(name)						\
256 		DEFINE_EVENT(xprtrdma_wrch_event, xprtrdma_chunk_##name,\
257 				TP_PROTO(				\
258 					const struct rpc_task *task,	\
259 					struct rpcrdma_mr *mr,		\
260 					int nsegs			\
261 				),					\
262 				TP_ARGS(task, mr, nsegs))
263 
264 DECLARE_EVENT_CLASS(xprtrdma_frwr_done,
265 	TP_PROTO(
266 		const struct ib_wc *wc,
267 		const struct rpcrdma_frwr *frwr
268 	),
269 
270 	TP_ARGS(wc, frwr),
271 
272 	TP_STRUCT__entry(
273 		__field(u32, mr_id)
274 		__field(unsigned int, status)
275 		__field(unsigned int, vendor_err)
276 	),
277 
278 	TP_fast_assign(
279 		__entry->mr_id = frwr->fr_mr->res.id;
280 		__entry->status = wc->status;
281 		__entry->vendor_err = __entry->status ? wc->vendor_err : 0;
282 	),
283 
284 	TP_printk(
285 		"mr.id=%u: %s (%u/0x%x)",
286 		__entry->mr_id, rdma_show_wc_status(__entry->status),
287 		__entry->status, __entry->vendor_err
288 	)
289 );
290 
291 #define DEFINE_FRWR_DONE_EVENT(name)					\
292 		DEFINE_EVENT(xprtrdma_frwr_done, name,			\
293 				TP_PROTO(				\
294 					const struct ib_wc *wc,		\
295 					const struct rpcrdma_frwr *frwr	\
296 				),					\
297 				TP_ARGS(wc, frwr))
298 
299 TRACE_DEFINE_ENUM(DMA_BIDIRECTIONAL);
300 TRACE_DEFINE_ENUM(DMA_TO_DEVICE);
301 TRACE_DEFINE_ENUM(DMA_FROM_DEVICE);
302 TRACE_DEFINE_ENUM(DMA_NONE);
303 
304 #define xprtrdma_show_direction(x)					\
305 		__print_symbolic(x,					\
306 				{ DMA_BIDIRECTIONAL, "BIDIR" },		\
307 				{ DMA_TO_DEVICE, "TO_DEVICE" },		\
308 				{ DMA_FROM_DEVICE, "FROM_DEVICE" },	\
309 				{ DMA_NONE, "NONE" })
310 
311 DECLARE_EVENT_CLASS(xprtrdma_mr,
312 	TP_PROTO(
313 		const struct rpcrdma_mr *mr
314 	),
315 
316 	TP_ARGS(mr),
317 
318 	TP_STRUCT__entry(
319 		__field(u32, mr_id)
320 		__field(int, nents)
321 		__field(u32, handle)
322 		__field(u32, length)
323 		__field(u64, offset)
324 		__field(u32, dir)
325 	),
326 
327 	TP_fast_assign(
328 		__entry->mr_id  = mr->frwr.fr_mr->res.id;
329 		__entry->nents  = mr->mr_nents;
330 		__entry->handle = mr->mr_handle;
331 		__entry->length = mr->mr_length;
332 		__entry->offset = mr->mr_offset;
333 		__entry->dir    = mr->mr_dir;
334 	),
335 
336 	TP_printk("mr.id=%u nents=%d %u@0x%016llx:0x%08x (%s)",
337 		__entry->mr_id, __entry->nents, __entry->length,
338 		(unsigned long long)__entry->offset, __entry->handle,
339 		xprtrdma_show_direction(__entry->dir)
340 	)
341 );
342 
343 #define DEFINE_MR_EVENT(name) \
344 		DEFINE_EVENT(xprtrdma_mr, xprtrdma_mr_##name, \
345 				TP_PROTO( \
346 					const struct rpcrdma_mr *mr \
347 				), \
348 				TP_ARGS(mr))
349 
350 DECLARE_EVENT_CLASS(xprtrdma_cb_event,
351 	TP_PROTO(
352 		const struct rpc_rqst *rqst
353 	),
354 
355 	TP_ARGS(rqst),
356 
357 	TP_STRUCT__entry(
358 		__field(const void *, rqst)
359 		__field(const void *, rep)
360 		__field(const void *, req)
361 		__field(u32, xid)
362 	),
363 
364 	TP_fast_assign(
365 		__entry->rqst = rqst;
366 		__entry->req = rpcr_to_rdmar(rqst);
367 		__entry->rep = rpcr_to_rdmar(rqst)->rl_reply;
368 		__entry->xid = be32_to_cpu(rqst->rq_xid);
369 	),
370 
371 	TP_printk("xid=0x%08x, rqst=%p req=%p rep=%p",
372 		__entry->xid, __entry->rqst, __entry->req, __entry->rep
373 	)
374 );
375 
376 #define DEFINE_CB_EVENT(name)						\
377 		DEFINE_EVENT(xprtrdma_cb_event, name,			\
378 				TP_PROTO(				\
379 					const struct rpc_rqst *rqst	\
380 				),					\
381 				TP_ARGS(rqst))
382 
383 /**
384  ** Connection events
385  **/
386 
387 TRACE_EVENT(xprtrdma_inline_thresh,
388 	TP_PROTO(
389 		const struct rpcrdma_ep *ep
390 	),
391 
392 	TP_ARGS(ep),
393 
394 	TP_STRUCT__entry(
395 		__field(unsigned int, inline_send)
396 		__field(unsigned int, inline_recv)
397 		__field(unsigned int, max_send)
398 		__field(unsigned int, max_recv)
399 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
400 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
401 	),
402 
403 	TP_fast_assign(
404 		const struct rdma_cm_id *id = ep->re_id;
405 
406 		__entry->inline_send = ep->re_inline_send;
407 		__entry->inline_recv = ep->re_inline_recv;
408 		__entry->max_send = ep->re_max_inline_send;
409 		__entry->max_recv = ep->re_max_inline_recv;
410 		memcpy(__entry->srcaddr, &id->route.addr.src_addr,
411 		       sizeof(struct sockaddr_in6));
412 		memcpy(__entry->dstaddr, &id->route.addr.dst_addr,
413 		       sizeof(struct sockaddr_in6));
414 	),
415 
416 	TP_printk("%pISpc -> %pISpc neg send/recv=%u/%u, calc send/recv=%u/%u",
417 		__entry->srcaddr, __entry->dstaddr,
418 		__entry->inline_send, __entry->inline_recv,
419 		__entry->max_send, __entry->max_recv
420 	)
421 );
422 
423 DEFINE_CONN_EVENT(connect);
424 DEFINE_CONN_EVENT(disconnect);
425 
426 DEFINE_RXPRT_EVENT(xprtrdma_op_inject_dsc);
427 
428 TRACE_EVENT(xprtrdma_op_connect,
429 	TP_PROTO(
430 		const struct rpcrdma_xprt *r_xprt,
431 		unsigned long delay
432 	),
433 
434 	TP_ARGS(r_xprt, delay),
435 
436 	TP_STRUCT__entry(
437 		__field(const void *, r_xprt)
438 		__field(unsigned long, delay)
439 		__string(addr, rpcrdma_addrstr(r_xprt))
440 		__string(port, rpcrdma_portstr(r_xprt))
441 	),
442 
443 	TP_fast_assign(
444 		__entry->r_xprt = r_xprt;
445 		__entry->delay = delay;
446 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
447 		__assign_str(port, rpcrdma_portstr(r_xprt));
448 	),
449 
450 	TP_printk("peer=[%s]:%s r_xprt=%p delay=%lu",
451 		__get_str(addr), __get_str(port), __entry->r_xprt,
452 		__entry->delay
453 	)
454 );
455 
456 
457 TRACE_EVENT(xprtrdma_op_set_cto,
458 	TP_PROTO(
459 		const struct rpcrdma_xprt *r_xprt,
460 		unsigned long connect,
461 		unsigned long reconnect
462 	),
463 
464 	TP_ARGS(r_xprt, connect, reconnect),
465 
466 	TP_STRUCT__entry(
467 		__field(const void *, r_xprt)
468 		__field(unsigned long, connect)
469 		__field(unsigned long, reconnect)
470 		__string(addr, rpcrdma_addrstr(r_xprt))
471 		__string(port, rpcrdma_portstr(r_xprt))
472 	),
473 
474 	TP_fast_assign(
475 		__entry->r_xprt = r_xprt;
476 		__entry->connect = connect;
477 		__entry->reconnect = reconnect;
478 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
479 		__assign_str(port, rpcrdma_portstr(r_xprt));
480 	),
481 
482 	TP_printk("peer=[%s]:%s r_xprt=%p: connect=%lu reconnect=%lu",
483 		__get_str(addr), __get_str(port), __entry->r_xprt,
484 		__entry->connect / HZ, __entry->reconnect / HZ
485 	)
486 );
487 
488 TRACE_EVENT(xprtrdma_qp_event,
489 	TP_PROTO(
490 		const struct rpcrdma_ep *ep,
491 		const struct ib_event *event
492 	),
493 
494 	TP_ARGS(ep, event),
495 
496 	TP_STRUCT__entry(
497 		__field(unsigned long, event)
498 		__string(name, event->device->name)
499 		__array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
500 		__array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
501 	),
502 
503 	TP_fast_assign(
504 		const struct rdma_cm_id *id = ep->re_id;
505 
506 		__entry->event = event->event;
507 		__assign_str(name, event->device->name);
508 		memcpy(__entry->srcaddr, &id->route.addr.src_addr,
509 		       sizeof(struct sockaddr_in6));
510 		memcpy(__entry->dstaddr, &id->route.addr.dst_addr,
511 		       sizeof(struct sockaddr_in6));
512 	),
513 
514 	TP_printk("%pISpc -> %pISpc device=%s %s (%lu)",
515 		__entry->srcaddr, __entry->dstaddr, __get_str(name),
516 		rdma_show_ib_event(__entry->event), __entry->event
517 	)
518 );
519 
520 /**
521  ** Call events
522  **/
523 
524 TRACE_EVENT(xprtrdma_createmrs,
525 	TP_PROTO(
526 		const struct rpcrdma_xprt *r_xprt,
527 		unsigned int count
528 	),
529 
530 	TP_ARGS(r_xprt, count),
531 
532 	TP_STRUCT__entry(
533 		__field(const void *, r_xprt)
534 		__string(addr, rpcrdma_addrstr(r_xprt))
535 		__string(port, rpcrdma_portstr(r_xprt))
536 		__field(unsigned int, count)
537 	),
538 
539 	TP_fast_assign(
540 		__entry->r_xprt = r_xprt;
541 		__entry->count = count;
542 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
543 		__assign_str(port, rpcrdma_portstr(r_xprt));
544 	),
545 
546 	TP_printk("peer=[%s]:%s r_xprt=%p: created %u MRs",
547 		__get_str(addr), __get_str(port), __entry->r_xprt,
548 		__entry->count
549 	)
550 );
551 
552 TRACE_EVENT(xprtrdma_mr_get,
553 	TP_PROTO(
554 		const struct rpcrdma_req *req
555 	),
556 
557 	TP_ARGS(req),
558 
559 	TP_STRUCT__entry(
560 		__field(const void *, req)
561 		__field(unsigned int, task_id)
562 		__field(unsigned int, client_id)
563 		__field(u32, xid)
564 	),
565 
566 	TP_fast_assign(
567 		const struct rpc_rqst *rqst = &req->rl_slot;
568 
569 		__entry->req = req;
570 		__entry->task_id = rqst->rq_task->tk_pid;
571 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
572 		__entry->xid = be32_to_cpu(rqst->rq_xid);
573 	),
574 
575 	TP_printk("task:%u@%u xid=0x%08x req=%p",
576 		__entry->task_id, __entry->client_id, __entry->xid,
577 		__entry->req
578 	)
579 );
580 
581 TRACE_EVENT(xprtrdma_nomrs,
582 	TP_PROTO(
583 		const struct rpcrdma_req *req
584 	),
585 
586 	TP_ARGS(req),
587 
588 	TP_STRUCT__entry(
589 		__field(const void *, req)
590 		__field(unsigned int, task_id)
591 		__field(unsigned int, client_id)
592 		__field(u32, xid)
593 	),
594 
595 	TP_fast_assign(
596 		const struct rpc_rqst *rqst = &req->rl_slot;
597 
598 		__entry->req = req;
599 		__entry->task_id = rqst->rq_task->tk_pid;
600 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
601 		__entry->xid = be32_to_cpu(rqst->rq_xid);
602 	),
603 
604 	TP_printk("task:%u@%u xid=0x%08x req=%p",
605 		__entry->task_id, __entry->client_id, __entry->xid,
606 		__entry->req
607 	)
608 );
609 
610 DEFINE_RDCH_EVENT(read);
611 DEFINE_WRCH_EVENT(write);
612 DEFINE_WRCH_EVENT(reply);
613 
614 TRACE_DEFINE_ENUM(rpcrdma_noch);
615 TRACE_DEFINE_ENUM(rpcrdma_noch_pullup);
616 TRACE_DEFINE_ENUM(rpcrdma_noch_mapped);
617 TRACE_DEFINE_ENUM(rpcrdma_readch);
618 TRACE_DEFINE_ENUM(rpcrdma_areadch);
619 TRACE_DEFINE_ENUM(rpcrdma_writech);
620 TRACE_DEFINE_ENUM(rpcrdma_replych);
621 
622 #define xprtrdma_show_chunktype(x)					\
623 		__print_symbolic(x,					\
624 				{ rpcrdma_noch, "inline" },		\
625 				{ rpcrdma_noch_pullup, "pullup" },	\
626 				{ rpcrdma_noch_mapped, "mapped" },	\
627 				{ rpcrdma_readch, "read list" },	\
628 				{ rpcrdma_areadch, "*read list" },	\
629 				{ rpcrdma_writech, "write list" },	\
630 				{ rpcrdma_replych, "reply chunk" })
631 
632 TRACE_EVENT(xprtrdma_marshal,
633 	TP_PROTO(
634 		const struct rpcrdma_req *req,
635 		unsigned int rtype,
636 		unsigned int wtype
637 	),
638 
639 	TP_ARGS(req, rtype, wtype),
640 
641 	TP_STRUCT__entry(
642 		__field(unsigned int, task_id)
643 		__field(unsigned int, client_id)
644 		__field(u32, xid)
645 		__field(unsigned int, hdrlen)
646 		__field(unsigned int, headlen)
647 		__field(unsigned int, pagelen)
648 		__field(unsigned int, taillen)
649 		__field(unsigned int, rtype)
650 		__field(unsigned int, wtype)
651 	),
652 
653 	TP_fast_assign(
654 		const struct rpc_rqst *rqst = &req->rl_slot;
655 
656 		__entry->task_id = rqst->rq_task->tk_pid;
657 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
658 		__entry->xid = be32_to_cpu(rqst->rq_xid);
659 		__entry->hdrlen = req->rl_hdrbuf.len;
660 		__entry->headlen = rqst->rq_snd_buf.head[0].iov_len;
661 		__entry->pagelen = rqst->rq_snd_buf.page_len;
662 		__entry->taillen = rqst->rq_snd_buf.tail[0].iov_len;
663 		__entry->rtype = rtype;
664 		__entry->wtype = wtype;
665 	),
666 
667 	TP_printk("task:%u@%u xid=0x%08x: hdr=%u xdr=%u/%u/%u %s/%s",
668 		__entry->task_id, __entry->client_id, __entry->xid,
669 		__entry->hdrlen,
670 		__entry->headlen, __entry->pagelen, __entry->taillen,
671 		xprtrdma_show_chunktype(__entry->rtype),
672 		xprtrdma_show_chunktype(__entry->wtype)
673 	)
674 );
675 
676 TRACE_EVENT(xprtrdma_marshal_failed,
677 	TP_PROTO(const struct rpc_rqst *rqst,
678 		 int ret
679 	),
680 
681 	TP_ARGS(rqst, ret),
682 
683 	TP_STRUCT__entry(
684 		__field(unsigned int, task_id)
685 		__field(unsigned int, client_id)
686 		__field(u32, xid)
687 		__field(int, ret)
688 	),
689 
690 	TP_fast_assign(
691 		__entry->task_id = rqst->rq_task->tk_pid;
692 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
693 		__entry->xid = be32_to_cpu(rqst->rq_xid);
694 		__entry->ret = ret;
695 	),
696 
697 	TP_printk("task:%u@%u xid=0x%08x: ret=%d",
698 		__entry->task_id, __entry->client_id, __entry->xid,
699 		__entry->ret
700 	)
701 );
702 
703 TRACE_EVENT(xprtrdma_prepsend_failed,
704 	TP_PROTO(const struct rpc_rqst *rqst,
705 		 int ret
706 	),
707 
708 	TP_ARGS(rqst, ret),
709 
710 	TP_STRUCT__entry(
711 		__field(unsigned int, task_id)
712 		__field(unsigned int, client_id)
713 		__field(u32, xid)
714 		__field(int, ret)
715 	),
716 
717 	TP_fast_assign(
718 		__entry->task_id = rqst->rq_task->tk_pid;
719 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
720 		__entry->xid = be32_to_cpu(rqst->rq_xid);
721 		__entry->ret = ret;
722 	),
723 
724 	TP_printk("task:%u@%u xid=0x%08x: ret=%d",
725 		__entry->task_id, __entry->client_id, __entry->xid,
726 		__entry->ret
727 	)
728 );
729 
730 TRACE_EVENT(xprtrdma_post_send,
731 	TP_PROTO(
732 		const struct rpcrdma_req *req
733 	),
734 
735 	TP_ARGS(req),
736 
737 	TP_STRUCT__entry(
738 		__field(const void *, req)
739 		__field(const void *, sc)
740 		__field(unsigned int, task_id)
741 		__field(unsigned int, client_id)
742 		__field(int, num_sge)
743 		__field(int, signaled)
744 	),
745 
746 	TP_fast_assign(
747 		const struct rpc_rqst *rqst = &req->rl_slot;
748 
749 		__entry->task_id = rqst->rq_task->tk_pid;
750 		__entry->client_id = rqst->rq_task->tk_client ?
751 				     rqst->rq_task->tk_client->cl_clid : -1;
752 		__entry->req = req;
753 		__entry->sc = req->rl_sendctx;
754 		__entry->num_sge = req->rl_wr.num_sge;
755 		__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
756 	),
757 
758 	TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %s",
759 		__entry->task_id, __entry->client_id,
760 		__entry->req, __entry->sc, __entry->num_sge,
761 		(__entry->num_sge == 1 ? "" : "s"),
762 		(__entry->signaled ? "signaled" : "")
763 	)
764 );
765 
766 TRACE_EVENT(xprtrdma_post_recv,
767 	TP_PROTO(
768 		const struct rpcrdma_rep *rep
769 	),
770 
771 	TP_ARGS(rep),
772 
773 	TP_STRUCT__entry(
774 		__field(const void *, rep)
775 	),
776 
777 	TP_fast_assign(
778 		__entry->rep = rep;
779 	),
780 
781 	TP_printk("rep=%p",
782 		__entry->rep
783 	)
784 );
785 
786 TRACE_EVENT(xprtrdma_post_recvs,
787 	TP_PROTO(
788 		const struct rpcrdma_xprt *r_xprt,
789 		unsigned int count,
790 		int status
791 	),
792 
793 	TP_ARGS(r_xprt, count, status),
794 
795 	TP_STRUCT__entry(
796 		__field(const void *, r_xprt)
797 		__field(unsigned int, count)
798 		__field(int, status)
799 		__field(int, posted)
800 		__string(addr, rpcrdma_addrstr(r_xprt))
801 		__string(port, rpcrdma_portstr(r_xprt))
802 	),
803 
804 	TP_fast_assign(
805 		__entry->r_xprt = r_xprt;
806 		__entry->count = count;
807 		__entry->status = status;
808 		__entry->posted = r_xprt->rx_ep->re_receive_count;
809 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
810 		__assign_str(port, rpcrdma_portstr(r_xprt));
811 	),
812 
813 	TP_printk("peer=[%s]:%s r_xprt=%p: %u new recvs, %d active (rc %d)",
814 		__get_str(addr), __get_str(port), __entry->r_xprt,
815 		__entry->count, __entry->posted, __entry->status
816 	)
817 );
818 
819 TRACE_EVENT(xprtrdma_post_linv,
820 	TP_PROTO(
821 		const struct rpcrdma_req *req,
822 		int status
823 	),
824 
825 	TP_ARGS(req, status),
826 
827 	TP_STRUCT__entry(
828 		__field(const void *, req)
829 		__field(int, status)
830 		__field(u32, xid)
831 	),
832 
833 	TP_fast_assign(
834 		__entry->req = req;
835 		__entry->status = status;
836 		__entry->xid = be32_to_cpu(req->rl_slot.rq_xid);
837 	),
838 
839 	TP_printk("req=%p xid=0x%08x status=%d",
840 		__entry->req, __entry->xid, __entry->status
841 	)
842 );
843 
844 /**
845  ** Completion events
846  **/
847 
848 TRACE_EVENT(xprtrdma_wc_send,
849 	TP_PROTO(
850 		const struct rpcrdma_sendctx *sc,
851 		const struct ib_wc *wc
852 	),
853 
854 	TP_ARGS(sc, wc),
855 
856 	TP_STRUCT__entry(
857 		__field(const void *, req)
858 		__field(const void *, sc)
859 		__field(unsigned int, unmap_count)
860 		__field(unsigned int, status)
861 		__field(unsigned int, vendor_err)
862 	),
863 
864 	TP_fast_assign(
865 		__entry->req = sc->sc_req;
866 		__entry->sc = sc;
867 		__entry->unmap_count = sc->sc_unmap_count;
868 		__entry->status = wc->status;
869 		__entry->vendor_err = __entry->status ? wc->vendor_err : 0;
870 	),
871 
872 	TP_printk("req=%p sc=%p unmapped=%u: %s (%u/0x%x)",
873 		__entry->req, __entry->sc, __entry->unmap_count,
874 		rdma_show_wc_status(__entry->status),
875 		__entry->status, __entry->vendor_err
876 	)
877 );
878 
879 TRACE_EVENT(xprtrdma_wc_receive,
880 	TP_PROTO(
881 		const struct ib_wc *wc
882 	),
883 
884 	TP_ARGS(wc),
885 
886 	TP_STRUCT__entry(
887 		__field(const void *, rep)
888 		__field(u32, byte_len)
889 		__field(unsigned int, status)
890 		__field(u32, vendor_err)
891 	),
892 
893 	TP_fast_assign(
894 		__entry->rep = container_of(wc->wr_cqe, struct rpcrdma_rep,
895 					    rr_cqe);
896 		__entry->status = wc->status;
897 		if (wc->status) {
898 			__entry->byte_len = 0;
899 			__entry->vendor_err = wc->vendor_err;
900 		} else {
901 			__entry->byte_len = wc->byte_len;
902 			__entry->vendor_err = 0;
903 		}
904 	),
905 
906 	TP_printk("rep=%p %u bytes: %s (%u/0x%x)",
907 		__entry->rep, __entry->byte_len,
908 		rdma_show_wc_status(__entry->status),
909 		__entry->status, __entry->vendor_err
910 	)
911 );
912 
913 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_fastreg);
914 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li);
915 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li_wake);
916 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li_done);
917 
918 TRACE_EVENT(xprtrdma_frwr_alloc,
919 	TP_PROTO(
920 		const struct rpcrdma_mr *mr,
921 		int rc
922 	),
923 
924 	TP_ARGS(mr, rc),
925 
926 	TP_STRUCT__entry(
927 		__field(u32, mr_id)
928 		__field(int, rc)
929 	),
930 
931 	TP_fast_assign(
932 		__entry->mr_id = mr->frwr.fr_mr->res.id;
933 		__entry->rc = rc;
934 	),
935 
936 	TP_printk("mr.id=%u: rc=%d",
937 		__entry->mr_id, __entry->rc
938 	)
939 );
940 
941 TRACE_EVENT(xprtrdma_frwr_dereg,
942 	TP_PROTO(
943 		const struct rpcrdma_mr *mr,
944 		int rc
945 	),
946 
947 	TP_ARGS(mr, rc),
948 
949 	TP_STRUCT__entry(
950 		__field(u32, mr_id)
951 		__field(int, nents)
952 		__field(u32, handle)
953 		__field(u32, length)
954 		__field(u64, offset)
955 		__field(u32, dir)
956 		__field(int, rc)
957 	),
958 
959 	TP_fast_assign(
960 		__entry->mr_id  = mr->frwr.fr_mr->res.id;
961 		__entry->nents  = mr->mr_nents;
962 		__entry->handle = mr->mr_handle;
963 		__entry->length = mr->mr_length;
964 		__entry->offset = mr->mr_offset;
965 		__entry->dir    = mr->mr_dir;
966 		__entry->rc	= rc;
967 	),
968 
969 	TP_printk("mr.id=%u nents=%d %u@0x%016llx:0x%08x (%s): rc=%d",
970 		__entry->mr_id, __entry->nents, __entry->length,
971 		(unsigned long long)__entry->offset, __entry->handle,
972 		xprtrdma_show_direction(__entry->dir),
973 		__entry->rc
974 	)
975 );
976 
977 TRACE_EVENT(xprtrdma_frwr_sgerr,
978 	TP_PROTO(
979 		const struct rpcrdma_mr *mr,
980 		int sg_nents
981 	),
982 
983 	TP_ARGS(mr, sg_nents),
984 
985 	TP_STRUCT__entry(
986 		__field(u32, mr_id)
987 		__field(u64, addr)
988 		__field(u32, dir)
989 		__field(int, nents)
990 	),
991 
992 	TP_fast_assign(
993 		__entry->mr_id = mr->frwr.fr_mr->res.id;
994 		__entry->addr = mr->mr_sg->dma_address;
995 		__entry->dir = mr->mr_dir;
996 		__entry->nents = sg_nents;
997 	),
998 
999 	TP_printk("mr.id=%u DMA addr=0x%llx (%s) sg_nents=%d",
1000 		__entry->mr_id, __entry->addr,
1001 		xprtrdma_show_direction(__entry->dir),
1002 		__entry->nents
1003 	)
1004 );
1005 
1006 TRACE_EVENT(xprtrdma_frwr_maperr,
1007 	TP_PROTO(
1008 		const struct rpcrdma_mr *mr,
1009 		int num_mapped
1010 	),
1011 
1012 	TP_ARGS(mr, num_mapped),
1013 
1014 	TP_STRUCT__entry(
1015 		__field(u32, mr_id)
1016 		__field(u64, addr)
1017 		__field(u32, dir)
1018 		__field(int, num_mapped)
1019 		__field(int, nents)
1020 	),
1021 
1022 	TP_fast_assign(
1023 		__entry->mr_id = mr->frwr.fr_mr->res.id;
1024 		__entry->addr = mr->mr_sg->dma_address;
1025 		__entry->dir = mr->mr_dir;
1026 		__entry->num_mapped = num_mapped;
1027 		__entry->nents = mr->mr_nents;
1028 	),
1029 
1030 	TP_printk("mr.id=%u DMA addr=0x%llx (%s) nents=%d of %d",
1031 		__entry->mr_id, __entry->addr,
1032 		xprtrdma_show_direction(__entry->dir),
1033 		__entry->num_mapped, __entry->nents
1034 	)
1035 );
1036 
1037 DEFINE_MR_EVENT(localinv);
1038 DEFINE_MR_EVENT(map);
1039 DEFINE_MR_EVENT(unmap);
1040 DEFINE_MR_EVENT(reminv);
1041 DEFINE_MR_EVENT(recycle);
1042 
1043 TRACE_EVENT(xprtrdma_dma_maperr,
1044 	TP_PROTO(
1045 		u64 addr
1046 	),
1047 
1048 	TP_ARGS(addr),
1049 
1050 	TP_STRUCT__entry(
1051 		__field(u64, addr)
1052 	),
1053 
1054 	TP_fast_assign(
1055 		__entry->addr = addr;
1056 	),
1057 
1058 	TP_printk("dma addr=0x%llx\n", __entry->addr)
1059 );
1060 
1061 /**
1062  ** Reply events
1063  **/
1064 
1065 TRACE_EVENT(xprtrdma_reply,
1066 	TP_PROTO(
1067 		const struct rpc_task *task,
1068 		const struct rpcrdma_rep *rep,
1069 		const struct rpcrdma_req *req,
1070 		unsigned int credits
1071 	),
1072 
1073 	TP_ARGS(task, rep, req, credits),
1074 
1075 	TP_STRUCT__entry(
1076 		__field(unsigned int, task_id)
1077 		__field(unsigned int, client_id)
1078 		__field(const void *, rep)
1079 		__field(const void *, req)
1080 		__field(u32, xid)
1081 		__field(unsigned int, credits)
1082 	),
1083 
1084 	TP_fast_assign(
1085 		__entry->task_id = task->tk_pid;
1086 		__entry->client_id = task->tk_client->cl_clid;
1087 		__entry->rep = rep;
1088 		__entry->req = req;
1089 		__entry->xid = be32_to_cpu(rep->rr_xid);
1090 		__entry->credits = credits;
1091 	),
1092 
1093 	TP_printk("task:%u@%u xid=0x%08x, %u credits, rep=%p -> req=%p",
1094 		__entry->task_id, __entry->client_id, __entry->xid,
1095 		__entry->credits, __entry->rep, __entry->req
1096 	)
1097 );
1098 
1099 TRACE_EVENT(xprtrdma_defer_cmp,
1100 	TP_PROTO(
1101 		const struct rpcrdma_rep *rep
1102 	),
1103 
1104 	TP_ARGS(rep),
1105 
1106 	TP_STRUCT__entry(
1107 		__field(unsigned int, task_id)
1108 		__field(unsigned int, client_id)
1109 		__field(const void *, rep)
1110 		__field(u32, xid)
1111 	),
1112 
1113 	TP_fast_assign(
1114 		__entry->task_id = rep->rr_rqst->rq_task->tk_pid;
1115 		__entry->client_id = rep->rr_rqst->rq_task->tk_client->cl_clid;
1116 		__entry->rep = rep;
1117 		__entry->xid = be32_to_cpu(rep->rr_xid);
1118 	),
1119 
1120 	TP_printk("task:%u@%u xid=0x%08x rep=%p",
1121 		__entry->task_id, __entry->client_id, __entry->xid,
1122 		__entry->rep
1123 	)
1124 );
1125 
1126 DEFINE_REPLY_EVENT(xprtrdma_reply_vers);
1127 DEFINE_REPLY_EVENT(xprtrdma_reply_rqst);
1128 DEFINE_REPLY_EVENT(xprtrdma_reply_short);
1129 DEFINE_REPLY_EVENT(xprtrdma_reply_hdr);
1130 
1131 TRACE_EVENT(xprtrdma_fixup,
1132 	TP_PROTO(
1133 		const struct rpc_rqst *rqst,
1134 		unsigned long fixup
1135 	),
1136 
1137 	TP_ARGS(rqst, fixup),
1138 
1139 	TP_STRUCT__entry(
1140 		__field(unsigned int, task_id)
1141 		__field(unsigned int, client_id)
1142 		__field(unsigned long, fixup)
1143 		__field(size_t, headlen)
1144 		__field(unsigned int, pagelen)
1145 		__field(size_t, taillen)
1146 	),
1147 
1148 	TP_fast_assign(
1149 		__entry->task_id = rqst->rq_task->tk_pid;
1150 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
1151 		__entry->fixup = fixup;
1152 		__entry->headlen = rqst->rq_rcv_buf.head[0].iov_len;
1153 		__entry->pagelen = rqst->rq_rcv_buf.page_len;
1154 		__entry->taillen = rqst->rq_rcv_buf.tail[0].iov_len;
1155 	),
1156 
1157 	TP_printk("task:%u@%u fixup=%lu xdr=%zu/%u/%zu",
1158 		__entry->task_id, __entry->client_id, __entry->fixup,
1159 		__entry->headlen, __entry->pagelen, __entry->taillen
1160 	)
1161 );
1162 
1163 TRACE_EVENT(xprtrdma_decode_seg,
1164 	TP_PROTO(
1165 		u32 handle,
1166 		u32 length,
1167 		u64 offset
1168 	),
1169 
1170 	TP_ARGS(handle, length, offset),
1171 
1172 	TP_STRUCT__entry(
1173 		__field(u32, handle)
1174 		__field(u32, length)
1175 		__field(u64, offset)
1176 	),
1177 
1178 	TP_fast_assign(
1179 		__entry->handle = handle;
1180 		__entry->length = length;
1181 		__entry->offset = offset;
1182 	),
1183 
1184 	TP_printk("%u@0x%016llx:0x%08x",
1185 		__entry->length, (unsigned long long)__entry->offset,
1186 		__entry->handle
1187 	)
1188 );
1189 
1190 /**
1191  ** Callback events
1192  **/
1193 
1194 TRACE_EVENT(xprtrdma_cb_setup,
1195 	TP_PROTO(
1196 		const struct rpcrdma_xprt *r_xprt,
1197 		unsigned int reqs
1198 	),
1199 
1200 	TP_ARGS(r_xprt, reqs),
1201 
1202 	TP_STRUCT__entry(
1203 		__field(const void *, r_xprt)
1204 		__field(unsigned int, reqs)
1205 		__string(addr, rpcrdma_addrstr(r_xprt))
1206 		__string(port, rpcrdma_portstr(r_xprt))
1207 	),
1208 
1209 	TP_fast_assign(
1210 		__entry->r_xprt = r_xprt;
1211 		__entry->reqs = reqs;
1212 		__assign_str(addr, rpcrdma_addrstr(r_xprt));
1213 		__assign_str(port, rpcrdma_portstr(r_xprt));
1214 	),
1215 
1216 	TP_printk("peer=[%s]:%s r_xprt=%p: %u reqs",
1217 		__get_str(addr), __get_str(port),
1218 		__entry->r_xprt, __entry->reqs
1219 	)
1220 );
1221 
1222 DEFINE_CB_EVENT(xprtrdma_cb_call);
1223 DEFINE_CB_EVENT(xprtrdma_cb_reply);
1224 
1225 TRACE_EVENT(xprtrdma_leaked_rep,
1226 	TP_PROTO(
1227 		const struct rpc_rqst *rqst,
1228 		const struct rpcrdma_rep *rep
1229 	),
1230 
1231 	TP_ARGS(rqst, rep),
1232 
1233 	TP_STRUCT__entry(
1234 		__field(unsigned int, task_id)
1235 		__field(unsigned int, client_id)
1236 		__field(u32, xid)
1237 		__field(const void *, rep)
1238 	),
1239 
1240 	TP_fast_assign(
1241 		__entry->task_id = rqst->rq_task->tk_pid;
1242 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
1243 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1244 		__entry->rep = rep;
1245 	),
1246 
1247 	TP_printk("task:%u@%u xid=0x%08x rep=%p",
1248 		__entry->task_id, __entry->client_id, __entry->xid,
1249 		__entry->rep
1250 	)
1251 );
1252 
1253 /**
1254  ** Server-side RPC/RDMA events
1255  **/
1256 
1257 DECLARE_EVENT_CLASS(svcrdma_accept_class,
1258 	TP_PROTO(
1259 		const struct svcxprt_rdma *rdma,
1260 		long status
1261 	),
1262 
1263 	TP_ARGS(rdma, status),
1264 
1265 	TP_STRUCT__entry(
1266 		__field(long, status)
1267 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1268 	),
1269 
1270 	TP_fast_assign(
1271 		__entry->status = status;
1272 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1273 	),
1274 
1275 	TP_printk("addr=%s status=%ld",
1276 		__get_str(addr), __entry->status
1277 	)
1278 );
1279 
1280 #define DEFINE_ACCEPT_EVENT(name) \
1281 		DEFINE_EVENT(svcrdma_accept_class, svcrdma_##name##_err, \
1282 				TP_PROTO( \
1283 					const struct svcxprt_rdma *rdma, \
1284 					long status \
1285 				), \
1286 				TP_ARGS(rdma, status))
1287 
1288 DEFINE_ACCEPT_EVENT(pd);
1289 DEFINE_ACCEPT_EVENT(qp);
1290 DEFINE_ACCEPT_EVENT(fabric);
1291 DEFINE_ACCEPT_EVENT(initdepth);
1292 DEFINE_ACCEPT_EVENT(accept);
1293 
1294 TRACE_DEFINE_ENUM(RDMA_MSG);
1295 TRACE_DEFINE_ENUM(RDMA_NOMSG);
1296 TRACE_DEFINE_ENUM(RDMA_MSGP);
1297 TRACE_DEFINE_ENUM(RDMA_DONE);
1298 TRACE_DEFINE_ENUM(RDMA_ERROR);
1299 
1300 #define show_rpcrdma_proc(x)						\
1301 		__print_symbolic(x,					\
1302 				{ RDMA_MSG, "RDMA_MSG" },		\
1303 				{ RDMA_NOMSG, "RDMA_NOMSG" },		\
1304 				{ RDMA_MSGP, "RDMA_MSGP" },		\
1305 				{ RDMA_DONE, "RDMA_DONE" },		\
1306 				{ RDMA_ERROR, "RDMA_ERROR" })
1307 
1308 TRACE_EVENT(svcrdma_decode_rqst,
1309 	TP_PROTO(
1310 		const struct svc_rdma_recv_ctxt *ctxt,
1311 		__be32 *p,
1312 		unsigned int hdrlen
1313 	),
1314 
1315 	TP_ARGS(ctxt, p, hdrlen),
1316 
1317 	TP_STRUCT__entry(
1318 		__field(u32, cq_id)
1319 		__field(int, completion_id)
1320 		__field(u32, xid)
1321 		__field(u32, vers)
1322 		__field(u32, proc)
1323 		__field(u32, credits)
1324 		__field(unsigned int, hdrlen)
1325 	),
1326 
1327 	TP_fast_assign(
1328 		__entry->cq_id = ctxt->rc_cid.ci_queue_id;
1329 		__entry->completion_id = ctxt->rc_cid.ci_completion_id;
1330 		__entry->xid = be32_to_cpup(p++);
1331 		__entry->vers = be32_to_cpup(p++);
1332 		__entry->credits = be32_to_cpup(p++);
1333 		__entry->proc = be32_to_cpup(p);
1334 		__entry->hdrlen = hdrlen;
1335 	),
1336 
1337 	TP_printk("cq.id=%u cid=%d xid=0x%08x vers=%u credits=%u proc=%s hdrlen=%u",
1338 		__entry->cq_id, __entry->completion_id,
1339 		__entry->xid, __entry->vers, __entry->credits,
1340 		show_rpcrdma_proc(__entry->proc), __entry->hdrlen)
1341 );
1342 
1343 TRACE_EVENT(svcrdma_decode_short_err,
1344 	TP_PROTO(
1345 		const struct svc_rdma_recv_ctxt *ctxt,
1346 		unsigned int hdrlen
1347 	),
1348 
1349 	TP_ARGS(ctxt, hdrlen),
1350 
1351 	TP_STRUCT__entry(
1352 		__field(u32, cq_id)
1353 		__field(int, completion_id)
1354 		__field(unsigned int, hdrlen)
1355 	),
1356 
1357 	TP_fast_assign(
1358 		__entry->cq_id = ctxt->rc_cid.ci_queue_id;
1359 		__entry->completion_id = ctxt->rc_cid.ci_completion_id;
1360 		__entry->hdrlen = hdrlen;
1361 	),
1362 
1363 	TP_printk("cq.id=%u cid=%d hdrlen=%u",
1364 		__entry->cq_id, __entry->completion_id,
1365 		__entry->hdrlen)
1366 );
1367 
1368 DECLARE_EVENT_CLASS(svcrdma_badreq_event,
1369 	TP_PROTO(
1370 		const struct svc_rdma_recv_ctxt *ctxt,
1371 		__be32 *p
1372 	),
1373 
1374 	TP_ARGS(ctxt, p),
1375 
1376 	TP_STRUCT__entry(
1377 		__field(u32, cq_id)
1378 		__field(int, completion_id)
1379 		__field(u32, xid)
1380 		__field(u32, vers)
1381 		__field(u32, proc)
1382 		__field(u32, credits)
1383 	),
1384 
1385 	TP_fast_assign(
1386 		__entry->cq_id = ctxt->rc_cid.ci_queue_id;
1387 		__entry->completion_id = ctxt->rc_cid.ci_completion_id;
1388 		__entry->xid = be32_to_cpup(p++);
1389 		__entry->vers = be32_to_cpup(p++);
1390 		__entry->credits = be32_to_cpup(p++);
1391 		__entry->proc = be32_to_cpup(p);
1392 	),
1393 
1394 	TP_printk("cq.id=%u cid=%d xid=0x%08x vers=%u credits=%u proc=%u",
1395 		__entry->cq_id, __entry->completion_id,
1396 		__entry->xid, __entry->vers, __entry->credits, __entry->proc)
1397 );
1398 
1399 #define DEFINE_BADREQ_EVENT(name)					\
1400 		DEFINE_EVENT(svcrdma_badreq_event,			\
1401 			     svcrdma_decode_##name##_err,		\
1402 				TP_PROTO(				\
1403 					const struct svc_rdma_recv_ctxt *ctxt,	\
1404 					__be32 *p			\
1405 				),					\
1406 				TP_ARGS(ctxt, p))
1407 
1408 DEFINE_BADREQ_EVENT(badvers);
1409 DEFINE_BADREQ_EVENT(drop);
1410 DEFINE_BADREQ_EVENT(badproc);
1411 DEFINE_BADREQ_EVENT(parse);
1412 
1413 DECLARE_EVENT_CLASS(svcrdma_segment_event,
1414 	TP_PROTO(
1415 		u32 handle,
1416 		u32 length,
1417 		u64 offset
1418 	),
1419 
1420 	TP_ARGS(handle, length, offset),
1421 
1422 	TP_STRUCT__entry(
1423 		__field(u32, handle)
1424 		__field(u32, length)
1425 		__field(u64, offset)
1426 	),
1427 
1428 	TP_fast_assign(
1429 		__entry->handle = handle;
1430 		__entry->length = length;
1431 		__entry->offset = offset;
1432 	),
1433 
1434 	TP_printk("%u@0x%016llx:0x%08x",
1435 		__entry->length, (unsigned long long)__entry->offset,
1436 		__entry->handle
1437 	)
1438 );
1439 
1440 #define DEFINE_SEGMENT_EVENT(name)					\
1441 		DEFINE_EVENT(svcrdma_segment_event, svcrdma_##name,\
1442 				TP_PROTO(				\
1443 					u32 handle,			\
1444 					u32 length,			\
1445 					u64 offset			\
1446 				),					\
1447 				TP_ARGS(handle, length, offset))
1448 
1449 DEFINE_SEGMENT_EVENT(decode_wseg);
1450 DEFINE_SEGMENT_EVENT(encode_rseg);
1451 DEFINE_SEGMENT_EVENT(send_rseg);
1452 DEFINE_SEGMENT_EVENT(encode_wseg);
1453 DEFINE_SEGMENT_EVENT(send_wseg);
1454 
1455 DECLARE_EVENT_CLASS(svcrdma_chunk_event,
1456 	TP_PROTO(
1457 		u32 length
1458 	),
1459 
1460 	TP_ARGS(length),
1461 
1462 	TP_STRUCT__entry(
1463 		__field(u32, length)
1464 	),
1465 
1466 	TP_fast_assign(
1467 		__entry->length = length;
1468 	),
1469 
1470 	TP_printk("length=%u",
1471 		__entry->length
1472 	)
1473 );
1474 
1475 #define DEFINE_CHUNK_EVENT(name)					\
1476 		DEFINE_EVENT(svcrdma_chunk_event, svcrdma_##name,	\
1477 				TP_PROTO(				\
1478 					u32 length			\
1479 				),					\
1480 				TP_ARGS(length))
1481 
1482 DEFINE_CHUNK_EVENT(send_pzr);
1483 DEFINE_CHUNK_EVENT(encode_write_chunk);
1484 DEFINE_CHUNK_EVENT(send_write_chunk);
1485 DEFINE_CHUNK_EVENT(encode_read_chunk);
1486 DEFINE_CHUNK_EVENT(send_reply_chunk);
1487 
1488 TRACE_EVENT(svcrdma_send_read_chunk,
1489 	TP_PROTO(
1490 		u32 length,
1491 		u32 position
1492 	),
1493 
1494 	TP_ARGS(length, position),
1495 
1496 	TP_STRUCT__entry(
1497 		__field(u32, length)
1498 		__field(u32, position)
1499 	),
1500 
1501 	TP_fast_assign(
1502 		__entry->length = length;
1503 		__entry->position = position;
1504 	),
1505 
1506 	TP_printk("length=%u position=%u",
1507 		__entry->length, __entry->position
1508 	)
1509 );
1510 
1511 DECLARE_EVENT_CLASS(svcrdma_error_event,
1512 	TP_PROTO(
1513 		__be32 xid
1514 	),
1515 
1516 	TP_ARGS(xid),
1517 
1518 	TP_STRUCT__entry(
1519 		__field(u32, xid)
1520 	),
1521 
1522 	TP_fast_assign(
1523 		__entry->xid = be32_to_cpu(xid);
1524 	),
1525 
1526 	TP_printk("xid=0x%08x",
1527 		__entry->xid
1528 	)
1529 );
1530 
1531 #define DEFINE_ERROR_EVENT(name)					\
1532 		DEFINE_EVENT(svcrdma_error_event, svcrdma_err_##name,	\
1533 				TP_PROTO(				\
1534 					__be32 xid			\
1535 				),					\
1536 				TP_ARGS(xid))
1537 
1538 DEFINE_ERROR_EVENT(vers);
1539 DEFINE_ERROR_EVENT(chunk);
1540 
1541 /**
1542  ** Server-side RDMA API events
1543  **/
1544 
1545 DECLARE_EVENT_CLASS(svcrdma_dma_map_class,
1546 	TP_PROTO(
1547 		const struct svcxprt_rdma *rdma,
1548 		u64 dma_addr,
1549 		u32 length
1550 	),
1551 
1552 	TP_ARGS(rdma, dma_addr, length),
1553 
1554 	TP_STRUCT__entry(
1555 		__field(u64, dma_addr)
1556 		__field(u32, length)
1557 		__string(device, rdma->sc_cm_id->device->name)
1558 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1559 	),
1560 
1561 	TP_fast_assign(
1562 		__entry->dma_addr = dma_addr;
1563 		__entry->length = length;
1564 		__assign_str(device, rdma->sc_cm_id->device->name);
1565 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1566 	),
1567 
1568 	TP_printk("addr=%s device=%s dma_addr=%llu length=%u",
1569 		__get_str(addr), __get_str(device),
1570 		__entry->dma_addr, __entry->length
1571 	)
1572 );
1573 
1574 #define DEFINE_SVC_DMA_EVENT(name)					\
1575 		DEFINE_EVENT(svcrdma_dma_map_class, svcrdma_##name,	\
1576 				TP_PROTO(				\
1577 					const struct svcxprt_rdma *rdma,\
1578 					u64 dma_addr,			\
1579 					u32 length			\
1580 				),					\
1581 				TP_ARGS(rdma, dma_addr, length))
1582 
1583 DEFINE_SVC_DMA_EVENT(dma_map_page);
1584 DEFINE_SVC_DMA_EVENT(dma_unmap_page);
1585 
1586 TRACE_EVENT(svcrdma_dma_map_rw_err,
1587 	TP_PROTO(
1588 		const struct svcxprt_rdma *rdma,
1589 		unsigned int nents,
1590 		int status
1591 	),
1592 
1593 	TP_ARGS(rdma, nents, status),
1594 
1595 	TP_STRUCT__entry(
1596 		__field(int, status)
1597 		__field(unsigned int, nents)
1598 		__string(device, rdma->sc_cm_id->device->name)
1599 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1600 	),
1601 
1602 	TP_fast_assign(
1603 		__entry->status = status;
1604 		__entry->nents = nents;
1605 		__assign_str(device, rdma->sc_cm_id->device->name);
1606 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1607 	),
1608 
1609 	TP_printk("addr=%s device=%s nents=%u status=%d",
1610 		__get_str(addr), __get_str(device), __entry->nents,
1611 		__entry->status
1612 	)
1613 );
1614 
1615 TRACE_EVENT(svcrdma_no_rwctx_err,
1616 	TP_PROTO(
1617 		const struct svcxprt_rdma *rdma,
1618 		unsigned int num_sges
1619 	),
1620 
1621 	TP_ARGS(rdma, num_sges),
1622 
1623 	TP_STRUCT__entry(
1624 		__field(unsigned int, num_sges)
1625 		__string(device, rdma->sc_cm_id->device->name)
1626 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1627 	),
1628 
1629 	TP_fast_assign(
1630 		__entry->num_sges = num_sges;
1631 		__assign_str(device, rdma->sc_cm_id->device->name);
1632 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1633 	),
1634 
1635 	TP_printk("addr=%s device=%s num_sges=%d",
1636 		__get_str(addr), __get_str(device), __entry->num_sges
1637 	)
1638 );
1639 
1640 TRACE_EVENT(svcrdma_page_overrun_err,
1641 	TP_PROTO(
1642 		const struct svcxprt_rdma *rdma,
1643 		const struct svc_rqst *rqst,
1644 		unsigned int pageno
1645 	),
1646 
1647 	TP_ARGS(rdma, rqst, pageno),
1648 
1649 	TP_STRUCT__entry(
1650 		__field(unsigned int, pageno)
1651 		__field(u32, xid)
1652 		__string(device, rdma->sc_cm_id->device->name)
1653 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1654 	),
1655 
1656 	TP_fast_assign(
1657 		__entry->pageno = pageno;
1658 		__entry->xid = __be32_to_cpu(rqst->rq_xid);
1659 		__assign_str(device, rdma->sc_cm_id->device->name);
1660 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1661 	),
1662 
1663 	TP_printk("addr=%s device=%s xid=0x%08x pageno=%u", __get_str(addr),
1664 		__get_str(device), __entry->xid, __entry->pageno
1665 	)
1666 );
1667 
1668 TRACE_EVENT(svcrdma_small_wrch_err,
1669 	TP_PROTO(
1670 		const struct svcxprt_rdma *rdma,
1671 		unsigned int remaining,
1672 		unsigned int seg_no,
1673 		unsigned int num_segs
1674 	),
1675 
1676 	TP_ARGS(rdma, remaining, seg_no, num_segs),
1677 
1678 	TP_STRUCT__entry(
1679 		__field(unsigned int, remaining)
1680 		__field(unsigned int, seg_no)
1681 		__field(unsigned int, num_segs)
1682 		__string(device, rdma->sc_cm_id->device->name)
1683 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1684 	),
1685 
1686 	TP_fast_assign(
1687 		__entry->remaining = remaining;
1688 		__entry->seg_no = seg_no;
1689 		__entry->num_segs = num_segs;
1690 		__assign_str(device, rdma->sc_cm_id->device->name);
1691 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1692 	),
1693 
1694 	TP_printk("addr=%s device=%s remaining=%u seg_no=%u num_segs=%u",
1695 		__get_str(addr), __get_str(device), __entry->remaining,
1696 		__entry->seg_no, __entry->num_segs
1697 	)
1698 );
1699 
1700 TRACE_EVENT(svcrdma_send_pullup,
1701 	TP_PROTO(
1702 		unsigned int len
1703 	),
1704 
1705 	TP_ARGS(len),
1706 
1707 	TP_STRUCT__entry(
1708 		__field(unsigned int, len)
1709 	),
1710 
1711 	TP_fast_assign(
1712 		__entry->len = len;
1713 	),
1714 
1715 	TP_printk("len=%u", __entry->len)
1716 );
1717 
1718 TRACE_EVENT(svcrdma_send_err,
1719 	TP_PROTO(
1720 		const struct svc_rqst *rqst,
1721 		int status
1722 	),
1723 
1724 	TP_ARGS(rqst, status),
1725 
1726 	TP_STRUCT__entry(
1727 		__field(int, status)
1728 		__field(u32, xid)
1729 		__string(addr, rqst->rq_xprt->xpt_remotebuf)
1730 	),
1731 
1732 	TP_fast_assign(
1733 		__entry->status = status;
1734 		__entry->xid = __be32_to_cpu(rqst->rq_xid);
1735 		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
1736 	),
1737 
1738 	TP_printk("addr=%s xid=0x%08x status=%d", __get_str(addr),
1739 		__entry->xid, __entry->status
1740 	)
1741 );
1742 
1743 TRACE_EVENT(svcrdma_post_send,
1744 	TP_PROTO(
1745 		const struct svc_rdma_send_ctxt *ctxt
1746 	),
1747 
1748 	TP_ARGS(ctxt),
1749 
1750 	TP_STRUCT__entry(
1751 		__field(u32, cq_id)
1752 		__field(int, completion_id)
1753 		__field(unsigned int, num_sge)
1754 		__field(u32, inv_rkey)
1755 	),
1756 
1757 	TP_fast_assign(
1758 		const struct ib_send_wr *wr = &ctxt->sc_send_wr;
1759 
1760 		__entry->cq_id = ctxt->sc_cid.ci_queue_id;
1761 		__entry->completion_id = ctxt->sc_cid.ci_completion_id;
1762 		__entry->num_sge = wr->num_sge;
1763 		__entry->inv_rkey = (wr->opcode == IB_WR_SEND_WITH_INV) ?
1764 					wr->ex.invalidate_rkey : 0;
1765 	),
1766 
1767 	TP_printk("cq_id=%u cid=%d num_sge=%u inv_rkey=0x%08x",
1768 		__entry->cq_id, __entry->completion_id,
1769 		__entry->num_sge, __entry->inv_rkey
1770 	)
1771 );
1772 
1773 DEFINE_COMPLETION_EVENT(svcrdma_wc_send);
1774 
1775 TRACE_EVENT(svcrdma_post_recv,
1776 	TP_PROTO(
1777 		const struct svc_rdma_recv_ctxt *ctxt
1778 	),
1779 
1780 	TP_ARGS(ctxt),
1781 
1782 	TP_STRUCT__entry(
1783 		__field(u32, cq_id)
1784 		__field(int, completion_id)
1785 	),
1786 
1787 	TP_fast_assign(
1788 		__entry->cq_id = ctxt->rc_cid.ci_queue_id;
1789 		__entry->completion_id = ctxt->rc_cid.ci_completion_id;
1790 	),
1791 
1792 	TP_printk("cq.id=%d cid=%d",
1793 		__entry->cq_id, __entry->completion_id
1794 	)
1795 );
1796 
1797 DEFINE_COMPLETION_EVENT(svcrdma_wc_receive);
1798 
1799 TRACE_EVENT(svcrdma_rq_post_err,
1800 	TP_PROTO(
1801 		const struct svcxprt_rdma *rdma,
1802 		int status
1803 	),
1804 
1805 	TP_ARGS(rdma, status),
1806 
1807 	TP_STRUCT__entry(
1808 		__field(int, status)
1809 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1810 	),
1811 
1812 	TP_fast_assign(
1813 		__entry->status = status;
1814 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1815 	),
1816 
1817 	TP_printk("addr=%s status=%d",
1818 		__get_str(addr), __entry->status
1819 	)
1820 );
1821 
1822 TRACE_EVENT(svcrdma_post_chunk,
1823 	TP_PROTO(
1824 		const struct rpc_rdma_cid *cid,
1825 		int sqecount
1826 	),
1827 
1828 	TP_ARGS(cid, sqecount),
1829 
1830 	TP_STRUCT__entry(
1831 		__field(u32, cq_id)
1832 		__field(int, completion_id)
1833 		__field(int, sqecount)
1834 	),
1835 
1836 	TP_fast_assign(
1837 		__entry->cq_id = cid->ci_queue_id;
1838 		__entry->completion_id = cid->ci_completion_id;
1839 		__entry->sqecount = sqecount;
1840 	),
1841 
1842 	TP_printk("cq.id=%u cid=%d sqecount=%d",
1843 		__entry->cq_id, __entry->completion_id,
1844 		__entry->sqecount
1845 	)
1846 );
1847 
1848 DEFINE_COMPLETION_EVENT(svcrdma_wc_read);
1849 DEFINE_COMPLETION_EVENT(svcrdma_wc_write);
1850 
1851 TRACE_EVENT(svcrdma_qp_error,
1852 	TP_PROTO(
1853 		const struct ib_event *event,
1854 		const struct sockaddr *sap
1855 	),
1856 
1857 	TP_ARGS(event, sap),
1858 
1859 	TP_STRUCT__entry(
1860 		__field(unsigned int, event)
1861 		__string(device, event->device->name)
1862 		__array(__u8, addr, INET6_ADDRSTRLEN + 10)
1863 	),
1864 
1865 	TP_fast_assign(
1866 		__entry->event = event->event;
1867 		__assign_str(device, event->device->name);
1868 		snprintf(__entry->addr, sizeof(__entry->addr) - 1,
1869 			 "%pISpc", sap);
1870 	),
1871 
1872 	TP_printk("addr=%s dev=%s event=%s (%u)",
1873 		__entry->addr, __get_str(device),
1874 		rdma_show_ib_event(__entry->event), __entry->event
1875 	)
1876 );
1877 
1878 DECLARE_EVENT_CLASS(svcrdma_sendqueue_event,
1879 	TP_PROTO(
1880 		const struct svcxprt_rdma *rdma
1881 	),
1882 
1883 	TP_ARGS(rdma),
1884 
1885 	TP_STRUCT__entry(
1886 		__field(int, avail)
1887 		__field(int, depth)
1888 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1889 	),
1890 
1891 	TP_fast_assign(
1892 		__entry->avail = atomic_read(&rdma->sc_sq_avail);
1893 		__entry->depth = rdma->sc_sq_depth;
1894 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1895 	),
1896 
1897 	TP_printk("addr=%s sc_sq_avail=%d/%d",
1898 		__get_str(addr), __entry->avail, __entry->depth
1899 	)
1900 );
1901 
1902 #define DEFINE_SQ_EVENT(name)						\
1903 		DEFINE_EVENT(svcrdma_sendqueue_event, svcrdma_sq_##name,\
1904 				TP_PROTO(				\
1905 					const struct svcxprt_rdma *rdma \
1906 				),					\
1907 				TP_ARGS(rdma))
1908 
1909 DEFINE_SQ_EVENT(full);
1910 DEFINE_SQ_EVENT(retry);
1911 
1912 TRACE_EVENT(svcrdma_sq_post_err,
1913 	TP_PROTO(
1914 		const struct svcxprt_rdma *rdma,
1915 		int status
1916 	),
1917 
1918 	TP_ARGS(rdma, status),
1919 
1920 	TP_STRUCT__entry(
1921 		__field(int, avail)
1922 		__field(int, depth)
1923 		__field(int, status)
1924 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
1925 	),
1926 
1927 	TP_fast_assign(
1928 		__entry->avail = atomic_read(&rdma->sc_sq_avail);
1929 		__entry->depth = rdma->sc_sq_depth;
1930 		__entry->status = status;
1931 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
1932 	),
1933 
1934 	TP_printk("addr=%s sc_sq_avail=%d/%d status=%d",
1935 		__get_str(addr), __entry->avail, __entry->depth,
1936 		__entry->status
1937 	)
1938 );
1939 
1940 #endif /* _TRACE_RPCRDMA_H */
1941 
1942 #include <trace/define_trace.h>
1943