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