xref: /openbmc/linux/include/trace/events/sunrpc.h (revision 7419995a)
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(disconnect_cleanup);
1008 DEFINE_RPC_XPRT_LIFETIME_EVENT(destroy);
1009 
1010 DECLARE_EVENT_CLASS(rpc_xprt_event,
1011 	TP_PROTO(
1012 		const struct rpc_xprt *xprt,
1013 		__be32 xid,
1014 		int status
1015 	),
1016 
1017 	TP_ARGS(xprt, xid, status),
1018 
1019 	TP_STRUCT__entry(
1020 		__field(u32, xid)
1021 		__field(int, status)
1022 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
1023 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
1024 	),
1025 
1026 	TP_fast_assign(
1027 		__entry->xid = be32_to_cpu(xid);
1028 		__entry->status = status;
1029 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
1030 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
1031 	),
1032 
1033 	TP_printk("peer=[%s]:%s xid=0x%08x status=%d", __get_str(addr),
1034 			__get_str(port), __entry->xid,
1035 			__entry->status)
1036 );
1037 #define DEFINE_RPC_XPRT_EVENT(name) \
1038 	DEFINE_EVENT(rpc_xprt_event, xprt_##name, \
1039 			TP_PROTO( \
1040 				const struct rpc_xprt *xprt, \
1041 				__be32 xid, \
1042 				int status \
1043 			), \
1044 			TP_ARGS(xprt, xid, status))
1045 
1046 DEFINE_RPC_XPRT_EVENT(timer);
1047 DEFINE_RPC_XPRT_EVENT(lookup_rqst);
1048 
1049 TRACE_EVENT(xprt_transmit,
1050 	TP_PROTO(
1051 		const struct rpc_rqst *rqst,
1052 		int status
1053 	),
1054 
1055 	TP_ARGS(rqst, status),
1056 
1057 	TP_STRUCT__entry(
1058 		__field(unsigned int, task_id)
1059 		__field(unsigned int, client_id)
1060 		__field(u32, xid)
1061 		__field(u32, seqno)
1062 		__field(int, status)
1063 	),
1064 
1065 	TP_fast_assign(
1066 		__entry->task_id = rqst->rq_task->tk_pid;
1067 		__entry->client_id = rqst->rq_task->tk_client ?
1068 			rqst->rq_task->tk_client->cl_clid : -1;
1069 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1070 		__entry->seqno = rqst->rq_seqno;
1071 		__entry->status = status;
1072 	),
1073 
1074 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1075 		  " xid=0x%08x seqno=%u status=%d",
1076 		__entry->task_id, __entry->client_id, __entry->xid,
1077 		__entry->seqno, __entry->status)
1078 );
1079 
1080 TRACE_EVENT(xprt_retransmit,
1081 	TP_PROTO(
1082 		const struct rpc_rqst *rqst
1083 	),
1084 
1085 	TP_ARGS(rqst),
1086 
1087 	TP_STRUCT__entry(
1088 		__field(unsigned int, task_id)
1089 		__field(unsigned int, client_id)
1090 		__field(u32, xid)
1091 		__field(int, ntrans)
1092 		__field(int, version)
1093 		__field(unsigned long, timeout)
1094 		__string(progname,
1095 			 rqst->rq_task->tk_client->cl_program->name)
1096 		__string(procname, rpc_proc_name(rqst->rq_task))
1097 	),
1098 
1099 	TP_fast_assign(
1100 		struct rpc_task *task = rqst->rq_task;
1101 
1102 		__entry->task_id = task->tk_pid;
1103 		__entry->client_id = task->tk_client ?
1104 			task->tk_client->cl_clid : -1;
1105 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1106 		__entry->ntrans = rqst->rq_ntrans;
1107 		__entry->timeout = task->tk_timeout;
1108 		__assign_str(progname,
1109 			     task->tk_client->cl_program->name);
1110 		__entry->version = task->tk_client->cl_vers;
1111 		__assign_str(procname, rpc_proc_name(task));
1112 	),
1113 
1114 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1115 		  " xid=0x%08x %sv%d %s ntrans=%d timeout=%lu",
1116 		__entry->task_id, __entry->client_id, __entry->xid,
1117 		__get_str(progname), __entry->version, __get_str(procname),
1118 		__entry->ntrans, __entry->timeout
1119 	)
1120 );
1121 
1122 TRACE_EVENT(xprt_ping,
1123 	TP_PROTO(const struct rpc_xprt *xprt, int status),
1124 
1125 	TP_ARGS(xprt, status),
1126 
1127 	TP_STRUCT__entry(
1128 		__field(int, status)
1129 		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
1130 		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
1131 	),
1132 
1133 	TP_fast_assign(
1134 		__entry->status = status;
1135 		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
1136 		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
1137 	),
1138 
1139 	TP_printk("peer=[%s]:%s status=%d",
1140 			__get_str(addr), __get_str(port), __entry->status)
1141 );
1142 
1143 DECLARE_EVENT_CLASS(xprt_writelock_event,
1144 	TP_PROTO(
1145 		const struct rpc_xprt *xprt, const struct rpc_task *task
1146 	),
1147 
1148 	TP_ARGS(xprt, task),
1149 
1150 	TP_STRUCT__entry(
1151 		__field(unsigned int, task_id)
1152 		__field(unsigned int, client_id)
1153 		__field(unsigned int, snd_task_id)
1154 	),
1155 
1156 	TP_fast_assign(
1157 		if (task) {
1158 			__entry->task_id = task->tk_pid;
1159 			__entry->client_id = task->tk_client ?
1160 					     task->tk_client->cl_clid : -1;
1161 		} else {
1162 			__entry->task_id = -1;
1163 			__entry->client_id = -1;
1164 		}
1165 		if (xprt->snd_task &&
1166 		    !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
1167 			__entry->snd_task_id = xprt->snd_task->tk_pid;
1168 		else
1169 			__entry->snd_task_id = -1;
1170 	),
1171 
1172 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1173 		  " snd_task:" SUNRPC_TRACE_PID_SPECIFIER,
1174 			__entry->task_id, __entry->client_id,
1175 			__entry->snd_task_id)
1176 );
1177 
1178 #define DEFINE_WRITELOCK_EVENT(name) \
1179 	DEFINE_EVENT(xprt_writelock_event, xprt_##name, \
1180 			TP_PROTO( \
1181 				const struct rpc_xprt *xprt, \
1182 				const struct rpc_task *task \
1183 			), \
1184 			TP_ARGS(xprt, task))
1185 
1186 DEFINE_WRITELOCK_EVENT(reserve_xprt);
1187 DEFINE_WRITELOCK_EVENT(release_xprt);
1188 
1189 DECLARE_EVENT_CLASS(xprt_cong_event,
1190 	TP_PROTO(
1191 		const struct rpc_xprt *xprt, const struct rpc_task *task
1192 	),
1193 
1194 	TP_ARGS(xprt, task),
1195 
1196 	TP_STRUCT__entry(
1197 		__field(unsigned int, task_id)
1198 		__field(unsigned int, client_id)
1199 		__field(unsigned int, snd_task_id)
1200 		__field(unsigned long, cong)
1201 		__field(unsigned long, cwnd)
1202 		__field(bool, wait)
1203 	),
1204 
1205 	TP_fast_assign(
1206 		if (task) {
1207 			__entry->task_id = task->tk_pid;
1208 			__entry->client_id = task->tk_client ?
1209 					     task->tk_client->cl_clid : -1;
1210 		} else {
1211 			__entry->task_id = -1;
1212 			__entry->client_id = -1;
1213 		}
1214 		if (xprt->snd_task &&
1215 		    !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
1216 			__entry->snd_task_id = xprt->snd_task->tk_pid;
1217 		else
1218 			__entry->snd_task_id = -1;
1219 
1220 		__entry->cong = xprt->cong;
1221 		__entry->cwnd = xprt->cwnd;
1222 		__entry->wait = test_bit(XPRT_CWND_WAIT, &xprt->state);
1223 	),
1224 
1225 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1226 		  " snd_task:" SUNRPC_TRACE_PID_SPECIFIER
1227 		  " cong=%lu cwnd=%lu%s",
1228 			__entry->task_id, __entry->client_id,
1229 			__entry->snd_task_id, __entry->cong, __entry->cwnd,
1230 			__entry->wait ? " (wait)" : "")
1231 );
1232 
1233 #define DEFINE_CONG_EVENT(name) \
1234 	DEFINE_EVENT(xprt_cong_event, xprt_##name, \
1235 			TP_PROTO( \
1236 				const struct rpc_xprt *xprt, \
1237 				const struct rpc_task *task \
1238 			), \
1239 			TP_ARGS(xprt, task))
1240 
1241 DEFINE_CONG_EVENT(reserve_cong);
1242 DEFINE_CONG_EVENT(release_cong);
1243 DEFINE_CONG_EVENT(get_cong);
1244 DEFINE_CONG_EVENT(put_cong);
1245 
1246 TRACE_EVENT(xprt_reserve,
1247 	TP_PROTO(
1248 		const struct rpc_rqst *rqst
1249 	),
1250 
1251 	TP_ARGS(rqst),
1252 
1253 	TP_STRUCT__entry(
1254 		__field(unsigned int, task_id)
1255 		__field(unsigned int, client_id)
1256 		__field(u32, xid)
1257 	),
1258 
1259 	TP_fast_assign(
1260 		__entry->task_id = rqst->rq_task->tk_pid;
1261 		__entry->client_id = rqst->rq_task->tk_client->cl_clid;
1262 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1263 	),
1264 
1265 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " xid=0x%08x",
1266 		__entry->task_id, __entry->client_id, __entry->xid
1267 	)
1268 );
1269 
1270 TRACE_EVENT(xs_stream_read_data,
1271 	TP_PROTO(struct rpc_xprt *xprt, ssize_t err, size_t total),
1272 
1273 	TP_ARGS(xprt, err, total),
1274 
1275 	TP_STRUCT__entry(
1276 		__field(ssize_t, err)
1277 		__field(size_t, total)
1278 		__string(addr, xprt ? xprt->address_strings[RPC_DISPLAY_ADDR] :
1279 				"(null)")
1280 		__string(port, xprt ? xprt->address_strings[RPC_DISPLAY_PORT] :
1281 				"(null)")
1282 	),
1283 
1284 	TP_fast_assign(
1285 		__entry->err = err;
1286 		__entry->total = total;
1287 		__assign_str(addr, xprt ?
1288 			xprt->address_strings[RPC_DISPLAY_ADDR] : "(null)");
1289 		__assign_str(port, xprt ?
1290 			xprt->address_strings[RPC_DISPLAY_PORT] : "(null)");
1291 	),
1292 
1293 	TP_printk("peer=[%s]:%s err=%zd total=%zu", __get_str(addr),
1294 			__get_str(port), __entry->err, __entry->total)
1295 );
1296 
1297 TRACE_EVENT(xs_stream_read_request,
1298 	TP_PROTO(struct sock_xprt *xs),
1299 
1300 	TP_ARGS(xs),
1301 
1302 	TP_STRUCT__entry(
1303 		__string(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR])
1304 		__string(port, xs->xprt.address_strings[RPC_DISPLAY_PORT])
1305 		__field(u32, xid)
1306 		__field(unsigned long, copied)
1307 		__field(unsigned int, reclen)
1308 		__field(unsigned int, offset)
1309 	),
1310 
1311 	TP_fast_assign(
1312 		__assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]);
1313 		__assign_str(port, xs->xprt.address_strings[RPC_DISPLAY_PORT]);
1314 		__entry->xid = be32_to_cpu(xs->recv.xid);
1315 		__entry->copied = xs->recv.copied;
1316 		__entry->reclen = xs->recv.len;
1317 		__entry->offset = xs->recv.offset;
1318 	),
1319 
1320 	TP_printk("peer=[%s]:%s xid=0x%08x copied=%lu reclen=%u offset=%u",
1321 			__get_str(addr), __get_str(port), __entry->xid,
1322 			__entry->copied, __entry->reclen, __entry->offset)
1323 );
1324 
1325 TRACE_EVENT(rpcb_getport,
1326 	TP_PROTO(
1327 		const struct rpc_clnt *clnt,
1328 		const struct rpc_task *task,
1329 		unsigned int bind_version
1330 	),
1331 
1332 	TP_ARGS(clnt, task, bind_version),
1333 
1334 	TP_STRUCT__entry(
1335 		__field(unsigned int, task_id)
1336 		__field(unsigned int, client_id)
1337 		__field(unsigned int, program)
1338 		__field(unsigned int, version)
1339 		__field(int, protocol)
1340 		__field(unsigned int, bind_version)
1341 		__string(servername, task->tk_xprt->servername)
1342 	),
1343 
1344 	TP_fast_assign(
1345 		__entry->task_id = task->tk_pid;
1346 		__entry->client_id = clnt->cl_clid;
1347 		__entry->program = clnt->cl_prog;
1348 		__entry->version = clnt->cl_vers;
1349 		__entry->protocol = task->tk_xprt->prot;
1350 		__entry->bind_version = bind_version;
1351 		__assign_str(servername, task->tk_xprt->servername);
1352 	),
1353 
1354 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1355 		  " server=%s program=%u version=%u protocol=%d bind_version=%u",
1356 		__entry->task_id, __entry->client_id, __get_str(servername),
1357 		__entry->program, __entry->version, __entry->protocol,
1358 		__entry->bind_version
1359 	)
1360 );
1361 
1362 TRACE_EVENT(rpcb_setport,
1363 	TP_PROTO(
1364 		const struct rpc_task *task,
1365 		int status,
1366 		unsigned short port
1367 	),
1368 
1369 	TP_ARGS(task, status, port),
1370 
1371 	TP_STRUCT__entry(
1372 		__field(unsigned int, task_id)
1373 		__field(unsigned int, client_id)
1374 		__field(int, status)
1375 		__field(unsigned short, port)
1376 	),
1377 
1378 	TP_fast_assign(
1379 		__entry->task_id = task->tk_pid;
1380 		__entry->client_id = task->tk_client->cl_clid;
1381 		__entry->status = status;
1382 		__entry->port = port;
1383 	),
1384 
1385 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER " status=%d port=%u",
1386 		__entry->task_id, __entry->client_id,
1387 		__entry->status, __entry->port
1388 	)
1389 );
1390 
1391 TRACE_EVENT(pmap_register,
1392 	TP_PROTO(
1393 		u32 program,
1394 		u32 version,
1395 		int protocol,
1396 		unsigned short port
1397 	),
1398 
1399 	TP_ARGS(program, version, protocol, port),
1400 
1401 	TP_STRUCT__entry(
1402 		__field(unsigned int, program)
1403 		__field(unsigned int, version)
1404 		__field(int, protocol)
1405 		__field(unsigned int, port)
1406 	),
1407 
1408 	TP_fast_assign(
1409 		__entry->program = program;
1410 		__entry->version = version;
1411 		__entry->protocol = protocol;
1412 		__entry->port = port;
1413 	),
1414 
1415 	TP_printk("program=%u version=%u protocol=%d port=%u",
1416 		__entry->program, __entry->version,
1417 		__entry->protocol, __entry->port
1418 	)
1419 );
1420 
1421 TRACE_EVENT(rpcb_register,
1422 	TP_PROTO(
1423 		u32 program,
1424 		u32 version,
1425 		const char *addr,
1426 		const char *netid
1427 	),
1428 
1429 	TP_ARGS(program, version, addr, netid),
1430 
1431 	TP_STRUCT__entry(
1432 		__field(unsigned int, program)
1433 		__field(unsigned int, version)
1434 		__string(addr, addr)
1435 		__string(netid, netid)
1436 	),
1437 
1438 	TP_fast_assign(
1439 		__entry->program = program;
1440 		__entry->version = version;
1441 		__assign_str(addr, addr);
1442 		__assign_str(netid, netid);
1443 	),
1444 
1445 	TP_printk("program=%u version=%u addr=%s netid=%s",
1446 		__entry->program, __entry->version,
1447 		__get_str(addr), __get_str(netid)
1448 	)
1449 );
1450 
1451 TRACE_EVENT(rpcb_unregister,
1452 	TP_PROTO(
1453 		u32 program,
1454 		u32 version,
1455 		const char *netid
1456 	),
1457 
1458 	TP_ARGS(program, version, netid),
1459 
1460 	TP_STRUCT__entry(
1461 		__field(unsigned int, program)
1462 		__field(unsigned int, version)
1463 		__string(netid, netid)
1464 	),
1465 
1466 	TP_fast_assign(
1467 		__entry->program = program;
1468 		__entry->version = version;
1469 		__assign_str(netid, netid);
1470 	),
1471 
1472 	TP_printk("program=%u version=%u netid=%s",
1473 		__entry->program, __entry->version, __get_str(netid)
1474 	)
1475 );
1476 
1477 /* Record an xdr_buf containing a fully-formed RPC message */
1478 DECLARE_EVENT_CLASS(svc_xdr_msg_class,
1479 	TP_PROTO(
1480 		const struct xdr_buf *xdr
1481 	),
1482 
1483 	TP_ARGS(xdr),
1484 
1485 	TP_STRUCT__entry(
1486 		__field(u32, xid)
1487 		__field(const void *, head_base)
1488 		__field(size_t, head_len)
1489 		__field(const void *, tail_base)
1490 		__field(size_t, tail_len)
1491 		__field(unsigned int, page_len)
1492 		__field(unsigned int, msg_len)
1493 	),
1494 
1495 	TP_fast_assign(
1496 		__be32 *p = (__be32 *)xdr->head[0].iov_base;
1497 
1498 		__entry->xid = be32_to_cpu(*p);
1499 		__entry->head_base = p;
1500 		__entry->head_len = xdr->head[0].iov_len;
1501 		__entry->tail_base = xdr->tail[0].iov_base;
1502 		__entry->tail_len = xdr->tail[0].iov_len;
1503 		__entry->page_len = xdr->page_len;
1504 		__entry->msg_len = xdr->len;
1505 	),
1506 
1507 	TP_printk("xid=0x%08x head=[%p,%zu] page=%u tail=[%p,%zu] len=%u",
1508 		__entry->xid,
1509 		__entry->head_base, __entry->head_len, __entry->page_len,
1510 		__entry->tail_base, __entry->tail_len, __entry->msg_len
1511 	)
1512 );
1513 
1514 #define DEFINE_SVCXDRMSG_EVENT(name)					\
1515 		DEFINE_EVENT(svc_xdr_msg_class,				\
1516 				svc_xdr_##name,				\
1517 				TP_PROTO(				\
1518 					const struct xdr_buf *xdr	\
1519 				),					\
1520 				TP_ARGS(xdr))
1521 
1522 DEFINE_SVCXDRMSG_EVENT(recvfrom);
1523 
1524 /* Record an xdr_buf containing arbitrary data, tagged with an XID */
1525 DECLARE_EVENT_CLASS(svc_xdr_buf_class,
1526 	TP_PROTO(
1527 		__be32 xid,
1528 		const struct xdr_buf *xdr
1529 	),
1530 
1531 	TP_ARGS(xid, xdr),
1532 
1533 	TP_STRUCT__entry(
1534 		__field(u32, xid)
1535 		__field(const void *, head_base)
1536 		__field(size_t, head_len)
1537 		__field(const void *, tail_base)
1538 		__field(size_t, tail_len)
1539 		__field(unsigned int, page_base)
1540 		__field(unsigned int, page_len)
1541 		__field(unsigned int, msg_len)
1542 	),
1543 
1544 	TP_fast_assign(
1545 		__entry->xid = be32_to_cpu(xid);
1546 		__entry->head_base = xdr->head[0].iov_base;
1547 		__entry->head_len = xdr->head[0].iov_len;
1548 		__entry->tail_base = xdr->tail[0].iov_base;
1549 		__entry->tail_len = xdr->tail[0].iov_len;
1550 		__entry->page_base = xdr->page_base;
1551 		__entry->page_len = xdr->page_len;
1552 		__entry->msg_len = xdr->len;
1553 	),
1554 
1555 	TP_printk("xid=0x%08x head=[%p,%zu] page=%u(%u) tail=[%p,%zu] len=%u",
1556 		__entry->xid,
1557 		__entry->head_base, __entry->head_len,
1558 		__entry->page_len, __entry->page_base,
1559 		__entry->tail_base, __entry->tail_len,
1560 		__entry->msg_len
1561 	)
1562 );
1563 
1564 #define DEFINE_SVCXDRBUF_EVENT(name)					\
1565 		DEFINE_EVENT(svc_xdr_buf_class,				\
1566 				svc_xdr_##name,				\
1567 				TP_PROTO(				\
1568 					__be32 xid,			\
1569 					const struct xdr_buf *xdr	\
1570 				),					\
1571 				TP_ARGS(xid, xdr))
1572 
1573 DEFINE_SVCXDRBUF_EVENT(sendto);
1574 
1575 /*
1576  * from include/linux/sunrpc/svc.h
1577  */
1578 #define SVC_RQST_FLAG_LIST						\
1579 	svc_rqst_flag(SECURE)						\
1580 	svc_rqst_flag(LOCAL)						\
1581 	svc_rqst_flag(USEDEFERRAL)					\
1582 	svc_rqst_flag(DROPME)						\
1583 	svc_rqst_flag(SPLICE_OK)					\
1584 	svc_rqst_flag(VICTIM)						\
1585 	svc_rqst_flag(BUSY)						\
1586 	svc_rqst_flag_end(DATA)
1587 
1588 #undef svc_rqst_flag
1589 #undef svc_rqst_flag_end
1590 #define svc_rqst_flag(x)	TRACE_DEFINE_ENUM(RQ_##x);
1591 #define svc_rqst_flag_end(x)	TRACE_DEFINE_ENUM(RQ_##x);
1592 
1593 SVC_RQST_FLAG_LIST
1594 
1595 #undef svc_rqst_flag
1596 #undef svc_rqst_flag_end
1597 #define svc_rqst_flag(x)	{ BIT(RQ_##x), #x },
1598 #define svc_rqst_flag_end(x)	{ BIT(RQ_##x), #x }
1599 
1600 #define show_rqstp_flags(flags)						\
1601 		__print_flags(flags, "|", SVC_RQST_FLAG_LIST)
1602 
1603 TRACE_DEFINE_ENUM(SVC_GARBAGE);
1604 TRACE_DEFINE_ENUM(SVC_SYSERR);
1605 TRACE_DEFINE_ENUM(SVC_VALID);
1606 TRACE_DEFINE_ENUM(SVC_NEGATIVE);
1607 TRACE_DEFINE_ENUM(SVC_OK);
1608 TRACE_DEFINE_ENUM(SVC_DROP);
1609 TRACE_DEFINE_ENUM(SVC_CLOSE);
1610 TRACE_DEFINE_ENUM(SVC_DENIED);
1611 TRACE_DEFINE_ENUM(SVC_PENDING);
1612 TRACE_DEFINE_ENUM(SVC_COMPLETE);
1613 
1614 #define svc_show_status(status)				\
1615 	__print_symbolic(status,			\
1616 		{ SVC_GARBAGE,	"SVC_GARBAGE" },	\
1617 		{ SVC_SYSERR,	"SVC_SYSERR" },		\
1618 		{ SVC_VALID,	"SVC_VALID" },		\
1619 		{ SVC_NEGATIVE,	"SVC_NEGATIVE" },	\
1620 		{ SVC_OK,	"SVC_OK" },		\
1621 		{ SVC_DROP,	"SVC_DROP" },		\
1622 		{ SVC_CLOSE,	"SVC_CLOSE" },		\
1623 		{ SVC_DENIED,	"SVC_DENIED" },		\
1624 		{ SVC_PENDING,	"SVC_PENDING" },	\
1625 		{ SVC_COMPLETE,	"SVC_COMPLETE" })
1626 
1627 #define SVC_RQST_ENDPOINT_FIELDS(r) \
1628 		__sockaddr(server, (r)->rq_xprt->xpt_locallen) \
1629 		__sockaddr(client, (r)->rq_xprt->xpt_remotelen) \
1630 		__field(unsigned int, netns_ino) \
1631 		__field(u32, xid)
1632 
1633 #define SVC_RQST_ENDPOINT_ASSIGNMENTS(r) \
1634 		do { \
1635 			struct svc_xprt *xprt = (r)->rq_xprt; \
1636 			__assign_sockaddr(server, &xprt->xpt_local, \
1637 					  xprt->xpt_locallen); \
1638 			__assign_sockaddr(client, &xprt->xpt_remote, \
1639 					  xprt->xpt_remotelen); \
1640 			__entry->netns_ino = xprt->xpt_net->ns.inum; \
1641 			__entry->xid = be32_to_cpu((r)->rq_xid); \
1642 		} while (0)
1643 
1644 #define SVC_RQST_ENDPOINT_FORMAT \
1645 		"xid=0x%08x server=%pISpc client=%pISpc"
1646 
1647 #define SVC_RQST_ENDPOINT_VARARGS \
1648 		__entry->xid, __get_sockaddr(server), __get_sockaddr(client)
1649 
1650 TRACE_EVENT(svc_authenticate,
1651 	TP_PROTO(const struct svc_rqst *rqst, int auth_res),
1652 
1653 	TP_ARGS(rqst, auth_res),
1654 
1655 	TP_STRUCT__entry(
1656 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1657 
1658 		__field(unsigned long, svc_status)
1659 		__field(unsigned long, auth_stat)
1660 	),
1661 
1662 	TP_fast_assign(
1663 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1664 
1665 		__entry->svc_status = auth_res;
1666 		__entry->auth_stat = be32_to_cpu(rqst->rq_auth_stat);
1667 	),
1668 
1669 	TP_printk(SVC_RQST_ENDPOINT_FORMAT
1670 		" auth_res=%s auth_stat=%s",
1671 		SVC_RQST_ENDPOINT_VARARGS,
1672 		svc_show_status(__entry->svc_status),
1673 		rpc_show_auth_stat(__entry->auth_stat))
1674 );
1675 
1676 TRACE_EVENT(svc_process,
1677 	TP_PROTO(const struct svc_rqst *rqst, const char *name),
1678 
1679 	TP_ARGS(rqst, name),
1680 
1681 	TP_STRUCT__entry(
1682 		__field(u32, xid)
1683 		__field(u32, vers)
1684 		__field(u32, proc)
1685 		__string(service, name)
1686 		__string(procedure, svc_proc_name(rqst))
1687 		__string(addr, rqst->rq_xprt ?
1688 			 rqst->rq_xprt->xpt_remotebuf : "(null)")
1689 	),
1690 
1691 	TP_fast_assign(
1692 		__entry->xid = be32_to_cpu(rqst->rq_xid);
1693 		__entry->vers = rqst->rq_vers;
1694 		__entry->proc = rqst->rq_proc;
1695 		__assign_str(service, name);
1696 		__assign_str(procedure, svc_proc_name(rqst));
1697 		__assign_str(addr, rqst->rq_xprt ?
1698 			     rqst->rq_xprt->xpt_remotebuf : "(null)");
1699 	),
1700 
1701 	TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%s",
1702 			__get_str(addr), __entry->xid,
1703 			__get_str(service), __entry->vers,
1704 			__get_str(procedure)
1705 	)
1706 );
1707 
1708 DECLARE_EVENT_CLASS(svc_rqst_event,
1709 	TP_PROTO(
1710 		const struct svc_rqst *rqst
1711 	),
1712 
1713 	TP_ARGS(rqst),
1714 
1715 	TP_STRUCT__entry(
1716 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1717 
1718 		__field(unsigned long, flags)
1719 	),
1720 
1721 	TP_fast_assign(
1722 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1723 
1724 		__entry->flags = rqst->rq_flags;
1725 	),
1726 
1727 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " flags=%s",
1728 		SVC_RQST_ENDPOINT_VARARGS,
1729 		show_rqstp_flags(__entry->flags))
1730 );
1731 #define DEFINE_SVC_RQST_EVENT(name) \
1732 	DEFINE_EVENT(svc_rqst_event, svc_##name, \
1733 			TP_PROTO( \
1734 				const struct svc_rqst *rqst \
1735 			), \
1736 			TP_ARGS(rqst))
1737 
1738 DEFINE_SVC_RQST_EVENT(defer);
1739 DEFINE_SVC_RQST_EVENT(drop);
1740 
1741 DECLARE_EVENT_CLASS(svc_rqst_status,
1742 	TP_PROTO(
1743 		const struct svc_rqst *rqst,
1744 		int status
1745 	),
1746 
1747 	TP_ARGS(rqst, status),
1748 
1749 	TP_STRUCT__entry(
1750 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1751 
1752 		__field(int, status)
1753 		__field(unsigned long, flags)
1754 	),
1755 
1756 	TP_fast_assign(
1757 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1758 
1759 		__entry->status = status;
1760 		__entry->flags = rqst->rq_flags;
1761 	),
1762 
1763 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " status=%d flags=%s",
1764 		SVC_RQST_ENDPOINT_VARARGS,
1765 		__entry->status, show_rqstp_flags(__entry->flags))
1766 );
1767 
1768 DEFINE_EVENT(svc_rqst_status, svc_send,
1769 	TP_PROTO(const struct svc_rqst *rqst, int status),
1770 	TP_ARGS(rqst, status));
1771 
1772 TRACE_EVENT(svc_stats_latency,
1773 	TP_PROTO(
1774 		const struct svc_rqst *rqst
1775 	),
1776 
1777 	TP_ARGS(rqst),
1778 
1779 	TP_STRUCT__entry(
1780 		SVC_RQST_ENDPOINT_FIELDS(rqst)
1781 
1782 		__field(unsigned long, execute)
1783 		__string(procedure, svc_proc_name(rqst))
1784 	),
1785 
1786 	TP_fast_assign(
1787 		SVC_RQST_ENDPOINT_ASSIGNMENTS(rqst);
1788 
1789 		__entry->execute = ktime_to_us(ktime_sub(ktime_get(),
1790 							 rqst->rq_stime));
1791 		__assign_str(procedure, svc_proc_name(rqst));
1792 	),
1793 
1794 	TP_printk(SVC_RQST_ENDPOINT_FORMAT " proc=%s execute-us=%lu",
1795 		SVC_RQST_ENDPOINT_VARARGS,
1796 		__get_str(procedure), __entry->execute)
1797 );
1798 
1799 #define show_svc_xprt_flags(flags)					\
1800 	__print_flags(flags, "|",					\
1801 		{ (1UL << XPT_BUSY),		"XPT_BUSY"},		\
1802 		{ (1UL << XPT_CONN),		"XPT_CONN"},		\
1803 		{ (1UL << XPT_CLOSE),		"XPT_CLOSE"},		\
1804 		{ (1UL << XPT_DATA),		"XPT_DATA"},		\
1805 		{ (1UL << XPT_TEMP),		"XPT_TEMP"},		\
1806 		{ (1UL << XPT_DEAD),		"XPT_DEAD"},		\
1807 		{ (1UL << XPT_CHNGBUF),		"XPT_CHNGBUF"},		\
1808 		{ (1UL << XPT_DEFERRED),	"XPT_DEFERRED"},	\
1809 		{ (1UL << XPT_OLD),		"XPT_OLD"},		\
1810 		{ (1UL << XPT_LISTENER),	"XPT_LISTENER"},	\
1811 		{ (1UL << XPT_CACHE_AUTH),	"XPT_CACHE_AUTH"},	\
1812 		{ (1UL << XPT_LOCAL),		"XPT_LOCAL"},		\
1813 		{ (1UL << XPT_KILL_TEMP),	"XPT_KILL_TEMP"},	\
1814 		{ (1UL << XPT_CONG_CTRL),	"XPT_CONG_CTRL"})
1815 
1816 TRACE_EVENT(svc_xprt_create_err,
1817 	TP_PROTO(
1818 		const char *program,
1819 		const char *protocol,
1820 		struct sockaddr *sap,
1821 		size_t salen,
1822 		const struct svc_xprt *xprt
1823 	),
1824 
1825 	TP_ARGS(program, protocol, sap, salen, xprt),
1826 
1827 	TP_STRUCT__entry(
1828 		__field(long, error)
1829 		__string(program, program)
1830 		__string(protocol, protocol)
1831 		__sockaddr(addr, salen)
1832 	),
1833 
1834 	TP_fast_assign(
1835 		__entry->error = PTR_ERR(xprt);
1836 		__assign_str(program, program);
1837 		__assign_str(protocol, protocol);
1838 		__assign_sockaddr(addr, sap, salen);
1839 	),
1840 
1841 	TP_printk("addr=%pISpc program=%s protocol=%s error=%ld",
1842 		__get_sockaddr(addr), __get_str(program), __get_str(protocol),
1843 		__entry->error)
1844 );
1845 
1846 #define SVC_XPRT_ENDPOINT_FIELDS(x) \
1847 		__sockaddr(server, (x)->xpt_locallen) \
1848 		__sockaddr(client, (x)->xpt_remotelen) \
1849 		__field(unsigned long, flags) \
1850 		__field(unsigned int, netns_ino)
1851 
1852 #define SVC_XPRT_ENDPOINT_ASSIGNMENTS(x) \
1853 		do { \
1854 			__assign_sockaddr(server, &(x)->xpt_local, \
1855 					  (x)->xpt_locallen); \
1856 			__assign_sockaddr(client, &(x)->xpt_remote, \
1857 					  (x)->xpt_remotelen); \
1858 			__entry->flags = (x)->xpt_flags; \
1859 			__entry->netns_ino = (x)->xpt_net->ns.inum; \
1860 		} while (0)
1861 
1862 #define SVC_XPRT_ENDPOINT_FORMAT \
1863 		"server=%pISpc client=%pISpc flags=%s"
1864 
1865 #define SVC_XPRT_ENDPOINT_VARARGS \
1866 		__get_sockaddr(server), __get_sockaddr(client), \
1867 		show_svc_xprt_flags(__entry->flags)
1868 
1869 TRACE_EVENT(svc_xprt_enqueue,
1870 	TP_PROTO(
1871 		const struct svc_xprt *xprt,
1872 		const struct svc_rqst *rqst
1873 	),
1874 
1875 	TP_ARGS(xprt, rqst),
1876 
1877 	TP_STRUCT__entry(
1878 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1879 
1880 		__field(int, pid)
1881 	),
1882 
1883 	TP_fast_assign(
1884 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1885 
1886 		__entry->pid = rqst? rqst->rq_task->pid : 0;
1887 	),
1888 
1889 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " pid=%d",
1890 		SVC_XPRT_ENDPOINT_VARARGS, __entry->pid)
1891 );
1892 
1893 TRACE_EVENT(svc_xprt_dequeue,
1894 	TP_PROTO(
1895 		const struct svc_rqst *rqst
1896 	),
1897 
1898 	TP_ARGS(rqst),
1899 
1900 	TP_STRUCT__entry(
1901 		SVC_XPRT_ENDPOINT_FIELDS(rqst->rq_xprt)
1902 
1903 		__field(unsigned long, wakeup)
1904 	),
1905 
1906 	TP_fast_assign(
1907 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(rqst->rq_xprt);
1908 
1909 		__entry->wakeup = ktime_to_us(ktime_sub(ktime_get(),
1910 							rqst->rq_qtime));
1911 	),
1912 
1913 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " wakeup-us=%lu",
1914 		SVC_XPRT_ENDPOINT_VARARGS, __entry->wakeup)
1915 );
1916 
1917 DECLARE_EVENT_CLASS(svc_xprt_event,
1918 	TP_PROTO(
1919 		const struct svc_xprt *xprt
1920 	),
1921 
1922 	TP_ARGS(xprt),
1923 
1924 	TP_STRUCT__entry(
1925 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1926 	),
1927 
1928 	TP_fast_assign(
1929 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1930 	),
1931 
1932 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT, SVC_XPRT_ENDPOINT_VARARGS)
1933 );
1934 
1935 #define DEFINE_SVC_XPRT_EVENT(name) \
1936 	DEFINE_EVENT(svc_xprt_event, svc_xprt_##name, \
1937 			TP_PROTO( \
1938 				const struct svc_xprt *xprt \
1939 			), \
1940 			TP_ARGS(xprt))
1941 
1942 DEFINE_SVC_XPRT_EVENT(no_write_space);
1943 DEFINE_SVC_XPRT_EVENT(close);
1944 DEFINE_SVC_XPRT_EVENT(detach);
1945 DEFINE_SVC_XPRT_EVENT(free);
1946 
1947 TRACE_EVENT(svc_xprt_accept,
1948 	TP_PROTO(
1949 		const struct svc_xprt *xprt,
1950 		const char *service
1951 	),
1952 
1953 	TP_ARGS(xprt, service),
1954 
1955 	TP_STRUCT__entry(
1956 		SVC_XPRT_ENDPOINT_FIELDS(xprt)
1957 
1958 		__string(protocol, xprt->xpt_class->xcl_name)
1959 		__string(service, service)
1960 	),
1961 
1962 	TP_fast_assign(
1963 		SVC_XPRT_ENDPOINT_ASSIGNMENTS(xprt);
1964 
1965 		__assign_str(protocol, xprt->xpt_class->xcl_name);
1966 		__assign_str(service, service);
1967 	),
1968 
1969 	TP_printk(SVC_XPRT_ENDPOINT_FORMAT " protocol=%s service=%s",
1970 		SVC_XPRT_ENDPOINT_VARARGS,
1971 		__get_str(protocol), __get_str(service)
1972 	)
1973 );
1974 
1975 TRACE_EVENT(svc_wake_up,
1976 	TP_PROTO(int pid),
1977 
1978 	TP_ARGS(pid),
1979 
1980 	TP_STRUCT__entry(
1981 		__field(int, pid)
1982 	),
1983 
1984 	TP_fast_assign(
1985 		__entry->pid = pid;
1986 	),
1987 
1988 	TP_printk("pid=%d", __entry->pid)
1989 );
1990 
1991 TRACE_EVENT(svc_alloc_arg_err,
1992 	TP_PROTO(
1993 		unsigned int pages
1994 	),
1995 
1996 	TP_ARGS(pages),
1997 
1998 	TP_STRUCT__entry(
1999 		__field(unsigned int, pages)
2000 	),
2001 
2002 	TP_fast_assign(
2003 		__entry->pages = pages;
2004 	),
2005 
2006 	TP_printk("pages=%u", __entry->pages)
2007 );
2008 
2009 DECLARE_EVENT_CLASS(svc_deferred_event,
2010 	TP_PROTO(
2011 		const struct svc_deferred_req *dr
2012 	),
2013 
2014 	TP_ARGS(dr),
2015 
2016 	TP_STRUCT__entry(
2017 		__field(const void *, dr)
2018 		__field(u32, xid)
2019 		__string(addr, dr->xprt->xpt_remotebuf)
2020 	),
2021 
2022 	TP_fast_assign(
2023 		__entry->dr = dr;
2024 		__entry->xid = be32_to_cpu(*(__be32 *)(dr->args +
2025 						       (dr->xprt_hlen>>2)));
2026 		__assign_str(addr, dr->xprt->xpt_remotebuf);
2027 	),
2028 
2029 	TP_printk("addr=%s dr=%p xid=0x%08x", __get_str(addr), __entry->dr,
2030 		__entry->xid)
2031 );
2032 
2033 #define DEFINE_SVC_DEFERRED_EVENT(name) \
2034 	DEFINE_EVENT(svc_deferred_event, svc_defer_##name, \
2035 			TP_PROTO( \
2036 				const struct svc_deferred_req *dr \
2037 			), \
2038 			TP_ARGS(dr))
2039 
2040 DEFINE_SVC_DEFERRED_EVENT(drop);
2041 DEFINE_SVC_DEFERRED_EVENT(queue);
2042 DEFINE_SVC_DEFERRED_EVENT(recv);
2043 
2044 TRACE_EVENT(svcsock_new_socket,
2045 	TP_PROTO(
2046 		const struct socket *socket
2047 	),
2048 
2049 	TP_ARGS(socket),
2050 
2051 	TP_STRUCT__entry(
2052 		__field(unsigned long, type)
2053 		__field(unsigned long, family)
2054 		__field(bool, listener)
2055 	),
2056 
2057 	TP_fast_assign(
2058 		__entry->type = socket->type;
2059 		__entry->family = socket->sk->sk_family;
2060 		__entry->listener = (socket->sk->sk_state == TCP_LISTEN);
2061 	),
2062 
2063 	TP_printk("type=%s family=%s%s",
2064 		show_socket_type(__entry->type),
2065 		rpc_show_address_family(__entry->family),
2066 		__entry->listener ? " (listener)" : ""
2067 	)
2068 );
2069 
2070 TRACE_EVENT(svcsock_marker,
2071 	TP_PROTO(
2072 		const struct svc_xprt *xprt,
2073 		__be32 marker
2074 	),
2075 
2076 	TP_ARGS(xprt, marker),
2077 
2078 	TP_STRUCT__entry(
2079 		__field(unsigned int, length)
2080 		__field(bool, last)
2081 		__string(addr, xprt->xpt_remotebuf)
2082 	),
2083 
2084 	TP_fast_assign(
2085 		__entry->length = be32_to_cpu(marker) & RPC_FRAGMENT_SIZE_MASK;
2086 		__entry->last = be32_to_cpu(marker) & RPC_LAST_STREAM_FRAGMENT;
2087 		__assign_str(addr, xprt->xpt_remotebuf);
2088 	),
2089 
2090 	TP_printk("addr=%s length=%u%s", __get_str(addr),
2091 		__entry->length, __entry->last ? " (last)" : "")
2092 );
2093 
2094 DECLARE_EVENT_CLASS(svcsock_class,
2095 	TP_PROTO(
2096 		const struct svc_xprt *xprt,
2097 		ssize_t result
2098 	),
2099 
2100 	TP_ARGS(xprt, result),
2101 
2102 	TP_STRUCT__entry(
2103 		__field(ssize_t, result)
2104 		__field(unsigned long, flags)
2105 		__string(addr, xprt->xpt_remotebuf)
2106 	),
2107 
2108 	TP_fast_assign(
2109 		__entry->result = result;
2110 		__entry->flags = xprt->xpt_flags;
2111 		__assign_str(addr, xprt->xpt_remotebuf);
2112 	),
2113 
2114 	TP_printk("addr=%s result=%zd flags=%s", __get_str(addr),
2115 		__entry->result, show_svc_xprt_flags(__entry->flags)
2116 	)
2117 );
2118 
2119 #define DEFINE_SVCSOCK_EVENT(name) \
2120 	DEFINE_EVENT(svcsock_class, svcsock_##name, \
2121 			TP_PROTO( \
2122 				const struct svc_xprt *xprt, \
2123 				ssize_t result \
2124 			), \
2125 			TP_ARGS(xprt, result))
2126 
2127 DEFINE_SVCSOCK_EVENT(udp_send);
2128 DEFINE_SVCSOCK_EVENT(udp_recv);
2129 DEFINE_SVCSOCK_EVENT(udp_recv_err);
2130 DEFINE_SVCSOCK_EVENT(tcp_send);
2131 DEFINE_SVCSOCK_EVENT(tcp_recv);
2132 DEFINE_SVCSOCK_EVENT(tcp_recv_eagain);
2133 DEFINE_SVCSOCK_EVENT(tcp_recv_err);
2134 DEFINE_SVCSOCK_EVENT(data_ready);
2135 DEFINE_SVCSOCK_EVENT(write_space);
2136 
2137 TRACE_EVENT(svcsock_tcp_recv_short,
2138 	TP_PROTO(
2139 		const struct svc_xprt *xprt,
2140 		u32 expected,
2141 		u32 received
2142 	),
2143 
2144 	TP_ARGS(xprt, expected, received),
2145 
2146 	TP_STRUCT__entry(
2147 		__field(u32, expected)
2148 		__field(u32, received)
2149 		__field(unsigned long, flags)
2150 		__string(addr, xprt->xpt_remotebuf)
2151 	),
2152 
2153 	TP_fast_assign(
2154 		__entry->expected = expected;
2155 		__entry->received = received;
2156 		__entry->flags = xprt->xpt_flags;
2157 		__assign_str(addr, xprt->xpt_remotebuf);
2158 	),
2159 
2160 	TP_printk("addr=%s flags=%s expected=%u received=%u",
2161 		__get_str(addr), show_svc_xprt_flags(__entry->flags),
2162 		__entry->expected, __entry->received
2163 	)
2164 );
2165 
2166 TRACE_EVENT(svcsock_tcp_state,
2167 	TP_PROTO(
2168 		const struct svc_xprt *xprt,
2169 		const struct socket *socket
2170 	),
2171 
2172 	TP_ARGS(xprt, socket),
2173 
2174 	TP_STRUCT__entry(
2175 		__field(unsigned long, socket_state)
2176 		__field(unsigned long, sock_state)
2177 		__field(unsigned long, flags)
2178 		__string(addr, xprt->xpt_remotebuf)
2179 	),
2180 
2181 	TP_fast_assign(
2182 		__entry->socket_state = socket->state;
2183 		__entry->sock_state = socket->sk->sk_state;
2184 		__entry->flags = xprt->xpt_flags;
2185 		__assign_str(addr, xprt->xpt_remotebuf);
2186 	),
2187 
2188 	TP_printk("addr=%s state=%s sk_state=%s flags=%s", __get_str(addr),
2189 		rpc_show_socket_state(__entry->socket_state),
2190 		rpc_show_sock_state(__entry->sock_state),
2191 		show_svc_xprt_flags(__entry->flags)
2192 	)
2193 );
2194 
2195 DECLARE_EVENT_CLASS(svcsock_accept_class,
2196 	TP_PROTO(
2197 		const struct svc_xprt *xprt,
2198 		const char *service,
2199 		long status
2200 	),
2201 
2202 	TP_ARGS(xprt, service, status),
2203 
2204 	TP_STRUCT__entry(
2205 		__field(long, status)
2206 		__string(service, service)
2207 		__field(unsigned int, netns_ino)
2208 	),
2209 
2210 	TP_fast_assign(
2211 		__entry->status = status;
2212 		__assign_str(service, service);
2213 		__entry->netns_ino = xprt->xpt_net->ns.inum;
2214 	),
2215 
2216 	TP_printk("addr=listener service=%s status=%ld",
2217 		__get_str(service), __entry->status
2218 	)
2219 );
2220 
2221 #define DEFINE_ACCEPT_EVENT(name) \
2222 	DEFINE_EVENT(svcsock_accept_class, svcsock_##name##_err, \
2223 			TP_PROTO( \
2224 				const struct svc_xprt *xprt, \
2225 				const char *service, \
2226 				long status \
2227 			), \
2228 			TP_ARGS(xprt, service, status))
2229 
2230 DEFINE_ACCEPT_EVENT(accept);
2231 DEFINE_ACCEPT_EVENT(getpeername);
2232 
2233 DECLARE_EVENT_CLASS(cache_event,
2234 	TP_PROTO(
2235 		const struct cache_detail *cd,
2236 		const struct cache_head *h
2237 	),
2238 
2239 	TP_ARGS(cd, h),
2240 
2241 	TP_STRUCT__entry(
2242 		__field(const struct cache_head *, h)
2243 		__string(name, cd->name)
2244 	),
2245 
2246 	TP_fast_assign(
2247 		__entry->h = h;
2248 		__assign_str(name, cd->name);
2249 	),
2250 
2251 	TP_printk("cache=%s entry=%p", __get_str(name), __entry->h)
2252 );
2253 #define DEFINE_CACHE_EVENT(name) \
2254 	DEFINE_EVENT(cache_event, name, \
2255 			TP_PROTO( \
2256 				const struct cache_detail *cd, \
2257 				const struct cache_head *h \
2258 			), \
2259 			TP_ARGS(cd, h))
2260 DEFINE_CACHE_EVENT(cache_entry_expired);
2261 DEFINE_CACHE_EVENT(cache_entry_upcall);
2262 DEFINE_CACHE_EVENT(cache_entry_update);
2263 DEFINE_CACHE_EVENT(cache_entry_make_negative);
2264 DEFINE_CACHE_EVENT(cache_entry_no_listener);
2265 
2266 DECLARE_EVENT_CLASS(register_class,
2267 	TP_PROTO(
2268 		const char *program,
2269 		const u32 version,
2270 		const int family,
2271 		const unsigned short protocol,
2272 		const unsigned short port,
2273 		int error
2274 	),
2275 
2276 	TP_ARGS(program, version, family, protocol, port, error),
2277 
2278 	TP_STRUCT__entry(
2279 		__field(u32, version)
2280 		__field(unsigned long, family)
2281 		__field(unsigned short, protocol)
2282 		__field(unsigned short, port)
2283 		__field(int, error)
2284 		__string(program, program)
2285 	),
2286 
2287 	TP_fast_assign(
2288 		__entry->version = version;
2289 		__entry->family = family;
2290 		__entry->protocol = protocol;
2291 		__entry->port = port;
2292 		__entry->error = error;
2293 		__assign_str(program, program);
2294 	),
2295 
2296 	TP_printk("program=%sv%u proto=%s port=%u family=%s error=%d",
2297 		__get_str(program), __entry->version,
2298 		__entry->protocol == IPPROTO_UDP ? "udp" : "tcp",
2299 		__entry->port, rpc_show_address_family(__entry->family),
2300 		__entry->error
2301 	)
2302 );
2303 
2304 #define DEFINE_REGISTER_EVENT(name) \
2305 	DEFINE_EVENT(register_class, svc_##name, \
2306 			TP_PROTO( \
2307 				const char *program, \
2308 				const u32 version, \
2309 				const int family, \
2310 				const unsigned short protocol, \
2311 				const unsigned short port, \
2312 				int error \
2313 			), \
2314 			TP_ARGS(program, version, family, protocol, \
2315 				port, error))
2316 
2317 DEFINE_REGISTER_EVENT(register);
2318 DEFINE_REGISTER_EVENT(noregister);
2319 
2320 TRACE_EVENT(svc_unregister,
2321 	TP_PROTO(
2322 		const char *program,
2323 		const u32 version,
2324 		int error
2325 	),
2326 
2327 	TP_ARGS(program, version, error),
2328 
2329 	TP_STRUCT__entry(
2330 		__field(u32, version)
2331 		__field(int, error)
2332 		__string(program, program)
2333 	),
2334 
2335 	TP_fast_assign(
2336 		__entry->version = version;
2337 		__entry->error = error;
2338 		__assign_str(program, program);
2339 	),
2340 
2341 	TP_printk("program=%sv%u error=%d",
2342 		__get_str(program), __entry->version, __entry->error
2343 	)
2344 );
2345 
2346 #endif /* _TRACE_SUNRPC_H */
2347 
2348 #include <trace/define_trace.h>
2349