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  * Please use this 3-part article as a reference for writing new tracepoints:
8  * https://lwn.net/Articles/379903/
9  */
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM cifs
12 
13 #if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define _CIFS_TRACE_H
15 
16 #include <linux/tracepoint.h>
17 #include <linux/net.h>
18 #include <linux/inet.h>
19 
20 /*
21  * Specify enums for tracing information.
22  */
23 #define smb3_rw_credits_traces \
24 	EM(cifs_trace_rw_credits_call_readv_adjust,	"rd-call-adj") \
25 	EM(cifs_trace_rw_credits_call_writev_adjust,	"wr-call-adj") \
26 	EM(cifs_trace_rw_credits_free_subreq,		"free-subreq") \
27 	EM(cifs_trace_rw_credits_issue_read_adjust,	"rd-issu-adj") \
28 	EM(cifs_trace_rw_credits_issue_write_adjust,	"wr-issu-adj") \
29 	EM(cifs_trace_rw_credits_no_adjust_up,		"no-adj-up  ") \
30 	EM(cifs_trace_rw_credits_old_session,		"old-session") \
31 	EM(cifs_trace_rw_credits_read_response_add,	"rd-resp-add") \
32 	EM(cifs_trace_rw_credits_read_response_clear,	"rd-resp-clr") \
33 	EM(cifs_trace_rw_credits_read_resubmit,		"rd-resubmit") \
34 	EM(cifs_trace_rw_credits_read_submit,		"rd-submit  ") \
35 	EM(cifs_trace_rw_credits_write_prepare,		"wr-prepare ") \
36 	EM(cifs_trace_rw_credits_write_response_add,	"wr-resp-add") \
37 	EM(cifs_trace_rw_credits_write_response_clear,	"wr-resp-clr") \
38 	E_(cifs_trace_rw_credits_zero_in_flight,	"ZERO-IN-FLT")
39 
40 #define smb3_tcon_ref_traces					      \
41 	EM(netfs_trace_tcon_ref_dec_dfs_refer,		"DEC DfsRef") \
42 	EM(netfs_trace_tcon_ref_free,			"FRE       ") \
43 	EM(netfs_trace_tcon_ref_free_fail,		"FRE Fail  ") \
44 	EM(netfs_trace_tcon_ref_free_ipc,		"FRE Ipc   ") \
45 	EM(netfs_trace_tcon_ref_free_ipc_fail,		"FRE Ipc-F ") \
46 	EM(netfs_trace_tcon_ref_free_reconnect_server,	"FRE Reconn") \
47 	EM(netfs_trace_tcon_ref_get_cancelled_close,	"GET Cn-Cls") \
48 	EM(netfs_trace_tcon_ref_get_dfs_refer,		"GET DfsRef") \
49 	EM(netfs_trace_tcon_ref_get_find,		"GET Find  ") \
50 	EM(netfs_trace_tcon_ref_get_find_sess_tcon,	"GET FndSes") \
51 	EM(netfs_trace_tcon_ref_get_reconnect_server,	"GET Reconn") \
52 	EM(netfs_trace_tcon_ref_new,			"NEW       ") \
53 	EM(netfs_trace_tcon_ref_new_ipc,		"NEW Ipc   ") \
54 	EM(netfs_trace_tcon_ref_new_reconnect_server,	"NEW Reconn") \
55 	EM(netfs_trace_tcon_ref_put_cancelled_close,	"PUT Cn-Cls") \
56 	EM(netfs_trace_tcon_ref_put_cancelled_close_fid, "PUT Cn-Fid") \
57 	EM(netfs_trace_tcon_ref_put_cancelled_mid,	"PUT Cn-Mid") \
58 	EM(netfs_trace_tcon_ref_put_mnt_ctx,		"PUT MntCtx") \
59 	EM(netfs_trace_tcon_ref_put_reconnect_server,	"PUT Reconn") \
60 	EM(netfs_trace_tcon_ref_put_tlink,		"PUT Tlink ") \
61 	EM(netfs_trace_tcon_ref_see_cancelled_close,	"SEE Cn-Cls") \
62 	EM(netfs_trace_tcon_ref_see_fscache_collision,	"SEE FV-CO!") \
63 	EM(netfs_trace_tcon_ref_see_fscache_okay,	"SEE FV-Ok ") \
64 	EM(netfs_trace_tcon_ref_see_fscache_relinq,	"SEE FV-Rlq") \
65 	E_(netfs_trace_tcon_ref_see_umount,		"SEE Umount")
66 
67 #undef EM
68 #undef E_
69 
70 /*
71  * Define those tracing enums.
72  */
73 #ifndef __SMB3_DECLARE_TRACE_ENUMS_ONCE_ONLY
74 #define __SMB3_DECLARE_TRACE_ENUMS_ONCE_ONLY
75 
76 #define EM(a, b) a,
77 #define E_(a, b) a
78 
79 enum smb3_rw_credits_trace	{ smb3_rw_credits_traces } __mode(byte);
80 enum smb3_tcon_ref_trace	{ smb3_tcon_ref_traces } __mode(byte);
81 
82 #undef EM
83 #undef E_
84 #endif
85 
86 /*
87  * Export enum symbols via userspace.
88  */
89 #define EM(a, b) TRACE_DEFINE_ENUM(a);
90 #define E_(a, b) TRACE_DEFINE_ENUM(a);
91 
92 smb3_rw_credits_traces;
93 smb3_tcon_ref_traces;
94 
95 #undef EM
96 #undef E_
97 
98 /*
99  * Now redefine the EM() and E_() macros to map the enums to the strings that
100  * will be printed in the output.
101  */
102 #define EM(a, b)	{ a, b },
103 #define E_(a, b)	{ a, b }
104 
105 /* For logging errors in read or write */
106 DECLARE_EVENT_CLASS(smb3_rw_err_class,
107 	TP_PROTO(unsigned int rreq_debug_id,
108 		 unsigned int rreq_debug_index,
109 		 unsigned int xid,
110 		 __u64	fid,
111 		 __u32	tid,
112 		 __u64	sesid,
113 		 __u64	offset,
114 		 __u32	len,
115 		 int	rc),
116 	TP_ARGS(rreq_debug_id, rreq_debug_index,
117 		xid, fid, tid, sesid, offset, len, rc),
118 	TP_STRUCT__entry(
119 		__field(unsigned int, rreq_debug_id)
120 		__field(unsigned int, rreq_debug_index)
121 		__field(unsigned int, xid)
122 		__field(__u64, fid)
123 		__field(__u32, tid)
124 		__field(__u64, sesid)
125 		__field(__u64, offset)
126 		__field(__u32, len)
127 		__field(int, rc)
128 	),
129 	TP_fast_assign(
130 		__entry->rreq_debug_id = rreq_debug_id;
131 		__entry->rreq_debug_index = rreq_debug_index;
132 		__entry->xid = xid;
133 		__entry->fid = fid;
134 		__entry->tid = tid;
135 		__entry->sesid = sesid;
136 		__entry->offset = offset;
137 		__entry->len = len;
138 		__entry->rc = rc;
139 	),
140 	TP_printk("\tR=%08x[%x] xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
141 		  __entry->rreq_debug_id, __entry->rreq_debug_index,
142 		  __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
143 		  __entry->offset, __entry->len, __entry->rc)
144 )
145 
146 #define DEFINE_SMB3_RW_ERR_EVENT(name)          \
147 DEFINE_EVENT(smb3_rw_err_class, smb3_##name,    \
148 	TP_PROTO(unsigned int rreq_debug_id,	\
149 		 unsigned int rreq_debug_index,		\
150 		 unsigned int xid,			\
151 		 __u64	fid,				\
152 		 __u32	tid,				\
153 		 __u64	sesid,				\
154 		 __u64	offset,				\
155 		 __u32	len,				\
156 		 int	rc),				\
157 	TP_ARGS(rreq_debug_id, rreq_debug_index, xid, fid, tid, sesid, offset, len, rc))
158 
159 DEFINE_SMB3_RW_ERR_EVENT(read_err);
160 DEFINE_SMB3_RW_ERR_EVENT(write_err);
161 
162 /* For logging errors in other file I/O ops */
163 DECLARE_EVENT_CLASS(smb3_other_err_class,
164 	TP_PROTO(unsigned int xid,
165 		__u64	fid,
166 		__u32	tid,
167 		__u64	sesid,
168 		__u64	offset,
169 		__u32	len,
170 		int	rc),
171 	TP_ARGS(xid, fid, tid, sesid, offset, len, rc),
172 	TP_STRUCT__entry(
173 		__field(unsigned int, xid)
174 		__field(__u64, fid)
175 		__field(__u32, tid)
176 		__field(__u64, sesid)
177 		__field(__u64, offset)
178 		__field(__u32, len)
179 		__field(int, rc)
180 	),
181 	TP_fast_assign(
182 		__entry->xid = xid;
183 		__entry->fid = fid;
184 		__entry->tid = tid;
185 		__entry->sesid = sesid;
186 		__entry->offset = offset;
187 		__entry->len = len;
188 		__entry->rc = rc;
189 	),
190 	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
191 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
192 		__entry->offset, __entry->len, __entry->rc)
193 )
194 
195 #define DEFINE_SMB3_OTHER_ERR_EVENT(name)	\
196 DEFINE_EVENT(smb3_other_err_class, smb3_##name, \
197 	TP_PROTO(unsigned int xid,		\
198 		__u64	fid,			\
199 		__u32	tid,			\
200 		__u64	sesid,			\
201 		__u64	offset,			\
202 		__u32	len,			\
203 		int	rc),			\
204 	TP_ARGS(xid, fid, tid, sesid, offset, len, rc))
205 
206 DEFINE_SMB3_OTHER_ERR_EVENT(query_dir_err);
207 DEFINE_SMB3_OTHER_ERR_EVENT(zero_err);
208 DEFINE_SMB3_OTHER_ERR_EVENT(falloc_err);
209 
210 /*
211  * For logging errors in reflink and copy_range ops e.g. smb2_copychunk_range
212  * and smb2_duplicate_extents
213  */
214 DECLARE_EVENT_CLASS(smb3_copy_range_err_class,
215 	TP_PROTO(unsigned int xid,
216 		__u64	src_fid,
217 		__u64   target_fid,
218 		__u32	tid,
219 		__u64	sesid,
220 		__u64	src_offset,
221 		__u64   target_offset,
222 		__u32	len,
223 		int	rc),
224 	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc),
225 	TP_STRUCT__entry(
226 		__field(unsigned int, xid)
227 		__field(__u64, src_fid)
228 		__field(__u64, target_fid)
229 		__field(__u32, tid)
230 		__field(__u64, sesid)
231 		__field(__u64, src_offset)
232 		__field(__u64, target_offset)
233 		__field(__u32, len)
234 		__field(int, rc)
235 	),
236 	TP_fast_assign(
237 		__entry->xid = xid;
238 		__entry->src_fid = src_fid;
239 		__entry->target_fid = target_fid;
240 		__entry->tid = tid;
241 		__entry->sesid = sesid;
242 		__entry->src_offset = src_offset;
243 		__entry->target_offset = target_offset;
244 		__entry->len = len;
245 		__entry->rc = rc;
246 	),
247 	TP_printk("\txid=%u sid=0x%llx tid=0x%x source fid=0x%llx source offset=0x%llx target fid=0x%llx target offset=0x%llx len=0x%x rc=%d",
248 		__entry->xid, __entry->sesid, __entry->tid, __entry->target_fid,
249 		__entry->src_offset, __entry->target_fid, __entry->target_offset, __entry->len, __entry->rc)
250 )
251 
252 #define DEFINE_SMB3_COPY_RANGE_ERR_EVENT(name)	\
253 DEFINE_EVENT(smb3_copy_range_err_class, smb3_##name, \
254 	TP_PROTO(unsigned int xid,		\
255 		__u64	src_fid,		\
256 		__u64   target_fid,		\
257 		__u32	tid,			\
258 		__u64	sesid,			\
259 		__u64	src_offset,		\
260 		__u64	target_offset,		\
261 		__u32	len,			\
262 		int	rc),			\
263 	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc))
264 
265 DEFINE_SMB3_COPY_RANGE_ERR_EVENT(clone_err);
266 /* TODO: Add SMB3_COPY_RANGE_ERR_EVENT(copychunk_err) */
267 
268 DECLARE_EVENT_CLASS(smb3_copy_range_done_class,
269 	TP_PROTO(unsigned int xid,
270 		__u64	src_fid,
271 		__u64   target_fid,
272 		__u32	tid,
273 		__u64	sesid,
274 		__u64	src_offset,
275 		__u64   target_offset,
276 		__u32	len),
277 	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len),
278 	TP_STRUCT__entry(
279 		__field(unsigned int, xid)
280 		__field(__u64, src_fid)
281 		__field(__u64, target_fid)
282 		__field(__u32, tid)
283 		__field(__u64, sesid)
284 		__field(__u64, src_offset)
285 		__field(__u64, target_offset)
286 		__field(__u32, len)
287 	),
288 	TP_fast_assign(
289 		__entry->xid = xid;
290 		__entry->src_fid = src_fid;
291 		__entry->target_fid = target_fid;
292 		__entry->tid = tid;
293 		__entry->sesid = sesid;
294 		__entry->src_offset = src_offset;
295 		__entry->target_offset = target_offset;
296 		__entry->len = len;
297 	),
298 	TP_printk("\txid=%u sid=0x%llx tid=0x%x source fid=0x%llx source offset=0x%llx target fid=0x%llx target offset=0x%llx len=0x%x",
299 		__entry->xid, __entry->sesid, __entry->tid, __entry->target_fid,
300 		__entry->src_offset, __entry->target_fid, __entry->target_offset, __entry->len)
301 )
302 
303 #define DEFINE_SMB3_COPY_RANGE_DONE_EVENT(name)	\
304 DEFINE_EVENT(smb3_copy_range_done_class, smb3_##name, \
305 	TP_PROTO(unsigned int xid,		\
306 		__u64	src_fid,		\
307 		__u64   target_fid,		\
308 		__u32	tid,			\
309 		__u64	sesid,			\
310 		__u64	src_offset,		\
311 		__u64	target_offset,		\
312 		__u32	len),			\
313 	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len))
314 
315 DEFINE_SMB3_COPY_RANGE_DONE_EVENT(copychunk_enter);
316 DEFINE_SMB3_COPY_RANGE_DONE_EVENT(clone_enter);
317 DEFINE_SMB3_COPY_RANGE_DONE_EVENT(copychunk_done);
318 DEFINE_SMB3_COPY_RANGE_DONE_EVENT(clone_done);
319 
320 
321 /* For logging successful read or write */
322 DECLARE_EVENT_CLASS(smb3_rw_done_class,
323 	TP_PROTO(unsigned int rreq_debug_id,
324 		 unsigned int rreq_debug_index,
325 		 unsigned int xid,
326 		 __u64	fid,
327 		 __u32	tid,
328 		 __u64	sesid,
329 		 __u64	offset,
330 		 __u32	len),
331 	TP_ARGS(rreq_debug_id, rreq_debug_index,
332 		xid, fid, tid, sesid, offset, len),
333 	TP_STRUCT__entry(
334 		__field(unsigned int, rreq_debug_id)
335 		__field(unsigned int, rreq_debug_index)
336 		__field(unsigned int, xid)
337 		__field(__u64, fid)
338 		__field(__u32, tid)
339 		__field(__u64, sesid)
340 		__field(__u64, offset)
341 		__field(__u32, len)
342 	),
343 	TP_fast_assign(
344 		__entry->rreq_debug_id = rreq_debug_id;
345 		__entry->rreq_debug_index = rreq_debug_index;
346 		__entry->xid = xid;
347 		__entry->fid = fid;
348 		__entry->tid = tid;
349 		__entry->sesid = sesid;
350 		__entry->offset = offset;
351 		__entry->len = len;
352 	),
353 	TP_printk("R=%08x[%x] xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
354 		  __entry->rreq_debug_id, __entry->rreq_debug_index,
355 		  __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
356 		  __entry->offset, __entry->len)
357 )
358 
359 #define DEFINE_SMB3_RW_DONE_EVENT(name)         \
360 DEFINE_EVENT(smb3_rw_done_class, smb3_##name,   \
361 	TP_PROTO(unsigned int rreq_debug_id,	\
362 		 unsigned int rreq_debug_index,	\
363 		 unsigned int xid,		\
364 		__u64	fid,			\
365 		__u32	tid,			\
366 		__u64	sesid,			\
367 		__u64	offset,			\
368 		__u32	len),			\
369 	TP_ARGS(rreq_debug_id, rreq_debug_index, xid, fid, tid, sesid, offset, len))
370 
371 DEFINE_SMB3_RW_DONE_EVENT(read_enter);
372 DEFINE_SMB3_RW_DONE_EVENT(read_done);
373 DEFINE_SMB3_RW_DONE_EVENT(write_enter);
374 DEFINE_SMB3_RW_DONE_EVENT(write_done);
375 
376 /* For logging successful other op */
377 DECLARE_EVENT_CLASS(smb3_other_done_class,
378 	TP_PROTO(unsigned int xid,
379 		__u64	fid,
380 		__u32	tid,
381 		__u64	sesid,
382 		__u64	offset,
383 		__u32	len),
384 	TP_ARGS(xid, fid, tid, sesid, offset, len),
385 	TP_STRUCT__entry(
386 		__field(unsigned int, xid)
387 		__field(__u64, fid)
388 		__field(__u32, tid)
389 		__field(__u64, sesid)
390 		__field(__u64, offset)
391 		__field(__u32, len)
392 	),
393 	TP_fast_assign(
394 		__entry->xid = xid;
395 		__entry->fid = fid;
396 		__entry->tid = tid;
397 		__entry->sesid = sesid;
398 		__entry->offset = offset;
399 		__entry->len = len;
400 	),
401 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
402 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
403 		__entry->offset, __entry->len)
404 )
405 
406 #define DEFINE_SMB3_OTHER_DONE_EVENT(name)         \
407 DEFINE_EVENT(smb3_other_done_class, smb3_##name,   \
408 	TP_PROTO(unsigned int xid,		\
409 		__u64	fid,			\
410 		__u32	tid,			\
411 		__u64	sesid,			\
412 		__u64	offset,			\
413 		__u32	len),			\
414 	TP_ARGS(xid, fid, tid, sesid, offset, len))
415 
416 DEFINE_SMB3_OTHER_DONE_EVENT(query_dir_enter);
417 DEFINE_SMB3_OTHER_DONE_EVENT(zero_enter);
418 DEFINE_SMB3_OTHER_DONE_EVENT(falloc_enter);
419 DEFINE_SMB3_OTHER_DONE_EVENT(query_dir_done);
420 DEFINE_SMB3_OTHER_DONE_EVENT(zero_done);
421 DEFINE_SMB3_OTHER_DONE_EVENT(falloc_done);
422 
423 /* For logging successful set EOF (truncate) */
424 DECLARE_EVENT_CLASS(smb3_eof_class,
425 	TP_PROTO(unsigned int xid,
426 		__u64	fid,
427 		__u32	tid,
428 		__u64	sesid,
429 		__u64	offset),
430 	TP_ARGS(xid, fid, tid, sesid, offset),
431 	TP_STRUCT__entry(
432 		__field(unsigned int, xid)
433 		__field(__u64, fid)
434 		__field(__u32, tid)
435 		__field(__u64, sesid)
436 		__field(__u64, offset)
437 	),
438 	TP_fast_assign(
439 		__entry->xid = xid;
440 		__entry->fid = fid;
441 		__entry->tid = tid;
442 		__entry->sesid = sesid;
443 		__entry->offset = offset;
444 	),
445 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx",
446 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
447 		__entry->offset)
448 )
449 
450 #define DEFINE_SMB3_EOF_EVENT(name)         \
451 DEFINE_EVENT(smb3_eof_class, smb3_##name,   \
452 	TP_PROTO(unsigned int xid,		\
453 		__u64	fid,			\
454 		__u32	tid,			\
455 		__u64	sesid,			\
456 		__u64	offset),		\
457 	TP_ARGS(xid, fid, tid, sesid, offset))
458 
459 DEFINE_SMB3_EOF_EVENT(set_eof);
460 
461 /*
462  * For handle based calls other than read and write, and get/set info
463  */
464 DECLARE_EVENT_CLASS(smb3_fd_class,
465 	TP_PROTO(unsigned int xid,
466 		__u64	fid,
467 		__u32	tid,
468 		__u64	sesid),
469 	TP_ARGS(xid, fid, tid, sesid),
470 	TP_STRUCT__entry(
471 		__field(unsigned int, xid)
472 		__field(__u64, fid)
473 		__field(__u32, tid)
474 		__field(__u64, sesid)
475 	),
476 	TP_fast_assign(
477 		__entry->xid = xid;
478 		__entry->fid = fid;
479 		__entry->tid = tid;
480 		__entry->sesid = sesid;
481 	),
482 	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx",
483 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid)
484 )
485 
486 #define DEFINE_SMB3_FD_EVENT(name)          \
487 DEFINE_EVENT(smb3_fd_class, smb3_##name,    \
488 	TP_PROTO(unsigned int xid,		\
489 		__u64	fid,			\
490 		__u32	tid,			\
491 		__u64	sesid),			\
492 	TP_ARGS(xid, fid, tid, sesid))
493 
494 DEFINE_SMB3_FD_EVENT(flush_enter);
495 DEFINE_SMB3_FD_EVENT(flush_done);
496 DEFINE_SMB3_FD_EVENT(close_enter);
497 DEFINE_SMB3_FD_EVENT(close_done);
498 DEFINE_SMB3_FD_EVENT(oplock_not_found);
499 
500 DECLARE_EVENT_CLASS(smb3_fd_err_class,
501 	TP_PROTO(unsigned int xid,
502 		__u64	fid,
503 		__u32	tid,
504 		__u64	sesid,
505 		int	rc),
506 	TP_ARGS(xid, fid, tid, sesid, rc),
507 	TP_STRUCT__entry(
508 		__field(unsigned int, xid)
509 		__field(__u64, fid)
510 		__field(__u32, tid)
511 		__field(__u64, sesid)
512 		__field(int, rc)
513 	),
514 	TP_fast_assign(
515 		__entry->xid = xid;
516 		__entry->fid = fid;
517 		__entry->tid = tid;
518 		__entry->sesid = sesid;
519 		__entry->rc = rc;
520 	),
521 	TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx rc=%d",
522 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
523 		__entry->rc)
524 )
525 
526 #define DEFINE_SMB3_FD_ERR_EVENT(name)          \
527 DEFINE_EVENT(smb3_fd_err_class, smb3_##name,    \
528 	TP_PROTO(unsigned int xid,		\
529 		__u64	fid,			\
530 		__u32	tid,			\
531 		__u64	sesid,			\
532 		int	rc),			\
533 	TP_ARGS(xid, fid, tid, sesid, rc))
534 
535 DEFINE_SMB3_FD_ERR_EVENT(flush_err);
536 DEFINE_SMB3_FD_ERR_EVENT(lock_err);
537 DEFINE_SMB3_FD_ERR_EVENT(close_err);
538 
539 /*
540  * For handle based query/set info calls
541  */
542 DECLARE_EVENT_CLASS(smb3_inf_enter_class,
543 	TP_PROTO(unsigned int xid,
544 		__u64	fid,
545 		__u32	tid,
546 		__u64	sesid,
547 		__u8	infclass,
548 		__u32	type),
549 	TP_ARGS(xid, fid, tid, sesid, infclass, type),
550 	TP_STRUCT__entry(
551 		__field(unsigned int, xid)
552 		__field(__u64, fid)
553 		__field(__u32, tid)
554 		__field(__u64, sesid)
555 		__field(__u8, infclass)
556 		__field(__u32, type)
557 	),
558 	TP_fast_assign(
559 		__entry->xid = xid;
560 		__entry->fid = fid;
561 		__entry->tid = tid;
562 		__entry->sesid = sesid;
563 		__entry->infclass = infclass;
564 		__entry->type = type;
565 	),
566 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x",
567 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
568 		__entry->infclass, __entry->type)
569 )
570 
571 #define DEFINE_SMB3_INF_ENTER_EVENT(name)          \
572 DEFINE_EVENT(smb3_inf_enter_class, smb3_##name,    \
573 	TP_PROTO(unsigned int xid,		\
574 		__u64	fid,			\
575 		__u32	tid,			\
576 		__u64	sesid,			\
577 		__u8	infclass,		\
578 		__u32	type),			\
579 	TP_ARGS(xid, fid, tid, sesid, infclass, type))
580 
581 DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
582 DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
583 DEFINE_SMB3_INF_ENTER_EVENT(notify_enter);
584 DEFINE_SMB3_INF_ENTER_EVENT(notify_done);
585 
586 DECLARE_EVENT_CLASS(smb3_inf_err_class,
587 	TP_PROTO(unsigned int xid,
588 		__u64	fid,
589 		__u32	tid,
590 		__u64	sesid,
591 		__u8	infclass,
592 		__u32	type,
593 		int	rc),
594 	TP_ARGS(xid, fid, tid, sesid, infclass, type, rc),
595 	TP_STRUCT__entry(
596 		__field(unsigned int, xid)
597 		__field(__u64, fid)
598 		__field(__u32, tid)
599 		__field(__u64, sesid)
600 		__field(__u8, infclass)
601 		__field(__u32, type)
602 		__field(int, rc)
603 	),
604 	TP_fast_assign(
605 		__entry->xid = xid;
606 		__entry->fid = fid;
607 		__entry->tid = tid;
608 		__entry->sesid = sesid;
609 		__entry->infclass = infclass;
610 		__entry->type = type;
611 		__entry->rc = rc;
612 	),
613 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x rc=%d",
614 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
615 		__entry->infclass, __entry->type, __entry->rc)
616 )
617 
618 #define DEFINE_SMB3_INF_ERR_EVENT(name)          \
619 DEFINE_EVENT(smb3_inf_err_class, smb3_##name,    \
620 	TP_PROTO(unsigned int xid,		\
621 		__u64	fid,			\
622 		__u32	tid,			\
623 		__u64	sesid,			\
624 		__u8	infclass,		\
625 		__u32	type,			\
626 		int	rc),			\
627 	TP_ARGS(xid, fid, tid, sesid, infclass, type, rc))
628 
629 DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
630 DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
631 DEFINE_SMB3_INF_ERR_EVENT(notify_err);
632 DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
633 
634 DECLARE_EVENT_CLASS(smb3_inf_compound_enter_class,
635 	TP_PROTO(unsigned int xid,
636 		__u32	tid,
637 		__u64	sesid,
638 		const char *full_path),
639 	TP_ARGS(xid, tid, sesid, full_path),
640 	TP_STRUCT__entry(
641 		__field(unsigned int, xid)
642 		__field(__u32, tid)
643 		__field(__u64, sesid)
644 		__string(path, full_path)
645 	),
646 	TP_fast_assign(
647 		__entry->xid = xid;
648 		__entry->tid = tid;
649 		__entry->sesid = sesid;
650 		__assign_str(path);
651 	),
652 	TP_printk("xid=%u sid=0x%llx tid=0x%x path=%s",
653 		__entry->xid, __entry->sesid, __entry->tid,
654 		__get_str(path))
655 )
656 
657 #define DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(name)     \
658 DEFINE_EVENT(smb3_inf_compound_enter_class, smb3_##name,    \
659 	TP_PROTO(unsigned int xid,		\
660 		__u32	tid,			\
661 		__u64	sesid,			\
662 		const char *full_path),		\
663 	TP_ARGS(xid, tid, sesid, full_path))
664 
665 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter);
666 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(posix_query_info_compound_enter);
667 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter);
668 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter);
669 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter);
670 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
671 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
672 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_reparse_compound_enter);
673 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(get_reparse_compound_enter);
674 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
675 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
676 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter);
677 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mknod_enter);
678 
679 DECLARE_EVENT_CLASS(smb3_inf_compound_done_class,
680 	TP_PROTO(unsigned int xid,
681 		__u32	tid,
682 		__u64	sesid),
683 	TP_ARGS(xid, tid, sesid),
684 	TP_STRUCT__entry(
685 		__field(unsigned int, xid)
686 		__field(__u32, tid)
687 		__field(__u64, sesid)
688 	),
689 	TP_fast_assign(
690 		__entry->xid = xid;
691 		__entry->tid = tid;
692 		__entry->sesid = sesid;
693 	),
694 	TP_printk("xid=%u sid=0x%llx tid=0x%x",
695 		__entry->xid, __entry->sesid, __entry->tid)
696 )
697 
698 #define DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(name)     \
699 DEFINE_EVENT(smb3_inf_compound_done_class, smb3_##name,    \
700 	TP_PROTO(unsigned int xid,		\
701 		__u32	tid,			\
702 		__u64	sesid),			\
703 	TP_ARGS(xid, tid, sesid))
704 
705 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_info_compound_done);
706 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(posix_query_info_compound_done);
707 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done);
708 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done);
709 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done);
710 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
711 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
712 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_reparse_compound_done);
713 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(get_reparse_compound_done);
714 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_wsl_ea_compound_done);
715 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
716 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
717 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done);
718 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mknod_done);
719 
720 DECLARE_EVENT_CLASS(smb3_inf_compound_err_class,
721 	TP_PROTO(unsigned int xid,
722 		__u32	tid,
723 		__u64	sesid,
724 		int	rc),
725 	TP_ARGS(xid, tid, sesid, rc),
726 	TP_STRUCT__entry(
727 		__field(unsigned int, xid)
728 		__field(__u32, tid)
729 		__field(__u64, sesid)
730 		__field(int, rc)
731 	),
732 	TP_fast_assign(
733 		__entry->xid = xid;
734 		__entry->tid = tid;
735 		__entry->sesid = sesid;
736 		__entry->rc = rc;
737 	),
738 	TP_printk("xid=%u sid=0x%llx tid=0x%x rc=%d",
739 		__entry->xid, __entry->sesid, __entry->tid,
740 		__entry->rc)
741 )
742 
743 #define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name)     \
744 DEFINE_EVENT(smb3_inf_compound_err_class, smb3_##name,    \
745 	TP_PROTO(unsigned int xid,		\
746 		__u32	tid,			\
747 		__u64	sesid,			\
748 		int rc),			\
749 	TP_ARGS(xid, tid, sesid, rc))
750 
751 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err);
752 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(posix_query_info_compound_err);
753 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err);
754 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err);
755 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err);
756 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
757 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
758 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_reparse_compound_err);
759 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(get_reparse_compound_err);
760 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_wsl_ea_compound_err);
761 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
762 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
763 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err);
764 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mknod_err);
765 
766 /*
767  * For logging SMB3 Status code and Command for responses which return errors
768  */
769 DECLARE_EVENT_CLASS(smb3_cmd_err_class,
770 	TP_PROTO(__u32	tid,
771 		__u64	sesid,
772 		__u16	cmd,
773 		__u64	mid,
774 		__u32	status,
775 		int	rc),
776 	TP_ARGS(tid, sesid, cmd, mid, status, rc),
777 	TP_STRUCT__entry(
778 		__field(__u32, tid)
779 		__field(__u64, sesid)
780 		__field(__u16, cmd)
781 		__field(__u64, mid)
782 		__field(__u32, status)
783 		__field(int, rc)
784 	),
785 	TP_fast_assign(
786 		__entry->tid = tid;
787 		__entry->sesid = sesid;
788 		__entry->cmd = cmd;
789 		__entry->mid = mid;
790 		__entry->status = status;
791 		__entry->rc = rc;
792 	),
793 	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
794 		__entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
795 		__entry->status, __entry->rc)
796 )
797 
798 #define DEFINE_SMB3_CMD_ERR_EVENT(name)          \
799 DEFINE_EVENT(smb3_cmd_err_class, smb3_##name,    \
800 	TP_PROTO(__u32	tid,			\
801 		__u64	sesid,			\
802 		__u16	cmd,			\
803 		__u64	mid,			\
804 		__u32	status,			\
805 		int	rc),			\
806 	TP_ARGS(tid, sesid, cmd, mid, status, rc))
807 
808 DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
809 
810 DECLARE_EVENT_CLASS(smb3_cmd_done_class,
811 	TP_PROTO(__u32	tid,
812 		__u64	sesid,
813 		__u16	cmd,
814 		__u64	mid),
815 	TP_ARGS(tid, sesid, cmd, mid),
816 	TP_STRUCT__entry(
817 		__field(__u32, tid)
818 		__field(__u64, sesid)
819 		__field(__u16, cmd)
820 		__field(__u64, mid)
821 	),
822 	TP_fast_assign(
823 		__entry->tid = tid;
824 		__entry->sesid = sesid;
825 		__entry->cmd = cmd;
826 		__entry->mid = mid;
827 	),
828 	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
829 		__entry->sesid, __entry->tid,
830 		__entry->cmd, __entry->mid)
831 )
832 
833 #define DEFINE_SMB3_CMD_DONE_EVENT(name)          \
834 DEFINE_EVENT(smb3_cmd_done_class, smb3_##name,    \
835 	TP_PROTO(__u32	tid,			\
836 		__u64	sesid,			\
837 		__u16	cmd,			\
838 		__u64	mid),			\
839 	TP_ARGS(tid, sesid, cmd, mid))
840 
841 DEFINE_SMB3_CMD_DONE_EVENT(cmd_enter);
842 DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
843 DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
844 
845 DECLARE_EVENT_CLASS(smb3_mid_class,
846 	TP_PROTO(__u16	cmd,
847 		__u64	mid,
848 		__u32	pid,
849 		unsigned long when_sent,
850 		unsigned long when_received),
851 	TP_ARGS(cmd, mid, pid, when_sent, when_received),
852 	TP_STRUCT__entry(
853 		__field(__u16, cmd)
854 		__field(__u64, mid)
855 		__field(__u32, pid)
856 		__field(unsigned long, when_sent)
857 		__field(unsigned long, when_received)
858 	),
859 	TP_fast_assign(
860 		__entry->cmd = cmd;
861 		__entry->mid = mid;
862 		__entry->pid = pid;
863 		__entry->when_sent = when_sent;
864 		__entry->when_received = when_received;
865 	),
866 	TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
867 		__entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
868 		__entry->when_received)
869 )
870 
871 #define DEFINE_SMB3_MID_EVENT(name)          \
872 DEFINE_EVENT(smb3_mid_class, smb3_##name,    \
873 	TP_PROTO(__u16	cmd,			\
874 		__u64	mid,			\
875 		__u32	pid,			\
876 		unsigned long when_sent,	\
877 		unsigned long when_received),	\
878 	TP_ARGS(cmd, mid, pid, when_sent, when_received))
879 
880 DEFINE_SMB3_MID_EVENT(slow_rsp);
881 
882 DECLARE_EVENT_CLASS(smb3_exit_err_class,
883 	TP_PROTO(unsigned int xid,
884 		const char *func_name,
885 		int	rc),
886 	TP_ARGS(xid, func_name, rc),
887 	TP_STRUCT__entry(
888 		__field(unsigned int, xid)
889 		__string(func_name, func_name)
890 		__field(int, rc)
891 	),
892 	TP_fast_assign(
893 		__entry->xid = xid;
894 		__assign_str(func_name);
895 		__entry->rc = rc;
896 	),
897 	TP_printk("\t%s: xid=%u rc=%d",
898 		__get_str(func_name), __entry->xid, __entry->rc)
899 )
900 
901 #define DEFINE_SMB3_EXIT_ERR_EVENT(name)          \
902 DEFINE_EVENT(smb3_exit_err_class, smb3_##name,    \
903 	TP_PROTO(unsigned int xid,		\
904 		const char *func_name,		\
905 		int	rc),			\
906 	TP_ARGS(xid, func_name, rc))
907 
908 DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
909 
910 
911 DECLARE_EVENT_CLASS(smb3_sync_err_class,
912 	TP_PROTO(unsigned long ino,
913 		int	rc),
914 	TP_ARGS(ino, rc),
915 	TP_STRUCT__entry(
916 		__field(unsigned long, ino)
917 		__field(int, rc)
918 	),
919 	TP_fast_assign(
920 		__entry->ino = ino;
921 		__entry->rc = rc;
922 	),
923 	TP_printk("\tino=%lu rc=%d",
924 		__entry->ino, __entry->rc)
925 )
926 
927 #define DEFINE_SMB3_SYNC_ERR_EVENT(name)          \
928 DEFINE_EVENT(smb3_sync_err_class, cifs_##name,    \
929 	TP_PROTO(unsigned long ino,		\
930 		int	rc),			\
931 	TP_ARGS(ino, rc))
932 
933 DEFINE_SMB3_SYNC_ERR_EVENT(fsync_err);
934 DEFINE_SMB3_SYNC_ERR_EVENT(flush_err);
935 
936 
937 DECLARE_EVENT_CLASS(smb3_enter_exit_class,
938 	TP_PROTO(unsigned int xid,
939 		const char *func_name),
940 	TP_ARGS(xid, func_name),
941 	TP_STRUCT__entry(
942 		__field(unsigned int, xid)
943 		__string(func_name, func_name)
944 	),
945 	TP_fast_assign(
946 		__entry->xid = xid;
947 		__assign_str(func_name);
948 	),
949 	TP_printk("\t%s: xid=%u",
950 		__get_str(func_name), __entry->xid)
951 )
952 
953 #define DEFINE_SMB3_ENTER_EXIT_EVENT(name)        \
954 DEFINE_EVENT(smb3_enter_exit_class, smb3_##name,  \
955 	TP_PROTO(unsigned int xid,		\
956 		const char *func_name),		\
957 	TP_ARGS(xid, func_name))
958 
959 DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
960 DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
961 
962 /*
963  * For SMB2/SMB3 tree connect
964  */
965 
966 DECLARE_EVENT_CLASS(smb3_tcon_class,
967 	TP_PROTO(unsigned int xid,
968 		__u32	tid,
969 		__u64	sesid,
970 		const char *unc_name,
971 		int	rc),
972 	TP_ARGS(xid, tid, sesid, unc_name, rc),
973 	TP_STRUCT__entry(
974 		__field(unsigned int, xid)
975 		__field(__u32, tid)
976 		__field(__u64, sesid)
977 		__string(name, unc_name)
978 		__field(int, rc)
979 	),
980 	TP_fast_assign(
981 		__entry->xid = xid;
982 		__entry->tid = tid;
983 		__entry->sesid = sesid;
984 		__assign_str(name);
985 		__entry->rc = rc;
986 	),
987 	TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d",
988 		__entry->xid, __entry->sesid, __entry->tid,
989 		__get_str(name), __entry->rc)
990 )
991 
992 #define DEFINE_SMB3_TCON_EVENT(name)          \
993 DEFINE_EVENT(smb3_tcon_class, smb3_##name,    \
994 	TP_PROTO(unsigned int xid,		\
995 		__u32	tid,			\
996 		__u64	sesid,			\
997 		const char *unc_name,		\
998 		int	rc),			\
999 	TP_ARGS(xid, tid, sesid, unc_name, rc))
1000 
1001 DEFINE_SMB3_TCON_EVENT(tcon);
1002 DEFINE_SMB3_TCON_EVENT(qfs_done);
1003 
1004 /*
1005  * For smb2/smb3 open (including create and mkdir) calls
1006  */
1007 
1008 DECLARE_EVENT_CLASS(smb3_open_enter_class,
1009 	TP_PROTO(unsigned int xid,
1010 		__u32	tid,
1011 		__u64	sesid,
1012 		const char *full_path,
1013 		int	create_options,
1014 		int	desired_access),
1015 	TP_ARGS(xid, tid, sesid, full_path, create_options, desired_access),
1016 	TP_STRUCT__entry(
1017 		__field(unsigned int, xid)
1018 		__field(__u32, tid)
1019 		__field(__u64, sesid)
1020 		__string(path, full_path)
1021 		__field(int, create_options)
1022 		__field(int, desired_access)
1023 	),
1024 	TP_fast_assign(
1025 		__entry->xid = xid;
1026 		__entry->tid = tid;
1027 		__entry->sesid = sesid;
1028 		__assign_str(path);
1029 		__entry->create_options = create_options;
1030 		__entry->desired_access = desired_access;
1031 	),
1032 	TP_printk("xid=%u sid=0x%llx tid=0x%x path=%s cr_opts=0x%x des_access=0x%x",
1033 		__entry->xid, __entry->sesid, __entry->tid, __get_str(path),
1034 		__entry->create_options, __entry->desired_access)
1035 )
1036 
1037 #define DEFINE_SMB3_OPEN_ENTER_EVENT(name)        \
1038 DEFINE_EVENT(smb3_open_enter_class, smb3_##name,  \
1039 	TP_PROTO(unsigned int xid,		\
1040 		__u32	tid,			\
1041 		__u64	sesid,			\
1042 		const char *full_path,		\
1043 		int	create_options,		\
1044 		int	desired_access),	\
1045 	TP_ARGS(xid, tid, sesid, full_path, create_options, desired_access))
1046 
1047 DEFINE_SMB3_OPEN_ENTER_EVENT(open_enter);
1048 DEFINE_SMB3_OPEN_ENTER_EVENT(posix_mkdir_enter);
1049 
1050 DECLARE_EVENT_CLASS(smb3_open_err_class,
1051 	TP_PROTO(unsigned int xid,
1052 		__u32	tid,
1053 		__u64	sesid,
1054 		int	create_options,
1055 		int	desired_access,
1056 		int	rc),
1057 	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
1058 	TP_STRUCT__entry(
1059 		__field(unsigned int, xid)
1060 		__field(__u32, tid)
1061 		__field(__u64, sesid)
1062 		__field(int,   create_options)
1063 		__field(int, desired_access)
1064 		__field(int, rc)
1065 	),
1066 	TP_fast_assign(
1067 		__entry->xid = xid;
1068 		__entry->tid = tid;
1069 		__entry->sesid = sesid;
1070 		__entry->create_options = create_options;
1071 		__entry->desired_access = desired_access;
1072 		__entry->rc = rc;
1073 	),
1074 	TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
1075 		__entry->xid, __entry->sesid, __entry->tid,
1076 		__entry->create_options, __entry->desired_access, __entry->rc)
1077 )
1078 
1079 #define DEFINE_SMB3_OPEN_ERR_EVENT(name)          \
1080 DEFINE_EVENT(smb3_open_err_class, smb3_##name,    \
1081 	TP_PROTO(unsigned int xid,		\
1082 		__u32	tid,			\
1083 		__u64	sesid,			\
1084 		int	create_options,		\
1085 		int	desired_access,		\
1086 		int	rc),			\
1087 	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
1088 
1089 DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
1090 DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
1091 
1092 DECLARE_EVENT_CLASS(smb3_open_done_class,
1093 	TP_PROTO(unsigned int xid,
1094 		__u64	fid,
1095 		__u32	tid,
1096 		__u64	sesid,
1097 		int	create_options,
1098 		int	desired_access),
1099 	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
1100 	TP_STRUCT__entry(
1101 		__field(unsigned int, xid)
1102 		__field(__u64, fid)
1103 		__field(__u32, tid)
1104 		__field(__u64, sesid)
1105 		__field(int, create_options)
1106 		__field(int, desired_access)
1107 	),
1108 	TP_fast_assign(
1109 		__entry->xid = xid;
1110 		__entry->fid = fid;
1111 		__entry->tid = tid;
1112 		__entry->sesid = sesid;
1113 		__entry->create_options = create_options;
1114 		__entry->desired_access = desired_access;
1115 	),
1116 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
1117 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
1118 		__entry->create_options, __entry->desired_access)
1119 )
1120 
1121 #define DEFINE_SMB3_OPEN_DONE_EVENT(name)        \
1122 DEFINE_EVENT(smb3_open_done_class, smb3_##name,  \
1123 	TP_PROTO(unsigned int xid,		\
1124 		__u64	fid,			\
1125 		__u32	tid,			\
1126 		__u64	sesid,			\
1127 		int	create_options,		\
1128 		int	desired_access),	\
1129 	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
1130 
1131 DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
1132 DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
1133 
1134 
1135 DECLARE_EVENT_CLASS(smb3_lease_done_class,
1136 	TP_PROTO(__u32	lease_state,
1137 		__u32	tid,
1138 		__u64	sesid,
1139 		__u64	lease_key_low,
1140 		__u64	lease_key_high),
1141 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high),
1142 	TP_STRUCT__entry(
1143 		__field(__u32, lease_state)
1144 		__field(__u32, tid)
1145 		__field(__u64, sesid)
1146 		__field(__u64, lease_key_low)
1147 		__field(__u64, lease_key_high)
1148 	),
1149 	TP_fast_assign(
1150 		__entry->lease_state = lease_state;
1151 		__entry->tid = tid;
1152 		__entry->sesid = sesid;
1153 		__entry->lease_key_low = lease_key_low;
1154 		__entry->lease_key_high = lease_key_high;
1155 	),
1156 	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x",
1157 		__entry->sesid, __entry->tid, __entry->lease_key_high,
1158 		__entry->lease_key_low, __entry->lease_state)
1159 )
1160 
1161 #define DEFINE_SMB3_LEASE_DONE_EVENT(name)        \
1162 DEFINE_EVENT(smb3_lease_done_class, smb3_##name,  \
1163 	TP_PROTO(__u32	lease_state,		\
1164 		__u32	tid,			\
1165 		__u64	sesid,			\
1166 		__u64	lease_key_low,		\
1167 		__u64	lease_key_high),	\
1168 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high))
1169 
1170 DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
1171 DEFINE_SMB3_LEASE_DONE_EVENT(lease_not_found);
1172 
1173 DECLARE_EVENT_CLASS(smb3_lease_err_class,
1174 	TP_PROTO(__u32	lease_state,
1175 		__u32	tid,
1176 		__u64	sesid,
1177 		__u64	lease_key_low,
1178 		__u64	lease_key_high,
1179 		int	rc),
1180 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc),
1181 	TP_STRUCT__entry(
1182 		__field(__u32, lease_state)
1183 		__field(__u32, tid)
1184 		__field(__u64, sesid)
1185 		__field(__u64, lease_key_low)
1186 		__field(__u64, lease_key_high)
1187 		__field(int, rc)
1188 	),
1189 	TP_fast_assign(
1190 		__entry->lease_state = lease_state;
1191 		__entry->tid = tid;
1192 		__entry->sesid = sesid;
1193 		__entry->lease_key_low = lease_key_low;
1194 		__entry->lease_key_high = lease_key_high;
1195 		__entry->rc = rc;
1196 	),
1197 	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x rc=%d",
1198 		__entry->sesid, __entry->tid, __entry->lease_key_high,
1199 		__entry->lease_key_low, __entry->lease_state, __entry->rc)
1200 )
1201 
1202 #define DEFINE_SMB3_LEASE_ERR_EVENT(name)        \
1203 DEFINE_EVENT(smb3_lease_err_class, smb3_##name,  \
1204 	TP_PROTO(__u32	lease_state,		\
1205 		__u32	tid,			\
1206 		__u64	sesid,			\
1207 		__u64	lease_key_low,		\
1208 		__u64	lease_key_high,		\
1209 		int	rc),			\
1210 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc))
1211 
1212 DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
1213 
1214 DECLARE_EVENT_CLASS(smb3_connect_class,
1215 	TP_PROTO(char *hostname,
1216 		__u64 conn_id,
1217 		const struct __kernel_sockaddr_storage *dst_addr),
1218 	TP_ARGS(hostname, conn_id, dst_addr),
1219 	TP_STRUCT__entry(
1220 		__string(hostname, hostname)
1221 		__field(__u64, conn_id)
1222 		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
1223 	),
1224 	TP_fast_assign(
1225 		struct sockaddr_storage *pss = NULL;
1226 
1227 		__entry->conn_id = conn_id;
1228 		pss = (struct sockaddr_storage *)__entry->dst_addr;
1229 		*pss = *dst_addr;
1230 		__assign_str(hostname);
1231 	),
1232 	TP_printk("conn_id=0x%llx server=%s addr=%pISpsfc",
1233 		__entry->conn_id,
1234 		__get_str(hostname),
1235 		__entry->dst_addr)
1236 )
1237 
1238 #define DEFINE_SMB3_CONNECT_EVENT(name)        \
1239 DEFINE_EVENT(smb3_connect_class, smb3_##name,  \
1240 	TP_PROTO(char *hostname,		\
1241 		__u64 conn_id,			\
1242 		const struct __kernel_sockaddr_storage *addr),	\
1243 	TP_ARGS(hostname, conn_id, addr))
1244 
1245 DEFINE_SMB3_CONNECT_EVENT(connect_done);
1246 DEFINE_SMB3_CONNECT_EVENT(smbd_connect_done);
1247 DEFINE_SMB3_CONNECT_EVENT(smbd_connect_err);
1248 
1249 DECLARE_EVENT_CLASS(smb3_connect_err_class,
1250 	TP_PROTO(char *hostname, __u64 conn_id,
1251 		const struct __kernel_sockaddr_storage *dst_addr, int rc),
1252 	TP_ARGS(hostname, conn_id, dst_addr, rc),
1253 	TP_STRUCT__entry(
1254 		__string(hostname, hostname)
1255 		__field(__u64, conn_id)
1256 		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
1257 		__field(int, rc)
1258 	),
1259 	TP_fast_assign(
1260 		struct sockaddr_storage *pss = NULL;
1261 
1262 		__entry->conn_id = conn_id;
1263 		__entry->rc = rc;
1264 		pss = (struct sockaddr_storage *)__entry->dst_addr;
1265 		*pss = *dst_addr;
1266 		__assign_str(hostname);
1267 	),
1268 	TP_printk("rc=%d conn_id=0x%llx server=%s addr=%pISpsfc",
1269 		__entry->rc,
1270 		__entry->conn_id,
1271 		__get_str(hostname),
1272 		__entry->dst_addr)
1273 )
1274 
1275 #define DEFINE_SMB3_CONNECT_ERR_EVENT(name)        \
1276 DEFINE_EVENT(smb3_connect_err_class, smb3_##name,  \
1277 	TP_PROTO(char *hostname,		\
1278 		__u64 conn_id,			\
1279 		const struct __kernel_sockaddr_storage *addr,	\
1280 		int rc),			\
1281 	TP_ARGS(hostname, conn_id, addr, rc))
1282 
1283 DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err);
1284 
1285 DECLARE_EVENT_CLASS(smb3_sess_setup_err_class,
1286 	TP_PROTO(char *hostname, char *username, __u64 conn_id,
1287 		const struct __kernel_sockaddr_storage *dst_addr, int rc),
1288 	TP_ARGS(hostname, username, conn_id, dst_addr, rc),
1289 	TP_STRUCT__entry(
1290 		__string(hostname, hostname)
1291 		__string(username, username)
1292 		__field(__u64, conn_id)
1293 		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
1294 		__field(int, rc)
1295 	),
1296 	TP_fast_assign(
1297 		struct sockaddr_storage *pss = NULL;
1298 
1299 		__entry->conn_id = conn_id;
1300 		__entry->rc = rc;
1301 		pss = (struct sockaddr_storage *)__entry->dst_addr;
1302 		*pss = *dst_addr;
1303 		__assign_str(hostname);
1304 		__assign_str(username);
1305 	),
1306 	TP_printk("rc=%d user=%s conn_id=0x%llx server=%s addr=%pISpsfc",
1307 		__entry->rc,
1308 		__get_str(username),
1309 		__entry->conn_id,
1310 		__get_str(hostname),
1311 		__entry->dst_addr)
1312 )
1313 
1314 #define DEFINE_SMB3_SES_SETUP_ERR_EVENT(name)        \
1315 DEFINE_EVENT(smb3_sess_setup_err_class, smb3_##name,  \
1316 	TP_PROTO(char *hostname,		\
1317 		char *username,			\
1318 		__u64 conn_id,			\
1319 		const struct __kernel_sockaddr_storage *addr,	\
1320 		int rc),			\
1321 	TP_ARGS(hostname, username, conn_id, addr, rc))
1322 
1323 DEFINE_SMB3_SES_SETUP_ERR_EVENT(key_expired);
1324 
1325 DECLARE_EVENT_CLASS(smb3_reconnect_class,
1326 	TP_PROTO(__u64	currmid,
1327 		__u64 conn_id,
1328 		char *hostname),
1329 	TP_ARGS(currmid, conn_id, hostname),
1330 	TP_STRUCT__entry(
1331 		__field(__u64, currmid)
1332 		__field(__u64, conn_id)
1333 		__string(hostname, hostname)
1334 	),
1335 	TP_fast_assign(
1336 		__entry->currmid = currmid;
1337 		__entry->conn_id = conn_id;
1338 		__assign_str(hostname);
1339 	),
1340 	TP_printk("conn_id=0x%llx server=%s current_mid=%llu",
1341 		__entry->conn_id,
1342 		__get_str(hostname),
1343 		__entry->currmid)
1344 )
1345 
1346 #define DEFINE_SMB3_RECONNECT_EVENT(name)        \
1347 DEFINE_EVENT(smb3_reconnect_class, smb3_##name,  \
1348 	TP_PROTO(__u64	currmid,		\
1349 		__u64 conn_id,			\
1350 		char *hostname),				\
1351 	TP_ARGS(currmid, conn_id, hostname))
1352 
1353 DEFINE_SMB3_RECONNECT_EVENT(reconnect);
1354 DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
1355 
1356 DECLARE_EVENT_CLASS(smb3_ses_class,
1357 	TP_PROTO(__u64	sesid),
1358 	TP_ARGS(sesid),
1359 	TP_STRUCT__entry(
1360 		__field(__u64, sesid)
1361 	),
1362 	TP_fast_assign(
1363 		__entry->sesid = sesid;
1364 	),
1365 	TP_printk("sid=0x%llx",
1366 		__entry->sesid)
1367 )
1368 
1369 #define DEFINE_SMB3_SES_EVENT(name)        \
1370 DEFINE_EVENT(smb3_ses_class, smb3_##name,  \
1371 	TP_PROTO(__u64	sesid),				\
1372 	TP_ARGS(sesid))
1373 
1374 DEFINE_SMB3_SES_EVENT(ses_not_found);
1375 
1376 DECLARE_EVENT_CLASS(smb3_ioctl_class,
1377 	TP_PROTO(unsigned int xid,
1378 		__u64	fid,
1379 		unsigned int command),
1380 	TP_ARGS(xid, fid, command),
1381 	TP_STRUCT__entry(
1382 		__field(unsigned int, xid)
1383 		__field(__u64, fid)
1384 		__field(unsigned int, command)
1385 	),
1386 	TP_fast_assign(
1387 		__entry->xid = xid;
1388 		__entry->fid = fid;
1389 		__entry->command = command;
1390 	),
1391 	TP_printk("xid=%u fid=0x%llx ioctl cmd=0x%x",
1392 		  __entry->xid, __entry->fid, __entry->command)
1393 )
1394 
1395 #define DEFINE_SMB3_IOCTL_EVENT(name)        \
1396 DEFINE_EVENT(smb3_ioctl_class, smb3_##name,  \
1397 	TP_PROTO(unsigned int xid,	     \
1398 		__u64 fid,		     \
1399 		unsigned int command),	     \
1400 	TP_ARGS(xid, fid, command))
1401 
1402 DEFINE_SMB3_IOCTL_EVENT(ioctl);
1403 
1404 DECLARE_EVENT_CLASS(smb3_shutdown_class,
1405 	TP_PROTO(__u32 flags,
1406 		__u32 tid),
1407 	TP_ARGS(flags, tid),
1408 	TP_STRUCT__entry(
1409 		__field(__u32, flags)
1410 		__field(__u32, tid)
1411 	),
1412 	TP_fast_assign(
1413 		__entry->flags = flags;
1414 		__entry->tid = tid;
1415 	),
1416 	TP_printk("flags=0x%x tid=0x%x",
1417 		  __entry->flags, __entry->tid)
1418 )
1419 
1420 #define DEFINE_SMB3_SHUTDOWN_EVENT(name)        \
1421 DEFINE_EVENT(smb3_shutdown_class, smb3_##name,  \
1422 	TP_PROTO(__u32 flags,		     \
1423 		__u32 tid),		     \
1424 	TP_ARGS(flags, tid))
1425 
1426 DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_enter);
1427 DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_done);
1428 
1429 DECLARE_EVENT_CLASS(smb3_shutdown_err_class,
1430 	TP_PROTO(int rc,
1431 		__u32 flags,
1432 		__u32 tid),
1433 	TP_ARGS(rc, flags, tid),
1434 	TP_STRUCT__entry(
1435 		__field(int, rc)
1436 		__field(__u32, flags)
1437 		__field(__u32, tid)
1438 	),
1439 	TP_fast_assign(
1440 		__entry->rc = rc;
1441 		__entry->flags = flags;
1442 		__entry->tid = tid;
1443 	),
1444 	TP_printk("rc=%d flags=0x%x tid=0x%x",
1445 		__entry->rc, __entry->flags, __entry->tid)
1446 )
1447 
1448 #define DEFINE_SMB3_SHUTDOWN_ERR_EVENT(name)        \
1449 DEFINE_EVENT(smb3_shutdown_err_class, smb3_##name,  \
1450 	TP_PROTO(int rc,		     \
1451 		__u32 flags,		     \
1452 		__u32 tid),		     \
1453 	TP_ARGS(rc, flags, tid))
1454 
1455 DEFINE_SMB3_SHUTDOWN_ERR_EVENT(shutdown_err);
1456 
1457 DECLARE_EVENT_CLASS(smb3_credit_class,
1458 	TP_PROTO(__u64	currmid,
1459 		__u64 conn_id,
1460 		char *hostname,
1461 		int credits,
1462 		int credits_to_add,
1463 		int in_flight),
1464 	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight),
1465 	TP_STRUCT__entry(
1466 		__field(__u64, currmid)
1467 		__field(__u64, conn_id)
1468 		__string(hostname, hostname)
1469 		__field(int, credits)
1470 		__field(int, credits_to_add)
1471 		__field(int, in_flight)
1472 	),
1473 	TP_fast_assign(
1474 		__entry->currmid = currmid;
1475 		__entry->conn_id = conn_id;
1476 		__assign_str(hostname);
1477 		__entry->credits = credits;
1478 		__entry->credits_to_add = credits_to_add;
1479 		__entry->in_flight = in_flight;
1480 	),
1481 	TP_printk("conn_id=0x%llx server=%s current_mid=%llu "
1482 			"credits=%d credit_change=%d in_flight=%d",
1483 		__entry->conn_id,
1484 		__get_str(hostname),
1485 		__entry->currmid,
1486 		__entry->credits,
1487 		__entry->credits_to_add,
1488 		__entry->in_flight)
1489 )
1490 
1491 #define DEFINE_SMB3_CREDIT_EVENT(name)        \
1492 DEFINE_EVENT(smb3_credit_class, smb3_##name,  \
1493 	TP_PROTO(__u64	currmid,		\
1494 		__u64 conn_id,			\
1495 		char *hostname,			\
1496 		int  credits,			\
1497 		int  credits_to_add,	\
1498 		int in_flight),			\
1499 	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight))
1500 
1501 DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
1502 DEFINE_SMB3_CREDIT_EVENT(reconnect_detected);
1503 DEFINE_SMB3_CREDIT_EVENT(credit_timeout);
1504 DEFINE_SMB3_CREDIT_EVENT(insufficient_credits);
1505 DEFINE_SMB3_CREDIT_EVENT(too_many_credits);
1506 DEFINE_SMB3_CREDIT_EVENT(add_credits);
1507 DEFINE_SMB3_CREDIT_EVENT(adj_credits);
1508 DEFINE_SMB3_CREDIT_EVENT(hdr_credits);
1509 DEFINE_SMB3_CREDIT_EVENT(nblk_credits);
1510 DEFINE_SMB3_CREDIT_EVENT(pend_credits);
1511 DEFINE_SMB3_CREDIT_EVENT(wait_credits);
1512 DEFINE_SMB3_CREDIT_EVENT(waitff_credits);
1513 DEFINE_SMB3_CREDIT_EVENT(overflow_credits);
1514 DEFINE_SMB3_CREDIT_EVENT(set_credits);
1515 
1516 
1517 TRACE_EVENT(smb3_tcon_ref,
1518 	    TP_PROTO(unsigned int tcon_debug_id, int ref,
1519 		     enum smb3_tcon_ref_trace trace),
1520 	    TP_ARGS(tcon_debug_id, ref, trace),
1521 	    TP_STRUCT__entry(
1522 		    __field(unsigned int,		tcon)
1523 		    __field(int,			ref)
1524 		    __field(enum smb3_tcon_ref_trace,	trace)
1525 			     ),
1526 	    TP_fast_assign(
1527 		    __entry->tcon	= tcon_debug_id;
1528 		    __entry->ref	= ref;
1529 		    __entry->trace	= trace;
1530 			   ),
1531 	    TP_printk("TC=%08x %s r=%u",
1532 		      __entry->tcon,
1533 		      __print_symbolic(__entry->trace, smb3_tcon_ref_traces),
1534 		      __entry->ref)
1535 	    );
1536 
1537 TRACE_EVENT(smb3_rw_credits,
1538 	    TP_PROTO(unsigned int rreq_debug_id,
1539 		     unsigned int subreq_debug_index,
1540 		     unsigned int subreq_credits,
1541 		     unsigned int server_credits,
1542 		     int server_in_flight,
1543 		     int credit_change,
1544 		     enum smb3_rw_credits_trace trace),
1545 	    TP_ARGS(rreq_debug_id, subreq_debug_index, subreq_credits,
1546 		    server_credits, server_in_flight, credit_change, trace),
1547 	    TP_STRUCT__entry(
1548 		    __field(unsigned int, rreq_debug_id)
1549 		    __field(unsigned int, subreq_debug_index)
1550 		    __field(unsigned int, subreq_credits)
1551 		    __field(unsigned int, server_credits)
1552 		    __field(int,	  in_flight)
1553 		    __field(int,	  credit_change)
1554 		    __field(enum smb3_rw_credits_trace, trace)
1555 			     ),
1556 	    TP_fast_assign(
1557 		    __entry->rreq_debug_id	= rreq_debug_id;
1558 		    __entry->subreq_debug_index	= subreq_debug_index;
1559 		    __entry->subreq_credits	= subreq_credits;
1560 		    __entry->server_credits	= server_credits;
1561 		    __entry->in_flight		= server_in_flight;
1562 		    __entry->credit_change	= credit_change;
1563 		    __entry->trace		= trace;
1564 			   ),
1565 	    TP_printk("R=%08x[%x] %s cred=%u chg=%d pool=%u ifl=%d",
1566 		      __entry->rreq_debug_id, __entry->subreq_debug_index,
1567 		      __print_symbolic(__entry->trace, smb3_rw_credits_traces),
1568 		      __entry->subreq_credits, __entry->credit_change,
1569 		      __entry->server_credits, __entry->in_flight)
1570 	    );
1571 
1572 
1573 #undef EM
1574 #undef E_
1575 #endif /* _CIFS_TRACE_H */
1576 
1577 #undef TRACE_INCLUDE_PATH
1578 #define TRACE_INCLUDE_PATH .
1579 #define TRACE_INCLUDE_FILE trace
1580 #include <trace/define_trace.h>
1581