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