Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * Copyright (c) International Business Machines Corp., 2000,2002 |
| 5 | * Modified by Steve French (sfrench@us.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | #ifndef _H_CIFS_DEBUG |
| 9 | #define _H_CIFS_DEBUG |
| 10 | |
| 11 | void cifs_dump_mem(char *label, void *data, int length); |
Ronnie Sahlberg | 14547f7 | 2018-04-22 14:45:53 -0600 | [diff] [blame] | 12 | void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 13 | void cifs_dump_mids(struct TCP_Server_Info *); |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 14 | extern bool traceSMB; /* flag which enables the function below */ |
Pavel Shilovsky | 792af7b | 2012-03-23 14:28:02 -0400 | [diff] [blame] | 15 | void dump_smb(void *, int); |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 16 | #define CIFS_INFO 0x01 |
Steve French | 13cd4b7 | 2010-10-07 18:46:32 +0000 | [diff] [blame] | 17 | #define CIFS_RC 0x02 |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 18 | #define CIFS_TIMER 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 20 | #define VFS 1 |
| 21 | #define FYI 2 |
Joe Perches | bde9819 | 2012-12-05 12:42:47 -0800 | [diff] [blame] | 22 | extern int cifsFYI; |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 23 | #ifdef CONFIG_CIFS_DEBUG2 |
| 24 | #define NOISY 4 |
| 25 | #else |
| 26 | #define NOISY 0 |
| 27 | #endif |
Aurelien Aptel | f2f176b | 2018-04-10 17:01:13 +0200 | [diff] [blame] | 28 | #define ONCE 8 |
Joe Perches | bde9819 | 2012-12-05 12:42:47 -0800 | [diff] [blame] | 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | /* |
| 31 | * debug ON |
| 32 | * -------- |
| 33 | */ |
Joe Perches | 471b1f9 | 2012-12-05 12:42:58 -0800 | [diff] [blame] | 34 | #ifdef CONFIG_CIFS_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Steve French | 8c1beb9 | 2018-10-07 13:52:18 -0500 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * When adding tracepoints and debug messages we have various choices. |
| 39 | * Some considerations: |
| 40 | * |
| 41 | * Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see |
| 42 | * cifs_info(...) slightly less important, admin can filter via loglevel > 6 |
| 43 | * cifs_dbg(FYI, ...) minor debugging messages, off by default |
| 44 | * trace_smb3_* ftrace functions are preferred for complex debug messages |
| 45 | * intended for developers or experienced admins, off by default |
| 46 | */ |
| 47 | |
Rodrigo Freire | 9a0efec | 2018-10-07 12:21:25 -0300 | [diff] [blame] | 48 | /* Information level messages, minor events */ |
| 49 | #define cifs_info_func(ratefunc, fmt, ...) \ |
| 50 | do { \ |
| 51 | pr_info_ ## ratefunc("CIFS: " fmt, ##__VA_ARGS__); \ |
| 52 | } while (0) |
| 53 | |
| 54 | #define cifs_info(fmt, ...) \ |
| 55 | do { \ |
| 56 | cifs_info_func(ratelimited, fmt, ##__VA_ARGS__); \ |
| 57 | } while (0) |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /* information message: e.g., configuration, major event */ |
Aurelien Aptel | f2f176b | 2018-04-10 17:01:13 +0200 | [diff] [blame] | 60 | #define cifs_dbg_func(ratefunc, type, fmt, ...) \ |
| 61 | do { \ |
| 62 | if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
| 63 | pr_debug_ ## ratefunc("%s: " \ |
| 64 | fmt, __FILE__, ##__VA_ARGS__); \ |
| 65 | } else if ((type) & VFS) { \ |
Aurelien Aptel | 596632d | 2018-04-19 10:44:20 +0200 | [diff] [blame] | 66 | pr_err_ ## ratefunc("CIFS VFS: " \ |
Aurelien Aptel | f2f176b | 2018-04-10 17:01:13 +0200 | [diff] [blame] | 67 | 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, \ |
| 77 | type, fmt, ##__VA_ARGS__); \ |
| 78 | else \ |
| 79 | cifs_dbg_func(ratelimited, \ |
| 80 | type, fmt, ##__VA_ARGS__); \ |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 81 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 83 | #define cifs_server_dbg_func(ratefunc, type, fmt, ...) \ |
| 84 | do { \ |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 85 | const char *sn = ""; \ |
| 86 | if (server && server->hostname) \ |
| 87 | sn = server->hostname; \ |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 88 | if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 89 | pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \ |
| 90 | __FILE__, sn, ##__VA_ARGS__); \ |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 91 | } else if ((type) & VFS) { \ |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 92 | pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt, \ |
| 93 | sn, ##__VA_ARGS__); \ |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 94 | } else if ((type) & NOISY && (NOISY != 0)) { \ |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 95 | pr_debug_ ## ratefunc("\\\\%s " fmt, \ |
| 96 | sn, ##__VA_ARGS__); \ |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 97 | } \ |
| 98 | } while (0) |
| 99 | |
| 100 | #define cifs_server_dbg(type, fmt, ...) \ |
| 101 | do { \ |
| 102 | if ((type) & ONCE) \ |
| 103 | cifs_server_dbg_func(once, \ |
| 104 | type, fmt, ##__VA_ARGS__); \ |
| 105 | else \ |
| 106 | cifs_server_dbg_func(ratelimited, \ |
| 107 | type, fmt, ##__VA_ARGS__); \ |
| 108 | } while (0) |
| 109 | |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 110 | #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \ |
| 111 | do { \ |
| 112 | const char *tn = ""; \ |
| 113 | if (tcon && tcon->treeName) \ |
| 114 | tn = tcon->treeName; \ |
| 115 | if ((type) & FYI && cifsFYI & CIFS_INFO) { \ |
| 116 | pr_debug_ ## ratefunc("%s: %s " fmt, \ |
| 117 | __FILE__, tn, ##__VA_ARGS__); \ |
| 118 | } else if ((type) & VFS) { \ |
| 119 | pr_err_ ## ratefunc("CIFS VFS: %s " fmt, \ |
| 120 | tn, ##__VA_ARGS__); \ |
| 121 | } else if ((type) & NOISY && (NOISY != 0)) { \ |
| 122 | pr_debug_ ## ratefunc("%s " fmt, \ |
| 123 | tn, ##__VA_ARGS__); \ |
| 124 | } \ |
| 125 | } while (0) |
| 126 | |
| 127 | #define cifs_tcon_dbg(type, fmt, ...) \ |
| 128 | do { \ |
| 129 | if ((type) & ONCE) \ |
| 130 | cifs_tcon_dbg_func(once, \ |
| 131 | type, fmt, ##__VA_ARGS__); \ |
| 132 | else \ |
| 133 | cifs_tcon_dbg_func(ratelimited, \ |
| 134 | type, fmt, ##__VA_ARGS__); \ |
| 135 | } while (0) |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | /* |
| 138 | * debug OFF |
| 139 | * --------- |
| 140 | */ |
| 141 | #else /* _CIFS_DEBUG */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 142 | #define cifs_dbg(type, fmt, ...) \ |
Joe Perches | bde9819 | 2012-12-05 12:42:47 -0800 | [diff] [blame] | 143 | do { \ |
| 144 | if (0) \ |
Andy Shevchenko | 0b456f0 | 2014-08-27 16:49:44 +0300 | [diff] [blame] | 145 | pr_debug(fmt, ##__VA_ARGS__); \ |
Joe Perches | bde9819 | 2012-12-05 12:42:47 -0800 | [diff] [blame] | 146 | } while (0) |
Rodrigo Freire | 9a0efec | 2018-10-07 12:21:25 -0300 | [diff] [blame] | 147 | |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 148 | #define cifs_server_dbg(type, fmt, ...) \ |
| 149 | do { \ |
| 150 | if (0) \ |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 151 | pr_debug("\\\\%s " fmt, \ |
Ronnie Sahlberg | afe6f65 | 2019-08-28 17:15:35 +1000 | [diff] [blame] | 152 | server->hostname, ##__VA_ARGS__); \ |
| 153 | } while (0) |
| 154 | |
Ronnie Sahlberg | 3175eb9 | 2019-09-04 12:32:41 +1000 | [diff] [blame] | 155 | #define cifs_tcon_dbg(type, fmt, ...) \ |
| 156 | do { \ |
| 157 | if (0) \ |
| 158 | pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \ |
| 159 | } while (0) |
| 160 | |
Rodrigo Freire | 9a0efec | 2018-10-07 12:21:25 -0300 | [diff] [blame] | 161 | #define cifs_info(fmt, ...) \ |
| 162 | do { \ |
| 163 | pr_info("CIFS: "fmt, ##__VA_ARGS__); \ |
| 164 | } while (0) |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 165 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
| 167 | #endif /* _H_CIFS_DEBUG */ |