xref: /openbmc/linux/include/trace/events/sunrpc.h (revision 2a12187d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM sunrpc
4 
5 #if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_SUNRPC_H
7 
8 #include <linux/sunrpc/sched.h>
9 #include <linux/sunrpc/clnt.h>
10 #include <linux/sunrpc/svc.h>
11 #include <linux/sunrpc/xprtsock.h>
12 #include <linux/sunrpc/svc_xprt.h>
13 #include <net/tcp_states.h>
14 #include <linux/net.h>
15 #include <linux/tracepoint.h>
16 
17 #include <trace/misc/sunrpc.h>
18 
19 TRACE_DEFINE_ENUM(SOCK_STREAM);
20 TRACE_DEFINE_ENUM(SOCK_DGRAM);
21 TRACE_DEFINE_ENUM(SOCK_RAW);
22 TRACE_DEFINE_ENUM(SOCK_RDM);
23 TRACE_DEFINE_ENUM(SOCK_SEQPACKET);
24 TRACE_DEFINE_ENUM(SOCK_DCCP);
25 TRACE_DEFINE_ENUM(SOCK_PACKET);
26 
27 #define show_socket_type(type)					\
28 	__print_symbolic(type,					\
29 		{ SOCK_STREAM,		"STREAM" },		\
30 		{ SOCK_DGRAM,		"DGRAM" },		\
31 		{ SOCK_RAW,		"RAW" },		\
32 		{ SOCK_RDM,		"RDM" },		\
33 		{ SOCK_SEQPACKET,	"SEQPACKET" },		\
34 		{ SOCK_DCCP,		"DCCP" },		\
35 		{ SOCK_PACKET,		"PACKET" })
36 
37 /* This list is known to be incomplete, add new enums as needed. */
38 TRACE_DEFINE_ENUM(AF_UNSPEC);
39 TRACE_DEFINE_ENUM(AF_UNIX);
40 TRACE_DEFINE_ENUM(AF_LOCAL);
41 TRACE_DEFINE_ENUM(AF_INET);
42 TRACE_DEFINE_ENUM(AF_INET6);
43 
44 #define rpc_show_address_family(family)				\
45 	__print_symbolic(family,				\
46 		{ AF_UNSPEC,		"AF_UNSPEC" },		\
47 		{ AF_UNIX,		"AF_UNIX" },		\
48 		{ AF_LOCAL,		"AF_LOCAL" },		\
49 		{ AF_INET,		"AF_INET" },		\
50 		{ AF_INET6,		"AF_INET6" })
51 
52 DECLARE_EVENT_CLASS(rpc_xdr_buf_class,
53 	TP_PROTO(
54 		const struct rpc_task *task,
55 		const struct xdr_buf *xdr
56 	),
57 
58 	TP_ARGS(task, xdr),
59 
60 	TP_STRUCT__entry(
61 		__field(unsigned int, task_id)
62 		__field(unsigned int, client_id)
63 		__field(const void *, head_base)
64 		__field(size_t, head_len)
65 		__field(const void *, tail_base)
66 		__field(size_t, tail_len)
67 		__field(unsigned int, page_base)
68 		__field(unsigned int, page_len)
69 		__field(unsigned int, msg_len)
70 	),
71 
72 	TP_fast_assign(
73 		__entry->task_id = task->tk_pid;
74 		__entry->client_id = task->tk_client ?
75 				     task->tk_client->cl_clid : -1;
76 		__entry->head_base = xdr->head[0].iov_base;
77 		__entry->head_len = xdr->head[0].iov_len;
78 		__entry->tail_base = xdr->tail[0].iov_base;
79 		__entry->tail_len = xdr->tail[0].iov_len;
80 		__entry->page_base = xdr->page_base;
81 		__entry->page_len = xdr->page_len;
82 		__entry->msg_len = xdr->len;
83 	),
84 
85 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
86 		  " head=[%p,%zu] page=%u(%u) tail=[%p,%zu] len=%u",
87 		__entry->task_id, __entry->client_id,
88 		__entry->head_base, __entry->head_len,
89 		__entry->page_len, __entry->page_base,
90 		__entry->tail_base, __entry->tail_len,
91 		__entry->msg_len
92 	)
93 );
94 
95 #define DEFINE_RPCXDRBUF_EVENT(name)					\
96 		DEFINE_EVENT(rpc_xdr_buf_class,				\
97 				rpc_xdr_##name,				\
98 				TP_PROTO(				\
99 					const struct rpc_task *task,	\
100 					const struct xdr_buf *xdr	\
101 				),					\
102 				TP_ARGS(task, xdr))
103 
104 DEFINE_RPCXDRBUF_EVENT(sendto);
105 DEFINE_RPCXDRBUF_EVENT(recvfrom);
106 DEFINE_RPCXDRBUF_EVENT(reply_pages);
107 
108 
109 DECLARE_EVENT_CLASS(rpc_clnt_class,
110 	TP_PROTO(
111 		const struct rpc_clnt *clnt
112 	),
113 
114 	TP_ARGS(clnt),
115 
116 	TP_STRUCT__entry(
117 		__field(unsigned int, client_id)
118 	),
119 
120 	TP_fast_assign(
121 		__entry->client_id = clnt->cl_clid;
122 	),
123 
124 	TP_printk("client=" SUNRPC_TRACE_CLID_SPECIFIER, __entry->client_id)
125 );
126 
127 #define DEFINE_RPC_CLNT_EVENT(name)					\
128 		DEFINE_EVENT(rpc_clnt_class,				\
129 				rpc_clnt_##name,			\
130 				TP_PROTO(				\
131 					const struct rpc_clnt *clnt	\
132 				),					\
133 				TP_ARGS(clnt))
134 
135 DEFINE_RPC_CLNT_EVENT(free);
136 DEFINE_RPC_CLNT_EVENT(killall);
137 DEFINE_RPC_CLNT_EVENT(shutdown);
138 DEFINE_RPC_CLNT_EVENT(release);
139 DEFINE_RPC_CLNT_EVENT(replace_xprt);
140 DEFINE_RPC_CLNT_EVENT(replace_xprt_err);
141 
142 TRACE_EVENT(rpc_clnt_new,
143 	TP_PROTO(
144 		const struct rpc_clnt *clnt,
145 		const struct rpc_xprt *xprt,
146 		const char *program,
147 		const char *server
148 	),
149 
150 	TP_ARGS(clnt, xprt, program, server),
151 
152 	TP_STRUCT__entry(
153 		__field(unsigned int, client_id)
154 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
155 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
156 		__string(program, program)
157 		__string(server, server)
158 	),
159 
160 	TP_fast_assign(
161 		__entry->client_id = clnt->cl_clid;
162 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
163 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
164 		__assign_str(program, program);
165 		__assign_str(server, server);
166 	),
167 
168 	TP_printk("client=" SUNRPC_TRACE_CLID_SPECIFIER
169 		  " peer=[%s]:%s program=%s server=%s",
170 		__entry->client_id, __get_str(addr), __get_str(port),
171 		__get_str(program), __get_str(server))
172 );
173 
174 TRACE_EVENT(rpc_clnt_new_err,
175 	TP_PROTO(
176 		const char *program,
177 		const char *server,
178 		int error
179 	),
180 
181 	TP_ARGS(program, server, error),
182 
183 	TP_STRUCT__entry(
184 		__field(int, error)
185 		__string(program, program)
186 		__string(server, server)
187 	),
188 
189 	TP_fast_assign(
190 		__entry->error = error;
191 		__assign_str(program, program);
192 		__assign_str(server, server);
193 	),
194 
195 	TP_printk("program=%s server=%s error=%d",
196 		__get_str(program), __get_str(server), __entry->error)
197 );
198 
199 TRACE_EVENT(rpc_clnt_clone_err,
200 	TP_PROTO(
201 		const struct rpc_clnt *clnt,
202 		int error
203 	),
204 
205 	TP_ARGS(clnt, error),
206 
207 	TP_STRUCT__entry(
208 		__field(unsigned int, client_id)
209 		__field(int, error)
210 	),
211 
212 	TP_fast_assign(
213 		__entry->client_id = clnt->cl_clid;
214 		__entry->error = error;
215 	),
216 
217 	TP_printk("client=" SUNRPC_TRACE_CLID_SPECIFIER " error=%d",
218 		__entry->client_id, __entry->error)
219 );
220 
221 
222 TRACE_DEFINE_ENUM(RPC_AUTH_OK);
223 TRACE_DEFINE_ENUM(RPC_AUTH_BADCRED);
224 TRACE_DEFINE_ENUM(RPC_AUTH_REJECTEDCRED);
225 TRACE_DEFINE_ENUM(RPC_AUTH_BADVERF);
226 TRACE_DEFINE_ENUM(RPC_AUTH_REJECTEDVERF);
227 TRACE_DEFINE_ENUM(RPC_AUTH_TOOWEAK);
228 TRACE_DEFINE_ENUM(RPCSEC_GSS_CREDPROBLEM);
229 TRACE_DEFINE_ENUM(RPCSEC_GSS_CTXPROBLEM);
230 
231 #define rpc_show_auth_stat(status)					\
232 	__print_symbolic(status,					\
233 		{ RPC_AUTH_OK,			"AUTH_OK" },		\
234 		{ RPC_AUTH_BADCRED,		"BADCRED" },		\
235 		{ RPC_AUTH_REJECTEDCRED,	"REJECTEDCRED" },	\
236 		{ RPC_AUTH_BADVERF,		"BADVERF" },		\
237 		{ RPC_AUTH_REJECTEDVERF,	"REJECTEDVERF" },	\
238 		{ RPC_AUTH_TOOWEAK,		"TOOWEAK" },		\
239 		{ RPCSEC_GSS_CREDPROBLEM,	"GSS_CREDPROBLEM" },	\
240 		{ RPCSEC_GSS_CTXPROBLEM,	"GSS_CTXPROBLEM" })	\
241 
242 DECLARE_EVENT_CLASS(rpc_task_status,
243 
244 	TP_PROTO(const struct rpc_task *task),
245 
246 	TP_ARGS(task),
247 
248 	TP_STRUCT__entry(
249 		__field(unsigned int, task_id)
250 		__field(unsigned int, client_id)
251 		__field(int, status)
252 	),
253 
254 	TP_fast_assign(
255 		__entry->task_id = task->tk_pid;
256 		__entry->client_id = task->tk_client->cl_clid;
257 		__entry->status = task->tk_status;
258 	),
259 
260 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " status=%d",
261 		__entry->task_id, __entry->client_id,
262 		__entry->status)
263 );
264 #define DEFINE_RPC_STATUS_EVENT(name) \
265 	DEFINE_EVENT(rpc_task_status, rpc_##name##_status, \
266 			TP_PROTO( \
267 				const struct rpc_task *task \
268 			), \
269 			TP_ARGS(task))
270 
271 DEFINE_RPC_STATUS_EVENT(call);
272 DEFINE_RPC_STATUS_EVENT(connect);
273 DEFINE_RPC_STATUS_EVENT(timeout);
274 DEFINE_RPC_STATUS_EVENT(retry_refresh);
275 DEFINE_RPC_STATUS_EVENT(refresh);
276 
277 TRACE_EVENT(rpc_request,
278 	TP_PROTO(const struct rpc_task *task),
279 
280 	TP_ARGS(task),
281 
282 	TP_STRUCT__entry(
283 		__field(unsigned int, task_id)
284 		__field(unsigned int, client_id)
285 		__field(int, version)
286 		__field(bool, async)
287 		__string(progname, task->tk_client->cl_program->name)
288 		__string(procname, rpc_proc_name(task))
289 	),
290 
291 	TP_fast_assign(
292 		__entry->task_id = task->tk_pid;
293 		__entry->client_id = task->tk_client->cl_clid;
294 		__entry->version = task->tk_client->cl_vers;
295 		__entry->async = RPC_IS_ASYNC(task);
296 		__assign_str(progname, task->tk_client->cl_program->name);
297 		__assign_str(procname, rpc_proc_name(task));
298 	),
299 
300 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " %sv%d %s (%ssync)",
301 		__entry->task_id, __entry->client_id,
302 		__get_str(progname), __entry->version,
303 		__get_str(procname), __entry->async ? "a": ""
304 		)
305 );
306 
307 #define rpc_show_task_flags(flags)					\
308 	__print_flags(flags, "|",					\
309 		{ RPC_TASK_ASYNC, "ASYNC" },				\
310 		{ RPC_TASK_SWAPPER, "SWAPPER" },			\
311 		{ RPC_TASK_MOVEABLE, "MOVEABLE" },			\
312 		{ RPC_TASK_NULLCREDS, "NULLCREDS" },			\
313 		{ RPC_CALL_MAJORSEEN, "MAJORSEEN" },			\
314 		{ RPC_TASK_DYNAMIC, "DYNAMIC" },			\
315 		{ RPC_TASK_NO_ROUND_ROBIN, "NO_ROUND_ROBIN" },		\
316 		{ RPC_TASK_SOFT, "SOFT" },				\
317 		{ RPC_TASK_SOFTCONN, "SOFTCONN" },			\
318 		{ RPC_TASK_SENT, "SENT" },				\
319 		{ RPC_TASK_TIMEOUT, "TIMEOUT" },			\
320 		{ RPC_TASK_NOCONNECT, "NOCONNECT" },			\
321 		{ RPC_TASK_NO_RETRANS_TIMEOUT, "NORTO" },		\
322 		{ RPC_TASK_CRED_NOREF, "CRED_NOREF" })
323 
324 #define rpc_show_runstate(flags)					\
325 	__print_flags(flags, "|",					\
326 		{ (1UL << RPC_TASK_RUNNING), "RUNNING" },		\
327 		{ (1UL << RPC_TASK_QUEUED), "QUEUED" },			\
328 		{ (1UL << RPC_TASK_ACTIVE), "ACTIVE" },			\
329 		{ (1UL << RPC_TASK_NEED_XMIT), "NEED_XMIT" },		\
330 		{ (1UL << RPC_TASK_NEED_RECV), "NEED_RECV" },		\
331 		{ (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" },	\
332 		{ (1UL << RPC_TASK_SIGNALLED), "SIGNALLED" })
333 
334 DECLARE_EVENT_CLASS(rpc_task_running,
335 
336 	TP_PROTO(const struct rpc_task *task, const void *action),
337 
338 	TP_ARGS(task, action),
339 
340 	TP_STRUCT__entry(
341 		__field(unsigned int, task_id)
342 		__field(unsigned int, client_id)
343 		__field(const void *, action)
344 		__field(unsigned long, runstate)
345 		__field(int, status)
346 		__field(unsigned short, flags)
347 		),
348 
349 	TP_fast_assign(
350 		__entry->client_id = task->tk_client ?
351 				     task->tk_client->cl_clid : -1;
352 		__entry->task_id = task->tk_pid;
353 		__entry->action = action;
354 		__entry->runstate = task->tk_runstate;
355 		__entry->status = task->tk_status;
356 		__entry->flags = task->tk_flags;
357 		),
358 
359 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
360 		  " flags=%s runstate=%s status=%d action=%ps",
361 		__entry->task_id, __entry->client_id,
362 		rpc_show_task_flags(__entry->flags),
363 		rpc_show_runstate(__entry->runstate),
364 		__entry->status,
365 		__entry->action
366 		)
367 );
368 #define DEFINE_RPC_RUNNING_EVENT(name) \
369 	DEFINE_EVENT(rpc_task_running, rpc_task_##name, \
370 			TP_PROTO( \
371 				const struct rpc_task *task, \
372 				const void *action \
373 			), \
374 			TP_ARGS(task, action))
375 
376 DEFINE_RPC_RUNNING_EVENT(begin);
377 DEFINE_RPC_RUNNING_EVENT(run_action);
378 DEFINE_RPC_RUNNING_EVENT(sync_sleep);
379 DEFINE_RPC_RUNNING_EVENT(sync_wake);
380 DEFINE_RPC_RUNNING_EVENT(complete);
381 DEFINE_RPC_RUNNING_EVENT(timeout);
382 DEFINE_RPC_RUNNING_EVENT(signalled);
383 DEFINE_RPC_RUNNING_EVENT(end);
384 DEFINE_RPC_RUNNING_EVENT(call_done);
385 
386 DECLARE_EVENT_CLASS(rpc_task_queued,
387 
388 	TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
389 
390 	TP_ARGS(task, q),
391 
392 	TP_STRUCT__entry(
393 		__field(unsigned int, task_id)
394 		__field(unsigned int, client_id)
395 		__field(unsigned long, timeout)
396 		__field(unsigned long, runstate)
397 		__field(int, status)
398 		__field(unsigned short, flags)
399 		__string(q_name, rpc_qname(q))
400 		),
401 
402 	TP_fast_assign(
403 		__entry->client_id = task->tk_client ?
404 				     task->tk_client->cl_clid : -1;
405 		__entry->task_id = task->tk_pid;
406 		__entry->timeout = rpc_task_timeout(task);
407 		__entry->runstate = task->tk_runstate;
408 		__entry->status = task->tk_status;
409 		__entry->flags = task->tk_flags;
410 		__assign_str(q_name, rpc_qname(q));
411 		),
412 
413 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
414 		  " flags=%s runstate=%s status=%d timeout=%lu queue=%s",
415 		__entry->task_id, __entry->client_id,
416 		rpc_show_task_flags(__entry->flags),
417 		rpc_show_runstate(__entry->runstate),
418 		__entry->status,
419 		__entry->timeout,
420 		__get_str(q_name)
421 		)
422 );
423 #define DEFINE_RPC_QUEUED_EVENT(name) \
424 	DEFINE_EVENT(rpc_task_queued, rpc_task_##name, \
425 			TP_PROTO( \
426 				const struct rpc_task *task, \
427 				const struct rpc_wait_queue *q \
428 			), \
429 			TP_ARGS(task, q))
430 
431 DEFINE_RPC_QUEUED_EVENT(sleep);
432 DEFINE_RPC_QUEUED_EVENT(wakeup);
433 
434 DECLARE_EVENT_CLASS(rpc_failure,
435 
436 	TP_PROTO(const struct rpc_task *task),
437 
438 	TP_ARGS(task),
439 
440 	TP_STRUCT__entry(
441 		__field(unsigned int, task_id)
442 		__field(unsigned int, client_id)
443 	),
444 
445 	TP_fast_assign(
446 		__entry->task_id = task->tk_pid;
447 		__entry->client_id = task->tk_client->cl_clid;
448 	),
449 
450 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER,
451 		__entry->task_id, __entry->client_id)
452 );
453 
454 #define DEFINE_RPC_FAILURE(name)					\
455 	DEFINE_EVENT(rpc_failure, rpc_bad_##name,			\
456 			TP_PROTO(					\
457 				const struct rpc_task *task		\
458 			),						\
459 			TP_ARGS(task))
460 
461 DEFINE_RPC_FAILURE(callhdr);
462 DEFINE_RPC_FAILURE(verifier);
463 
464 DECLARE_EVENT_CLASS(rpc_reply_event,
465 
466 	TP_PROTO(
467 		const struct rpc_task *task
468 	),
469 
470 	TP_ARGS(task),
471 
472 	TP_STRUCT__entry(
473 		__field(unsigned int, task_id)
474 		__field(unsigned int, client_id)
475 		__field(u32, xid)
476 		__string(progname, task->tk_client->cl_program->name)
477 		__field(u32, version)
478 		__string(procname, rpc_proc_name(task))
479 		__string(servername, task->tk_xprt->servername)
480 	),
481 
482 	TP_fast_assign(
483 		__entry->task_id = task->tk_pid;
484 		__entry->client_id = task->tk_client->cl_clid;
485 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
486 		__assign_str(progname, task->tk_client->cl_program->name);
487 		__entry->version = task->tk_client->cl_vers;
488 		__assign_str(procname, rpc_proc_name(task));
489 		__assign_str(servername, task->tk_xprt->servername);
490 	),
491 
492 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
493 		  " server=%s xid=0x%08x %sv%d %s",
494 		__entry->task_id, __entry->client_id, __get_str(servername),
495 		__entry->xid, __get_str(progname), __entry->version,
496 		__get_str(procname))
497 )
498 
499 #define DEFINE_RPC_REPLY_EVENT(name)					\
500 	DEFINE_EVENT(rpc_reply_event, rpc__##name,			\
501 			TP_PROTO(					\
502 				const struct rpc_task *task		\
503 			),						\
504 			TP_ARGS(task))
505 
506 DEFINE_RPC_REPLY_EVENT(prog_unavail);
507 DEFINE_RPC_REPLY_EVENT(prog_mismatch);
508 DEFINE_RPC_REPLY_EVENT(proc_unavail);
509 DEFINE_RPC_REPLY_EVENT(garbage_args);
510 DEFINE_RPC_REPLY_EVENT(unparsable);
511 DEFINE_RPC_REPLY_EVENT(mismatch);
512 DEFINE_RPC_REPLY_EVENT(stale_creds);
513 DEFINE_RPC_REPLY_EVENT(bad_creds);
514 DEFINE_RPC_REPLY_EVENT(auth_tooweak);
515 
516 #define DEFINE_RPCB_ERROR_EVENT(name)					\
517 	DEFINE_EVENT(rpc_reply_event, rpcb_##name##_err,		\
518 			TP_PROTO(					\
519 				const struct rpc_task *task		\
520 			),						\
521 			TP_ARGS(task))
522 
523 DEFINE_RPCB_ERROR_EVENT(prog_unavail);
524 DEFINE_RPCB_ERROR_EVENT(timeout);
525 DEFINE_RPCB_ERROR_EVENT(bind_version);
526 DEFINE_RPCB_ERROR_EVENT(unreachable);
527 DEFINE_RPCB_ERROR_EVENT(unrecognized);
528 
529 TRACE_EVENT(rpc_buf_alloc,
530 	TP_PROTO(
531 		const struct rpc_task *task,
532 		int status
533 	),
534 
535 	TP_ARGS(task, status),
536 
537 	TP_STRUCT__entry(
538 		__field(unsigned int, task_id)
539 		__field(unsigned int, client_id)
540 		__field(size_t, callsize)
541 		__field(size_t, recvsize)
542 		__field(int, status)
543 	),
544 
545 	TP_fast_assign(
546 		__entry->task_id = task->tk_pid;
547 		__entry->client_id = task->tk_client->cl_clid;
548 		__entry->callsize = task->tk_rqstp->rq_callsize;
549 		__entry->recvsize = task->tk_rqstp->rq_rcvsize;
550 		__entry->status = status;
551 	),
552 
553 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
554 		  " callsize=%zu recvsize=%zu status=%d",
555 		__entry->task_id, __entry->client_id,
556 		__entry->callsize, __entry->recvsize, __entry->status
557 	)
558 );
559 
560 TRACE_EVENT(rpc_call_rpcerror,
561 	TP_PROTO(
562 		const struct rpc_task *task,
563 		int tk_status,
564 		int rpc_status
565 	),
566 
567 	TP_ARGS(task, tk_status, rpc_status),
568 
569 	TP_STRUCT__entry(
570 		__field(unsigned int, task_id)
571 		__field(unsigned int, client_id)
572 		__field(int, tk_status)
573 		__field(int, rpc_status)
574 	),
575 
576 	TP_fast_assign(
577 		__entry->client_id = task->tk_client->cl_clid;
578 		__entry->task_id = task->tk_pid;
579 		__entry->tk_status = tk_status;
580 		__entry->rpc_status = rpc_status;
581 	),
582 
583 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
584 		  " tk_status=%d rpc_status=%d",
585 		__entry->task_id, __entry->client_id,
586 		__entry->tk_status, __entry->rpc_status)
587 );
588 
589 TRACE_EVENT(rpc_stats_latency,
590 
591 	TP_PROTO(
592 		const struct rpc_task *task,
593 		ktime_t backlog,
594 		ktime_t rtt,
595 		ktime_t execute
596 	),
597 
598 	TP_ARGS(task, backlog, rtt, execute),
599 
600 	TP_STRUCT__entry(
601 		__field(unsigned int, task_id)
602 		__field(unsigned int, client_id)
603 		__field(u32, xid)
604 		__field(int, version)
605 		__string(progname, task->tk_client->cl_program->name)
606 		__string(procname, rpc_proc_name(task))
607 		__field(unsigned long, backlog)
608 		__field(unsigned long, rtt)
609 		__field(unsigned long, execute)
610 	),
611 
612 	TP_fast_assign(
613 		__entry->client_id = task->tk_client->cl_clid;
614 		__entry->task_id = task->tk_pid;
615 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
616 		__entry->version = task->tk_client->cl_vers;
617 		__assign_str(progname, task->tk_client->cl_program->name);
618 		__assign_str(procname, rpc_proc_name(task));
619 		__entry->backlog = ktime_to_us(backlog);
620 		__entry->rtt = ktime_to_us(rtt);
621 		__entry->execute = ktime_to_us(execute);
622 	),
623 
624 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
625 		  " xid=0x%08x %sv%d %s backlog=%lu rtt=%lu execute=%lu",
626 		__entry->task_id, __entry->client_id, __entry->xid,
627 		__get_str(progname), __entry->version, __get_str(procname),
628 		__entry->backlog, __entry->rtt, __entry->execute)
629 );
630 
631 TRACE_EVENT(rpc_xdr_overflow,
632 	TP_PROTO(
633 		const struct xdr_stream *xdr,
634 		size_t requested
635 	),
636 
637 	TP_ARGS(xdr, requested),
638 
639 	TP_STRUCT__entry(
640 		__field(unsigned int, task_id)
641 		__field(unsigned int, client_id)
642 		__field(int, version)
643 		__field(size_t, requested)
644 		__field(const void *, end)
645 		__field(const void *, p)
646 		__field(const void *, head_base)
647 		__field(size_t, head_len)
648 		__field(const void *, tail_base)
649 		__field(size_t, tail_len)
650 		__field(unsigned int, page_len)
651 		__field(unsigned int, len)
652 		__string(progname, xdr->rqst ?
653 			 xdr->rqst->rq_task->tk_client->cl_program->name : "unknown")
654 		__string(procedure, xdr->rqst ?
655 			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name : "unknown")
656 	),
657 
658 	TP_fast_assign(
659 		if (xdr->rqst) {
660 			const struct rpc_task *task = xdr->rqst->rq_task;
661 
662 			__entry->task_id = task->tk_pid;
663 			__entry->client_id = task->tk_client->cl_clid;
664 			__assign_str(progname,
665 				     task->tk_client->cl_program->name);
666 			__entry->version = task->tk_client->cl_vers;
667 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
668 		} else {
669 			__entry->task_id = -1;
670 			__entry->client_id = -1;
671 			__assign_str(progname, "unknown");
672 			__entry->version = 0;
673 			__assign_str(procedure, "unknown");
674 		}
675 		__entry->requested = requested;
676 		__entry->end = xdr->end;
677 		__entry->p = xdr->p;
678 		__entry->head_base = xdr->buf->head[0].iov_base,
679 		__entry->head_len = xdr->buf->head[0].iov_len,
680 		__entry->page_len = xdr->buf->page_len,
681 		__entry->tail_base = xdr->buf->tail[0].iov_base,
682 		__entry->tail_len = xdr->buf->tail[0].iov_len,
683 		__entry->len = xdr->buf->len;
684 	),
685 
686 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
687 		  " %sv%d %s requested=%zu p=%p end=%p xdr=[%p,%zu]/%u/[%p,%zu]/%u\n",
688 		__entry->task_id, __entry->client_id,
689 		__get_str(progname), __entry->version, __get_str(procedure),
690 		__entry->requested, __entry->p, __entry->end,
691 		__entry->head_base, __entry->head_len,
692 		__entry->page_len,
693 		__entry->tail_base, __entry->tail_len,
694 		__entry->len
695 	)
696 );
697 
698 TRACE_EVENT(rpc_xdr_alignment,
699 	TP_PROTO(
700 		const struct xdr_stream *xdr,
701 		size_t offset,
702 		unsigned int copied
703 	),
704 
705 	TP_ARGS(xdr, offset, copied),
706 
707 	TP_STRUCT__entry(
708 		__field(unsigned int, task_id)
709 		__field(unsigned int, client_id)
710 		__field(int, version)
711 		__field(size_t, offset)
712 		__field(unsigned int, copied)
713 		__field(const void *, head_base)
714 		__field(size_t, head_len)
715 		__field(const void *, tail_base)
716 		__field(size_t, tail_len)
717 		__field(unsigned int, page_len)
718 		__field(unsigned int, len)
719 		__string(progname,
720 			 xdr->rqst->rq_task->tk_client->cl_program->name)
721 		__string(procedure,
722 			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
723 	),
724 
725 	TP_fast_assign(
726 		const struct rpc_task *task = xdr->rqst->rq_task;
727 
728 		__entry->task_id = task->tk_pid;
729 		__entry->client_id = task->tk_client->cl_clid;
730 		__assign_str(progname,
731 			     task->tk_client->cl_program->name);
732 		__entry->version = task->tk_client->cl_vers;
733 		__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
734 
735 		__entry->offset = offset;
736 		__entry->copied = copied;
737 		__entry->head_base = xdr->buf->head[0].iov_base,
738 		__entry->head_len = xdr->buf->head[0].iov_len,
739 		__entry->page_len = xdr->buf->page_len,
740 		__entry->tail_base = xdr->buf->tail[0].iov_base,
741 		__entry->tail_len = xdr->buf->tail[0].iov_len,
742 		__entry->len = xdr->buf->len;
743 	),
744 
745 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
746 		  " %sv%d %s offset=%zu copied=%u xdr=[%p,%zu]/%u/[%p,%zu]/%u\n",
747 		__entry->task_id, __entry->client_id,
748 		__get_str(progname), __entry->version, __get_str(procedure),
749 		__entry->offset, __entry->copied,
750 		__entry->head_base, __entry->head_len,
751 		__entry->page_len,
752 		__entry->tail_base, __entry->tail_len,
753 		__entry->len
754 	)
755 );
756 
757 /*
758  * First define the enums in the below macros to be exported to userspace
759  * via TRACE_DEFINE_ENUM().
760  */
761 #undef EM
762 #undef EMe
763 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
764 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
765 
766 #define RPC_SHOW_SOCKET				\
767 	EM( SS_FREE, "FREE" )			\
768 	EM( SS_UNCONNECTED, "UNCONNECTED" )	\
769 	EM( SS_CONNECTING, "CONNECTING" )	\
770 	EM( SS_CONNECTED, "CONNECTED" )		\
771 	EMe( SS_DISCONNECTING, "DISCONNECTING" )
772 
773 #define rpc_show_socket_state(state) \
774 	__print_symbolic(state, RPC_SHOW_SOCKET)
775 
776 RPC_SHOW_SOCKET
777 
778 #define RPC_SHOW_SOCK				\
779 	EM( TCP_ESTABLISHED, "ESTABLISHED" )	\
780 	EM( TCP_SYN_SENT, "SYN_SENT" )		\
781 	EM( TCP_SYN_RECV, "SYN_RECV" )		\
782 	EM( TCP_FIN_WAIT1, "FIN_WAIT1" )	\
783 	EM( TCP_FIN_WAIT2, "FIN_WAIT2" )	\
784 	EM( TCP_TIME_WAIT, "TIME_WAIT" )	\
785 	EM( TCP_CLOSE, "CLOSE" )		\
786 	EM( TCP_CLOSE_WAIT, "CLOSE_WAIT" )	\
787 	EM( TCP_LAST_ACK, "LAST_ACK" )		\
788 	EM( TCP_LISTEN, "LISTEN" )		\
789 	EMe( TCP_CLOSING, "CLOSING" )
790 
791 #define rpc_show_sock_state(state) \
792 	__print_symbolic(state, RPC_SHOW_SOCK)
793 
794 RPC_SHOW_SOCK
795 
796 
797 #include <trace/events/net_probe_common.h>
798 
799 /*
800  * Now redefine the EM() and EMe() macros to map the enums to the strings
801  * that will be printed in the output.
802  */
803 #undef EM
804 #undef EMe
805 #define EM(a, b)	{a, b},
806 #define EMe(a, b)	{a, b}
807 
808 DECLARE_EVENT_CLASS(xs_socket_event,
809 
810 		TP_PROTO(
811 			struct rpc_xprt *xprt,
812 			struct socket *socket
813 		),
814 
815 		TP_ARGS(xprt, socket),
816 
817 		TP_STRUCT__entry(
818 			__field(unsigned int, socket_state)
819 			__field(unsigned int, sock_state)
820 			__field(unsigned long long, ino)
821 			__array(__u8, saddr, sizeof(struct sockaddr_in6))
822 			__array(__u8, daddr, sizeof(struct sockaddr_in6))
823 		),
824 
825 		TP_fast_assign(
826 			struct inode *inode = SOCK_INODE(socket);
827 			const struct sock *sk = socket->sk;
828 			const struct inet_sock *inet = inet_sk(sk);
829 
830 			memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
831 			memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
832 
833 			TP_STORE_ADDR_PORTS(__entry, inet, sk);
834 
835 			__entry->socket_state = socket->state;
836 			__entry->sock_state = socket->sk->sk_state;
837 			__entry->ino = (unsigned long long)inode->i_ino;
838 
839 		),
840 
841 		TP_printk(
842 			"socket:[%llu] srcaddr=%pISpc dstaddr=%pISpc "
843 			"state=%u (%s) sk_state=%u (%s)",
844 			__entry->ino,
845 			__entry->saddr,
846 			__entry->daddr,
847 			__entry->socket_state,
848 			rpc_show_socket_state(__entry->socket_state),
849 			__entry->sock_state,
850 			rpc_show_sock_state(__entry->sock_state)
851 		)
852 );
853 #define DEFINE_RPC_SOCKET_EVENT(name) \
854 	DEFINE_EVENT(xs_socket_event, name, \
855 			TP_PROTO( \
856 				struct rpc_xprt *xprt, \
857 				struct socket *socket \
858 			), \
859 			TP_ARGS(xprt, socket))
860 
861 DECLARE_EVENT_CLASS(xs_socket_event_done,
862 
863 		TP_PROTO(
864 			struct rpc_xprt *xprt,
865 			struct socket *socket,
866 			int error
867 		),
868 
869 		TP_ARGS(xprt, socket, error),
870 
871 		TP_STRUCT__entry(
872 			__field(int, error)
873 			__field(unsigned int, socket_state)
874 			__field(unsigned int, sock_state)
875 			__field(unsigned long long, ino)
876 			__array(__u8, saddr, sizeof(struct sockaddr_in6))
877 			__array(__u8, daddr, sizeof(struct sockaddr_in6))
878 		),
879 
880 		TP_fast_assign(
881 			struct inode *inode = SOCK_INODE(socket);
882 			const struct sock *sk = socket->sk;
883 			const struct inet_sock *inet = inet_sk(sk);
884 
885 			memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
886 			memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
887 
888 			TP_STORE_ADDR_PORTS(__entry, inet, sk);
889 
890 			__entry->socket_state = socket->state;
891 			__entry->sock_state = socket->sk->sk_state;
892 			__entry->ino = (unsigned long long)inode->i_ino;
893 			__entry->error = error;
894 		),
895 
896 		TP_printk(
897 			"error=%d socket:[%llu] srcaddr=%pISpc dstaddr=%pISpc "
898 			"state=%u (%s) sk_state=%u (%s)",
899 			__entry->error,
900 			__entry->ino,
901 			__entry->saddr,
902 			__entry->daddr,
903 			__entry->socket_state,
904 			rpc_show_socket_state(__entry->socket_state),
905 			__entry->sock_state,
906 			rpc_show_sock_state(__entry->sock_state)
907 		)
908 );
909 #define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
910 	DEFINE_EVENT(xs_socket_event_done, name, \
911 			TP_PROTO( \
912 				struct rpc_xprt *xprt, \
913 				struct socket *socket, \
914 				int error \
915 			), \
916 			TP_ARGS(xprt, socket, error))
917 
918 DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change);
919 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect);
920 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_error);
921 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
922 DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
923 DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
924 
925 TRACE_EVENT(rpc_socket_nospace,
926 	TP_PROTO(
927 		const struct rpc_rqst *rqst,
928 		const struct sock_xprt *transport
929 	),
930 
931 	TP_ARGS(rqst, transport),
932 
933 	TP_STRUCT__entry(
934 		__field(unsigned int, task_id)
935 		__field(unsigned int, client_id)
936 		__field(unsigned int, total)
937 		__field(unsigned int, remaining)
938 	),
939 
940 	TP_fast_assign(
941 		__entry->task_id = rqst->rq_task->tk_pid;
942 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
943 		__entry->total = rqst->rq_slen;
944 		__entry->remaining = rqst->rq_slen - transport->xmit.offset;
945 	),
946 
947 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
948 		  " total=%u remaining=%u",
949 		__entry->task_id, __entry->client_id,
950 		__entry->total, __entry->remaining
951 	)
952 );
953 
954 #define rpc_show_xprt_state(x)						\
955 	__print_flags(x, "|",						\
956 		{ BIT(XPRT_LOCKED),		"LOCKED" },		\
957 		{ BIT(XPRT_CONNECTED),		"CONNECTED" },		\
958 		{ BIT(XPRT_CONNECTING),		"CONNECTING" },		\
959 		{ BIT(XPRT_CLOSE_WAIT),		"CLOSE_WAIT" },		\
960 		{ BIT(XPRT_BOUND),		"BOUND" },		\
961 		{ BIT(XPRT_BINDING),		"BINDING" },		\
962 		{ BIT(XPRT_CLOSING),		"CLOSING" },		\
963 		{ BIT(XPRT_OFFLINE),		"OFFLINE" },		\
964 		{ BIT(XPRT_REMOVE),		"REMOVE" },		\
965 		{ BIT(XPRT_CONGESTED),		"CONGESTED" },		\
966 		{ BIT(XPRT_CWND_WAIT),		"CWND_WAIT" },		\
967 		{ BIT(XPRT_WRITE_SPACE),	"WRITE_SPACE" },	\
968 		{ BIT(XPRT_SND_IS_COOKIE),	"SND_IS_COOKIE" })
969 
970 DECLARE_EVENT_CLASS(rpc_xprt_lifetime_class,
971 	TP_PROTO(
972 		const struct rpc_xprt *xprt
973 	),
974 
975 	TP_ARGS(xprt),
976 
977 	TP_STRUCT__entry(
978 		__field(unsigned long, state)
979 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
980 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
981 	),
982 
983 	TP_fast_assign(
984 		__entry->state = xprt->state;
985 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
986 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
987 	),
988 
989 	TP_printk("peer=[%s]:%s state=%s",
990 		__get_str(addr), __get_str(port),
991 		rpc_show_xprt_state(__entry->state))
992 );
993 
994 #define DEFINE_RPC_XPRT_LIFETIME_EVENT(name) \
995 	DEFINE_EVENT(rpc_xprt_lifetime_class, \
996 			xprt_##name, \
997 			TP_PROTO( \
998 				const struct rpc_xprt *xprt \
999 			), \
1000 			TP_ARGS(xprt))
1001 
1002 DEFINE_RPC_XPRT_LIFETIME_EVENT(create);
1003 DEFINE_RPC_XPRT_LIFETIME_EVENT(connect);
1004 DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_auto);
1005 DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_done);
1006 DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_force);
1007 DEFINE_RPC_XPRT_LIFETIME_EVENT(destroy);
1008 
1009 DECLARE_EVENT_CLASS(rpc_xprt_event,
1010 	TP_PROTO(
1011 		const struct rpc_xprt *xprt,
1012 		__be32 xid,
1013 		int status
1014 	),
1015 
1016 	TP_ARGS(xprt, xid, status),
1017 
1018 	TP_STRUCT__entry(
1019 		__field(u32, xid)
1020 		__field(int, status)
1021 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
1022 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
1023 	),
1024 
1025 	TP_fast_assign(
1026 		__entry->xid = be32_to_cpu(xid);
1027 		__entry->status = status;
1028 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
1029 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
1030 	),
1031 
1032 	TP_printk("peer=[%s]:%s xid=0x%08x status=%d", __get_str(addr),
1033 			__get_str(port), __entry->xid,
1034 			__entry->status)
1035 );
1036 #define DEFINE_RPC_XPRT_EVENT(name) \
1037 	DEFINE_EVENT(rpc_xprt_event, xprt_##name, \
1038 			TP_PROTO( \
1039 				const struct rpc_xprt *xprt, \
1040 				__be32 xid, \
1041 				int status \
1042 			), \
1043 			TP_ARGS(xprt, xid, status))
1044 
1045 DEFINE_RPC_XPRT_EVENT(timer);
1046 DEFINE_RPC_XPRT_EVENT(lookup_rqst);
1047 
1048 TRACE_EVENT(xprt_transmit,
1049 	TP_PROTO(
1050 		const struct rpc_rqst *rqst,
1051 		int status
1052 	),
1053 
1054 	TP_ARGS(rqst, status),
1055 
1056 	TP_STRUCT__entry(
1057 		__field(unsigned int, task_id)
1058 		__field(unsigned int, client_id)
1059 		__field(u32, xid)
1060 		__field(u32, seqno)
1061 		__field(int, status)
1062 	),
1063 
1064 	TP_fast_assign(
1065 		__entry->task_id = rqst->rq_task->tk_pid;
1066 		__entry->client_id = rqst->rq_task->tk_client ?
1067 			rqst->rq_task->tk_client->cl_clid : -1;
1068 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1069 		__entry->seqno = rqst->rq_seqno;
1070 		__entry->status = status;
1071 	),
1072 
1073 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1074 		  " xid=0x%08x seqno=%u status=%d",
1075 		__entry->task_id, __entry->client_id, __entry->xid,
1076 		__entry->seqno, __entry->status)
1077 );
1078 
1079 TRACE_EVENT(xprt_retransmit,
1080 	TP_PROTO(
1081 		const struct rpc_rqst *rqst
1082 	),
1083 
1084 	TP_ARGS(rqst),
1085 
1086 	TP_STRUCT__entry(
1087 		__field(unsigned int, task_id)
1088 		__field(unsigned int, client_id)
1089 		__field(u32, xid)
1090 		__field(int, ntrans)
1091 		__field(int, version)
1092 		__field(unsigned long, timeout)
1093 		__string(progname,
1094 			 rqst->rq_task->tk_client->cl_program->name)
1095 		__string(procname, rpc_proc_name(rqst->rq_task))
1096 	),
1097 
1098 	TP_fast_assign(
1099 		struct rpc_task *task = rqst->rq_task;
1100 
1101 		__entry->task_id = task->tk_pid;
1102 		__entry->client_id = task->tk_client ?
1103 			task->tk_client->cl_clid : -1;
1104 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1105 		__entry->ntrans = rqst->rq_ntrans;
1106 		__entry->timeout = task->tk_timeout;
1107 		__assign_str(progname,
1108 			     task->tk_client->cl_program->name);
1109 		__entry->version = task->tk_client->cl_vers;
1110 		__assign_str(procname, rpc_proc_name(task));
1111 	),
1112 
1113 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1114 		  " xid=0x%08x %sv%d %s ntrans=%d timeout=%lu",
1115 		__entry->task_id, __entry->client_id, __entry->xid,
1116 		__get_str(progname), __entry->version, __get_str(procname),
1117 		__entry->ntrans, __entry->timeout
1118 	)
1119 );
1120 
1121 TRACE_EVENT(xprt_ping,
1122 	TP_PROTO(const struct rpc_xprt *xprt, int status),
1123 
1124 	TP_ARGS(xprt, status),
1125 
1126 	TP_STRUCT__entry(
1127 		__field(int, status)
1128 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
1129 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
1130 	),
1131 
1132 	TP_fast_assign(
1133 		__entry->status = status;
1134 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
1135 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
1136 	),
1137 
1138 	TP_printk("peer=[%s]:%s status=%d",
1139 			__get_str(addr), __get_str(port), __entry->status)
1140 );
1141 
1142 DECLARE_EVENT_CLASS(xprt_writelock_event,
1143 	TP_PROTO(
1144 		const struct rpc_xprt *xprt, const struct rpc_task *task
1145 	),
1146 
1147 	TP_ARGS(xprt, task),
1148 
1149 	TP_STRUCT__entry(
1150 		__field(unsigned int, task_id)
1151 		__field(unsigned int, client_id)
1152 		__field(unsigned int, snd_task_id)
1153 	),
1154 
1155 	TP_fast_assign(
1156 		if (task) {
1157 			__entry->task_id = task->tk_pid;
1158 			__entry->client_id = task->tk_client ?
1159 					     task->tk_client->cl_clid : -1;
1160 		} else {
1161 			__entry->task_id = -1;
1162 			__entry->client_id = -1;
1163 		}
1164 		if (xprt->snd_task &&
1165 		    !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
1166 			__entry->snd_task_id = xprt->snd_task->tk_pid;
1167 		else
1168 			__entry->snd_task_id = -1;
1169 	),
1170 
1171 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1172 		  " snd_task:" SUNRPC_TRACE_PID_SPECIFIER,
1173 			__entry->task_id, __entry->client_id,
1174 			__entry->snd_task_id)
1175 );
1176 
1177 #define DEFINE_WRITELOCK_EVENT(name) \
1178 	DEFINE_EVENT(xprt_writelock_event, xprt_##name, \
1179 			TP_PROTO( \
1180 				const struct rpc_xprt *xprt, \
1181 				const struct rpc_task *task \
1182 			), \
1183 			TP_ARGS(xprt, task))
1184 
1185 DEFINE_WRITELOCK_EVENT(reserve_xprt);
1186 DEFINE_WRITELOCK_EVENT(release_xprt);
1187 
1188 DECLARE_EVENT_CLASS(xprt_cong_event,
1189 	TP_PROTO(
1190 		const struct rpc_xprt *xprt, const struct rpc_task *task
1191 	),
1192 
1193 	TP_ARGS(xprt, task),
1194 
1195 	TP_STRUCT__entry(
1196 		__field(unsigned int, task_id)
1197 		__field(unsigned int, client_id)
1198 		__field(unsigned int, snd_task_id)
1199 		__field(unsigned long, cong)
1200 		__field(unsigned long, cwnd)
1201 		__field(bool, wait)
1202 	),
1203 
1204 	TP_fast_assign(
1205 		if (task) {
1206 			__entry->task_id = task->tk_pid;
1207 			__entry->client_id = task->tk_client ?
1208 					     task->tk_client->cl_clid : -1;
1209 		} else {
1210 			__entry->task_id = -1;
1211 			__entry->client_id = -1;
1212 		}
1213 		if (xprt->snd_task &&
1214 		    !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
1215 			__entry->snd_task_id = xprt->snd_task->tk_pid;
1216 		else
1217 			__entry->snd_task_id = -1;
1218 
1219 		__entry->cong = xprt->cong;
1220 		__entry->cwnd = xprt->cwnd;
1221 		__entry->wait = test_bit(XPRT_CWND_WAIT, &xprt->state);
1222 	),
1223 
1224 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1225 		  " snd_task:" SUNRPC_TRACE_PID_SPECIFIER
1226 		  " cong=%lu cwnd=%lu%s",
1227 			__entry->task_id, __entry->client_id,
1228 			__entry->snd_task_id, __entry->cong, __entry->cwnd,
1229 			__entry->wait ? " (wait)" : "")
1230 );
1231 
1232 #define DEFINE_CONG_EVENT(name) \
1233 	DEFINE_EVENT(xprt_cong_event, xprt_##name, \
1234 			TP_PROTO( \
1235 				const struct rpc_xprt *xprt, \
1236 				const struct rpc_task *task \
1237 			), \
1238 			TP_ARGS(xprt, task))
1239 
1240 DEFINE_CONG_EVENT(reserve_cong);
1241 DEFINE_CONG_EVENT(release_cong);
1242 DEFINE_CONG_EVENT(get_cong);
1243 DEFINE_CONG_EVENT(put_cong);
1244 
1245 TRACE_EVENT(xprt_reserve,
1246 	TP_PROTO(
1247 		const struct rpc_rqst *rqst
1248 	),
1249 
1250 	TP_ARGS(rqst),
1251 
1252 	TP_STRUCT__entry(
1253 		__field(unsigned int, task_id)
1254 		__field(unsigned int, client_id)
1255 		__field(u32, xid)
1256 	),
1257 
1258 	TP_fast_assign(
1259 		__entry->task_id = rqst->rq_task->tk_pid;
1260 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
1261 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1262 	),
1263 
1264 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " xid=0x%08x",
1265 		__entry->task_id, __entry->client_id, __entry->xid
1266 	)
1267 );
1268 
1269 TRACE_EVENT(xs_data_ready,
1270 	TP_PROTO(
1271 		const struct rpc_xprt *xprt
1272 	),
1273 
1274 	TP_ARGS(xprt),
1275 
1276 	TP_STRUCT__entry(
1277 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
1278 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
1279 	),
1280 
1281 	TP_fast_assign(
1282 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
1283 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
1284 	),
1285 
1286 	TP_printk("peer=[%s]:%s", __get_str(addr), __get_str(port))
1287 );
1288 
1289 TRACE_EVENT(xs_stream_read_data,
1290 	TP_PROTO(struct rpc_xprt *xprt, ssize_t err, size_t total),
1291 
1292 	TP_ARGS(xprt, err, total),
1293 
1294 	TP_STRUCT__entry(
1295 		__field(ssize_t, err)
1296 		__field(size_t, total)
1297 		__string(addr, xprt ? xprt->address_strings[RPC_DISPLAY_ADDR] :
1298 				"(null)")
1299 		__string(port, xprt ? xprt->address_strings[RPC_DISPLAY_PORT] :
1300 				"(null)")
1301 	),
1302 
1303 	TP_fast_assign(
1304 		__entry->err = err;
1305 		__entry->total = total;
1306 		__assign_str(addr, xprt ?
1307 			xprt->address_strings[RPC_DISPLAY_ADDR] : "(null)");
1308 		__assign_str(port, xprt ?
1309 			xprt->address_strings[RPC_DISPLAY_PORT] : "(null)");
1310 	),
1311 
1312 	TP_printk("peer=[%s]:%s err=%zd total=%zu", __get_str(addr),
1313 			__get_str(port), __entry->err, __entry->total)
1314 );
1315 
1316 TRACE_EVENT(xs_stream_read_request,
1317 	TP_PROTO(struct sock_xprt *xs),
1318 
1319 	TP_ARGS(xs),
1320 
1321 	TP_STRUCT__entry(
1322 		__string(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR])
1323 		__string(port, xs->xprt.address_strings[RPC_DISPLAY_PORT])
1324 		__field(u32, xid)
1325 		__field(unsigned long, copied)
1326 		__field(unsigned int, reclen)
1327 		__field(unsigned int, offset)
1328 	),
1329 
1330 	TP_fast_assign(
1331 		__assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]);
1332 		__assign_str(port, xs->xprt.address_strings[RPC_DISPLAY_PORT]);
1333 		__entry->xid = be32_to_cpu(xs->recv.xid);
1334 		__entry->copied = xs->recv.copied;
1335 		__entry->reclen = xs->recv.len;
1336 		__entry->offset = xs->recv.offset;
1337 	),
1338 
1339 	TP_printk("peer=[%s]:%s xid=0x%08x copied=%lu reclen=%u offset=%u",
1340 			__get_str(addr), __get_str(port), __entry->xid,
1341 			__entry->copied, __entry->reclen, __entry->offset)
1342 );
1343 
1344 TRACE_EVENT(rpcb_getport,
1345 	TP_PROTO(
1346 		const struct rpc_clnt *clnt,
1347 		const struct rpc_task *task,
1348 		unsigned int bind_version
1349 	),
1350 
1351 	TP_ARGS(clnt, task, bind_version),
1352 
1353 	TP_STRUCT__entry(
1354 		__field(unsigned int, task_id)
1355 		__field(unsigned int, client_id)
1356 		__field(unsigned int, program)
1357 		__field(unsigned int, version)
1358 		__field(int, protocol)
1359 		__field(unsigned int, bind_version)
1360 		__string(servername, task->tk_xprt->servername)
1361 	),
1362 
1363 	TP_fast_assign(
1364 		__entry->task_id = task->tk_pid;
1365 		__entry->client_id = clnt->cl_clid;
1366 		__entry->program = clnt->cl_prog;
1367 		__entry->version = clnt->cl_vers;
1368 		__entry->protocol = task->tk_xprt->prot;
1369 		__entry->bind_version = bind_version;
1370 		__assign_str(servername, task->tk_xprt->servername);
1371 	),
1372 
1373 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1374 		  " server=%s program=%u version=%u protocol=%d bind_version=%u",
1375 		__entry->task_id, __entry->client_id, __get_str(servername),
1376 		__entry->program, __entry->version, __entry->protocol,
1377 		__entry->bind_version
1378 	)
1379 );
1380 
1381 TRACE_EVENT(rpcb_setport,
1382 	TP_PROTO(
1383 		const struct rpc_task *task,
1384 		int status,
1385 		unsigned short port
1386 	),
1387 
1388 	TP_ARGS(task, status, port),
1389 
1390 	TP_STRUCT__entry(
1391 		__field(unsigned int, task_id)
1392 		__field(unsigned int, client_id)
1393 		__field(int, status)
1394 		__field(unsigned short, port)
1395 	),
1396 
1397 	TP_fast_assign(
1398 		__entry->task_id = task->tk_pid;
1399 		__entry->client_id = task->tk_client->cl_clid;
1400 		__entry->status = status;
1401 		__entry->port = port;
1402 	),
1403 
1404 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " status=%d port=%u",
1405 		__entry->task_id, __entry->client_id,
1406 		__entry->status, __entry->port
1407 	)
1408 );
1409 
1410 TRACE_EVENT(pmap_register,
1411 	TP_PROTO(
1412 		u32 program,
1413 		u32 version,
1414 		int protocol,
1415 		unsigned short port
1416 	),
1417 
1418 	TP_ARGS(program, version, protocol, port),
1419 
1420 	TP_STRUCT__entry(
1421 		__field(unsigned int, program)
1422 		__field(unsigned int, version)
1423 		__field(int, protocol)
1424 		__field(unsigned int, port)
1425 	),
1426 
1427 	TP_fast_assign(
1428 		__entry->program = program;
1429 		__entry->version = version;
1430 		__entry->protocol = protocol;
1431 		__entry->port = port;
1432 	),
1433 
1434 	TP_printk("program=%u version=%u protocol=%d port=%u",
1435 		__entry->program, __entry->version,
1436 		__entry->protocol, __entry->port
1437 	)
1438 );
1439 
1440 TRACE_EVENT(rpcb_register,
1441 	TP_PROTO(
1442 		u32 program,
1443 		u32 version,
1444 		const char *addr,
1445 		const char *netid
1446 	),
1447 
1448 	TP_ARGS(program, version, addr, netid),
1449 
1450 	TP_STRUCT__entry(
1451 		__field(unsigned int, program)
1452 		__field(unsigned int, version)
1453 		__string(addr, addr)
1454 		__string(netid, netid)
1455 	),
1456 
1457 	TP_fast_assign(
1458 		__entry->program = program;
1459 		__entry->version = version;
1460 		__assign_str(addr, addr);
1461 		__assign_str(netid, netid);
1462 	),
1463 
1464 	TP_printk("program=%u version=%u addr=%s netid=%s",
1465 		__entry->program, __entry->version,
1466 		__get_str(addr), __get_str(netid)
1467 	)
1468 );
1469 
1470 TRACE_EVENT(rpcb_unregister,
1471 	TP_PROTO(
1472 		u32 program,
1473 		u32 version,
1474 		const char *netid
1475 	),
1476 
1477 	TP_ARGS(program, version, netid),
1478 
1479 	TP_STRUCT__entry(
1480 		__field(unsigned int, program)
1481 		__field(unsigned int, version)
1482 		__string(netid, netid)
1483 	),
1484 
1485 	TP_fast_assign(
1486 		__entry->program = program;
1487 		__entry->version = version;
1488 		__assign_str(netid, netid);
1489 	),
1490 
1491 	TP_printk("program=%u version=%u netid=%s",
1492 		__entry->program, __entry->version, __get_str(netid)
1493 	)
1494 );
1495 
1496 /* Record an xdr_buf containing a fully-formed RPC message */
1497 DECLARE_EVENT_CLASS(svc_xdr_msg_class,
1498 	TP_PROTO(
1499 		const struct xdr_buf *xdr
1500 	),
1501 
1502 	TP_ARGS(xdr),
1503 
1504 	TP_STRUCT__entry(
1505 		__field(u32, xid)
1506 		__field(const void *, head_base)
1507 		__field(size_t, head_len)
1508 		__field(const void *, tail_base)
1509 		__field(size_t, tail_len)
1510 		__field(unsigned int, page_len)
1511 		__field(unsigned int, msg_len)
1512 	),
1513 
1514 	TP_fast_assign(
1515 		__be32 *p = (__be32 *)xdr->head[0].iov_base;
1516 
1517 		__entry->xid = be32_to_cpu(*p);
1518 		__entry->head_base = p;
1519 		__entry->head_len = xdr->head[0].iov_len;
1520 		__entry->tail_base = xdr->tail[0].iov_base;
1521 		__entry->tail_len = xdr->tail[0].iov_len;
1522 		__entry->page_len = xdr->page_len;
1523 		__entry->msg_len = xdr->len;
1524 	),
1525 
1526 	TP_printk("xid=0x%08x head=[%p,%zu] page=%u tail=[%p,%zu] len=%u",
1527 		__entry->xid,
1528 		__entry->head_base, __entry->head_len, __entry->page_len,
1529 		__entry->tail_base, __entry->tail_len, __entry->msg_len
1530 	)
1531 );
1532 
1533 #define DEFINE_SVCXDRMSG_EVENT(name)					\
1534 		DEFINE_EVENT(svc_xdr_msg_class,				\
1535 				svc_xdr_##name,				\
1536 				TP_PROTO(				\
1537 					const struct xdr_buf *xdr	\
1538 				),					\
1539 				TP_ARGS(xdr))
1540 
1541 DEFINE_SVCXDRMSG_EVENT(recvfrom);
1542 
1543 /* Record an xdr_buf containing arbitrary data, tagged with an XID */
1544 DECLARE_EVENT_CLASS(svc_xdr_buf_class,
1545 	TP_PROTO(
1546 		__be32 xid,
1547 		const struct xdr_buf *xdr
1548 	),
1549 
1550 	TP_ARGS(xid, xdr),
1551 
1552 	TP_STRUCT__entry(
1553 		__field(u32, xid)
1554 		__field(const void *, head_base)
1555 		__field(size_t, head_len)
1556 		__field(const void *, tail_base)
1557 		__field(size_t, tail_len)
1558 		__field(unsigned int, page_base)
1559 		__field(unsigned int, page_len)
1560 		__field(unsigned int, msg_len)
1561 	),
1562 
1563 	TP_fast_assign(
1564 		__entry->xid = be32_to_cpu(xid);
1565 		__entry->head_base = xdr->head[0].iov_base;
1566 		__entry->head_len = xdr->head[0].iov_len;
1567 		__entry->tail_base = xdr->tail[0].iov_base;
1568 		__entry->tail_len = xdr->tail[0].iov_len;
1569 		__entry->page_base = xdr->page_base;
1570 		__entry->page_len = xdr->page_len;
1571 		__entry->msg_len = xdr->len;
1572 	),
1573 
1574 	TP_printk("xid=0x%08x head=[%p,%zu] page=%u(%u) tail=[%p,%zu] len=%u",
1575 		__entry->xid,
1576 		__entry->head_base, __entry->head_len,
1577 		__entry->page_len, __entry->page_base,
1578 		__entry->tail_base, __entry->tail_len,
1579 		__entry->msg_len
1580 	)
1581 );
1582 
1583 #define DEFINE_SVCXDRBUF_EVENT(name)					\
1584 		DEFINE_EVENT(svc_xdr_buf_class,				\
1585 				svc_xdr_##name,				\
1586 				TP_PROTO(				\
1587 					__be32 xid,			\
1588 					const struct xdr_buf *xdr	\
1589 				),					\
1590 				TP_ARGS(xid, xdr))
1591 
1592 DEFINE_SVCXDRBUF_EVENT(sendto);
1593 
1594 /*
1595  * from include/linux/sunrpc/svc.h
1596  */
1597 #define SVC_RQST_FLAG_LIST						\
1598 	svc_rqst_flag(SECURE)						\
1599 	svc_rqst_flag(LOCAL)						\
1600 	svc_rqst_flag(USEDEFERRAL)					\
1601 	svc_rqst_flag(DROPME)						\
1602 	svc_rqst_flag(SPLICE_OK)					\
1603 	svc_rqst_flag(VICTIM)						\
1604 	svc_rqst_flag(BUSY)						\
1605 	svc_rqst_flag_end(DATA)
1606 
1607 #undef svc_rqst_flag
1608 #undef svc_rqst_flag_end
1609 #define svc_rqst_flag(x)	TRACE_DEFINE_ENUM(RQ_##x);
1610 #define svc_rqst_flag_end(x)	TRACE_DEFINE_ENUM(RQ_##x);
1611 
1612 SVC_RQST_FLAG_LIST
1613 
1614 #undef svc_rqst_flag
1615 #undef svc_rqst_flag_end
1616 #define svc_rqst_flag(x)	{ BIT(RQ_##x), #x },
1617 #define svc_rqst_flag_end(x)	{ BIT(RQ_##x), #x }
1618 
1619 #define show_rqstp_flags(flags)						\
1620 		__print_flags(flags, "|", SVC_RQST_FLAG_LIST)
1621 
1622 TRACE_DEFINE_ENUM(SVC_GARBAGE);
1623 TRACE_DEFINE_ENUM(SVC_SYSERR);
1624 TRACE_DEFINE_ENUM(SVC_VALID);
1625 TRACE_DEFINE_ENUM(SVC_NEGATIVE);
1626 TRACE_DEFINE_ENUM(SVC_OK);
1627 TRACE_DEFINE_ENUM(SVC_DROP);
1628 TRACE_DEFINE_ENUM(SVC_CLOSE);
1629 TRACE_DEFINE_ENUM(SVC_DENIED);
1630 TRACE_DEFINE_ENUM(SVC_PENDING);
1631 TRACE_DEFINE_ENUM(SVC_COMPLETE);
1632 
1633 #define svc_show_status(status)				\
1634 	__print_symbolic(status,			\
1635 		{ SVC_GARBAGE,	"SVC_GARBAGE" },	\
1636 		{ SVC_SYSERR,	"SVC_SYSERR" },		\
1637 		{ SVC_VALID,	"SVC_VALID" },		\
1638 		{ SVC_NEGATIVE,	"SVC_NEGATIVE" },	\
1639 		{ SVC_OK,	"SVC_OK" },		\
1640 		{ SVC_DROP,	"SVC_DROP" },		\
1641 		{ SVC_CLOSE,	"SVC_CLOSE" },		\
1642 		{ SVC_DENIED,	"SVC_DENIED" },		\
1643 		{ SVC_PENDING,	"SVC_PENDING" },	\
1644 		{ SVC_COMPLETE,	"SVC_COMPLETE" })
1645 
1646 #define SVC_RQST_ENDPOINT_FIELDS(r) \
1647 		__sockaddr(server, (r)->rq_xprt->xpt_locallen) \
1648 		__sockaddr(client, (r)->rq_xprt->xpt_remotelen) \
1649 		__field(unsigned int, netns_ino) \
1650 		__field(u32, xid)
1651 
1652 #define SVC_RQST_ENDPOINT_ASSIGNMENTS(r) \
1653 		do { \
1654 			struct svc_xprt *xprt = (r)->rq_xprt; \
1655 			__assign_sockaddr(server, &xprt->xpt_local, \
1656 					  xprt->xpt_locallen); \
1657 			__assign_sockaddr(client, &xprt->xpt_remote, \
1658 					  xprt->xpt_remotelen); \
1659 			__entry->netns_ino = xprt->xpt_net->ns.inum; \
1660 			__entry->xid = be32_to_cpu((r)->rq_xid); \
1661 		} while (0)
1662 
1663 #define SVC_RQST_ENDPOINT_FORMAT \
1664 		"xid=0x%08x server=%pISpc client=%pISpc"
1665 
1666 #define SVC_RQST_ENDPOINT_VARARGS \
1667 		__entry->xid, __get_sockaddr(server), __get_sockaddr(client)
1668 
1669 TRACE_EVENT_CONDITION(svc_authenticate,
1670 	TP_PROTO(const struct svc_rqst *rqst, int auth_res),
1671 
1672 	TP_ARGS(rqst, auth_res),
1673 
1674 	TP_CONDITION(auth_res != SVC_OK && auth_res != SVC_COMPLETE),
1675 
1676 	TP_STRUCT__entry(
1677 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1678 
1679 		__field(unsigned long, svc_status)
1680 		__field(unsigned long, auth_stat)
1681 	),
1682 
1683 	TP_fast_assign(
1684 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1685 
1686 		__entry->svc_status = auth_res;
1687 		__entry->auth_stat = be32_to_cpu(rqst->rq_auth_stat);
1688 	),
1689 
1690 	TP_printk(SVC_RQST_ENDPOINT_FORMAT
1691 		" auth_res=%s auth_stat=%s",
1692 		SVC_RQST_ENDPOINT_VARARGS,
1693 		svc_show_status(__entry->svc_status),
1694 		rpc_show_auth_stat(__entry->auth_stat))
1695 );
1696 
1697 TRACE_EVENT(svc_process,
1698 	TP_PROTO(const struct svc_rqst *rqst, const char *name),
1699 
1700 	TP_ARGS(rqst, name),
1701 
1702 	TP_STRUCT__entry(
1703 		__field(u32, xid)
1704 		__field(u32, vers)
1705 		__field(u32, proc)
1706 		__string(service, name)
1707 		__string(procedure, svc_proc_name(rqst))
1708 		__string(addr, rqst->rq_xprt ?
1709 			 rqst->rq_xprt->xpt_remotebuf : "(null)")
1710 	),
1711 
1712 	TP_fast_assign(
1713 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1714 		__entry->vers = rqst->rq_vers;
1715 		__entry->proc = rqst->rq_proc;
1716 		__assign_str(service, name);
1717 		__assign_str(procedure, svc_proc_name(rqst));
1718 		__assign_str(addr, rqst->rq_xprt ?
1719 			     rqst->rq_xprt->xpt_remotebuf : "(null)");
1720 	),
1721 
1722 	TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%s",
1723 			__get_str(addr), __entry->xid,
1724 			__get_str(service), __entry->vers,
1725 			__get_str(procedure)
1726 	)
1727 );
1728 
1729 DECLARE_EVENT_CLASS(svc_rqst_event,
1730 	TP_PROTO(
1731 		const struct svc_rqst *rqst
1732 	),
1733 
1734 	TP_ARGS(rqst),
1735 
1736 	TP_STRUCT__entry(
1737 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1738 
1739 		__field(unsigned long, flags)
1740 	),
1741 
1742 	TP_fast_assign(
1743 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1744 
1745 		__entry->flags = rqst->rq_flags;
1746 	),
1747 
1748 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " flags=%s",
1749 		SVC_RQST_ENDPOINT_VARARGS,
1750 		show_rqstp_flags(__entry->flags))
1751 );
1752 #define DEFINE_SVC_RQST_EVENT(name) \
1753 	DEFINE_EVENT(svc_rqst_event, svc_##name, \
1754 			TP_PROTO( \
1755 				const struct svc_rqst *rqst \
1756 			), \
1757 			TP_ARGS(rqst))
1758 
1759 DEFINE_SVC_RQST_EVENT(defer);
1760 DEFINE_SVC_RQST_EVENT(drop);
1761 
1762 DECLARE_EVENT_CLASS(svc_rqst_status,
1763 	TP_PROTO(
1764 		const struct svc_rqst *rqst,
1765 		int status
1766 	),
1767 
1768 	TP_ARGS(rqst, status),
1769 
1770 	TP_STRUCT__entry(
1771 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1772 
1773 		__field(int, status)
1774 		__field(unsigned long, flags)
1775 	),
1776 
1777 	TP_fast_assign(
1778 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1779 
1780 		__entry->status = status;
1781 		__entry->flags = rqst->rq_flags;
1782 	),
1783 
1784 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " status=%d flags=%s",
1785 		SVC_RQST_ENDPOINT_VARARGS,
1786 		__entry->status, show_rqstp_flags(__entry->flags))
1787 );
1788 
1789 DEFINE_EVENT(svc_rqst_status, svc_send,
1790 	TP_PROTO(const struct svc_rqst *rqst, int status),
1791 	TP_ARGS(rqst, status));
1792 
1793 TRACE_EVENT(svc_stats_latency,
1794 	TP_PROTO(
1795 		const struct svc_rqst *rqst
1796 	),
1797 
1798 	TP_ARGS(rqst),
1799 
1800 	TP_STRUCT__entry(
1801 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1802 
1803 		__field(unsigned long, execute)
1804 		__string(procedure, svc_proc_name(rqst))
1805 	),
1806 
1807 	TP_fast_assign(
1808 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1809 
1810 		__entry->execute = ktime_to_us(ktime_sub(ktime_get(),
1811 							 rqst->rq_stime));
1812 		__assign_str(procedure, svc_proc_name(rqst));
1813 	),
1814 
1815 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " proc=%s execute-us=%lu",
1816 		SVC_RQST_ENDPOINT_VARARGS,
1817 		__get_str(procedure), __entry->execute)
1818 );
1819 
1820 #define show_svc_xprt_flags(flags)					\
1821 	__print_flags(flags, "|",					\
1822 		{ (1UL << XPT_BUSY),		"XPT_BUSY"},		\
1823 		{ (1UL << XPT_CONN),		"XPT_CONN"},		\
1824 		{ (1UL << XPT_CLOSE),		"XPT_CLOSE"},		\
1825 		{ (1UL << XPT_DATA),		"XPT_DATA"},		\
1826 		{ (1UL << XPT_TEMP),		"XPT_TEMP"},		\
1827 		{ (1UL << XPT_DEAD),		"XPT_DEAD"},		\
1828 		{ (1UL << XPT_CHNGBUF),		"XPT_CHNGBUF"},		\
1829 		{ (1UL << XPT_DEFERRED),	"XPT_DEFERRED"},	\
1830 		{ (1UL << XPT_OLD),		"XPT_OLD"},		\
1831 		{ (1UL << XPT_LISTENER),	"XPT_LISTENER"},	\
1832 		{ (1UL << XPT_CACHE_AUTH),	"XPT_CACHE_AUTH"},	\
1833 		{ (1UL << XPT_LOCAL),		"XPT_LOCAL"},		\
1834 		{ (1UL << XPT_KILL_TEMP),	"XPT_KILL_TEMP"},	\
1835 		{ (1UL << XPT_CONG_CTRL),	"XPT_CONG_CTRL"})
1836 
1837 TRACE_EVENT(svc_xprt_create_err,
1838 	TP_PROTO(
1839 		const char *program,
1840 		const char *protocol,
1841 		struct sockaddr *sap,
1842 		size_t salen,
1843 		const struct svc_xprt *xprt
1844 	),
1845 
1846 	TP_ARGS(program, protocol, sap, salen, xprt),
1847 
1848 	TP_STRUCT__entry(
1849 		__field(long, error)
1850 		__string(program, program)
1851 		__string(protocol, protocol)
1852 		__sockaddr(addr, salen)
1853 	),
1854 
1855 	TP_fast_assign(
1856 		__entry->error = PTR_ERR(xprt);
1857 		__assign_str(program, program);
1858 		__assign_str(protocol, protocol);
1859 		__assign_sockaddr(addr, sap, salen);
1860 	),
1861 
1862 	TP_printk("addr=%pISpc program=%s protocol=%s error=%ld",
1863 		__get_sockaddr(addr), __get_str(program), __get_str(protocol),
1864 		__entry->error)
1865 );
1866 
1867 #define SVC_XPRT_ENDPOINT_FIELDS(x) \
1868 		__sockaddr(server, (x)->xpt_locallen) \
1869 		__sockaddr(client, (x)->xpt_remotelen) \
1870 		__field(unsigned long, flags) \
1871 		__field(unsigned int, netns_ino)
1872 
1873 #define SVC_XPRT_ENDPOINT_ASSIGNMENTS(x) \
1874 		do { \
1875 			__assign_sockaddr(server, &(x)->xpt_local, \
1876 					  (x)->xpt_locallen); \
1877 			__assign_sockaddr(client, &(x)->xpt_remote, \
1878 					  (x)->xpt_remotelen); \
1879 			__entry->flags = (x)->xpt_flags; \
1880 			__entry->netns_ino = (x)->xpt_net->ns.inum; \
1881 		} while (0)
1882 
1883 #define SVC_XPRT_ENDPOINT_FORMAT \
1884 		"server=%pISpc client=%pISpc flags=%s"
1885 
1886 #define SVC_XPRT_ENDPOINT_VARARGS \
1887 		__get_sockaddr(server), __get_sockaddr(client), \
1888 		show_svc_xprt_flags(__entry->flags)
1889 
1890 TRACE_EVENT(svc_xprt_enqueue,
1891 	TP_PROTO(
1892 		const struct svc_xprt *xprt,
1893 		const struct svc_rqst *rqst
1894 	),
1895 
1896 	TP_ARGS(xprt, rqst),
1897 
1898 	TP_STRUCT__entry(
1899 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1900 
1901 		__field(int, pid)
1902 	),
1903 
1904 	TP_fast_assign(
1905 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1906 
1907 		__entry->pid = rqst? rqst->rq_task->pid : 0;
1908 	),
1909 
1910 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " pid=%d",
1911 		SVC_XPRT_ENDPOINT_VARARGS, __entry->pid)
1912 );
1913 
1914 TRACE_EVENT(svc_xprt_dequeue,
1915 	TP_PROTO(
1916 		const struct svc_rqst *rqst
1917 	),
1918 
1919 	TP_ARGS(rqst),
1920 
1921 	TP_STRUCT__entry(
1922 		SVC_XPRT_ENDPOINT_FIELDS(rqst->rq_xprt)
1923 
1924 		__field(unsigned long, wakeup)
1925 	),
1926 
1927 	TP_fast_assign(
1928 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(rqst->rq_xprt);
1929 
1930 		__entry->wakeup = ktime_to_us(ktime_sub(ktime_get(),
1931 							rqst->rq_qtime));
1932 	),
1933 
1934 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " wakeup-us=%lu",
1935 		SVC_XPRT_ENDPOINT_VARARGS, __entry->wakeup)
1936 );
1937 
1938 DECLARE_EVENT_CLASS(svc_xprt_event,
1939 	TP_PROTO(
1940 		const struct svc_xprt *xprt
1941 	),
1942 
1943 	TP_ARGS(xprt),
1944 
1945 	TP_STRUCT__entry(
1946 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1947 	),
1948 
1949 	TP_fast_assign(
1950 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1951 	),
1952 
1953 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT, SVC_XPRT_ENDPOINT_VARARGS)
1954 );
1955 
1956 #define DEFINE_SVC_XPRT_EVENT(name) \
1957 	DEFINE_EVENT(svc_xprt_event, svc_xprt_##name, \
1958 			TP_PROTO( \
1959 				const struct svc_xprt *xprt \
1960 			), \
1961 			TP_ARGS(xprt))
1962 
1963 DEFINE_SVC_XPRT_EVENT(no_write_space);
1964 DEFINE_SVC_XPRT_EVENT(close);
1965 DEFINE_SVC_XPRT_EVENT(detach);
1966 DEFINE_SVC_XPRT_EVENT(free);
1967 
1968 TRACE_EVENT(svc_xprt_accept,
1969 	TP_PROTO(
1970 		const struct svc_xprt *xprt,
1971 		const char *service
1972 	),
1973 
1974 	TP_ARGS(xprt, service),
1975 
1976 	TP_STRUCT__entry(
1977 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1978 
1979 		__string(protocol, xprt->xpt_class->xcl_name)
1980 		__string(service, service)
1981 	),
1982 
1983 	TP_fast_assign(
1984 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1985 
1986 		__assign_str(protocol, xprt->xpt_class->xcl_name);
1987 		__assign_str(service, service);
1988 	),
1989 
1990 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " protocol=%s service=%s",
1991 		SVC_XPRT_ENDPOINT_VARARGS,
1992 		__get_str(protocol), __get_str(service)
1993 	)
1994 );
1995 
1996 TRACE_EVENT(svc_wake_up,
1997 	TP_PROTO(int pid),
1998 
1999 	TP_ARGS(pid),
2000 
2001 	TP_STRUCT__entry(
2002 		__field(int, pid)
2003 	),
2004 
2005 	TP_fast_assign(
2006 		__entry->pid = pid;
2007 	),
2008 
2009 	TP_printk("pid=%d", __entry->pid)
2010 );
2011 
2012 TRACE_EVENT(svc_alloc_arg_err,
2013 	TP_PROTO(
2014 		unsigned int requested,
2015 		unsigned int allocated
2016 	),
2017 
2018 	TP_ARGS(requested, allocated),
2019 
2020 	TP_STRUCT__entry(
2021 		__field(unsigned int, requested)
2022 		__field(unsigned int, allocated)
2023 	),
2024 
2025 	TP_fast_assign(
2026 		__entry->requested = requested;
2027 		__entry->allocated = allocated;
2028 	),
2029 
2030 	TP_printk("requested=%u allocated=%u",
2031 		__entry->requested, __entry->allocated)
2032 );
2033 
2034 DECLARE_EVENT_CLASS(svc_deferred_event,
2035 	TP_PROTO(
2036 		const struct svc_deferred_req *dr
2037 	),
2038 
2039 	TP_ARGS(dr),
2040 
2041 	TP_STRUCT__entry(
2042 		__field(const void *, dr)
2043 		__field(u32, xid)
2044 		__sockaddr(addr, dr->addrlen)
2045 	),
2046 
2047 	TP_fast_assign(
2048 		__entry->dr = dr;
2049 		__entry->xid = be32_to_cpu(*(__be32 *)dr->args);
2050 		__assign_sockaddr(addr, &dr->addr, dr->addrlen);
2051 	),
2052 
2053 	TP_printk("addr=%pISpc dr=%p xid=0x%08x", __get_sockaddr(addr),
2054 		__entry->dr, __entry->xid)
2055 );
2056 
2057 #define DEFINE_SVC_DEFERRED_EVENT(name) \
2058 	DEFINE_EVENT(svc_deferred_event, svc_defer_##name, \
2059 			TP_PROTO( \
2060 				const struct svc_deferred_req *dr \
2061 			), \
2062 			TP_ARGS(dr))
2063 
2064 DEFINE_SVC_DEFERRED_EVENT(drop);
2065 DEFINE_SVC_DEFERRED_EVENT(queue);
2066 DEFINE_SVC_DEFERRED_EVENT(recv);
2067 
2068 TRACE_EVENT(svcsock_new_socket,
2069 	TP_PROTO(
2070 		const struct socket *socket
2071 	),
2072 
2073 	TP_ARGS(socket),
2074 
2075 	TP_STRUCT__entry(
2076 		__field(unsigned long, type)
2077 		__field(unsigned long, family)
2078 		__field(bool, listener)
2079 	),
2080 
2081 	TP_fast_assign(
2082 		__entry->type = socket->type;
2083 		__entry->family = socket->sk->sk_family;
2084 		__entry->listener = (socket->sk->sk_state == TCP_LISTEN);
2085 	),
2086 
2087 	TP_printk("type=%s family=%s%s",
2088 		show_socket_type(__entry->type),
2089 		rpc_show_address_family(__entry->family),
2090 		__entry->listener ? " (listener)" : ""
2091 	)
2092 );
2093 
2094 TRACE_EVENT(svcsock_marker,
2095 	TP_PROTO(
2096 		const struct svc_xprt *xprt,
2097 		__be32 marker
2098 	),
2099 
2100 	TP_ARGS(xprt, marker),
2101 
2102 	TP_STRUCT__entry(
2103 		__field(unsigned int, length)
2104 		__field(bool, last)
2105 		__string(addr, xprt->xpt_remotebuf)
2106 	),
2107 
2108 	TP_fast_assign(
2109 		__entry->length = be32_to_cpu(marker) & RPC_FRAGMENT_SIZE_MASK;
2110 		__entry->last = be32_to_cpu(marker) & RPC_LAST_STREAM_FRAGMENT;
2111 		__assign_str(addr, xprt->xpt_remotebuf);
2112 	),
2113 
2114 	TP_printk("addr=%s length=%u%s", __get_str(addr),
2115 		__entry->length, __entry->last ? " (last)" : "")
2116 );
2117 
2118 DECLARE_EVENT_CLASS(svcsock_class,
2119 	TP_PROTO(
2120 		const struct svc_xprt *xprt,
2121 		ssize_t result
2122 	),
2123 
2124 	TP_ARGS(xprt, result),
2125 
2126 	TP_STRUCT__entry(
2127 		__field(ssize_t, result)
2128 		__field(unsigned long, flags)
2129 		__string(addr, xprt->xpt_remotebuf)
2130 	),
2131 
2132 	TP_fast_assign(
2133 		__entry->result = result;
2134 		__entry->flags = xprt->xpt_flags;
2135 		__assign_str(addr, xprt->xpt_remotebuf);
2136 	),
2137 
2138 	TP_printk("addr=%s result=%zd flags=%s", __get_str(addr),
2139 		__entry->result, show_svc_xprt_flags(__entry->flags)
2140 	)
2141 );
2142 
2143 #define DEFINE_SVCSOCK_EVENT(name) \
2144 	DEFINE_EVENT(svcsock_class, svcsock_##name, \
2145 			TP_PROTO( \
2146 				const struct svc_xprt *xprt, \
2147 				ssize_t result \
2148 			), \
2149 			TP_ARGS(xprt, result))
2150 
2151 DEFINE_SVCSOCK_EVENT(udp_send);
2152 DEFINE_SVCSOCK_EVENT(udp_recv);
2153 DEFINE_SVCSOCK_EVENT(udp_recv_err);
2154 DEFINE_SVCSOCK_EVENT(tcp_send);
2155 DEFINE_SVCSOCK_EVENT(tcp_recv);
2156 DEFINE_SVCSOCK_EVENT(tcp_recv_eagain);
2157 DEFINE_SVCSOCK_EVENT(tcp_recv_err);
2158 DEFINE_SVCSOCK_EVENT(data_ready);
2159 DEFINE_SVCSOCK_EVENT(write_space);
2160 
2161 TRACE_EVENT(svcsock_tcp_recv_short,
2162 	TP_PROTO(
2163 		const struct svc_xprt *xprt,
2164 		u32 expected,
2165 		u32 received
2166 	),
2167 
2168 	TP_ARGS(xprt, expected, received),
2169 
2170 	TP_STRUCT__entry(
2171 		__field(u32, expected)
2172 		__field(u32, received)
2173 		__field(unsigned long, flags)
2174 		__string(addr, xprt->xpt_remotebuf)
2175 	),
2176 
2177 	TP_fast_assign(
2178 		__entry->expected = expected;
2179 		__entry->received = received;
2180 		__entry->flags = xprt->xpt_flags;
2181 		__assign_str(addr, xprt->xpt_remotebuf);
2182 	),
2183 
2184 	TP_printk("addr=%s flags=%s expected=%u received=%u",
2185 		__get_str(addr), show_svc_xprt_flags(__entry->flags),
2186 		__entry->expected, __entry->received
2187 	)
2188 );
2189 
2190 TRACE_EVENT(svcsock_tcp_state,
2191 	TP_PROTO(
2192 		const struct svc_xprt *xprt,
2193 		const struct socket *socket
2194 	),
2195 
2196 	TP_ARGS(xprt, socket),
2197 
2198 	TP_STRUCT__entry(
2199 		__field(unsigned long, socket_state)
2200 		__field(unsigned long, sock_state)
2201 		__field(unsigned long, flags)
2202 		__string(addr, xprt->xpt_remotebuf)
2203 	),
2204 
2205 	TP_fast_assign(
2206 		__entry->socket_state = socket->state;
2207 		__entry->sock_state = socket->sk->sk_state;
2208 		__entry->flags = xprt->xpt_flags;
2209 		__assign_str(addr, xprt->xpt_remotebuf);
2210 	),
2211 
2212 	TP_printk("addr=%s state=%s sk_state=%s flags=%s", __get_str(addr),
2213 		rpc_show_socket_state(__entry->socket_state),
2214 		rpc_show_sock_state(__entry->sock_state),
2215 		show_svc_xprt_flags(__entry->flags)
2216 	)
2217 );
2218 
2219 DECLARE_EVENT_CLASS(svcsock_accept_class,
2220 	TP_PROTO(
2221 		const struct svc_xprt *xprt,
2222 		const char *service,
2223 		long status
2224 	),
2225 
2226 	TP_ARGS(xprt, service, status),
2227 
2228 	TP_STRUCT__entry(
2229 		__field(long, status)
2230 		__string(service, service)
2231 		__field(unsigned int, netns_ino)
2232 	),
2233 
2234 	TP_fast_assign(
2235 		__entry->status = status;
2236 		__assign_str(service, service);
2237 		__entry->netns_ino = xprt->xpt_net->ns.inum;
2238 	),
2239 
2240 	TP_printk("addr=listener service=%s status=%ld",
2241 		__get_str(service), __entry->status
2242 	)
2243 );
2244 
2245 #define DEFINE_ACCEPT_EVENT(name) \
2246 	DEFINE_EVENT(svcsock_accept_class, svcsock_##name##_err, \
2247 			TP_PROTO( \
2248 				const struct svc_xprt *xprt, \
2249 				const char *service, \
2250 				long status \
2251 			), \
2252 			TP_ARGS(xprt, service, status))
2253 
2254 DEFINE_ACCEPT_EVENT(accept);
2255 DEFINE_ACCEPT_EVENT(getpeername);
2256 
2257 DECLARE_EVENT_CLASS(cache_event,
2258 	TP_PROTO(
2259 		const struct cache_detail *cd,
2260 		const struct cache_head *h
2261 	),
2262 
2263 	TP_ARGS(cd, h),
2264 
2265 	TP_STRUCT__entry(
2266 		__field(const struct cache_head *, h)
2267 		__string(name, cd->name)
2268 	),
2269 
2270 	TP_fast_assign(
2271 		__entry->h = h;
2272 		__assign_str(name, cd->name);
2273 	),
2274 
2275 	TP_printk("cache=%s entry=%p", __get_str(name), __entry->h)
2276 );
2277 #define DEFINE_CACHE_EVENT(name) \
2278 	DEFINE_EVENT(cache_event, name, \
2279 			TP_PROTO( \
2280 				const struct cache_detail *cd, \
2281 				const struct cache_head *h \
2282 			), \
2283 			TP_ARGS(cd, h))
2284 DEFINE_CACHE_EVENT(cache_entry_expired);
2285 DEFINE_CACHE_EVENT(cache_entry_upcall);
2286 DEFINE_CACHE_EVENT(cache_entry_update);
2287 DEFINE_CACHE_EVENT(cache_entry_make_negative);
2288 DEFINE_CACHE_EVENT(cache_entry_no_listener);
2289 
2290 DECLARE_EVENT_CLASS(register_class,
2291 	TP_PROTO(
2292 		const char *program,
2293 		const u32 version,
2294 		const int family,
2295 		const unsigned short protocol,
2296 		const unsigned short port,
2297 		int error
2298 	),
2299 
2300 	TP_ARGS(program, version, family, protocol, port, error),
2301 
2302 	TP_STRUCT__entry(
2303 		__field(u32, version)
2304 		__field(unsigned long, family)
2305 		__field(unsigned short, protocol)
2306 		__field(unsigned short, port)
2307 		__field(int, error)
2308 		__string(program, program)
2309 	),
2310 
2311 	TP_fast_assign(
2312 		__entry->version = version;
2313 		__entry->family = family;
2314 		__entry->protocol = protocol;
2315 		__entry->port = port;
2316 		__entry->error = error;
2317 		__assign_str(program, program);
2318 	),
2319 
2320 	TP_printk("program=%sv%u proto=%s port=%u family=%s error=%d",
2321 		__get_str(program), __entry->version,
2322 		__entry->protocol == IPPROTO_UDP ? "udp" : "tcp",
2323 		__entry->port, rpc_show_address_family(__entry->family),
2324 		__entry->error
2325 	)
2326 );
2327 
2328 #define DEFINE_REGISTER_EVENT(name) \
2329 	DEFINE_EVENT(register_class, svc_##name, \
2330 			TP_PROTO( \
2331 				const char *program, \
2332 				const u32 version, \
2333 				const int family, \
2334 				const unsigned short protocol, \
2335 				const unsigned short port, \
2336 				int error \
2337 			), \
2338 			TP_ARGS(program, version, family, protocol, \
2339 				port, error))
2340 
2341 DEFINE_REGISTER_EVENT(register);
2342 DEFINE_REGISTER_EVENT(noregister);
2343 
2344 TRACE_EVENT(svc_unregister,
2345 	TP_PROTO(
2346 		const char *program,
2347 		const u32 version,
2348 		int error
2349 	),
2350 
2351 	TP_ARGS(program, version, error),
2352 
2353 	TP_STRUCT__entry(
2354 		__field(u32, version)
2355 		__field(int, error)
2356 		__string(program, program)
2357 	),
2358 
2359 	TP_fast_assign(
2360 		__entry->version = version;
2361 		__entry->error = error;
2362 		__assign_str(program, program);
2363 	),
2364 
2365 	TP_printk("program=%sv%u error=%d",
2366 		__get_str(program), __entry->version, __entry->error
2367 	)
2368 );
2369 
2370 #endif /* _TRACE_SUNRPC_H */
2371 
2372 #include <trace/define_trace.h>
2373