xref: /linux/fs/smb/client/trace.h (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
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 */
23 DECLARE_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)          \
56 DEFINE_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 
66 DEFINE_SMB3_RW_ERR_EVENT(write_err);
67 DEFINE_SMB3_RW_ERR_EVENT(read_err);
68 DEFINE_SMB3_RW_ERR_EVENT(query_dir_err);
69 DEFINE_SMB3_RW_ERR_EVENT(zero_err);
70 DEFINE_SMB3_RW_ERR_EVENT(falloc_err);
71 
72 
73 /* For logging successful read or write */
74 DECLARE_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)         \
104 DEFINE_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 
113 DEFINE_SMB3_RW_DONE_EVENT(write_enter);
114 DEFINE_SMB3_RW_DONE_EVENT(read_enter);
115 DEFINE_SMB3_RW_DONE_EVENT(query_dir_enter);
116 DEFINE_SMB3_RW_DONE_EVENT(zero_enter);
117 DEFINE_SMB3_RW_DONE_EVENT(falloc_enter);
118 DEFINE_SMB3_RW_DONE_EVENT(write_done);
119 DEFINE_SMB3_RW_DONE_EVENT(read_done);
120 DEFINE_SMB3_RW_DONE_EVENT(query_dir_done);
121 DEFINE_SMB3_RW_DONE_EVENT(zero_done);
122 DEFINE_SMB3_RW_DONE_EVENT(falloc_done);
123 
124 /* For logging successful set EOF (truncate) */
125 DECLARE_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)         \
152 DEFINE_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 
160 DEFINE_SMB3_EOF_EVENT(set_eof);
161 
162 /*
163  * For handle based calls other than read and write, and get/set info
164  */
165 DECLARE_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)          \
188 DEFINE_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 
195 DEFINE_SMB3_FD_EVENT(flush_enter);
196 DEFINE_SMB3_FD_EVENT(flush_done);
197 DEFINE_SMB3_FD_EVENT(close_enter);
198 DEFINE_SMB3_FD_EVENT(close_done);
199 DEFINE_SMB3_FD_EVENT(oplock_not_found);
200 
201 DECLARE_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)          \
228 DEFINE_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 
236 DEFINE_SMB3_FD_ERR_EVENT(flush_err);
237 DEFINE_SMB3_FD_ERR_EVENT(lock_err);
238 DEFINE_SMB3_FD_ERR_EVENT(close_err);
239 
240 /*
241  * For handle based query/set info calls
242  */
243 DECLARE_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)          \
273 DEFINE_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 
282 DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
283 DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
284 DEFINE_SMB3_INF_ENTER_EVENT(notify_enter);
285 DEFINE_SMB3_INF_ENTER_EVENT(notify_done);
286 
287 DECLARE_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)          \
320 DEFINE_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 
330 DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
331 DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
332 DEFINE_SMB3_INF_ERR_EVENT(notify_err);
333 DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
334 
335 DECLARE_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)     \
359 DEFINE_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 
366 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter);
367 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(posix_query_info_compound_enter);
368 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter);
369 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter);
370 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter);
371 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
372 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
373 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_reparse_compound_enter);
374 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(get_reparse_compound_enter);
375 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
376 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
377 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter);
378 
379 DECLARE_EVENT_CLASS(smb3_inf_compound_done_class,
380 	TP_PROTO(unsigned int xid,
381 		__u32	tid,
382 		__u64	sesid),
383 	TP_ARGS(xid, tid, sesid),
384 	TP_STRUCT__entry(
385 		__field(unsigned int, xid)
386 		__field(__u32, tid)
387 		__field(__u64, sesid)
388 	),
389 	TP_fast_assign(
390 		__entry->xid = xid;
391 		__entry->tid = tid;
392 		__entry->sesid = sesid;
393 	),
394 	TP_printk("xid=%u sid=0x%llx tid=0x%x",
395 		__entry->xid, __entry->sesid, __entry->tid)
396 )
397 
398 #define DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(name)     \
399 DEFINE_EVENT(smb3_inf_compound_done_class, smb3_##name,    \
400 	TP_PROTO(unsigned int xid,		\
401 		__u32	tid,			\
402 		__u64	sesid),			\
403 	TP_ARGS(xid, tid, sesid))
404 
405 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_info_compound_done);
406 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(posix_query_info_compound_done);
407 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done);
408 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done);
409 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done);
410 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
411 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
412 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_reparse_compound_done);
413 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(get_reparse_compound_done);
414 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
415 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
416 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done);
417 
418 
419 DECLARE_EVENT_CLASS(smb3_inf_compound_err_class,
420 	TP_PROTO(unsigned int xid,
421 		__u32	tid,
422 		__u64	sesid,
423 		int	rc),
424 	TP_ARGS(xid, tid, sesid, rc),
425 	TP_STRUCT__entry(
426 		__field(unsigned int, xid)
427 		__field(__u32, tid)
428 		__field(__u64, sesid)
429 		__field(int, rc)
430 	),
431 	TP_fast_assign(
432 		__entry->xid = xid;
433 		__entry->tid = tid;
434 		__entry->sesid = sesid;
435 		__entry->rc = rc;
436 	),
437 	TP_printk("xid=%u sid=0x%llx tid=0x%x rc=%d",
438 		__entry->xid, __entry->sesid, __entry->tid,
439 		__entry->rc)
440 )
441 
442 #define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name)     \
443 DEFINE_EVENT(smb3_inf_compound_err_class, smb3_##name,    \
444 	TP_PROTO(unsigned int xid,		\
445 		__u32	tid,			\
446 		__u64	sesid,			\
447 		int rc),			\
448 	TP_ARGS(xid, tid, sesid, rc))
449 
450 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err);
451 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(posix_query_info_compound_err);
452 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err);
453 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err);
454 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err);
455 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
456 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
457 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_reparse_compound_err);
458 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(get_reparse_compound_err);
459 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
460 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
461 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err);
462 
463 /*
464  * For logging SMB3 Status code and Command for responses which return errors
465  */
466 DECLARE_EVENT_CLASS(smb3_cmd_err_class,
467 	TP_PROTO(__u32	tid,
468 		__u64	sesid,
469 		__u16	cmd,
470 		__u64	mid,
471 		__u32	status,
472 		int	rc),
473 	TP_ARGS(tid, sesid, cmd, mid, status, rc),
474 	TP_STRUCT__entry(
475 		__field(__u32, tid)
476 		__field(__u64, sesid)
477 		__field(__u16, cmd)
478 		__field(__u64, mid)
479 		__field(__u32, status)
480 		__field(int, rc)
481 	),
482 	TP_fast_assign(
483 		__entry->tid = tid;
484 		__entry->sesid = sesid;
485 		__entry->cmd = cmd;
486 		__entry->mid = mid;
487 		__entry->status = status;
488 		__entry->rc = rc;
489 	),
490 	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
491 		__entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
492 		__entry->status, __entry->rc)
493 )
494 
495 #define DEFINE_SMB3_CMD_ERR_EVENT(name)          \
496 DEFINE_EVENT(smb3_cmd_err_class, smb3_##name,    \
497 	TP_PROTO(__u32	tid,			\
498 		__u64	sesid,			\
499 		__u16	cmd,			\
500 		__u64	mid,			\
501 		__u32	status,			\
502 		int	rc),			\
503 	TP_ARGS(tid, sesid, cmd, mid, status, rc))
504 
505 DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
506 
507 DECLARE_EVENT_CLASS(smb3_cmd_done_class,
508 	TP_PROTO(__u32	tid,
509 		__u64	sesid,
510 		__u16	cmd,
511 		__u64	mid),
512 	TP_ARGS(tid, sesid, cmd, mid),
513 	TP_STRUCT__entry(
514 		__field(__u32, tid)
515 		__field(__u64, sesid)
516 		__field(__u16, cmd)
517 		__field(__u64, mid)
518 	),
519 	TP_fast_assign(
520 		__entry->tid = tid;
521 		__entry->sesid = sesid;
522 		__entry->cmd = cmd;
523 		__entry->mid = mid;
524 	),
525 	TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
526 		__entry->sesid, __entry->tid,
527 		__entry->cmd, __entry->mid)
528 )
529 
530 #define DEFINE_SMB3_CMD_DONE_EVENT(name)          \
531 DEFINE_EVENT(smb3_cmd_done_class, smb3_##name,    \
532 	TP_PROTO(__u32	tid,			\
533 		__u64	sesid,			\
534 		__u16	cmd,			\
535 		__u64	mid),			\
536 	TP_ARGS(tid, sesid, cmd, mid))
537 
538 DEFINE_SMB3_CMD_DONE_EVENT(cmd_enter);
539 DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
540 DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
541 
542 DECLARE_EVENT_CLASS(smb3_mid_class,
543 	TP_PROTO(__u16	cmd,
544 		__u64	mid,
545 		__u32	pid,
546 		unsigned long when_sent,
547 		unsigned long when_received),
548 	TP_ARGS(cmd, mid, pid, when_sent, when_received),
549 	TP_STRUCT__entry(
550 		__field(__u16, cmd)
551 		__field(__u64, mid)
552 		__field(__u32, pid)
553 		__field(unsigned long, when_sent)
554 		__field(unsigned long, when_received)
555 	),
556 	TP_fast_assign(
557 		__entry->cmd = cmd;
558 		__entry->mid = mid;
559 		__entry->pid = pid;
560 		__entry->when_sent = when_sent;
561 		__entry->when_received = when_received;
562 	),
563 	TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
564 		__entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
565 		__entry->when_received)
566 )
567 
568 #define DEFINE_SMB3_MID_EVENT(name)          \
569 DEFINE_EVENT(smb3_mid_class, smb3_##name,    \
570 	TP_PROTO(__u16	cmd,			\
571 		__u64	mid,			\
572 		__u32	pid,			\
573 		unsigned long when_sent,	\
574 		unsigned long when_received),	\
575 	TP_ARGS(cmd, mid, pid, when_sent, when_received))
576 
577 DEFINE_SMB3_MID_EVENT(slow_rsp);
578 
579 DECLARE_EVENT_CLASS(smb3_exit_err_class,
580 	TP_PROTO(unsigned int xid,
581 		const char *func_name,
582 		int	rc),
583 	TP_ARGS(xid, func_name, rc),
584 	TP_STRUCT__entry(
585 		__field(unsigned int, xid)
586 		__string(func_name, func_name)
587 		__field(int, rc)
588 	),
589 	TP_fast_assign(
590 		__entry->xid = xid;
591 		__assign_str(func_name, func_name);
592 		__entry->rc = rc;
593 	),
594 	TP_printk("\t%s: xid=%u rc=%d",
595 		__get_str(func_name), __entry->xid, __entry->rc)
596 )
597 
598 #define DEFINE_SMB3_EXIT_ERR_EVENT(name)          \
599 DEFINE_EVENT(smb3_exit_err_class, smb3_##name,    \
600 	TP_PROTO(unsigned int xid,		\
601 		const char *func_name,		\
602 		int	rc),			\
603 	TP_ARGS(xid, func_name, rc))
604 
605 DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
606 
607 
608 DECLARE_EVENT_CLASS(smb3_sync_err_class,
609 	TP_PROTO(unsigned long ino,
610 		int	rc),
611 	TP_ARGS(ino, rc),
612 	TP_STRUCT__entry(
613 		__field(unsigned long, ino)
614 		__field(int, rc)
615 	),
616 	TP_fast_assign(
617 		__entry->ino = ino;
618 		__entry->rc = rc;
619 	),
620 	TP_printk("\tino=%lu rc=%d",
621 		__entry->ino, __entry->rc)
622 )
623 
624 #define DEFINE_SMB3_SYNC_ERR_EVENT(name)          \
625 DEFINE_EVENT(smb3_sync_err_class, cifs_##name,    \
626 	TP_PROTO(unsigned long ino,		\
627 		int	rc),			\
628 	TP_ARGS(ino, rc))
629 
630 DEFINE_SMB3_SYNC_ERR_EVENT(fsync_err);
631 DEFINE_SMB3_SYNC_ERR_EVENT(flush_err);
632 
633 
634 DECLARE_EVENT_CLASS(smb3_enter_exit_class,
635 	TP_PROTO(unsigned int xid,
636 		const char *func_name),
637 	TP_ARGS(xid, func_name),
638 	TP_STRUCT__entry(
639 		__field(unsigned int, xid)
640 		__string(func_name, func_name)
641 	),
642 	TP_fast_assign(
643 		__entry->xid = xid;
644 		__assign_str(func_name, func_name);
645 	),
646 	TP_printk("\t%s: xid=%u",
647 		__get_str(func_name), __entry->xid)
648 )
649 
650 #define DEFINE_SMB3_ENTER_EXIT_EVENT(name)        \
651 DEFINE_EVENT(smb3_enter_exit_class, smb3_##name,  \
652 	TP_PROTO(unsigned int xid,		\
653 		const char *func_name),		\
654 	TP_ARGS(xid, func_name))
655 
656 DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
657 DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
658 
659 /*
660  * For SMB2/SMB3 tree connect
661  */
662 
663 DECLARE_EVENT_CLASS(smb3_tcon_class,
664 	TP_PROTO(unsigned int xid,
665 		__u32	tid,
666 		__u64	sesid,
667 		const char *unc_name,
668 		int	rc),
669 	TP_ARGS(xid, tid, sesid, unc_name, rc),
670 	TP_STRUCT__entry(
671 		__field(unsigned int, xid)
672 		__field(__u32, tid)
673 		__field(__u64, sesid)
674 		__string(name, unc_name)
675 		__field(int, rc)
676 	),
677 	TP_fast_assign(
678 		__entry->xid = xid;
679 		__entry->tid = tid;
680 		__entry->sesid = sesid;
681 		__assign_str(name, unc_name);
682 		__entry->rc = rc;
683 	),
684 	TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d",
685 		__entry->xid, __entry->sesid, __entry->tid,
686 		__get_str(name), __entry->rc)
687 )
688 
689 #define DEFINE_SMB3_TCON_EVENT(name)          \
690 DEFINE_EVENT(smb3_tcon_class, smb3_##name,    \
691 	TP_PROTO(unsigned int xid,		\
692 		__u32	tid,			\
693 		__u64	sesid,			\
694 		const char *unc_name,		\
695 		int	rc),			\
696 	TP_ARGS(xid, tid, sesid, unc_name, rc))
697 
698 DEFINE_SMB3_TCON_EVENT(tcon);
699 DEFINE_SMB3_TCON_EVENT(qfs_done);
700 
701 /*
702  * For smb2/smb3 open (including create and mkdir) calls
703  */
704 
705 DECLARE_EVENT_CLASS(smb3_open_enter_class,
706 	TP_PROTO(unsigned int xid,
707 		__u32	tid,
708 		__u64	sesid,
709 		const char *full_path,
710 		int	create_options,
711 		int	desired_access),
712 	TP_ARGS(xid, tid, sesid, full_path, create_options, desired_access),
713 	TP_STRUCT__entry(
714 		__field(unsigned int, xid)
715 		__field(__u32, tid)
716 		__field(__u64, sesid)
717 		__string(path, full_path)
718 		__field(int, create_options)
719 		__field(int, desired_access)
720 	),
721 	TP_fast_assign(
722 		__entry->xid = xid;
723 		__entry->tid = tid;
724 		__entry->sesid = sesid;
725 		__assign_str(path, full_path);
726 		__entry->create_options = create_options;
727 		__entry->desired_access = desired_access;
728 	),
729 	TP_printk("xid=%u sid=0x%llx tid=0x%x path=%s cr_opts=0x%x des_access=0x%x",
730 		__entry->xid, __entry->sesid, __entry->tid, __get_str(path),
731 		__entry->create_options, __entry->desired_access)
732 )
733 
734 #define DEFINE_SMB3_OPEN_ENTER_EVENT(name)        \
735 DEFINE_EVENT(smb3_open_enter_class, smb3_##name,  \
736 	TP_PROTO(unsigned int xid,		\
737 		__u32	tid,			\
738 		__u64	sesid,			\
739 		const char *full_path,		\
740 		int	create_options,		\
741 		int	desired_access),	\
742 	TP_ARGS(xid, tid, sesid, full_path, create_options, desired_access))
743 
744 DEFINE_SMB3_OPEN_ENTER_EVENT(open_enter);
745 DEFINE_SMB3_OPEN_ENTER_EVENT(posix_mkdir_enter);
746 
747 DECLARE_EVENT_CLASS(smb3_open_err_class,
748 	TP_PROTO(unsigned int xid,
749 		__u32	tid,
750 		__u64	sesid,
751 		int	create_options,
752 		int	desired_access,
753 		int	rc),
754 	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
755 	TP_STRUCT__entry(
756 		__field(unsigned int, xid)
757 		__field(__u32, tid)
758 		__field(__u64, sesid)
759 		__field(int,   create_options)
760 		__field(int, desired_access)
761 		__field(int, rc)
762 	),
763 	TP_fast_assign(
764 		__entry->xid = xid;
765 		__entry->tid = tid;
766 		__entry->sesid = sesid;
767 		__entry->create_options = create_options;
768 		__entry->desired_access = desired_access;
769 		__entry->rc = rc;
770 	),
771 	TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
772 		__entry->xid, __entry->sesid, __entry->tid,
773 		__entry->create_options, __entry->desired_access, __entry->rc)
774 )
775 
776 #define DEFINE_SMB3_OPEN_ERR_EVENT(name)          \
777 DEFINE_EVENT(smb3_open_err_class, smb3_##name,    \
778 	TP_PROTO(unsigned int xid,		\
779 		__u32	tid,			\
780 		__u64	sesid,			\
781 		int	create_options,		\
782 		int	desired_access,		\
783 		int	rc),			\
784 	TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
785 
786 DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
787 DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
788 
789 DECLARE_EVENT_CLASS(smb3_open_done_class,
790 	TP_PROTO(unsigned int xid,
791 		__u64	fid,
792 		__u32	tid,
793 		__u64	sesid,
794 		int	create_options,
795 		int	desired_access),
796 	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
797 	TP_STRUCT__entry(
798 		__field(unsigned int, xid)
799 		__field(__u64, fid)
800 		__field(__u32, tid)
801 		__field(__u64, sesid)
802 		__field(int, create_options)
803 		__field(int, desired_access)
804 	),
805 	TP_fast_assign(
806 		__entry->xid = xid;
807 		__entry->fid = fid;
808 		__entry->tid = tid;
809 		__entry->sesid = sesid;
810 		__entry->create_options = create_options;
811 		__entry->desired_access = desired_access;
812 	),
813 	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
814 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
815 		__entry->create_options, __entry->desired_access)
816 )
817 
818 #define DEFINE_SMB3_OPEN_DONE_EVENT(name)        \
819 DEFINE_EVENT(smb3_open_done_class, smb3_##name,  \
820 	TP_PROTO(unsigned int xid,		\
821 		__u64	fid,			\
822 		__u32	tid,			\
823 		__u64	sesid,			\
824 		int	create_options,		\
825 		int	desired_access),	\
826 	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
827 
828 DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
829 DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
830 
831 
832 DECLARE_EVENT_CLASS(smb3_lease_done_class,
833 	TP_PROTO(__u32	lease_state,
834 		__u32	tid,
835 		__u64	sesid,
836 		__u64	lease_key_low,
837 		__u64	lease_key_high),
838 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high),
839 	TP_STRUCT__entry(
840 		__field(__u32, lease_state)
841 		__field(__u32, tid)
842 		__field(__u64, sesid)
843 		__field(__u64, lease_key_low)
844 		__field(__u64, lease_key_high)
845 	),
846 	TP_fast_assign(
847 		__entry->lease_state = lease_state;
848 		__entry->tid = tid;
849 		__entry->sesid = sesid;
850 		__entry->lease_key_low = lease_key_low;
851 		__entry->lease_key_high = lease_key_high;
852 	),
853 	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x",
854 		__entry->sesid, __entry->tid, __entry->lease_key_high,
855 		__entry->lease_key_low, __entry->lease_state)
856 )
857 
858 #define DEFINE_SMB3_LEASE_DONE_EVENT(name)        \
859 DEFINE_EVENT(smb3_lease_done_class, smb3_##name,  \
860 	TP_PROTO(__u32	lease_state,		\
861 		__u32	tid,			\
862 		__u64	sesid,			\
863 		__u64	lease_key_low,		\
864 		__u64	lease_key_high),	\
865 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high))
866 
867 DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
868 DEFINE_SMB3_LEASE_DONE_EVENT(lease_not_found);
869 
870 DECLARE_EVENT_CLASS(smb3_lease_err_class,
871 	TP_PROTO(__u32	lease_state,
872 		__u32	tid,
873 		__u64	sesid,
874 		__u64	lease_key_low,
875 		__u64	lease_key_high,
876 		int	rc),
877 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc),
878 	TP_STRUCT__entry(
879 		__field(__u32, lease_state)
880 		__field(__u32, tid)
881 		__field(__u64, sesid)
882 		__field(__u64, lease_key_low)
883 		__field(__u64, lease_key_high)
884 		__field(int, rc)
885 	),
886 	TP_fast_assign(
887 		__entry->lease_state = lease_state;
888 		__entry->tid = tid;
889 		__entry->sesid = sesid;
890 		__entry->lease_key_low = lease_key_low;
891 		__entry->lease_key_high = lease_key_high;
892 		__entry->rc = rc;
893 	),
894 	TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x rc=%d",
895 		__entry->sesid, __entry->tid, __entry->lease_key_high,
896 		__entry->lease_key_low, __entry->lease_state, __entry->rc)
897 )
898 
899 #define DEFINE_SMB3_LEASE_ERR_EVENT(name)        \
900 DEFINE_EVENT(smb3_lease_err_class, smb3_##name,  \
901 	TP_PROTO(__u32	lease_state,		\
902 		__u32	tid,			\
903 		__u64	sesid,			\
904 		__u64	lease_key_low,		\
905 		__u64	lease_key_high,		\
906 		int	rc),			\
907 	TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc))
908 
909 DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
910 
911 DECLARE_EVENT_CLASS(smb3_connect_class,
912 	TP_PROTO(char *hostname,
913 		__u64 conn_id,
914 		const struct __kernel_sockaddr_storage *dst_addr),
915 	TP_ARGS(hostname, conn_id, dst_addr),
916 	TP_STRUCT__entry(
917 		__string(hostname, hostname)
918 		__field(__u64, conn_id)
919 		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
920 	),
921 	TP_fast_assign(
922 		struct sockaddr_storage *pss = NULL;
923 
924 		__entry->conn_id = conn_id;
925 		pss = (struct sockaddr_storage *)__entry->dst_addr;
926 		*pss = *dst_addr;
927 		__assign_str(hostname, hostname);
928 	),
929 	TP_printk("conn_id=0x%llx server=%s addr=%pISpsfc",
930 		__entry->conn_id,
931 		__get_str(hostname),
932 		__entry->dst_addr)
933 )
934 
935 #define DEFINE_SMB3_CONNECT_EVENT(name)        \
936 DEFINE_EVENT(smb3_connect_class, smb3_##name,  \
937 	TP_PROTO(char *hostname,		\
938 		__u64 conn_id,			\
939 		const struct __kernel_sockaddr_storage *addr),	\
940 	TP_ARGS(hostname, conn_id, addr))
941 
942 DEFINE_SMB3_CONNECT_EVENT(connect_done);
943 DEFINE_SMB3_CONNECT_EVENT(smbd_connect_done);
944 DEFINE_SMB3_CONNECT_EVENT(smbd_connect_err);
945 
946 DECLARE_EVENT_CLASS(smb3_connect_err_class,
947 	TP_PROTO(char *hostname, __u64 conn_id,
948 		const struct __kernel_sockaddr_storage *dst_addr, int rc),
949 	TP_ARGS(hostname, conn_id, dst_addr, rc),
950 	TP_STRUCT__entry(
951 		__string(hostname, hostname)
952 		__field(__u64, conn_id)
953 		__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
954 		__field(int, rc)
955 	),
956 	TP_fast_assign(
957 		struct sockaddr_storage *pss = NULL;
958 
959 		__entry->conn_id = conn_id;
960 		__entry->rc = rc;
961 		pss = (struct sockaddr_storage *)__entry->dst_addr;
962 		*pss = *dst_addr;
963 		__assign_str(hostname, hostname);
964 	),
965 	TP_printk("rc=%d conn_id=0x%llx server=%s addr=%pISpsfc",
966 		__entry->rc,
967 		__entry->conn_id,
968 		__get_str(hostname),
969 		__entry->dst_addr)
970 )
971 
972 #define DEFINE_SMB3_CONNECT_ERR_EVENT(name)        \
973 DEFINE_EVENT(smb3_connect_err_class, smb3_##name,  \
974 	TP_PROTO(char *hostname,		\
975 		__u64 conn_id,			\
976 		const struct __kernel_sockaddr_storage *addr,	\
977 		int rc),			\
978 	TP_ARGS(hostname, conn_id, addr, rc))
979 
980 DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err);
981 
982 DECLARE_EVENT_CLASS(smb3_reconnect_class,
983 	TP_PROTO(__u64	currmid,
984 		__u64 conn_id,
985 		char *hostname),
986 	TP_ARGS(currmid, conn_id, hostname),
987 	TP_STRUCT__entry(
988 		__field(__u64, currmid)
989 		__field(__u64, conn_id)
990 		__string(hostname, hostname)
991 	),
992 	TP_fast_assign(
993 		__entry->currmid = currmid;
994 		__entry->conn_id = conn_id;
995 		__assign_str(hostname, hostname);
996 	),
997 	TP_printk("conn_id=0x%llx server=%s current_mid=%llu",
998 		__entry->conn_id,
999 		__get_str(hostname),
1000 		__entry->currmid)
1001 )
1002 
1003 #define DEFINE_SMB3_RECONNECT_EVENT(name)        \
1004 DEFINE_EVENT(smb3_reconnect_class, smb3_##name,  \
1005 	TP_PROTO(__u64	currmid,		\
1006 		__u64 conn_id,			\
1007 		char *hostname),				\
1008 	TP_ARGS(currmid, conn_id, hostname))
1009 
1010 DEFINE_SMB3_RECONNECT_EVENT(reconnect);
1011 DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
1012 
1013 DECLARE_EVENT_CLASS(smb3_ses_class,
1014 	TP_PROTO(__u64	sesid),
1015 	TP_ARGS(sesid),
1016 	TP_STRUCT__entry(
1017 		__field(__u64, sesid)
1018 	),
1019 	TP_fast_assign(
1020 		__entry->sesid = sesid;
1021 	),
1022 	TP_printk("sid=0x%llx",
1023 		__entry->sesid)
1024 )
1025 
1026 #define DEFINE_SMB3_SES_EVENT(name)        \
1027 DEFINE_EVENT(smb3_ses_class, smb3_##name,  \
1028 	TP_PROTO(__u64	sesid),				\
1029 	TP_ARGS(sesid))
1030 
1031 DEFINE_SMB3_SES_EVENT(ses_not_found);
1032 
1033 DECLARE_EVENT_CLASS(smb3_credit_class,
1034 	TP_PROTO(__u64	currmid,
1035 		__u64 conn_id,
1036 		char *hostname,
1037 		int credits,
1038 		int credits_to_add,
1039 		int in_flight),
1040 	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight),
1041 	TP_STRUCT__entry(
1042 		__field(__u64, currmid)
1043 		__field(__u64, conn_id)
1044 		__string(hostname, hostname)
1045 		__field(int, credits)
1046 		__field(int, credits_to_add)
1047 		__field(int, in_flight)
1048 	),
1049 	TP_fast_assign(
1050 		__entry->currmid = currmid;
1051 		__entry->conn_id = conn_id;
1052 		__assign_str(hostname, hostname);
1053 		__entry->credits = credits;
1054 		__entry->credits_to_add = credits_to_add;
1055 		__entry->in_flight = in_flight;
1056 	),
1057 	TP_printk("conn_id=0x%llx server=%s current_mid=%llu "
1058 			"credits=%d credit_change=%d in_flight=%d",
1059 		__entry->conn_id,
1060 		__get_str(hostname),
1061 		__entry->currmid,
1062 		__entry->credits,
1063 		__entry->credits_to_add,
1064 		__entry->in_flight)
1065 )
1066 
1067 #define DEFINE_SMB3_CREDIT_EVENT(name)        \
1068 DEFINE_EVENT(smb3_credit_class, smb3_##name,  \
1069 	TP_PROTO(__u64	currmid,		\
1070 		__u64 conn_id,			\
1071 		char *hostname,			\
1072 		int  credits,			\
1073 		int  credits_to_add,	\
1074 		int in_flight),			\
1075 	TP_ARGS(currmid, conn_id, hostname, credits, credits_to_add, in_flight))
1076 
1077 DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
1078 DEFINE_SMB3_CREDIT_EVENT(reconnect_detected);
1079 DEFINE_SMB3_CREDIT_EVENT(credit_timeout);
1080 DEFINE_SMB3_CREDIT_EVENT(insufficient_credits);
1081 DEFINE_SMB3_CREDIT_EVENT(too_many_credits);
1082 DEFINE_SMB3_CREDIT_EVENT(add_credits);
1083 DEFINE_SMB3_CREDIT_EVENT(adj_credits);
1084 DEFINE_SMB3_CREDIT_EVENT(hdr_credits);
1085 DEFINE_SMB3_CREDIT_EVENT(nblk_credits);
1086 DEFINE_SMB3_CREDIT_EVENT(pend_credits);
1087 DEFINE_SMB3_CREDIT_EVENT(wait_credits);
1088 DEFINE_SMB3_CREDIT_EVENT(waitff_credits);
1089 DEFINE_SMB3_CREDIT_EVENT(overflow_credits);
1090 DEFINE_SMB3_CREDIT_EVENT(set_credits);
1091 
1092 #endif /* _CIFS_TRACE_H */
1093 
1094 #undef TRACE_INCLUDE_PATH
1095 #define TRACE_INCLUDE_PATH .
1096 #define TRACE_INCLUDE_FILE trace
1097 #include <trace/define_trace.h>
1098