1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * linux/include/linux/sunrpc/debug.h
4 *
5 * Debugging support for sunrpc module
6 *
7 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
8 */
9 #ifndef _LINUX_SUNRPC_DEBUG_H_
10 #define _LINUX_SUNRPC_DEBUG_H_
11
12 #include <uapi/linux/sunrpc/debug.h>
13
14 /*
15 * Debugging macros etc
16 */
17 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
18 extern unsigned int rpc_debug;
19 extern unsigned int nfs_debug;
20 extern unsigned int nfsd_debug;
21 extern unsigned int nlm_debug;
22 #endif
23
24 #define dprintk(fmt, ...) \
25 dfprintk(FACILITY, fmt, ##__VA_ARGS__)
26 #define dprintk_rcu(fmt, ...) \
27 dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__)
28
29 #undef ifdebug
30 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
31 # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
32
33 # if IS_ENABLED(CONFIG_SUNRPC_DEBUG_TRACE)
34 # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__)
35 # else
36 # define __sunrpc_printk(fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__)
37 # endif
38
39 # define dfprintk(fac, fmt, ...) \
40 do { \
41 ifdebug(fac) \
42 __sunrpc_printk(fmt, ##__VA_ARGS__); \
43 } while (0)
44
45 # define dfprintk_rcu(fac, fmt, ...) \
46 do { \
47 ifdebug(fac) { \
48 rcu_read_lock(); \
49 __sunrpc_printk(fmt, ##__VA_ARGS__); \
50 rcu_read_unlock(); \
51 } \
52 } while (0)
53
54 # define RPC_IFDEBUG(x) x
55 #else
56 # define ifdebug(fac) if (0)
57 # define dfprintk(fac, fmt, ...) do {} while (0)
58 # define dfprintk_rcu(fac, fmt, ...) do {} while (0)
59 # define RPC_IFDEBUG(x)
60 #endif
61
62 /*
63 * Sysctl interface for RPC debugging
64 */
65
66 struct rpc_clnt;
67 struct rpc_xprt;
68
69 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
70 void rpc_register_sysctl(void);
71 void rpc_unregister_sysctl(void);
72 void sunrpc_debugfs_init(void);
73 void sunrpc_debugfs_exit(void);
74 void rpc_clnt_debugfs_register(struct rpc_clnt *);
75 void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
76 void rpc_xprt_debugfs_register(struct rpc_xprt *);
77 void rpc_xprt_debugfs_unregister(struct rpc_xprt *);
78 #else
79 static inline void
sunrpc_debugfs_init(void)80 sunrpc_debugfs_init(void)
81 {
82 return;
83 }
84
85 static inline void
sunrpc_debugfs_exit(void)86 sunrpc_debugfs_exit(void)
87 {
88 return;
89 }
90
91 static inline void
rpc_clnt_debugfs_register(struct rpc_clnt * clnt)92 rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
93 {
94 return;
95 }
96
97 static inline void
rpc_clnt_debugfs_unregister(struct rpc_clnt * clnt)98 rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
99 {
100 return;
101 }
102
103 static inline void
rpc_xprt_debugfs_register(struct rpc_xprt * xprt)104 rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
105 {
106 return;
107 }
108
109 static inline void
rpc_xprt_debugfs_unregister(struct rpc_xprt * xprt)110 rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt)
111 {
112 return;
113 }
114 #endif
115
116 #endif /* _LINUX_SUNRPC_DEBUG_H_ */
117