xref: /openbmc/linux/include/trace/events/sunrpc.h (revision 0e407915)
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/events/sunrpc_base.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(svc_authenticate,
1670 	TP_PROTO(const struct svc_rqst *rqst, int auth_res),
1671 
1672 	TP_ARGS(rqst, auth_res),
1673 
1674 	TP_STRUCT__entry(
1675 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1676 
1677 		__field(unsigned long, svc_status)
1678 		__field(unsigned long, auth_stat)
1679 	),
1680 
1681 	TP_fast_assign(
1682 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1683 
1684 		__entry->svc_status = auth_res;
1685 		__entry->auth_stat = be32_to_cpu(rqst->rq_auth_stat);
1686 	),
1687 
1688 	TP_printk(SVC_RQST_ENDPOINT_FORMAT
1689 		" auth_res=%s auth_stat=%s",
1690 		SVC_RQST_ENDPOINT_VARARGS,
1691 		svc_show_status(__entry->svc_status),
1692 		rpc_show_auth_stat(__entry->auth_stat))
1693 );
1694 
1695 TRACE_EVENT(svc_process,
1696 	TP_PROTO(const struct svc_rqst *rqst, const char *name),
1697 
1698 	TP_ARGS(rqst, name),
1699 
1700 	TP_STRUCT__entry(
1701 		__field(u32, xid)
1702 		__field(u32, vers)
1703 		__field(u32, proc)
1704 		__string(service, name)
1705 		__string(procedure, svc_proc_name(rqst))
1706 		__string(addr, rqst->rq_xprt ?
1707 			 rqst->rq_xprt->xpt_remotebuf : "(null)")
1708 	),
1709 
1710 	TP_fast_assign(
1711 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1712 		__entry->vers = rqst->rq_vers;
1713 		__entry->proc = rqst->rq_proc;
1714 		__assign_str(service, name);
1715 		__assign_str(procedure, svc_proc_name(rqst));
1716 		__assign_str(addr, rqst->rq_xprt ?
1717 			     rqst->rq_xprt->xpt_remotebuf : "(null)");
1718 	),
1719 
1720 	TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%s",
1721 			__get_str(addr), __entry->xid,
1722 			__get_str(service), __entry->vers,
1723 			__get_str(procedure)
1724 	)
1725 );
1726 
1727 DECLARE_EVENT_CLASS(svc_rqst_event,
1728 	TP_PROTO(
1729 		const struct svc_rqst *rqst
1730 	),
1731 
1732 	TP_ARGS(rqst),
1733 
1734 	TP_STRUCT__entry(
1735 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1736 
1737 		__field(unsigned long, flags)
1738 	),
1739 
1740 	TP_fast_assign(
1741 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1742 
1743 		__entry->flags = rqst->rq_flags;
1744 	),
1745 
1746 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " flags=%s",
1747 		SVC_RQST_ENDPOINT_VARARGS,
1748 		show_rqstp_flags(__entry->flags))
1749 );
1750 #define DEFINE_SVC_RQST_EVENT(name) \
1751 	DEFINE_EVENT(svc_rqst_event, svc_##name, \
1752 			TP_PROTO( \
1753 				const struct svc_rqst *rqst \
1754 			), \
1755 			TP_ARGS(rqst))
1756 
1757 DEFINE_SVC_RQST_EVENT(defer);
1758 DEFINE_SVC_RQST_EVENT(drop);
1759 
1760 DECLARE_EVENT_CLASS(svc_rqst_status,
1761 	TP_PROTO(
1762 		const struct svc_rqst *rqst,
1763 		int status
1764 	),
1765 
1766 	TP_ARGS(rqst, status),
1767 
1768 	TP_STRUCT__entry(
1769 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1770 
1771 		__field(int, status)
1772 		__field(unsigned long, flags)
1773 	),
1774 
1775 	TP_fast_assign(
1776 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1777 
1778 		__entry->status = status;
1779 		__entry->flags = rqst->rq_flags;
1780 	),
1781 
1782 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " status=%d flags=%s",
1783 		SVC_RQST_ENDPOINT_VARARGS,
1784 		__entry->status, show_rqstp_flags(__entry->flags))
1785 );
1786 
1787 DEFINE_EVENT(svc_rqst_status, svc_send,
1788 	TP_PROTO(const struct svc_rqst *rqst, int status),
1789 	TP_ARGS(rqst, status));
1790 
1791 TRACE_EVENT(svc_stats_latency,
1792 	TP_PROTO(
1793 		const struct svc_rqst *rqst
1794 	),
1795 
1796 	TP_ARGS(rqst),
1797 
1798 	TP_STRUCT__entry(
1799 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1800 
1801 		__field(unsigned long, execute)
1802 		__string(procedure, svc_proc_name(rqst))
1803 	),
1804 
1805 	TP_fast_assign(
1806 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1807 
1808 		__entry->execute = ktime_to_us(ktime_sub(ktime_get(),
1809 							 rqst->rq_stime));
1810 		__assign_str(procedure, svc_proc_name(rqst));
1811 	),
1812 
1813 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " proc=%s execute-us=%lu",
1814 		SVC_RQST_ENDPOINT_VARARGS,
1815 		__get_str(procedure), __entry->execute)
1816 );
1817 
1818 #define show_svc_xprt_flags(flags)					\
1819 	__print_flags(flags, "|",					\
1820 		{ (1UL << XPT_BUSY),		"XPT_BUSY"},		\
1821 		{ (1UL << XPT_CONN),		"XPT_CONN"},		\
1822 		{ (1UL << XPT_CLOSE),		"XPT_CLOSE"},		\
1823 		{ (1UL << XPT_DATA),		"XPT_DATA"},		\
1824 		{ (1UL << XPT_TEMP),		"XPT_TEMP"},		\
1825 		{ (1UL << XPT_DEAD),		"XPT_DEAD"},		\
1826 		{ (1UL << XPT_CHNGBUF),		"XPT_CHNGBUF"},		\
1827 		{ (1UL << XPT_DEFERRED),	"XPT_DEFERRED"},	\
1828 		{ (1UL << XPT_OLD),		"XPT_OLD"},		\
1829 		{ (1UL << XPT_LISTENER),	"XPT_LISTENER"},	\
1830 		{ (1UL << XPT_CACHE_AUTH),	"XPT_CACHE_AUTH"},	\
1831 		{ (1UL << XPT_LOCAL),		"XPT_LOCAL"},		\
1832 		{ (1UL << XPT_KILL_TEMP),	"XPT_KILL_TEMP"},	\
1833 		{ (1UL << XPT_CONG_CTRL),	"XPT_CONG_CTRL"})
1834 
1835 TRACE_EVENT(svc_xprt_create_err,
1836 	TP_PROTO(
1837 		const char *program,
1838 		const char *protocol,
1839 		struct sockaddr *sap,
1840 		size_t salen,
1841 		const struct svc_xprt *xprt
1842 	),
1843 
1844 	TP_ARGS(program, protocol, sap, salen, xprt),
1845 
1846 	TP_STRUCT__entry(
1847 		__field(long, error)
1848 		__string(program, program)
1849 		__string(protocol, protocol)
1850 		__sockaddr(addr, salen)
1851 	),
1852 
1853 	TP_fast_assign(
1854 		__entry->error = PTR_ERR(xprt);
1855 		__assign_str(program, program);
1856 		__assign_str(protocol, protocol);
1857 		__assign_sockaddr(addr, sap, salen);
1858 	),
1859 
1860 	TP_printk("addr=%pISpc program=%s protocol=%s error=%ld",
1861 		__get_sockaddr(addr), __get_str(program), __get_str(protocol),
1862 		__entry->error)
1863 );
1864 
1865 #define SVC_XPRT_ENDPOINT_FIELDS(x) \
1866 		__sockaddr(server, (x)->xpt_locallen) \
1867 		__sockaddr(client, (x)->xpt_remotelen) \
1868 		__field(unsigned long, flags) \
1869 		__field(unsigned int, netns_ino)
1870 
1871 #define SVC_XPRT_ENDPOINT_ASSIGNMENTS(x) \
1872 		do { \
1873 			__assign_sockaddr(server, &(x)->xpt_local, \
1874 					  (x)->xpt_locallen); \
1875 			__assign_sockaddr(client, &(x)->xpt_remote, \
1876 					  (x)->xpt_remotelen); \
1877 			__entry->flags = (x)->xpt_flags; \
1878 			__entry->netns_ino = (x)->xpt_net->ns.inum; \
1879 		} while (0)
1880 
1881 #define SVC_XPRT_ENDPOINT_FORMAT \
1882 		"server=%pISpc client=%pISpc flags=%s"
1883 
1884 #define SVC_XPRT_ENDPOINT_VARARGS \
1885 		__get_sockaddr(server), __get_sockaddr(client), \
1886 		show_svc_xprt_flags(__entry->flags)
1887 
1888 TRACE_EVENT(svc_xprt_enqueue,
1889 	TP_PROTO(
1890 		const struct svc_xprt *xprt,
1891 		const struct svc_rqst *rqst
1892 	),
1893 
1894 	TP_ARGS(xprt, rqst),
1895 
1896 	TP_STRUCT__entry(
1897 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1898 
1899 		__field(int, pid)
1900 	),
1901 
1902 	TP_fast_assign(
1903 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1904 
1905 		__entry->pid = rqst? rqst->rq_task->pid : 0;
1906 	),
1907 
1908 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " pid=%d",
1909 		SVC_XPRT_ENDPOINT_VARARGS, __entry->pid)
1910 );
1911 
1912 TRACE_EVENT(svc_xprt_dequeue,
1913 	TP_PROTO(
1914 		const struct svc_rqst *rqst
1915 	),
1916 
1917 	TP_ARGS(rqst),
1918 
1919 	TP_STRUCT__entry(
1920 		SVC_XPRT_ENDPOINT_FIELDS(rqst->rq_xprt)
1921 
1922 		__field(unsigned long, wakeup)
1923 	),
1924 
1925 	TP_fast_assign(
1926 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(rqst->rq_xprt);
1927 
1928 		__entry->wakeup = ktime_to_us(ktime_sub(ktime_get(),
1929 							rqst->rq_qtime));
1930 	),
1931 
1932 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " wakeup-us=%lu",
1933 		SVC_XPRT_ENDPOINT_VARARGS, __entry->wakeup)
1934 );
1935 
1936 DECLARE_EVENT_CLASS(svc_xprt_event,
1937 	TP_PROTO(
1938 		const struct svc_xprt *xprt
1939 	),
1940 
1941 	TP_ARGS(xprt),
1942 
1943 	TP_STRUCT__entry(
1944 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1945 	),
1946 
1947 	TP_fast_assign(
1948 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1949 	),
1950 
1951 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT, SVC_XPRT_ENDPOINT_VARARGS)
1952 );
1953 
1954 #define DEFINE_SVC_XPRT_EVENT(name) \
1955 	DEFINE_EVENT(svc_xprt_event, svc_xprt_##name, \
1956 			TP_PROTO( \
1957 				const struct svc_xprt *xprt \
1958 			), \
1959 			TP_ARGS(xprt))
1960 
1961 DEFINE_SVC_XPRT_EVENT(no_write_space);
1962 DEFINE_SVC_XPRT_EVENT(close);
1963 DEFINE_SVC_XPRT_EVENT(detach);
1964 DEFINE_SVC_XPRT_EVENT(free);
1965 
1966 TRACE_EVENT(svc_xprt_accept,
1967 	TP_PROTO(
1968 		const struct svc_xprt *xprt,
1969 		const char *service
1970 	),
1971 
1972 	TP_ARGS(xprt, service),
1973 
1974 	TP_STRUCT__entry(
1975 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1976 
1977 		__string(protocol, xprt->xpt_class->xcl_name)
1978 		__string(service, service)
1979 	),
1980 
1981 	TP_fast_assign(
1982 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1983 
1984 		__assign_str(protocol, xprt->xpt_class->xcl_name);
1985 		__assign_str(service, service);
1986 	),
1987 
1988 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " protocol=%s service=%s",
1989 		SVC_XPRT_ENDPOINT_VARARGS,
1990 		__get_str(protocol), __get_str(service)
1991 	)
1992 );
1993 
1994 TRACE_EVENT(svc_wake_up,
1995 	TP_PROTO(int pid),
1996 
1997 	TP_ARGS(pid),
1998 
1999 	TP_STRUCT__entry(
2000 		__field(int, pid)
2001 	),
2002 
2003 	TP_fast_assign(
2004 		__entry->pid = pid;
2005 	),
2006 
2007 	TP_printk("pid=%d", __entry->pid)
2008 );
2009 
2010 TRACE_EVENT(svc_alloc_arg_err,
2011 	TP_PROTO(
2012 		unsigned int requested,
2013 		unsigned int allocated
2014 	),
2015 
2016 	TP_ARGS(requested, allocated),
2017 
2018 	TP_STRUCT__entry(
2019 		__field(unsigned int, requested)
2020 		__field(unsigned int, allocated)
2021 	),
2022 
2023 	TP_fast_assign(
2024 		__entry->requested = requested;
2025 		__entry->allocated = allocated;
2026 	),
2027 
2028 	TP_printk("requested=%u allocated=%u",
2029 		__entry->requested, __entry->allocated)
2030 );
2031 
2032 DECLARE_EVENT_CLASS(svc_deferred_event,
2033 	TP_PROTO(
2034 		const struct svc_deferred_req *dr
2035 	),
2036 
2037 	TP_ARGS(dr),
2038 
2039 	TP_STRUCT__entry(
2040 		__field(const void *, dr)
2041 		__field(u32, xid)
2042 		__sockaddr(addr, dr->addrlen)
2043 	),
2044 
2045 	TP_fast_assign(
2046 		__entry->dr = dr;
2047 		__entry->xid = be32_to_cpu(*(__be32 *)dr->args);
2048 		__assign_sockaddr(addr, &dr->addr, dr->addrlen);
2049 	),
2050 
2051 	TP_printk("addr=%pISpc dr=%p xid=0x%08x", __get_sockaddr(addr),
2052 		__entry->dr, __entry->xid)
2053 );
2054 
2055 #define DEFINE_SVC_DEFERRED_EVENT(name) \
2056 	DEFINE_EVENT(svc_deferred_event, svc_defer_##name, \
2057 			TP_PROTO( \
2058 				const struct svc_deferred_req *dr \
2059 			), \
2060 			TP_ARGS(dr))
2061 
2062 DEFINE_SVC_DEFERRED_EVENT(drop);
2063 DEFINE_SVC_DEFERRED_EVENT(queue);
2064 DEFINE_SVC_DEFERRED_EVENT(recv);
2065 
2066 TRACE_EVENT(svcsock_new_socket,
2067 	TP_PROTO(
2068 		const struct socket *socket
2069 	),
2070 
2071 	TP_ARGS(socket),
2072 
2073 	TP_STRUCT__entry(
2074 		__field(unsigned long, type)
2075 		__field(unsigned long, family)
2076 		__field(bool, listener)
2077 	),
2078 
2079 	TP_fast_assign(
2080 		__entry->type = socket->type;
2081 		__entry->family = socket->sk->sk_family;
2082 		__entry->listener = (socket->sk->sk_state == TCP_LISTEN);
2083 	),
2084 
2085 	TP_printk("type=%s family=%s%s",
2086 		show_socket_type(__entry->type),
2087 		rpc_show_address_family(__entry->family),
2088 		__entry->listener ? " (listener)" : ""
2089 	)
2090 );
2091 
2092 TRACE_EVENT(svcsock_marker,
2093 	TP_PROTO(
2094 		const struct svc_xprt *xprt,
2095 		__be32 marker
2096 	),
2097 
2098 	TP_ARGS(xprt, marker),
2099 
2100 	TP_STRUCT__entry(
2101 		__field(unsigned int, length)
2102 		__field(bool, last)
2103 		__string(addr, xprt->xpt_remotebuf)
2104 	),
2105 
2106 	TP_fast_assign(
2107 		__entry->length = be32_to_cpu(marker) & RPC_FRAGMENT_SIZE_MASK;
2108 		__entry->last = be32_to_cpu(marker) & RPC_LAST_STREAM_FRAGMENT;
2109 		__assign_str(addr, xprt->xpt_remotebuf);
2110 	),
2111 
2112 	TP_printk("addr=%s length=%u%s", __get_str(addr),
2113 		__entry->length, __entry->last ? " (last)" : "")
2114 );
2115 
2116 DECLARE_EVENT_CLASS(svcsock_class,
2117 	TP_PROTO(
2118 		const struct svc_xprt *xprt,
2119 		ssize_t result
2120 	),
2121 
2122 	TP_ARGS(xprt, result),
2123 
2124 	TP_STRUCT__entry(
2125 		__field(ssize_t, result)
2126 		__field(unsigned long, flags)
2127 		__string(addr, xprt->xpt_remotebuf)
2128 	),
2129 
2130 	TP_fast_assign(
2131 		__entry->result = result;
2132 		__entry->flags = xprt->xpt_flags;
2133 		__assign_str(addr, xprt->xpt_remotebuf);
2134 	),
2135 
2136 	TP_printk("addr=%s result=%zd flags=%s", __get_str(addr),
2137 		__entry->result, show_svc_xprt_flags(__entry->flags)
2138 	)
2139 );
2140 
2141 #define DEFINE_SVCSOCK_EVENT(name) \
2142 	DEFINE_EVENT(svcsock_class, svcsock_##name, \
2143 			TP_PROTO( \
2144 				const struct svc_xprt *xprt, \
2145 				ssize_t result \
2146 			), \
2147 			TP_ARGS(xprt, result))
2148 
2149 DEFINE_SVCSOCK_EVENT(udp_send);
2150 DEFINE_SVCSOCK_EVENT(udp_recv);
2151 DEFINE_SVCSOCK_EVENT(udp_recv_err);
2152 DEFINE_SVCSOCK_EVENT(tcp_send);
2153 DEFINE_SVCSOCK_EVENT(tcp_recv);
2154 DEFINE_SVCSOCK_EVENT(tcp_recv_eagain);
2155 DEFINE_SVCSOCK_EVENT(tcp_recv_err);
2156 DEFINE_SVCSOCK_EVENT(data_ready);
2157 DEFINE_SVCSOCK_EVENT(write_space);
2158 
2159 TRACE_EVENT(svcsock_tcp_recv_short,
2160 	TP_PROTO(
2161 		const struct svc_xprt *xprt,
2162 		u32 expected,
2163 		u32 received
2164 	),
2165 
2166 	TP_ARGS(xprt, expected, received),
2167 
2168 	TP_STRUCT__entry(
2169 		__field(u32, expected)
2170 		__field(u32, received)
2171 		__field(unsigned long, flags)
2172 		__string(addr, xprt->xpt_remotebuf)
2173 	),
2174 
2175 	TP_fast_assign(
2176 		__entry->expected = expected;
2177 		__entry->received = received;
2178 		__entry->flags = xprt->xpt_flags;
2179 		__assign_str(addr, xprt->xpt_remotebuf);
2180 	),
2181 
2182 	TP_printk("addr=%s flags=%s expected=%u received=%u",
2183 		__get_str(addr), show_svc_xprt_flags(__entry->flags),
2184 		__entry->expected, __entry->received
2185 	)
2186 );
2187 
2188 TRACE_EVENT(svcsock_tcp_state,
2189 	TP_PROTO(
2190 		const struct svc_xprt *xprt,
2191 		const struct socket *socket
2192 	),
2193 
2194 	TP_ARGS(xprt, socket),
2195 
2196 	TP_STRUCT__entry(
2197 		__field(unsigned long, socket_state)
2198 		__field(unsigned long, sock_state)
2199 		__field(unsigned long, flags)
2200 		__string(addr, xprt->xpt_remotebuf)
2201 	),
2202 
2203 	TP_fast_assign(
2204 		__entry->socket_state = socket->state;
2205 		__entry->sock_state = socket->sk->sk_state;
2206 		__entry->flags = xprt->xpt_flags;
2207 		__assign_str(addr, xprt->xpt_remotebuf);
2208 	),
2209 
2210 	TP_printk("addr=%s state=%s sk_state=%s flags=%s", __get_str(addr),
2211 		rpc_show_socket_state(__entry->socket_state),
2212 		rpc_show_sock_state(__entry->sock_state),
2213 		show_svc_xprt_flags(__entry->flags)
2214 	)
2215 );
2216 
2217 DECLARE_EVENT_CLASS(svcsock_accept_class,
2218 	TP_PROTO(
2219 		const struct svc_xprt *xprt,
2220 		const char *service,
2221 		long status
2222 	),
2223 
2224 	TP_ARGS(xprt, service, status),
2225 
2226 	TP_STRUCT__entry(
2227 		__field(long, status)
2228 		__string(service, service)
2229 		__field(unsigned int, netns_ino)
2230 	),
2231 
2232 	TP_fast_assign(
2233 		__entry->status = status;
2234 		__assign_str(service, service);
2235 		__entry->netns_ino = xprt->xpt_net->ns.inum;
2236 	),
2237 
2238 	TP_printk("addr=listener service=%s status=%ld",
2239 		__get_str(service), __entry->status
2240 	)
2241 );
2242 
2243 #define DEFINE_ACCEPT_EVENT(name) \
2244 	DEFINE_EVENT(svcsock_accept_class, svcsock_##name##_err, \
2245 			TP_PROTO( \
2246 				const struct svc_xprt *xprt, \
2247 				const char *service, \
2248 				long status \
2249 			), \
2250 			TP_ARGS(xprt, service, status))
2251 
2252 DEFINE_ACCEPT_EVENT(accept);
2253 DEFINE_ACCEPT_EVENT(getpeername);
2254 
2255 DECLARE_EVENT_CLASS(cache_event,
2256 	TP_PROTO(
2257 		const struct cache_detail *cd,
2258 		const struct cache_head *h
2259 	),
2260 
2261 	TP_ARGS(cd, h),
2262 
2263 	TP_STRUCT__entry(
2264 		__field(const struct cache_head *, h)
2265 		__string(name, cd->name)
2266 	),
2267 
2268 	TP_fast_assign(
2269 		__entry->h = h;
2270 		__assign_str(name, cd->name);
2271 	),
2272 
2273 	TP_printk("cache=%s entry=%p", __get_str(name), __entry->h)
2274 );
2275 #define DEFINE_CACHE_EVENT(name) \
2276 	DEFINE_EVENT(cache_event, name, \
2277 			TP_PROTO( \
2278 				const struct cache_detail *cd, \
2279 				const struct cache_head *h \
2280 			), \
2281 			TP_ARGS(cd, h))
2282 DEFINE_CACHE_EVENT(cache_entry_expired);
2283 DEFINE_CACHE_EVENT(cache_entry_upcall);
2284 DEFINE_CACHE_EVENT(cache_entry_update);
2285 DEFINE_CACHE_EVENT(cache_entry_make_negative);
2286 DEFINE_CACHE_EVENT(cache_entry_no_listener);
2287 
2288 DECLARE_EVENT_CLASS(register_class,
2289 	TP_PROTO(
2290 		const char *program,
2291 		const u32 version,
2292 		const int family,
2293 		const unsigned short protocol,
2294 		const unsigned short port,
2295 		int error
2296 	),
2297 
2298 	TP_ARGS(program, version, family, protocol, port, error),
2299 
2300 	TP_STRUCT__entry(
2301 		__field(u32, version)
2302 		__field(unsigned long, family)
2303 		__field(unsigned short, protocol)
2304 		__field(unsigned short, port)
2305 		__field(int, error)
2306 		__string(program, program)
2307 	),
2308 
2309 	TP_fast_assign(
2310 		__entry->version = version;
2311 		__entry->family = family;
2312 		__entry->protocol = protocol;
2313 		__entry->port = port;
2314 		__entry->error = error;
2315 		__assign_str(program, program);
2316 	),
2317 
2318 	TP_printk("program=%sv%u proto=%s port=%u family=%s error=%d",
2319 		__get_str(program), __entry->version,
2320 		__entry->protocol == IPPROTO_UDP ? "udp" : "tcp",
2321 		__entry->port, rpc_show_address_family(__entry->family),
2322 		__entry->error
2323 	)
2324 );
2325 
2326 #define DEFINE_REGISTER_EVENT(name) \
2327 	DEFINE_EVENT(register_class, svc_##name, \
2328 			TP_PROTO( \
2329 				const char *program, \
2330 				const u32 version, \
2331 				const int family, \
2332 				const unsigned short protocol, \
2333 				const unsigned short port, \
2334 				int error \
2335 			), \
2336 			TP_ARGS(program, version, family, protocol, \
2337 				port, error))
2338 
2339 DEFINE_REGISTER_EVENT(register);
2340 DEFINE_REGISTER_EVENT(noregister);
2341 
2342 TRACE_EVENT(svc_unregister,
2343 	TP_PROTO(
2344 		const char *program,
2345 		const u32 version,
2346 		int error
2347 	),
2348 
2349 	TP_ARGS(program, version, error),
2350 
2351 	TP_STRUCT__entry(
2352 		__field(u32, version)
2353 		__field(int, error)
2354 		__string(program, program)
2355 	),
2356 
2357 	TP_fast_assign(
2358 		__entry->version = version;
2359 		__entry->error = error;
2360 		__assign_str(program, program);
2361 	),
2362 
2363 	TP_printk("program=%sv%u error=%d",
2364 		__get_str(program), __entry->version, __entry->error
2365 	)
2366 );
2367 
2368 #endif /* _TRACE_SUNRPC_H */
2369 
2370 #include <trace/define_trace.h>
2371