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