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

trace.h (28055B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 *   Copyright (C) 2018, Microsoft Corporation.
      4 *
      5 *   Author(s): Steve French <stfrench@microsoft.com>
      6 */
      7#undef TRACE_SYSTEM
      8#define TRACE_SYSTEM cifs
      9
     10#if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
     11#define _CIFS_TRACE_H
     12
     13#include <linux/tracepoint.h>
     14#include <linux/net.h>
     15#include <linux/inet.h>
     16
     17/*
     18 * Please use this 3-part article as a reference for writing new tracepoints:
     19 * https://lwn.net/Articles/379903/
     20 */
     21
     22/* For logging errors in read or write */
     23DECLARE_EVENT_CLASS(smb3_rw_err_class,
     24	TP_PROTO(unsigned int xid,
     25		__u64	fid,
     26		__u32	tid,
     27		__u64	sesid,
     28		__u64	offset,
     29		__u32	len,
     30		int	rc),
     31	TP_ARGS(xid, fid, tid, sesid, offset, len, rc),
     32	TP_STRUCT__entry(
     33		__field(unsigned int, xid)
     34		__field(__u64, fid)
     35		__field(__u32, tid)
     36		__field(__u64, sesid)
     37		__field(__u64, offset)
     38		__field(__u32, len)
     39		__field(int, rc)
     40	),
     41	TP_fast_assign(
     42		__entry->xid = xid;
     43		__entry->fid = fid;
     44		__entry->tid = tid;
     45		__entry->sesid = sesid;
     46		__entry->offset = offset;
     47		__entry->len = len;
     48		__entry->rc = rc;
     49	),
     50	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
     51		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
     52		__entry->offset, __entry->len, __entry->rc)
     53)
     54
     55#define DEFINE_SMB3_RW_ERR_EVENT(name)          \
     56DEFINE_EVENT(smb3_rw_err_class, smb3_##name,    \
     57	TP_PROTO(unsigned int xid,		\
     58		__u64	fid,			\
     59		__u32	tid,			\
     60		__u64	sesid,			\
     61		__u64	offset,			\
     62		__u32	len,			\
     63		int	rc),			\
     64	TP_ARGS(xid, fid, tid, sesid, offset, len, rc))
     65
     66DEFINE_SMB3_RW_ERR_EVENT(write_err);
     67DEFINE_SMB3_RW_ERR_EVENT(read_err);
     68DEFINE_SMB3_RW_ERR_EVENT(query_dir_err);
     69DEFINE_SMB3_RW_ERR_EVENT(zero_err);
     70DEFINE_SMB3_RW_ERR_EVENT(falloc_err);
     71
     72
     73/* For logging successful read or write */
     74DECLARE_EVENT_CLASS(smb3_rw_done_class,
     75	TP_PROTO(unsigned int xid,
     76		__u64	fid,
     77		__u32	tid,
     78		__u64	sesid,
     79		__u64	offset,
     80		__u32	len),
     81	TP_ARGS(xid, fid, tid, sesid, offset, len),
     82	TP_STRUCT__entry(
     83		__field(unsigned int, xid)
     84		__field(__u64, fid)
     85		__field(__u32, tid)
     86		__field(__u64, sesid)
     87		__field(__u64, offset)
     88		__field(__u32, len)
     89	),
     90	TP_fast_assign(
     91		__entry->xid = xid;
     92		__entry->fid = fid;
     93		__entry->tid = tid;
     94		__entry->sesid = sesid;
     95		__entry->offset = offset;
     96		__entry->len = len;
     97	),
     98	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
     99		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    100		__entry->offset, __entry->len)
    101)
    102
    103#define DEFINE_SMB3_RW_DONE_EVENT(name)         \
    104DEFINE_EVENT(smb3_rw_done_class, smb3_##name,   \
    105	TP_PROTO(unsigned int xid,		\
    106		__u64	fid,			\
    107		__u32	tid,			\
    108		__u64	sesid,			\
    109		__u64	offset,			\
    110		__u32	len),			\
    111	TP_ARGS(xid, fid, tid, sesid, offset, len))
    112
    113DEFINE_SMB3_RW_DONE_EVENT(write_enter);
    114DEFINE_SMB3_RW_DONE_EVENT(read_enter);
    115DEFINE_SMB3_RW_DONE_EVENT(query_dir_enter);
    116DEFINE_SMB3_RW_DONE_EVENT(zero_enter);
    117DEFINE_SMB3_RW_DONE_EVENT(falloc_enter);
    118DEFINE_SMB3_RW_DONE_EVENT(write_done);
    119DEFINE_SMB3_RW_DONE_EVENT(read_done);
    120DEFINE_SMB3_RW_DONE_EVENT(query_dir_done);
    121DEFINE_SMB3_RW_DONE_EVENT(zero_done);
    122DEFINE_SMB3_RW_DONE_EVENT(falloc_done);
    123
    124/* For logging successful set EOF (truncate) */
    125DECLARE_EVENT_CLASS(smb3_eof_class,
    126	TP_PROTO(unsigned int xid,
    127		__u64	fid,
    128		__u32	tid,
    129		__u64	sesid,
    130		__u64	offset),
    131	TP_ARGS(xid, fid, tid, sesid, offset),
    132	TP_STRUCT__entry(
    133		__field(unsigned int, xid)
    134		__field(__u64, fid)
    135		__field(__u32, tid)
    136		__field(__u64, sesid)
    137		__field(__u64, offset)
    138	),
    139	TP_fast_assign(
    140		__entry->xid = xid;
    141		__entry->fid = fid;
    142		__entry->tid = tid;
    143		__entry->sesid = sesid;
    144		__entry->offset = offset;
    145	),
    146	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx",
    147		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    148		__entry->offset)
    149)
    150
    151#define DEFINE_SMB3_EOF_EVENT(name)         \
    152DEFINE_EVENT(smb3_eof_class, smb3_##name,   \
    153	TP_PROTO(unsigned int xid,		\
    154		__u64	fid,			\
    155		__u32	tid,			\
    156		__u64	sesid,			\
    157		__u64	offset),		\
    158	TP_ARGS(xid, fid, tid, sesid, offset))
    159
    160DEFINE_SMB3_EOF_EVENT(set_eof);
    161
    162/*
    163 * For handle based calls other than read and write, and get/set info
    164 */
    165DECLARE_EVENT_CLASS(smb3_fd_class,
    166	TP_PROTO(unsigned int xid,
    167		__u64	fid,
    168		__u32	tid,
    169		__u64	sesid),
    170	TP_ARGS(xid, fid, tid, sesid),
    171	TP_STRUCT__entry(
    172		__field(unsigned int, xid)
    173		__field(__u64, fid)
    174		__field(__u32, tid)
    175		__field(__u64, sesid)
    176	),
    177	TP_fast_assign(
    178		__entry->xid = xid;
    179		__entry->fid = fid;
    180		__entry->tid = tid;
    181		__entry->sesid = sesid;
    182	),
    183	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx",
    184		__entry->xid, __entry->sesid, __entry->tid, __entry->fid)
    185)
    186
    187#define DEFINE_SMB3_FD_EVENT(name)          \
    188DEFINE_EVENT(smb3_fd_class, smb3_##name,    \
    189	TP_PROTO(unsigned int xid,		\
    190		__u64	fid,			\
    191		__u32	tid,			\
    192		__u64	sesid),			\
    193	TP_ARGS(xid, fid, tid, sesid))
    194
    195DEFINE_SMB3_FD_EVENT(flush_enter);
    196DEFINE_SMB3_FD_EVENT(flush_done);
    197DEFINE_SMB3_FD_EVENT(close_enter);
    198DEFINE_SMB3_FD_EVENT(close_done);
    199DEFINE_SMB3_FD_EVENT(oplock_not_found);
    200
    201DECLARE_EVENT_CLASS(smb3_fd_err_class,
    202	TP_PROTO(unsigned int xid,
    203		__u64	fid,
    204		__u32	tid,
    205		__u64	sesid,
    206		int	rc),
    207	TP_ARGS(xid, fid, tid, sesid, rc),
    208	TP_STRUCT__entry(
    209		__field(unsigned int, xid)
    210		__field(__u64, fid)
    211		__field(__u32, tid)
    212		__field(__u64, sesid)
    213		__field(int, rc)
    214	),
    215	TP_fast_assign(
    216		__entry->xid = xid;
    217		__entry->fid = fid;
    218		__entry->tid = tid;
    219		__entry->sesid = sesid;
    220		__entry->rc = rc;
    221	),
    222	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx rc=%d",
    223		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    224		__entry->rc)
    225)
    226
    227#define DEFINE_SMB3_FD_ERR_EVENT(name)          \
    228DEFINE_EVENT(smb3_fd_err_class, smb3_##name,    \
    229	TP_PROTO(unsigned int xid,		\
    230		__u64	fid,			\
    231		__u32	tid,			\
    232		__u64	sesid,			\
    233		int	rc),			\
    234	TP_ARGS(xid, fid, tid, sesid, rc))
    235
    236DEFINE_SMB3_FD_ERR_EVENT(flush_err);
    237DEFINE_SMB3_FD_ERR_EVENT(lock_err);
    238DEFINE_SMB3_FD_ERR_EVENT(close_err);
    239
    240/*
    241 * For handle based query/set info calls
    242 */
    243DECLARE_EVENT_CLASS(smb3_inf_enter_class,
    244	TP_PROTO(unsigned int xid,
    245		__u64	fid,
    246		__u32	tid,
    247		__u64	sesid,
    248		__u8	infclass,
    249		__u32	type),
    250	TP_ARGS(xid, fid, tid, sesid, infclass, type),
    251	TP_STRUCT__entry(
    252		__field(unsigned int, xid)
    253		__field(__u64, fid)
    254		__field(__u32, tid)
    255		__field(__u64, sesid)
    256		__field(__u8, infclass)
    257		__field(__u32, type)
    258	),
    259	TP_fast_assign(
    260		__entry->xid = xid;
    261		__entry->fid = fid;
    262		__entry->tid = tid;
    263		__entry->sesid = sesid;
    264		__entry->infclass = infclass;
    265		__entry->type = type;
    266	),
    267	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x",
    268		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    269		__entry->infclass, __entry->type)
    270)
    271
    272#define DEFINE_SMB3_INF_ENTER_EVENT(name)          \
    273DEFINE_EVENT(smb3_inf_enter_class, smb3_##name,    \
    274	TP_PROTO(unsigned int xid,		\
    275		__u64	fid,			\
    276		__u32	tid,			\
    277		__u64	sesid,			\
    278		__u8	infclass,		\
    279		__u32	type),			\
    280	TP_ARGS(xid, fid, tid, sesid, infclass, type))
    281
    282DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
    283DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
    284DEFINE_SMB3_INF_ENTER_EVENT(notify_enter);
    285DEFINE_SMB3_INF_ENTER_EVENT(notify_done);
    286
    287DECLARE_EVENT_CLASS(smb3_inf_err_class,
    288	TP_PROTO(unsigned int xid,
    289		__u64	fid,
    290		__u32	tid,
    291		__u64	sesid,
    292		__u8	infclass,
    293		__u32	type,
    294		int	rc),
    295	TP_ARGS(xid, fid, tid, sesid, infclass, type, rc),
    296	TP_STRUCT__entry(
    297		__field(unsigned int, xid)
    298		__field(__u64, fid)
    299		__field(__u32, tid)
    300		__field(__u64, sesid)
    301		__field(__u8, infclass)
    302		__field(__u32, type)
    303		__field(int, rc)
    304	),
    305	TP_fast_assign(
    306		__entry->xid = xid;
    307		__entry->fid = fid;
    308		__entry->tid = tid;
    309		__entry->sesid = sesid;
    310		__entry->infclass = infclass;
    311		__entry->type = type;
    312		__entry->rc = rc;
    313	),
    314	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x rc=%d",
    315		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    316		__entry->infclass, __entry->type, __entry->rc)
    317)
    318
    319#define DEFINE_SMB3_INF_ERR_EVENT(name)          \
    320DEFINE_EVENT(smb3_inf_err_class, smb3_##name,    \
    321	TP_PROTO(unsigned int xid,		\
    322		__u64	fid,			\
    323		__u32	tid,			\
    324		__u64	sesid,			\
    325		__u8	infclass,		\
    326		__u32	type,			\
    327		int	rc),			\
    328	TP_ARGS(xid, fid, tid, sesid, infclass, type, rc))
    329
    330DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
    331DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
    332DEFINE_SMB3_INF_ERR_EVENT(notify_err);
    333DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
    334
    335DECLARE_EVENT_CLASS(smb3_inf_compound_enter_class,
    336	TP_PROTO(unsigned int xid,
    337		__u32	tid,
    338		__u64	sesid,
    339		const char *full_path),
    340	TP_ARGS(xid, tid, sesid, full_path),
    341	TP_STRUCT__entry(
    342		__field(unsigned int, xid)
    343		__field(__u32, tid)
    344		__field(__u64, sesid)
    345		__string(path, full_path)
    346	),
    347	TP_fast_assign(
    348		__entry->xid = xid;
    349		__entry->tid = tid;
    350		__entry->sesid = sesid;
    351		__assign_str(path, full_path);
    352	),
    353	TP_printk("xid=%u sid=0x%llx tid=0x%x path=%s",
    354		__entry->xid, __entry->sesid, __entry->tid,
    355		__get_str(path))
    356)
    357
    358#define DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(name)     \
    359DEFINE_EVENT(smb3_inf_compound_enter_class, smb3_##name,    \
    360	TP_PROTO(unsigned int xid,		\
    361		__u32	tid,			\
    362		__u64	sesid,			\
    363		const char *full_path),		\
    364	TP_ARGS(xid, tid, sesid, full_path))
    365
    366DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter);
    367DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(posix_query_info_compound_enter);
    368DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter);
    369DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter);
    370DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter);
    371DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
    372DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
    373DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
    374DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
    375
    376
    377DECLARE_EVENT_CLASS(smb3_inf_compound_done_class,
    378	TP_PROTO(unsigned int xid,
    379		__u32	tid,
    380		__u64	sesid),
    381	TP_ARGS(xid, tid, sesid),
    382	TP_STRUCT__entry(
    383		__field(unsigned int, xid)
    384		__field(__u32, tid)
    385		__field(__u64, sesid)
    386	),
    387	TP_fast_assign(
    388		__entry->xid = xid;
    389		__entry->tid = tid;
    390		__entry->sesid = sesid;
    391	),
    392	TP_printk("xid=%u sid=0x%llx tid=0x%x",
    393		__entry->xid, __entry->sesid, __entry->tid)
    394)
    395
    396#define DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(name)     \
    397DEFINE_EVENT(smb3_inf_compound_done_class, smb3_##name,    \
    398	TP_PROTO(unsigned int xid,		\
    399		__u32	tid,			\
    400		__u64	sesid),			\
    401	TP_ARGS(xid, tid, sesid))
    402
    403DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_info_compound_done);
    404DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(posix_query_info_compound_done);
    405DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done);
    406DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done);
    407DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done);
    408DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
    409DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
    410DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
    411DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
    412
    413
    414DECLARE_EVENT_CLASS(smb3_inf_compound_err_class,
    415	TP_PROTO(unsigned int xid,
    416		__u32	tid,
    417		__u64	sesid,
    418		int	rc),
    419	TP_ARGS(xid, tid, sesid, rc),
    420	TP_STRUCT__entry(
    421		__field(unsigned int, xid)
    422		__field(__u32, tid)
    423		__field(__u64, sesid)
    424		__field(int, rc)
    425	),
    426	TP_fast_assign(
    427		__entry->xid = xid;
    428		__entry->tid = tid;
    429		__entry->sesid = sesid;
    430		__entry->rc = rc;
    431	),
    432	TP_printk("xid=%u sid=0x%llx tid=0x%x rc=%d",
    433		__entry->xid, __entry->sesid, __entry->tid,
    434		__entry->rc)
    435)
    436
    437#define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name)     \
    438DEFINE_EVENT(smb3_inf_compound_err_class, smb3_##name,    \
    439	TP_PROTO(unsigned int xid,		\
    440		__u32	tid,			\
    441		__u64	sesid,			\
    442		int rc),			\
    443	TP_ARGS(xid, tid, sesid, rc))
    444
    445DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err);
    446DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(posix_query_info_compound_err);
    447DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err);
    448DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err);
    449DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err);
    450DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
    451DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
    452DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
    453DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
    454
    455/*
    456 * For logging SMB3 Status code and Command for responses which return errors
    457 */
    458DECLARE_EVENT_CLASS(smb3_cmd_err_class,
    459	TP_PROTO(__u32	tid,
    460		__u64	sesid,
    461		__u16	cmd,
    462		__u64	mid,
    463		__u32	status,
    464		int	rc),
    465	TP_ARGS(tid, sesid, cmd, mid, status, rc),
    466	TP_STRUCT__entry(
    467		__field(__u32, tid)
    468		__field(__u64, sesid)
    469		__field(__u16, cmd)
    470		__field(__u64, mid)
    471		__field(__u32, status)
    472		__field(int, rc)
    473	),
    474	TP_fast_assign(
    475		__entry->tid = tid;
    476		__entry->sesid = sesid;
    477		__entry->cmd = cmd;
    478		__entry->mid = mid;
    479		__entry->status = status;
    480		__entry->rc = rc;
    481	),
    482	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
    483		__entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
    484		__entry->status, __entry->rc)
    485)
    486
    487#define DEFINE_SMB3_CMD_ERR_EVENT(name)          \
    488DEFINE_EVENT(smb3_cmd_err_class, smb3_##name,    \
    489	TP_PROTO(__u32	tid,			\
    490		__u64	sesid,			\
    491		__u16	cmd,			\
    492		__u64	mid,			\
    493		__u32	status,			\
    494		int	rc),			\
    495	TP_ARGS(tid, sesid, cmd, mid, status, rc))
    496
    497DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
    498
    499DECLARE_EVENT_CLASS(smb3_cmd_done_class,
    500	TP_PROTO(__u32	tid,
    501		__u64	sesid,
    502		__u16	cmd,
    503		__u64	mid),
    504	TP_ARGS(tid, sesid, cmd, mid),
    505	TP_STRUCT__entry(
    506		__field(__u32, tid)
    507		__field(__u64, sesid)
    508		__field(__u16, cmd)
    509		__field(__u64, mid)
    510	),
    511	TP_fast_assign(
    512		__entry->tid = tid;
    513		__entry->sesid = sesid;
    514		__entry->cmd = cmd;
    515		__entry->mid = mid;
    516	),
    517	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
    518		__entry->sesid, __entry->tid,
    519		__entry->cmd, __entry->mid)
    520)
    521
    522#define DEFINE_SMB3_CMD_DONE_EVENT(name)          \
    523DEFINE_EVENT(smb3_cmd_done_class, smb3_##name,    \
    524	TP_PROTO(__u32	tid,			\
    525		__u64	sesid,			\
    526		__u16	cmd,			\
    527		__u64	mid),			\
    528	TP_ARGS(tid, sesid, cmd, mid))
    529
    530DEFINE_SMB3_CMD_DONE_EVENT(cmd_enter);
    531DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
    532DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
    533
    534DECLARE_EVENT_CLASS(smb3_mid_class,
    535	TP_PROTO(__u16	cmd,
    536		__u64	mid,
    537		__u32	pid,
    538		unsigned long when_sent,
    539		unsigned long when_received),
    540	TP_ARGS(cmd, mid, pid, when_sent, when_received),
    541	TP_STRUCT__entry(
    542		__field(__u16, cmd)
    543		__field(__u64, mid)
    544		__field(__u32, pid)
    545		__field(unsigned long, when_sent)
    546		__field(unsigned long, when_received)
    547	),
    548	TP_fast_assign(
    549		__entry->cmd = cmd;
    550		__entry->mid = mid;
    551		__entry->pid = pid;
    552		__entry->when_sent = when_sent;
    553		__entry->when_received = when_received;
    554	),
    555	TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
    556		__entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
    557		__entry->when_received)
    558)
    559
    560#define DEFINE_SMB3_MID_EVENT(name)          \
    561DEFINE_EVENT(smb3_mid_class, smb3_##name,    \
    562	TP_PROTO(__u16	cmd,			\
    563		__u64	mid,			\
    564		__u32	pid,			\
    565		unsigned long when_sent,	\
    566		unsigned long when_received),	\
    567	TP_ARGS(cmd, mid, pid, when_sent, when_received))
    568
    569DEFINE_SMB3_MID_EVENT(slow_rsp);
    570
    571DECLARE_EVENT_CLASS(smb3_exit_err_class,
    572	TP_PROTO(unsigned int xid,
    573		const char *func_name,
    574		int	rc),
    575	TP_ARGS(xid, func_name, rc),
    576	TP_STRUCT__entry(
    577		__field(unsigned int, xid)
    578		__string(func_name, func_name)
    579		__field(int, rc)
    580	),
    581	TP_fast_assign(
    582		__entry->xid = xid;
    583		__assign_str(func_name, func_name);
    584		__entry->rc = rc;
    585	),
    586	TP_printk("\t%s: xid=%u rc=%d",
    587		__get_str(func_name), __entry->xid, __entry->rc)
    588)
    589
    590#define DEFINE_SMB3_EXIT_ERR_EVENT(name)          \
    591DEFINE_EVENT(smb3_exit_err_class, smb3_##name,    \
    592	TP_PROTO(unsigned int xid,		\
    593		const char *func_name,		\
    594		int	rc),			\
    595	TP_ARGS(xid, func_name, rc))
    596
    597DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
    598
    599
    600DECLARE_EVENT_CLASS(smb3_sync_err_class,
    601	TP_PROTO(unsigned long ino,
    602		int	rc),
    603	TP_ARGS(ino, rc),
    604	TP_STRUCT__entry(
    605		__field(unsigned long, ino)
    606		__field(int, rc)
    607	),
    608	TP_fast_assign(
    609		__entry->ino = ino;
    610		__entry->rc = rc;
    611	),
    612	TP_printk("\tino=%lu rc=%d",
    613		__entry->ino, __entry->rc)
    614)
    615
    616#define DEFINE_SMB3_SYNC_ERR_EVENT(name)          \
    617DEFINE_EVENT(smb3_sync_err_class, cifs_##name,    \
    618	TP_PROTO(unsigned long ino,		\
    619		int	rc),			\
    620	TP_ARGS(ino, rc))
    621
    622DEFINE_SMB3_SYNC_ERR_EVENT(fsync_err);
    623DEFINE_SMB3_SYNC_ERR_EVENT(flush_err);
    624
    625
    626DECLARE_EVENT_CLASS(smb3_enter_exit_class,
    627	TP_PROTO(unsigned int xid,
    628		const char *func_name),
    629	TP_ARGS(xid, func_name),
    630	TP_STRUCT__entry(
    631		__field(unsigned int, xid)
    632		__string(func_name, func_name)
    633	),
    634	TP_fast_assign(
    635		__entry->xid = xid;
    636		__assign_str(func_name, func_name);
    637	),
    638	TP_printk("\t%s: xid=%u",
    639		__get_str(func_name), __entry->xid)
    640)
    641
    642#define DEFINE_SMB3_ENTER_EXIT_EVENT(name)        \
    643DEFINE_EVENT(smb3_enter_exit_class, smb3_##name,  \
    644	TP_PROTO(unsigned int xid,		\
    645		const char *func_name),		\
    646	TP_ARGS(xid, func_name))
    647
    648DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
    649DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
    650
    651/*
    652 * For SMB2/SMB3 tree connect
    653 */
    654
    655DECLARE_EVENT_CLASS(smb3_tcon_class,
    656	TP_PROTO(unsigned int xid,
    657		__u32	tid,
    658		__u64	sesid,
    659		const char *unc_name,
    660		int	rc),
    661	TP_ARGS(xid, tid, sesid, unc_name, rc),
    662	TP_STRUCT__entry(
    663		__field(unsigned int, xid)
    664		__field(__u32, tid)
    665		__field(__u64, sesid)
    666		__string(name, unc_name)
    667		__field(int, rc)
    668	),
    669	TP_fast_assign(
    670		__entry->xid = xid;
    671		__entry->tid = tid;
    672		__entry->sesid = sesid;
    673		__assign_str(name, unc_name);
    674		__entry->rc = rc;
    675	),
    676	TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d",
    677		__entry->xid, __entry->sesid, __entry->tid,
    678		__get_str(name), __entry->rc)
    679)
    680
    681#define DEFINE_SMB3_TCON_EVENT(name)          \
    682DEFINE_EVENT(smb3_tcon_class, smb3_##name,    \
    683	TP_PROTO(unsigned int xid,		\
    684		__u32	tid,			\
    685		__u64	sesid,			\
    686		const char *unc_name,		\
    687		int	rc),			\
    688	TP_ARGS(xid, tid, sesid, unc_name, rc))
    689
    690DEFINE_SMB3_TCON_EVENT(tcon);
    691
    692
    693/*
    694 * For smb2/smb3 open (including create and mkdir) calls
    695 */
    696
    697DECLARE_EVENT_CLASS(smb3_open_enter_class,
    698	TP_PROTO(unsigned int xid,
    699		__u32	tid,
    700		__u64	sesid,
    701		int	create_options,
    702		int	desired_access),
    703	TP_ARGS(xid, tid, sesid, create_options, desired_access),
    704	TP_STRUCT__entry(
    705		__field(unsigned int, xid)
    706		__field(__u32, tid)
    707		__field(__u64, sesid)
    708		__field(int, create_options)
    709		__field(int, desired_access)
    710	),
    711	TP_fast_assign(
    712		__entry->xid = xid;
    713		__entry->tid = tid;
    714		__entry->sesid = sesid;
    715		__entry->create_options = create_options;
    716		__entry->desired_access = desired_access;
    717	),
    718	TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x",
    719		__entry->xid, __entry->sesid, __entry->tid,
    720		__entry->create_options, __entry->desired_access)
    721)
    722
    723#define DEFINE_SMB3_OPEN_ENTER_EVENT(name)        \
    724DEFINE_EVENT(smb3_open_enter_class, smb3_##name,  \
    725	TP_PROTO(unsigned int xid,		\
    726		__u32	tid,			\
    727		__u64	sesid,			\
    728		int	create_options,		\
    729		int	desired_access),	\
    730	TP_ARGS(xid, tid, sesid, create_options, desired_access))
    731
    732DEFINE_SMB3_OPEN_ENTER_EVENT(open_enter);
    733DEFINE_SMB3_OPEN_ENTER_EVENT(posix_mkdir_enter);
    734
    735DECLARE_EVENT_CLASS(smb3_open_err_class,
    736	TP_PROTO(unsigned int xid,
    737		__u32	tid,
    738		__u64	sesid,
    739		int	create_options,
    740		int	desired_access,
    741		int	rc),
    742	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
    743	TP_STRUCT__entry(
    744		__field(unsigned int, xid)
    745		__field(__u32, tid)
    746		__field(__u64, sesid)
    747		__field(int,   create_options)
    748		__field(int, desired_access)
    749		__field(int, rc)
    750	),
    751	TP_fast_assign(
    752		__entry->xid = xid;
    753		__entry->tid = tid;
    754		__entry->sesid = sesid;
    755		__entry->create_options = create_options;
    756		__entry->desired_access = desired_access;
    757		__entry->rc = rc;
    758	),
    759	TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
    760		__entry->xid, __entry->sesid, __entry->tid,
    761		__entry->create_options, __entry->desired_access, __entry->rc)
    762)
    763
    764#define DEFINE_SMB3_OPEN_ERR_EVENT(name)          \
    765DEFINE_EVENT(smb3_open_err_class, smb3_##name,    \
    766	TP_PROTO(unsigned int xid,		\
    767		__u32	tid,			\
    768		__u64	sesid,			\
    769		int	create_options,		\
    770		int	desired_access,		\
    771		int	rc),			\
    772	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
    773
    774DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
    775DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
    776
    777DECLARE_EVENT_CLASS(smb3_open_done_class,
    778	TP_PROTO(unsigned int xid,
    779		__u64	fid,
    780		__u32	tid,
    781		__u64	sesid,
    782		int	create_options,
    783		int	desired_access),
    784	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
    785	TP_STRUCT__entry(
    786		__field(unsigned int, xid)
    787		__field(__u64, fid)
    788		__field(__u32, tid)
    789		__field(__u64, sesid)
    790		__field(int, create_options)
    791		__field(int, desired_access)
    792	),
    793	TP_fast_assign(
    794		__entry->xid = xid;
    795		__entry->fid = fid;
    796		__entry->tid = tid;
    797		__entry->sesid = sesid;
    798		__entry->create_options = create_options;
    799		__entry->desired_access = desired_access;
    800	),
    801	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
    802		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
    803		__entry->create_options, __entry->desired_access)
    804)
    805
    806#define DEFINE_SMB3_OPEN_DONE_EVENT(name)        \
    807DEFINE_EVENT(smb3_open_done_class, smb3_##name,  \
    808	TP_PROTO(unsigned int xid,		\
    809		__u64	fid,			\
    810		__u32	tid,			\
    811		__u64	sesid,			\
    812		int	create_options,		\
    813		int	desired_access),	\
    814	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
    815
    816DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
    817DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
    818
    819
    820DECLARE_EVENT_CLASS(smb3_lease_done_class,
    821	TP_PROTO(__u32	lease_state,
    822		__u32	tid,
    823		__u64	sesid,
    824		__u64	lease_key_low,
    825		__u64	lease_key_high),
    826	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high),
    827	TP_STRUCT__entry(
    828		__field(__u32, lease_state)
    829		__field(__u32, tid)
    830		__field(__u64, sesid)
    831		__field(__u64, lease_key_low)
    832		__field(__u64, lease_key_high)
    833	),
    834	TP_fast_assign(
    835		__entry->lease_state = lease_state;
    836		__entry->tid = tid;
    837		__entry->sesid = sesid;
    838		__entry->lease_key_low = lease_key_low;
    839		__entry->lease_key_high = lease_key_high;
    840	),
    841	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x",
    842		__entry->sesid, __entry->tid, __entry->lease_key_high,
    843		__entry->lease_key_low, __entry->lease_state)
    844)
    845
    846#define DEFINE_SMB3_LEASE_DONE_EVENT(name)        \
    847DEFINE_EVENT(smb3_lease_done_class, smb3_##name,  \
    848	TP_PROTO(__u32	lease_state,		\
    849		__u32	tid,			\
    850		__u64	sesid,			\
    851		__u64	lease_key_low,		\
    852		__u64	lease_key_high),	\
    853	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high))
    854
    855DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
    856DEFINE_SMB3_LEASE_DONE_EVENT(lease_not_found);
    857
    858DECLARE_EVENT_CLASS(smb3_lease_err_class,
    859	TP_PROTO(__u32	lease_state,
    860		__u32	tid,
    861		__u64	sesid,
    862		__u64	lease_key_low,
    863		__u64	lease_key_high,
    864		int	rc),
    865	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc),
    866	TP_STRUCT__entry(
    867		__field(__u32, lease_state)
    868		__field(__u32, tid)
    869		__field(__u64, sesid)
    870		__field(__u64, lease_key_low)
    871		__field(__u64, lease_key_high)
    872		__field(int, rc)
    873	),
    874	TP_fast_assign(
    875		__entry->lease_state = lease_state;
    876		__entry->tid = tid;
    877		__entry->sesid = sesid;
    878		__entry->lease_key_low = lease_key_low;
    879		__entry->lease_key_high = lease_key_high;
    880		__entry->rc = rc;
    881	),
    882	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x rc=%d",
    883		__entry->sesid, __entry->tid, __entry->lease_key_high,
    884		__entry->lease_key_low, __entry->lease_state, __entry->rc)
    885)
    886
    887#define DEFINE_SMB3_LEASE_ERR_EVENT(name)        \
    888DEFINE_EVENT(smb3_lease_err_class, smb3_##name,  \
    889	TP_PROTO(__u32	lease_state,		\
    890		__u32	tid,			\
    891		__u64	sesid,			\
    892		__u64	lease_key_low,		\
    893		__u64	lease_key_high,		\
    894		int	rc),			\
    895	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc))
    896
    897DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
    898
    899DECLARE_EVENT_CLASS(smb3_connect_class,
    900	TP_PROTO(char *hostname,
    901		__u64 conn_id,
    902		const struct __kernel_sockaddr_storage *dst_addr),
    903	TP_ARGS(hostname, conn_id, dst_addr),
    904	TP_STRUCT__entry(
    905		__string(hostname, hostname)
    906		__field(__u64, conn_id)
    907		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
    908	),
    909	TP_fast_assign(
    910		struct sockaddr_storage *pss = NULL;
    911
    912		__entry->conn_id = conn_id;
    913		pss = (struct sockaddr_storage *)__entry->dst_addr;
    914		*pss = *dst_addr;
    915		__assign_str(hostname, hostname);
    916	),
    917	TP_printk("conn_id=0x%llx server=%s addr=%pISpsfc",
    918		__entry->conn_id,
    919		__get_str(hostname),
    920		__entry->dst_addr)
    921)
    922
    923#define DEFINE_SMB3_CONNECT_EVENT(name)        \
    924DEFINE_EVENT(smb3_connect_class, smb3_##name,  \
    925	TP_PROTO(char *hostname,		\
    926		__u64 conn_id,			\
    927		const struct __kernel_sockaddr_storage *addr),	\
    928	TP_ARGS(hostname, conn_id, addr))
    929
    930DEFINE_SMB3_CONNECT_EVENT(connect_done);
    931
    932DECLARE_EVENT_CLASS(smb3_connect_err_class,
    933	TP_PROTO(char *hostname, __u64 conn_id,
    934		const struct __kernel_sockaddr_storage *dst_addr, int rc),
    935	TP_ARGS(hostname, conn_id, dst_addr, rc),
    936	TP_STRUCT__entry(
    937		__string(hostname, hostname)
    938		__field(__u64, conn_id)
    939		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
    940		__field(int, rc)
    941	),
    942	TP_fast_assign(
    943		struct sockaddr_storage *pss = NULL;
    944
    945		__entry->conn_id = conn_id;
    946		__entry->rc = rc;
    947		pss = (struct sockaddr_storage *)__entry->dst_addr;
    948		*pss = *dst_addr;
    949		__assign_str(hostname, hostname);
    950	),
    951	TP_printk("rc=%d conn_id=0x%llx server=%s addr=%pISpsfc",
    952		__entry->rc,
    953		__entry->conn_id,
    954		__get_str(hostname),
    955		__entry->dst_addr)
    956)
    957
    958#define DEFINE_SMB3_CONNECT_ERR_EVENT(name)        \
    959DEFINE_EVENT(smb3_connect_err_class, smb3_##name,  \
    960	TP_PROTO(char *hostname,		\
    961		__u64 conn_id,			\
    962		const struct __kernel_sockaddr_storage *addr,	\
    963		int rc),			\
    964	TP_ARGS(hostname, conn_id, addr, rc))
    965
    966DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err);
    967
    968DECLARE_EVENT_CLASS(smb3_reconnect_class,
    969	TP_PROTO(__u64	currmid,
    970		__u64 conn_id,
    971		char *hostname),
    972	TP_ARGS(currmid, conn_id, hostname),
    973	TP_STRUCT__entry(
    974		__field(__u64, currmid)
    975		__field(__u64, conn_id)
    976		__string(hostname, hostname)
    977	),
    978	TP_fast_assign(
    979		__entry->currmid = currmid;
    980		__entry->conn_id = conn_id;
    981		__assign_str(hostname, hostname);
    982	),
    983	TP_printk("conn_id=0x%llx server=%s current_mid=%llu",
    984		__entry->conn_id,
    985		__get_str(hostname),
    986		__entry->currmid)
    987)
    988
    989#define DEFINE_SMB3_RECONNECT_EVENT(name)        \
    990DEFINE_EVENT(smb3_reconnect_class, smb3_##name,  \
    991	TP_PROTO(__u64	currmid,		\
    992		__u64 conn_id,			\
    993		char *hostname),				\
    994	TP_ARGS(currmid, conn_id, hostname))
    995
    996DEFINE_SMB3_RECONNECT_EVENT(reconnect);
    997DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
    998
    999DECLARE_EVENT_CLASS(smb3_credit_class,
   1000	TP_PROTO(__u64	currmid,
   1001		__u64 conn_id,
   1002		char *hostname,
   1003		int credits,
   1004		int credits_to_add,
   1005		int in_flight),
   1006	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight),
   1007	TP_STRUCT__entry(
   1008		__field(__u64, currmid)
   1009		__field(__u64, conn_id)
   1010		__string(hostname, hostname)
   1011		__field(int, credits)
   1012		__field(int, credits_to_add)
   1013		__field(int, in_flight)
   1014	),
   1015	TP_fast_assign(
   1016		__entry->currmid = currmid;
   1017		__entry->conn_id = conn_id;
   1018		__assign_str(hostname, hostname);
   1019		__entry->credits = credits;
   1020		__entry->credits_to_add = credits_to_add;
   1021		__entry->in_flight = in_flight;
   1022	),
   1023	TP_printk("conn_id=0x%llx server=%s current_mid=%llu "
   1024			"credits=%d credit_change=%d in_flight=%d",
   1025		__entry->conn_id,
   1026		__get_str(hostname),
   1027		__entry->currmid,
   1028		__entry->credits,
   1029		__entry->credits_to_add,
   1030		__entry->in_flight)
   1031)
   1032
   1033#define DEFINE_SMB3_CREDIT_EVENT(name)        \
   1034DEFINE_EVENT(smb3_credit_class, smb3_##name,  \
   1035	TP_PROTO(__u64	currmid,		\
   1036		__u64 conn_id,			\
   1037		char *hostname,			\
   1038		int  credits,			\
   1039		int  credits_to_add,	\
   1040		int in_flight),			\
   1041	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight))
   1042
   1043DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
   1044DEFINE_SMB3_CREDIT_EVENT(reconnect_detected);
   1045DEFINE_SMB3_CREDIT_EVENT(credit_timeout);
   1046DEFINE_SMB3_CREDIT_EVENT(insufficient_credits);
   1047DEFINE_SMB3_CREDIT_EVENT(too_many_credits);
   1048DEFINE_SMB3_CREDIT_EVENT(add_credits);
   1049DEFINE_SMB3_CREDIT_EVENT(adj_credits);
   1050DEFINE_SMB3_CREDIT_EVENT(hdr_credits);
   1051DEFINE_SMB3_CREDIT_EVENT(nblk_credits);
   1052DEFINE_SMB3_CREDIT_EVENT(pend_credits);
   1053DEFINE_SMB3_CREDIT_EVENT(wait_credits);
   1054DEFINE_SMB3_CREDIT_EVENT(waitff_credits);
   1055DEFINE_SMB3_CREDIT_EVENT(overflow_credits);
   1056DEFINE_SMB3_CREDIT_EVENT(set_credits);
   1057
   1058#endif /* _CIFS_TRACE_H */
   1059
   1060#undef TRACE_INCLUDE_PATH
   1061#define TRACE_INCLUDE_PATH .
   1062#define TRACE_INCLUDE_FILE trace
   1063#include <trace/define_trace.h>