blob: ee4ea2b60c0fba8930b9edf62377ea098437b2fa [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 *
4 * Copyright (c) International Business Machines Corp., 2000,2002
5 * Modified by Steve French (sfrench@us.ibm.com)
Steve French929be902021-06-18 00:31:49 -05006 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#ifndef _H_CIFS_DEBUG
9#define _H_CIFS_DEBUG
10
Joe Perchesa0a30362020-04-14 22:42:53 -070011#ifdef pr_fmt
12#undef pr_fmt
13#endif
14
15#define pr_fmt(fmt) "CIFS: " fmt
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017void cifs_dump_mem(char *label, void *data, int length);
Ronnie Sahlberg14547f72018-04-22 14:45:53 -060018void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
Steve French39798772006-05-31 22:40:51 +000019void cifs_dump_mids(struct TCP_Server_Info *);
Kees Cook14042972016-03-17 14:22:54 -070020extern bool traceSMB; /* flag which enables the function below */
Pavel Shilovsky792af7b2012-03-23 14:28:02 -040021void dump_smb(void *, int);
Steve French1047abc2005-10-11 19:58:06 -070022#define CIFS_INFO 0x01
Steve French13cd4b72010-10-07 18:46:32 +000023#define CIFS_RC 0x02
Steve French1047abc2005-10-11 19:58:06 -070024#define CIFS_TIMER 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Joe Perchesf96637b2013-05-04 22:12:25 -050026#define VFS 1
27#define FYI 2
Joe Perchesbde98192012-12-05 12:42:47 -080028extern int cifsFYI;
Joe Perchesf96637b2013-05-04 22:12:25 -050029#ifdef CONFIG_CIFS_DEBUG2
30#define NOISY 4
31#else
32#define NOISY 0
33#endif
Aurelien Aptelf2f176b2018-04-10 17:01:13 +020034#define ONCE 8
Joe Perchesbde98192012-12-05 12:42:47 -080035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/*
37 * debug ON
38 * --------
39 */
Joe Perches471b1f92012-12-05 12:42:58 -080040#ifdef CONFIG_CIFS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Steve French8c1beb92018-10-07 13:52:18 -050042
43/*
44 * When adding tracepoints and debug messages we have various choices.
45 * Some considerations:
46 *
47 * Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see
48 * cifs_info(...) slightly less important, admin can filter via loglevel > 6
49 * cifs_dbg(FYI, ...) minor debugging messages, off by default
50 * trace_smb3_* ftrace functions are preferred for complex debug messages
51 * intended for developers or experienced admins, off by default
52 */
53
Rodrigo Freire9a0efec2018-10-07 12:21:25 -030054/* Information level messages, minor events */
Joe Perchesa0a30362020-04-14 22:42:53 -070055#define cifs_info_func(ratefunc, fmt, ...) \
56 pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
Rodrigo Freire9a0efec2018-10-07 12:21:25 -030057
Joe Perchesa0a30362020-04-14 22:42:53 -070058#define cifs_info(fmt, ...) \
59 cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
Rodrigo Freire9a0efec2018-10-07 12:21:25 -030060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/* information message: e.g., configuration, major event */
Joe Perchesa0a30362020-04-14 22:42:53 -070062#define cifs_dbg_func(ratefunc, type, fmt, ...) \
63do { \
64 if ((type) & FYI && cifsFYI & CIFS_INFO) { \
65 pr_debug_ ## ratefunc("%s: " fmt, \
66 __FILE__, ##__VA_ARGS__); \
67 } else if ((type) & VFS) { \
68 pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__); \
69 } else if ((type) & NOISY && (NOISY != 0)) { \
70 pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
71 } \
Aurelien Aptelf2f176b2018-04-10 17:01:13 +020072} while (0)
73
Joe Perchesa0a30362020-04-14 22:42:53 -070074#define cifs_dbg(type, fmt, ...) \
75do { \
76 if ((type) & ONCE) \
77 cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \
78 else \
79 cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \
Joe Perchesb6b38f72010-04-21 03:50:45 +000080} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Joe Perchesa0a30362020-04-14 22:42:53 -070082#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
83do { \
84 const char *sn = ""; \
85 if (server && server->hostname) \
86 sn = server->hostname; \
87 if ((type) & FYI && cifsFYI & CIFS_INFO) { \
88 pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
89 __FILE__, sn, ##__VA_ARGS__); \
90 } else if ((type) & VFS) { \
91 pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \
92 sn, ##__VA_ARGS__); \
93 } else if ((type) & NOISY && (NOISY != 0)) { \
94 pr_debug_ ## ratefunc("\\\\%s " fmt, \
95 sn, ##__VA_ARGS__); \
96 } \
Ronnie Sahlbergafe6f652019-08-28 17:15:35 +100097} while (0)
98
Joe Perchesa0a30362020-04-14 22:42:53 -070099#define cifs_server_dbg(type, fmt, ...) \
100do { \
101 if ((type) & ONCE) \
102 cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \
103 else \
104 cifs_server_dbg_func(ratelimited, type, fmt, \
105 ##__VA_ARGS__); \
Ronnie Sahlbergafe6f652019-08-28 17:15:35 +1000106} while (0)
107
Joe Perchesa0a30362020-04-14 22:42:53 -0700108#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
109do { \
110 const char *tn = ""; \
111 if (tcon && tcon->treeName) \
112 tn = tcon->treeName; \
113 if ((type) & FYI && cifsFYI & CIFS_INFO) { \
114 pr_debug_ ## ratefunc("%s: %s " fmt, \
115 __FILE__, tn, ##__VA_ARGS__); \
116 } else if ((type) & VFS) { \
117 pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \
118 } else if ((type) & NOISY && (NOISY != 0)) { \
119 pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__); \
120 } \
Ronnie Sahlberg3175eb92019-09-04 12:32:41 +1000121} while (0)
122
Joe Perchesa0a30362020-04-14 22:42:53 -0700123#define cifs_tcon_dbg(type, fmt, ...) \
124do { \
125 if ((type) & ONCE) \
126 cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
127 else \
128 cifs_tcon_dbg_func(ratelimited, type, fmt, \
129 ##__VA_ARGS__); \
Ronnie Sahlberg3175eb92019-09-04 12:32:41 +1000130} while (0)
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/*
133 * debug OFF
134 * ---------
135 */
136#else /* _CIFS_DEBUG */
Joe Perchesf96637b2013-05-04 22:12:25 -0500137#define cifs_dbg(type, fmt, ...) \
Joe Perchesbde98192012-12-05 12:42:47 -0800138do { \
139 if (0) \
Andy Shevchenko0b456f02014-08-27 16:49:44 +0300140 pr_debug(fmt, ##__VA_ARGS__); \
Joe Perchesbde98192012-12-05 12:42:47 -0800141} while (0)
Rodrigo Freire9a0efec2018-10-07 12:21:25 -0300142
Ronnie Sahlbergafe6f652019-08-28 17:15:35 +1000143#define cifs_server_dbg(type, fmt, ...) \
144do { \
145 if (0) \
Ronnie Sahlberg3175eb92019-09-04 12:32:41 +1000146 pr_debug("\\\\%s " fmt, \
Ronnie Sahlbergafe6f652019-08-28 17:15:35 +1000147 server->hostname, ##__VA_ARGS__); \
148} while (0)
149
Ronnie Sahlberg3175eb92019-09-04 12:32:41 +1000150#define cifs_tcon_dbg(type, fmt, ...) \
151do { \
152 if (0) \
153 pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
154} while (0)
155
Rodrigo Freire9a0efec2018-10-07 12:21:25 -0300156#define cifs_info(fmt, ...) \
Joe Perchesa0a30362020-04-14 22:42:53 -0700157 pr_info(fmt, ##__VA_ARGS__)
Joe Perchesf96637b2013-05-04 22:12:25 -0500158#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160#endif /* _H_CIFS_DEBUG */