1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (c) International Business Machines Corp., 2000,2002
5 * Modified by Steve French (sfrench@us.ibm.com)
15 #define pr_fmt(fmt) "CIFS: " fmt
17 void cifs_dump_mem(char *label, void *data, int length);
18 void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
19 void cifs_dump_mids(struct TCP_Server_Info *);
20 extern bool traceSMB; /* flag which enables the function below */
21 void dump_smb(void *, int);
22 #define CIFS_INFO 0x01
24 #define CIFS_TIMER 0x04
29 #ifdef CONFIG_CIFS_DEBUG2
40 #ifdef CONFIG_CIFS_DEBUG
44 * When adding tracepoints and debug messages we have various choices.
45 * Some considerations:
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
54 /* Information level messages, minor events */
55 #define cifs_info_func(ratefunc, fmt, ...) \
56 pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
58 #define cifs_info(fmt, ...) \
59 cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
61 /* information message: e.g., configuration, major event */
62 #define cifs_dbg_func(ratefunc, type, fmt, ...) \
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__); \
74 #define cifs_dbg(type, fmt, ...) \
77 cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \
79 cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \
82 #define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
84 spin_lock(&server->srv_lock); \
85 if ((type) & FYI && cifsFYI & CIFS_INFO) { \
86 pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
87 __FILE__, server->hostname, \
89 } else if ((type) & VFS) { \
90 pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \
91 server->hostname, ##__VA_ARGS__); \
92 } else if ((type) & NOISY && (NOISY != 0)) { \
93 pr_debug_ ## ratefunc("\\\\%s " fmt, \
94 server->hostname, ##__VA_ARGS__); \
96 spin_unlock(&server->srv_lock); \
99 #define cifs_server_dbg(type, fmt, ...) \
102 cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \
104 cifs_server_dbg_func(ratelimited, type, fmt, \
108 #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
110 const char *tn = ""; \
111 if (tcon && tcon->tree_name) \
112 tn = tcon->tree_name; \
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__); \
123 #define cifs_tcon_dbg(type, fmt, ...) \
126 cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
128 cifs_tcon_dbg_func(ratelimited, type, fmt, \
136 #else /* _CIFS_DEBUG */
137 #define cifs_dbg(type, fmt, ...) \
140 pr_debug(fmt, ##__VA_ARGS__); \
143 #define cifs_server_dbg(type, fmt, ...) \
146 pr_debug("\\\\%s " fmt, \
147 server->hostname, ##__VA_ARGS__); \
150 #define cifs_tcon_dbg(type, fmt, ...) \
153 pr_debug("%s " fmt, tcon->tree_name, ##__VA_ARGS__); \
156 #define cifs_info(fmt, ...) \
157 pr_info(fmt, ##__VA_ARGS__)
160 #endif /* _H_CIFS_DEBUG */