| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* |
| 4 |
* Copyright (c) International Business Machines Corp., 2000,2002 |
| 5 |
* Modified by Steve French ([email protected]) |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef _H_CIFS_DEBUG |
| 9 |
#define _H_CIFS_DEBUG |
| 10 |
|
| 11 |
#ifdef pr_fmt |
| 12 |
#undef pr_fmt |
| 13 |
#endif |
| 14 |
|
| 15 |
#define pr_fmt(fmt) "CIFS: " fmt |
| 16 |
|
| 17 |
void cifs_dump_mem(char *label, void *data, int length); |
| 18 |
void cifs_dump_mids(struct TCP_Server_Info *server); |
| 19 |
extern bool traceSMB; /* flag which enables the function below */ |
| 20 |
void dump_smb(void *buf, int smb_buf_length); |
| 21 |
#define CIFS_INFO 0x01 |
| 22 |
#define CIFS_RC 0x02 |
| 23 |
#define CIFS_TIMER 0x04 |
| 24 |
|
| 25 |
#define VFS 1 |
| 26 |
#define FYI 2 |
| 27 |
extern int cifsFYI; |
| 28 |
#ifdef CONFIG_CIFS_DEBUG2 |
| 29 |
#define NOISY 4 |
| 30 |
#else |
| 31 |
#define NOISY 0 |
| 32 |
#endif |
| 33 |
#define ONCE 8 |
| 34 |
|
| 35 |
/* |
| 36 |
* debug ON |
| 37 |
* -------- |
| 38 |
*/ |
| 39 |
#ifdef CONFIG_CIFS_DEBUG |
| 40 |
|
| 41 |
|
| 42 |
/* |
| 43 |
* When adding tracepoints and debug messages we have various choices. |
| 44 |
* Some considerations: |
| 45 |
* |
| 46 |
* Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see |
| 47 |
* cifs_info(...) slightly less important, admin can filter via loglevel > 6 |
| 48 |
* cifs_dbg(FYI, ...) minor debugging messages, off by default |
| 49 |
* trace_smb3_* ftrace functions are preferred for complex debug messages |
| 50 |
* intended for developers or experienced admins, off by default |
| 51 |
*/ |
| 52 |
|
| 53 |
/* Information level messages, minor events */ |
| 54 |
#define cifs_info_func(ratefunc, fmt, ...) \ |
| 55 |
pr_info_ ## ratefunc(fmt, ##__VA_ARGS__) |
| 56 |
|
| 57 |
#define cifs_info(fmt, ...) \ |
| 58 |
cifs_info_func(ratelimited, fmt, ##__VA_ARGS__) |
| 59 |
|
| 60 |
/* information message: e.g., configuration, major event */ |
| 61 |
#define cifs_dbg_func(ratefunc, type, fmt, ...) \ |
| 62 |
do { \ |
| 63 |
if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
| 64 |
pr_debug_ ## ratefunc("%s: " fmt, \ |
| 65 |
__FILE__, ##__VA_ARGS__); \ |
| 66 |
} else if ((type) & VFS) { \ |
| 67 |
pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__); \ |
| 68 |
} else if ((type) & NOISY && (NOISY != 0)) { \ |
| 69 |
pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \ |
| 70 |
} \ |
| 71 |
} while (0) |
| 72 |
|
| 73 |
#define cifs_dbg(type, fmt, ...) \ |
| 74 |
do { \ |
| 75 |
if ((type) & ONCE) \ |
| 76 |
cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \ |
| 77 |
else \ |
| 78 |
cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \ |
| 79 |
} while (0) |
| 80 |
|
| 81 |
#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \ |
| 82 |
do { \ |
| 83 |
spin_lock(&server->srv_lock); \ |
| 84 |
if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
| 85 |
pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \ |
| 86 |
__FILE__, server->hostname, \ |
| 87 |
##__VA_ARGS__); \ |
| 88 |
} else if ((type) & VFS) { \ |
| 89 |
pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \ |
| 90 |
server->hostname, ##__VA_ARGS__); \ |
| 91 |
} else if ((type) & NOISY && (NOISY != 0)) { \ |
| 92 |
pr_debug_ ## ratefunc("\\\\%s " fmt, \ |
| 93 |
server->hostname, ##__VA_ARGS__); \ |
| 94 |
} \ |
| 95 |
spin_unlock(&server->srv_lock); \ |
| 96 |
} while (0) |
| 97 |
|
| 98 |
#define cifs_server_dbg(type, fmt, ...) \ |
| 99 |
do { \ |
| 100 |
if ((type) & ONCE) \ |
| 101 |
cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \ |
| 102 |
else \ |
| 103 |
cifs_server_dbg_func(ratelimited, type, fmt, \ |
| 104 |
##__VA_ARGS__); \ |
| 105 |
} while (0) |
| 106 |
|
| 107 |
#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \ |
| 108 |
do { \ |
| 109 |
const char *tn = ""; \ |
| 110 |
if (tcon && tcon->tree_name) \ |
| 111 |
tn = tcon->tree_name; \ |
| 112 |
if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
| 113 |
pr_debug_ ## ratefunc("%s: %s " fmt, \ |
| 114 |
__FILE__, tn, ##__VA_ARGS__); \ |
| 115 |
} else if ((type) & VFS) { \ |
| 116 |
pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \ |
| 117 |
} else if ((type) & NOISY && (NOISY != 0)) { \ |
| 118 |
pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__); \ |
| 119 |
} \ |
| 120 |
} while (0) |
| 121 |
|
| 122 |
#define cifs_tcon_dbg(type, fmt, ...) \ |
| 123 |
do { \ |
| 124 |
if ((type) & ONCE) \ |
| 125 |
cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \ |
| 126 |
else \ |
| 127 |
cifs_tcon_dbg_func(ratelimited, type, fmt, \ |
| 128 |
##__VA_ARGS__); \ |
| 129 |
} while (0) |
| 130 |
|
| 131 |
/* |
| 132 |
* debug OFF |
| 133 |
* --------- |
| 134 |
*/ |
| 135 |
#else /* _CIFS_DEBUG */ |
| 136 |
#define cifs_dbg(type, fmt, ...) \ |
| 137 |
do { \ |
| 138 |
if (0) \ |
| 139 |
pr_debug(fmt, ##__VA_ARGS__); \ |
| 140 |
} while (0) |
| 141 |
|
| 142 |
#define cifs_server_dbg(type, fmt, ...) \ |
| 143 |
do { \ |
| 144 |
if (0) \ |
| 145 |
pr_debug("\\\\%s " fmt, \ |
| 146 |
server->hostname, ##__VA_ARGS__); \ |
| 147 |
} while (0) |
| 148 |
|
| 149 |
#define cifs_tcon_dbg(type, fmt, ...) \ |
| 150 |
do { \ |
| 151 |
if (0) \ |
| 152 |
pr_debug("%s " fmt, tcon->tree_name, ##__VA_ARGS__); \ |
| 153 |
} while (0) |
| 154 |
|
| 155 |
#define cifs_info(fmt, ...) \ |
| 156 |
pr_info(fmt, ##__VA_ARGS__) |
| 157 |
#endif |
| 158 |
|
| 159 |
#endif /* _H_CIFS_DEBUG */ |