]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - fs/cifs/cifs_debug.h
cifs: Standardize logging output
[mirror_ubuntu-jammy-kernel.git] / fs / cifs / cifs_debug.h
CommitLineData
1a59d1b8 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
2/*
3 *
4 * Copyright (c) International Business Machines Corp., 2000,2002
5 * Modified by Steve French (sfrench@us.ibm.com)
1da177e4 6*/
1da177e4
LT
7
8#ifndef _H_CIFS_DEBUG
9#define _H_CIFS_DEBUG
10
a0a3036b
JP
11#ifdef pr_fmt
12#undef pr_fmt
13#endif
14
15#define pr_fmt(fmt) "CIFS: " fmt
16
1da177e4 17void cifs_dump_mem(char *label, void *data, int length);
14547f7d 18void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
3979877e 19void cifs_dump_mids(struct TCP_Server_Info *);
1404297e 20extern bool traceSMB; /* flag which enables the function below */
792af7b0 21void dump_smb(void *, int);
1047abc1 22#define CIFS_INFO 0x01
13cd4b7f 23#define CIFS_RC 0x02
1047abc1 24#define CIFS_TIMER 0x04
1da177e4 25
f96637be
JP
26#define VFS 1
27#define FYI 2
bde98197 28extern int cifsFYI;
f96637be
JP
29#ifdef CONFIG_CIFS_DEBUG2
30#define NOISY 4
31#else
32#define NOISY 0
33#endif
f2f176b4 34#define ONCE 8
bde98197 35
1da177e4
LT
36/*
37 * debug ON
38 * --------
39 */
471b1f98 40#ifdef CONFIG_CIFS_DEBUG
1da177e4 41
8c1beb98
SF
42
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
9a0efecc 54/* Information level messages, minor events */
a0a3036b
JP
55#define cifs_info_func(ratefunc, fmt, ...) \
56 pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
9a0efecc 57
a0a3036b
JP
58#define cifs_info(fmt, ...) \
59 cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
9a0efecc 60
f96637be 61/* information message: e.g., configuration, major event */
a0a3036b
JP
62#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 } \
f2f176b4
AA
72} while (0)
73
a0a3036b
JP
74#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__); \
b6b38f70 80} while (0)
1da177e4 81
a0a3036b
JP
82#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 } \
afe6f653
RS
97} while (0)
98
a0a3036b
JP
99#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__); \
afe6f653
RS
106} while (0)
107
a0a3036b
JP
108#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 } \
3175eb9b
RS
121} while (0)
122
a0a3036b
JP
123#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__); \
3175eb9b
RS
130} while (0)
131
1da177e4
LT
132/*
133 * debug OFF
134 * ---------
135 */
136#else /* _CIFS_DEBUG */
f96637be 137#define cifs_dbg(type, fmt, ...) \
bde98197
JP
138do { \
139 if (0) \
0b456f04 140 pr_debug(fmt, ##__VA_ARGS__); \
bde98197 141} while (0)
9a0efecc 142
afe6f653
RS
143#define cifs_server_dbg(type, fmt, ...) \
144do { \
145 if (0) \
3175eb9b 146 pr_debug("\\\\%s " fmt, \
afe6f653
RS
147 server->hostname, ##__VA_ARGS__); \
148} while (0)
149
3175eb9b
RS
150#define cifs_tcon_dbg(type, fmt, ...) \
151do { \
152 if (0) \
153 pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
154} while (0)
155
9a0efecc 156#define cifs_info(fmt, ...) \
a0a3036b 157 pr_info(fmt, ##__VA_ARGS__)
f96637be 158#endif
1da177e4
LT
159
160#endif /* _H_CIFS_DEBUG */