cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

sunrpc.h (57507B)


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