Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *
0004  *   Copyright (c) International Business Machines  Corp., 2000,2002
0005  *   Modified by Steve French (sfrench@us.ibm.com)
0006  */
0007 
0008 #ifndef _H_CIFS_DEBUG
0009 #define _H_CIFS_DEBUG
0010 
0011 #ifdef pr_fmt
0012 #undef pr_fmt
0013 #endif
0014 
0015 #define pr_fmt(fmt) "CIFS: " fmt
0016 
0017 void cifs_dump_mem(char *label, void *data, int length);
0018 void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
0019 void cifs_dump_mids(struct TCP_Server_Info *);
0020 extern bool traceSMB;       /* flag which enables the function below */
0021 void dump_smb(void *, int);
0022 #define CIFS_INFO   0x01
0023 #define CIFS_RC     0x02
0024 #define CIFS_TIMER  0x04
0025 
0026 #define VFS 1
0027 #define FYI 2
0028 extern int cifsFYI;
0029 #ifdef CONFIG_CIFS_DEBUG2
0030 #define NOISY 4
0031 #else
0032 #define NOISY 0
0033 #endif
0034 #define ONCE 8
0035 
0036 /*
0037  *  debug ON
0038  *  --------
0039  */
0040 #ifdef CONFIG_CIFS_DEBUG
0041 
0042 
0043 /*
0044  * When adding tracepoints and debug messages we have various choices.
0045  * Some considerations:
0046  *
0047  * Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see
0048  *     cifs_info(...) slightly less important, admin can filter via loglevel > 6
0049  *     cifs_dbg(FYI, ...) minor debugging messages, off by default
0050  *     trace_smb3_*  ftrace functions are preferred for complex debug messages
0051  *                 intended for developers or experienced admins, off by default
0052  */
0053 
0054 /* Information level messages, minor events */
0055 #define cifs_info_func(ratefunc, fmt, ...)              \
0056     pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
0057 
0058 #define cifs_info(fmt, ...)                     \
0059     cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
0060 
0061 /* information message: e.g., configuration, major event */
0062 #define cifs_dbg_func(ratefunc, type, fmt, ...)             \
0063 do {                                    \
0064     if ((type) & FYI && cifsFYI & CIFS_INFO) {          \
0065         pr_debug_ ## ratefunc("%s: " fmt,           \
0066                       __FILE__, ##__VA_ARGS__);     \
0067     } else if ((type) & VFS) {                  \
0068         pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__);    \
0069     } else if ((type) & NOISY && (NOISY != 0)) {            \
0070         pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__);      \
0071     }                               \
0072 } while (0)
0073 
0074 #define cifs_dbg(type, fmt, ...)                    \
0075 do {                                    \
0076     if ((type) & ONCE)                      \
0077         cifs_dbg_func(once, type, fmt, ##__VA_ARGS__);      \
0078     else                                \
0079         cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__);   \
0080 } while (0)
0081 
0082 #define cifs_server_dbg_func(ratefunc, type, fmt, ...)          \
0083 do {                                    \
0084     const char *sn = "";                        \
0085     if (server && server->hostname)                 \
0086         sn = server->hostname;                  \
0087     if ((type) & FYI && cifsFYI & CIFS_INFO) {          \
0088         pr_debug_ ## ratefunc("%s: \\\\%s " fmt,        \
0089                       __FILE__, sn, ##__VA_ARGS__); \
0090     } else if ((type) & VFS) {                  \
0091         pr_err_ ## ratefunc("VFS: \\\\%s " fmt,         \
0092                     sn, ##__VA_ARGS__);         \
0093     } else if ((type) & NOISY && (NOISY != 0)) {            \
0094         pr_debug_ ## ratefunc("\\\\%s " fmt,            \
0095                       sn, ##__VA_ARGS__);       \
0096     }                               \
0097 } while (0)
0098 
0099 #define cifs_server_dbg(type, fmt, ...)                 \
0100 do {                                    \
0101     if ((type) & ONCE)                      \
0102         cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__);   \
0103     else                                \
0104         cifs_server_dbg_func(ratelimited, type, fmt,        \
0105                      ##__VA_ARGS__);            \
0106 } while (0)
0107 
0108 #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...)            \
0109 do {                                    \
0110     const char *tn = "";                        \
0111     if (tcon && tcon->treeName)                 \
0112         tn = tcon->treeName;                    \
0113     if ((type) & FYI && cifsFYI & CIFS_INFO) {          \
0114         pr_debug_ ## ratefunc("%s: %s " fmt,            \
0115                       __FILE__, tn, ##__VA_ARGS__); \
0116     } else if ((type) & VFS) {                  \
0117         pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \
0118     } else if ((type) & NOISY && (NOISY != 0)) {            \
0119         pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__);    \
0120     }                               \
0121 } while (0)
0122 
0123 #define cifs_tcon_dbg(type, fmt, ...)                   \
0124 do {                                    \
0125     if ((type) & ONCE)                      \
0126         cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
0127     else                                \
0128         cifs_tcon_dbg_func(ratelimited, type, fmt,      \
0129                    ##__VA_ARGS__);          \
0130 } while (0)
0131 
0132 /*
0133  *  debug OFF
0134  *  ---------
0135  */
0136 #else       /* _CIFS_DEBUG */
0137 #define cifs_dbg(type, fmt, ...)                    \
0138 do {                                    \
0139     if (0)                              \
0140         pr_debug(fmt, ##__VA_ARGS__);               \
0141 } while (0)
0142 
0143 #define cifs_server_dbg(type, fmt, ...)                 \
0144 do {                                    \
0145     if (0)                              \
0146         pr_debug("\\\\%s " fmt,                 \
0147              server->hostname, ##__VA_ARGS__);      \
0148 } while (0)
0149 
0150 #define cifs_tcon_dbg(type, fmt, ...)                   \
0151 do {                                    \
0152     if (0)                              \
0153         pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
0154 } while (0)
0155 
0156 #define cifs_info(fmt, ...)                     \
0157     pr_info(fmt, ##__VA_ARGS__)
0158 #endif
0159 
0160 #endif              /* _H_CIFS_DEBUG */