blob: 3d392620a2f49ec11b75d14358527f3eaec9c7b3 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 *
4 * Copyright (c) International Business Machines Corp., 2000,2002
5 * Modified by Steve French (sfrench@us.ibm.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#ifndef _H_CIFS_DEBUG
9#define _H_CIFS_DEBUG
10
11void cifs_dump_mem(char *label, void *data, int length);
Ronnie Sahlberg14547f72018-04-22 14:45:53 -060012void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
Steve French39798772006-05-31 22:40:51 +000013void cifs_dump_mids(struct TCP_Server_Info *);
Kees Cook14042972016-03-17 14:22:54 -070014extern bool traceSMB; /* flag which enables the function below */
Pavel Shilovsky792af7b2012-03-23 14:28:02 -040015void dump_smb(void *, int);
Steve French1047abc2005-10-11 19:58:06 -070016#define CIFS_INFO 0x01
Steve French13cd4b72010-10-07 18:46:32 +000017#define CIFS_RC 0x02
Steve French1047abc2005-10-11 19:58:06 -070018#define CIFS_TIMER 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Joe Perchesf96637b2013-05-04 22:12:25 -050020#define VFS 1
21#define FYI 2
Joe Perchesbde98192012-12-05 12:42:47 -080022extern int cifsFYI;
Joe Perchesf96637b2013-05-04 22:12:25 -050023#ifdef CONFIG_CIFS_DEBUG2
24#define NOISY 4
25#else
26#define NOISY 0
27#endif
Aurelien Aptelf2f176b2018-04-10 17:01:13 +020028#define ONCE 8
Joe Perchesbde98192012-12-05 12:42:47 -080029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030/*
31 * debug ON
32 * --------
33 */
Joe Perches471b1f92012-12-05 12:42:58 -080034#ifdef CONFIG_CIFS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Steve French8c1beb92018-10-07 13:52:18 -050036
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 Freire9a0efec2018-10-07 12:21:25 -030048/* Information level messages, minor events */
49#define cifs_info_func(ratefunc, fmt, ...) \
50do { \
51 pr_info_ ## ratefunc("CIFS: " fmt, ##__VA_ARGS__); \
52} while (0)
53
54#define cifs_info(fmt, ...) \
55do { \
56 cifs_info_func(ratelimited, fmt, ##__VA_ARGS__); \
57} while (0)
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* information message: e.g., configuration, major event */
Aurelien Aptelf2f176b2018-04-10 17:01:13 +020060#define cifs_dbg_func(ratefunc, type, fmt, ...) \
61do { \
62 if ((type) & FYI && cifsFYI & CIFS_INFO) { \
63 pr_debug_ ## ratefunc("%s: " \
64 fmt, __FILE__, ##__VA_ARGS__); \
65 } else if ((type) & VFS) { \
Aurelien Aptel596632d2018-04-19 10:44:20 +020066 pr_err_ ## ratefunc("CIFS VFS: " \
Aurelien Aptelf2f176b2018-04-10 17:01:13 +020067 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, ...) \
74do { \
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 Perchesb6b38f72010-04-21 03:50:45 +000081} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/*
84 * debug OFF
85 * ---------
86 */
87#else /* _CIFS_DEBUG */
Joe Perchesf96637b2013-05-04 22:12:25 -050088#define cifs_dbg(type, fmt, ...) \
Joe Perchesbde98192012-12-05 12:42:47 -080089do { \
90 if (0) \
Andy Shevchenko0b456f02014-08-27 16:49:44 +030091 pr_debug(fmt, ##__VA_ARGS__); \
Joe Perchesbde98192012-12-05 12:42:47 -080092} while (0)
Rodrigo Freire9a0efec2018-10-07 12:21:25 -030093
94#define cifs_info(fmt, ...) \
95do { \
96 pr_info("CIFS: "fmt, ##__VA_ARGS__); \
97} while (0)
Joe Perchesf96637b2013-05-04 22:12:25 -050098#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100#endif /* _H_CIFS_DEBUG */