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