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 extern unsigned int rpc_debug; 18 extern unsigned int nfs_debug; 19 extern unsigned int nfsd_debug; 20 extern unsigned int nlm_debug; 21 22 #define dprintk(fmt, ...) \ 23 dfprintk(FACILITY, fmt, ##__VA_ARGS__) 24 #define dprintk_rcu(fmt, ...) \ 25 dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__) 26 27 #undef ifdebug 28 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 29 # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) 30 31 # if IS_ENABLED(CONFIG_SUNRPC_DEBUG_TRACE) 32 # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__) 33 # else 34 # define __sunrpc_printk(fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__) 35 # endif 36 37 # define dfprintk(fac, fmt, ...) \ 38 do { \ 39 ifdebug(fac) \ 40 __sunrpc_printk(fmt, ##__VA_ARGS__); \ 41 } while (0) 42 43 # define dfprintk_rcu(fac, fmt, ...) \ 44 do { \ 45 ifdebug(fac) { \ 46 rcu_read_lock(); \ 47 __sunrpc_printk(fmt, ##__VA_ARGS__); \ 48 rcu_read_unlock(); \ 49 } \ 50 } while (0) 51 52 # define RPC_IFDEBUG(x) x 53 #else 54 # define ifdebug(fac) if (0) 55 # define dfprintk(fac, fmt, ...) do {} while (0) 56 # define dfprintk_rcu(fac, fmt, ...) do {} while (0) 57 # define RPC_IFDEBUG(x) 58 #endif 59 60 /* 61 * Sysctl interface for RPC debugging 62 */ 63 64 struct rpc_clnt; 65 struct rpc_xprt; 66 67 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 68 void rpc_register_sysctl(void); 69 void rpc_unregister_sysctl(void); 70 void sunrpc_debugfs_init(void); 71 void sunrpc_debugfs_exit(void); 72 void rpc_clnt_debugfs_register(struct rpc_clnt *); 73 void rpc_clnt_debugfs_unregister(struct rpc_clnt *); 74 void rpc_xprt_debugfs_register(struct rpc_xprt *); 75 void rpc_xprt_debugfs_unregister(struct rpc_xprt *); 76 #else 77 static inline void 78 sunrpc_debugfs_init(void) 79 { 80 return; 81 } 82 83 static inline void 84 sunrpc_debugfs_exit(void) 85 { 86 return; 87 } 88 89 static inline void 90 rpc_clnt_debugfs_register(struct rpc_clnt *clnt) 91 { 92 return; 93 } 94 95 static inline void 96 rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt) 97 { 98 return; 99 } 100 101 static inline void 102 rpc_xprt_debugfs_register(struct rpc_xprt *xprt) 103 { 104 return; 105 } 106 107 static inline void 108 rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt) 109 { 110 return; 111 } 112 #endif 113 114 #endif /* _LINUX_SUNRPC_DEBUG_H_ */ 115