1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * linux/include/linux/sunrpc/debug.h
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Debugging support for sunrpc module
61da177e4SLinus Torvalds *
71da177e4SLinus Torvalds * Copyright (C) 1996, Olaf Kirch <[email protected]>
81da177e4SLinus Torvalds */
91da177e4SLinus Torvalds #ifndef _LINUX_SUNRPC_DEBUG_H_
101da177e4SLinus Torvalds #define _LINUX_SUNRPC_DEBUG_H_
111da177e4SLinus Torvalds
12e3dd9a52SDavid Howells #include <uapi/linux/sunrpc/debug.h>
131da177e4SLinus Torvalds
141da177e4SLinus Torvalds /*
151da177e4SLinus Torvalds * Debugging macros etc
161da177e4SLinus Torvalds */
17f895b252SJeff Layton #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
181da177e4SLinus Torvalds extern unsigned int rpc_debug;
191da177e4SLinus Torvalds extern unsigned int nfs_debug;
201da177e4SLinus Torvalds extern unsigned int nfsd_debug;
211da177e4SLinus Torvalds extern unsigned int nlm_debug;
221da177e4SLinus Torvalds #endif
231da177e4SLinus Torvalds
24ddeaa637SJoe Perches #define dprintk(fmt, ...) \
25ddeaa637SJoe Perches dfprintk(FACILITY, fmt, ##__VA_ARGS__)
26ddeaa637SJoe Perches #define dprintk_cont(fmt, ...) \
27ddeaa637SJoe Perches dfprintk_cont(FACILITY, fmt, ##__VA_ARGS__)
28ddeaa637SJoe Perches #define dprintk_rcu(fmt, ...) \
29ddeaa637SJoe Perches dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__)
30ddeaa637SJoe Perches #define dprintk_rcu_cont(fmt, ...) \
31ddeaa637SJoe Perches dfprintk_rcu_cont(FACILITY, fmt, ##__VA_ARGS__)
321da177e4SLinus Torvalds
331da177e4SLinus Torvalds #undef ifdebug
34f895b252SJeff Layton #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
351da177e4SLinus Torvalds # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
362446ab60STrond Myklebust
37ddeaa637SJoe Perches # define dfprintk(fac, fmt, ...) \
38dbb9c2a2SChuck Lever do { \
39dbb9c2a2SChuck Lever ifdebug(fac) \
40ddeaa637SJoe Perches printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
41dbb9c2a2SChuck Lever } while (0)
422446ab60STrond Myklebust
43ddeaa637SJoe Perches # define dfprintk_cont(fac, fmt, ...) \
44ddeaa637SJoe Perches do { \
45ddeaa637SJoe Perches ifdebug(fac) \
46ddeaa637SJoe Perches printk(KERN_CONT fmt, ##__VA_ARGS__); \
47ddeaa637SJoe Perches } while (0)
48ddeaa637SJoe Perches
49ddeaa637SJoe Perches # define dfprintk_rcu(fac, fmt, ...) \
502446ab60STrond Myklebust do { \
512446ab60STrond Myklebust ifdebug(fac) { \
522446ab60STrond Myklebust rcu_read_lock(); \
53ddeaa637SJoe Perches printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
54ddeaa637SJoe Perches rcu_read_unlock(); \
55ddeaa637SJoe Perches } \
56ddeaa637SJoe Perches } while (0)
57ddeaa637SJoe Perches
58ddeaa637SJoe Perches # define dfprintk_rcu_cont(fac, fmt, ...) \
59ddeaa637SJoe Perches do { \
60ddeaa637SJoe Perches ifdebug(fac) { \
61ddeaa637SJoe Perches rcu_read_lock(); \
62ddeaa637SJoe Perches printk(KERN_CONT fmt, ##__VA_ARGS__); \
632446ab60STrond Myklebust rcu_read_unlock(); \
642446ab60STrond Myklebust } \
652446ab60STrond Myklebust } while (0)
662446ab60STrond Myklebust
671da177e4SLinus Torvalds # define RPC_IFDEBUG(x) x
681da177e4SLinus Torvalds #else
691da177e4SLinus Torvalds # define ifdebug(fac) if (0)
70ddeaa637SJoe Perches # define dfprintk(fac, fmt, ...) do {} while (0)
71ddeaa637SJoe Perches # define dfprintk_cont(fac, fmt, ...) do {} while (0)
72ddeaa637SJoe Perches # define dfprintk_rcu(fac, fmt, ...) do {} while (0)
731da177e4SLinus Torvalds # define RPC_IFDEBUG(x)
741da177e4SLinus Torvalds #endif
751da177e4SLinus Torvalds
761da177e4SLinus Torvalds /*
771da177e4SLinus Torvalds * Sysctl interface for RPC debugging
781da177e4SLinus Torvalds */
79b4b9d2ccSJeff Layton
80b4b9d2ccSJeff Layton struct rpc_clnt;
81388f0c77SJeff Layton struct rpc_xprt;
82b4b9d2ccSJeff Layton
83f895b252SJeff Layton #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
841da177e4SLinus Torvalds void rpc_register_sysctl(void);
851da177e4SLinus Torvalds void rpc_unregister_sysctl(void);
86f9c72d10SJeff Layton void sunrpc_debugfs_init(void);
87b4b9d2ccSJeff Layton void sunrpc_debugfs_exit(void);
88f9c72d10SJeff Layton void rpc_clnt_debugfs_register(struct rpc_clnt *);
89b4b9d2ccSJeff Layton void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
90f9c72d10SJeff Layton void rpc_xprt_debugfs_register(struct rpc_xprt *);
91388f0c77SJeff Layton void rpc_xprt_debugfs_unregister(struct rpc_xprt *);
92b4b9d2ccSJeff Layton #else
93f9c72d10SJeff Layton static inline void
sunrpc_debugfs_init(void)94b4b9d2ccSJeff Layton sunrpc_debugfs_init(void)
95b4b9d2ccSJeff Layton {
96f9c72d10SJeff Layton return;
97b4b9d2ccSJeff Layton }
98b4b9d2ccSJeff Layton
99b4b9d2ccSJeff Layton static inline void
sunrpc_debugfs_exit(void)100b4b9d2ccSJeff Layton sunrpc_debugfs_exit(void)
101b4b9d2ccSJeff Layton {
102b4b9d2ccSJeff Layton return;
103b4b9d2ccSJeff Layton }
104b4b9d2ccSJeff Layton
105f9c72d10SJeff Layton static inline void
rpc_clnt_debugfs_register(struct rpc_clnt * clnt)106b4b9d2ccSJeff Layton rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
107b4b9d2ccSJeff Layton {
108f9c72d10SJeff Layton return;
109b4b9d2ccSJeff Layton }
110b4b9d2ccSJeff Layton
111b4b9d2ccSJeff Layton static inline void
rpc_clnt_debugfs_unregister(struct rpc_clnt * clnt)112b4b9d2ccSJeff Layton rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
113b4b9d2ccSJeff Layton {
114b4b9d2ccSJeff Layton return;
115b4b9d2ccSJeff Layton }
116388f0c77SJeff Layton
117f9c72d10SJeff Layton static inline void
rpc_xprt_debugfs_register(struct rpc_xprt * xprt)118388f0c77SJeff Layton rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
119388f0c77SJeff Layton {
120f9c72d10SJeff Layton return;
121388f0c77SJeff Layton }
122388f0c77SJeff Layton
123388f0c77SJeff Layton static inline void
rpc_xprt_debugfs_unregister(struct rpc_xprt * xprt)124388f0c77SJeff Layton rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt)
125388f0c77SJeff Layton {
126388f0c77SJeff Layton return;
127388f0c77SJeff Layton }
1281da177e4SLinus Torvalds #endif
1291da177e4SLinus Torvalds
1301da177e4SLinus Torvalds #endif /* _LINUX_SUNRPC_DEBUG_H_ */
131