Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/sunrpc/debug.h |
| 3 | * |
| 4 | * Debugging support for sunrpc module |
| 5 | * |
| 6 | * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #ifndef _LINUX_SUNRPC_DEBUG_H_ |
| 9 | #define _LINUX_SUNRPC_DEBUG_H_ |
| 10 | |
David Howells | e3dd9a5 | 2012-10-09 09:49:04 +0100 | [diff] [blame] | 11 | #include <uapi/linux/sunrpc/debug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | /* |
| 14 | * Debugging macros etc |
| 15 | */ |
Jeff Layton | f895b25 | 2014-11-17 16:58:04 -0500 | [diff] [blame] | 16 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | extern unsigned int rpc_debug; |
| 18 | extern unsigned int nfs_debug; |
| 19 | extern unsigned int nfsd_debug; |
| 20 | extern unsigned int nlm_debug; |
| 21 | #endif |
| 22 | |
| 23 | #define dprintk(args...) dfprintk(FACILITY, ## args) |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 24 | #define dprintk_rcu(args...) dfprintk_rcu(FACILITY, ## args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #undef ifdebug |
Jeff Layton | f895b25 | 2014-11-17 16:58:04 -0500 | [diff] [blame] | 27 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 29 | |
Chuck Lever | dbb9c2a | 2012-02-15 16:35:08 -0500 | [diff] [blame] | 30 | # define dfprintk(fac, args...) \ |
| 31 | do { \ |
| 32 | ifdebug(fac) \ |
| 33 | printk(KERN_DEFAULT args); \ |
| 34 | } while (0) |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 35 | |
| 36 | # define dfprintk_rcu(fac, args...) \ |
| 37 | do { \ |
| 38 | ifdebug(fac) { \ |
| 39 | rcu_read_lock(); \ |
| 40 | printk(KERN_DEFAULT args); \ |
| 41 | rcu_read_unlock(); \ |
| 42 | } \ |
| 43 | } while (0) |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | # define RPC_IFDEBUG(x) x |
| 46 | #else |
| 47 | # define ifdebug(fac) if (0) |
Chuck Lever | b3b536a | 2012-03-20 19:20:53 -0400 | [diff] [blame] | 48 | # define dfprintk(fac, args...) do {} while (0) |
| 49 | # define dfprintk_rcu(fac, args...) do {} while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | # define RPC_IFDEBUG(x) |
| 51 | #endif |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Sysctl interface for RPC debugging |
| 55 | */ |
Jeff Layton | b4b9d2c | 2014-11-26 14:44:43 -0500 | [diff] [blame] | 56 | |
| 57 | struct rpc_clnt; |
Jeff Layton | 388f0c7 | 2014-11-26 14:44:44 -0500 | [diff] [blame] | 58 | struct rpc_xprt; |
Jeff Layton | b4b9d2c | 2014-11-26 14:44:43 -0500 | [diff] [blame] | 59 | |
Jeff Layton | f895b25 | 2014-11-17 16:58:04 -0500 | [diff] [blame] | 60 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | void rpc_register_sysctl(void); |
| 62 | void rpc_unregister_sysctl(void); |
Jeff Layton | b4b9d2c | 2014-11-26 14:44:43 -0500 | [diff] [blame] | 63 | int sunrpc_debugfs_init(void); |
| 64 | void sunrpc_debugfs_exit(void); |
| 65 | int rpc_clnt_debugfs_register(struct rpc_clnt *); |
| 66 | void rpc_clnt_debugfs_unregister(struct rpc_clnt *); |
Jeff Layton | 388f0c7 | 2014-11-26 14:44:44 -0500 | [diff] [blame] | 67 | int rpc_xprt_debugfs_register(struct rpc_xprt *); |
| 68 | void rpc_xprt_debugfs_unregister(struct rpc_xprt *); |
Jeff Layton | b4b9d2c | 2014-11-26 14:44:43 -0500 | [diff] [blame] | 69 | #else |
| 70 | static inline int |
| 71 | sunrpc_debugfs_init(void) |
| 72 | { |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | static inline void |
| 77 | sunrpc_debugfs_exit(void) |
| 78 | { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | static inline int |
| 83 | rpc_clnt_debugfs_register(struct rpc_clnt *clnt) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | static inline void |
| 89 | rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt) |
| 90 | { |
| 91 | return; |
| 92 | } |
Jeff Layton | 388f0c7 | 2014-11-26 14:44:44 -0500 | [diff] [blame] | 93 | |
| 94 | static inline int |
| 95 | rpc_xprt_debugfs_register(struct rpc_xprt *xprt) |
| 96 | { |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | static inline void |
| 101 | rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt) |
| 102 | { |
| 103 | return; |
| 104 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #endif |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | #endif /* _LINUX_SUNRPC_DEBUG_H_ */ |