xref: /linux/fs/orangefs/orangefs-debug.h (revision 296200d3bb649f9646f60abe6e8ebb9fd8d20f4b)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2575e9461SMike Marshall /*
3575e9461SMike Marshall  * (C) 2001 Clemson University and The University of Chicago
4575e9461SMike Marshall  *
5575e9461SMike Marshall  * See COPYING in top-level directory.
6575e9461SMike Marshall  */
7575e9461SMike Marshall 
8575e9461SMike Marshall /* This file just defines debugging masks to be used with the gossip
9575e9461SMike Marshall  * logging utility.  All debugging masks for ORANGEFS are kept here to make
10575e9461SMike Marshall  * sure we don't have collisions.
11575e9461SMike Marshall  */
12575e9461SMike Marshall 
13575e9461SMike Marshall #ifndef __ORANGEFS_DEBUG_H
14575e9461SMike Marshall #define __ORANGEFS_DEBUG_H
15575e9461SMike Marshall 
16575e9461SMike Marshall #ifdef __KERNEL__
17575e9461SMike Marshall #include <linux/types.h>
18*296200d3SJérémy Lefaure #include <linux/kernel.h>
19575e9461SMike Marshall #else
20575e9461SMike Marshall #include <stdint.h>
21*296200d3SJérémy Lefaure #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
22575e9461SMike Marshall #endif
23575e9461SMike Marshall 
24575e9461SMike Marshall #define	GOSSIP_NO_DEBUG			(__u64)0
25575e9461SMike Marshall 
26575e9461SMike Marshall #define GOSSIP_SUPER_DEBUG		((__u64)1 << 0)
27575e9461SMike Marshall #define GOSSIP_INODE_DEBUG		((__u64)1 << 1)
28575e9461SMike Marshall #define GOSSIP_FILE_DEBUG		((__u64)1 << 2)
29575e9461SMike Marshall #define GOSSIP_DIR_DEBUG		((__u64)1 << 3)
30575e9461SMike Marshall #define GOSSIP_UTILS_DEBUG		((__u64)1 << 4)
31575e9461SMike Marshall #define GOSSIP_WAIT_DEBUG		((__u64)1 << 5)
32575e9461SMike Marshall #define GOSSIP_ACL_DEBUG		((__u64)1 << 6)
33575e9461SMike Marshall #define GOSSIP_DCACHE_DEBUG		((__u64)1 << 7)
34575e9461SMike Marshall #define GOSSIP_DEV_DEBUG		((__u64)1 << 8)
35575e9461SMike Marshall #define GOSSIP_NAME_DEBUG		((__u64)1 << 9)
36575e9461SMike Marshall #define GOSSIP_BUFMAP_DEBUG		((__u64)1 << 10)
37575e9461SMike Marshall #define GOSSIP_CACHE_DEBUG		((__u64)1 << 11)
38575e9461SMike Marshall #define GOSSIP_DEBUGFS_DEBUG		((__u64)1 << 12)
39575e9461SMike Marshall #define GOSSIP_XATTR_DEBUG		((__u64)1 << 13)
40575e9461SMike Marshall #define GOSSIP_INIT_DEBUG		((__u64)1 << 14)
41575e9461SMike Marshall #define GOSSIP_SYSFS_DEBUG		((__u64)1 << 15)
42575e9461SMike Marshall 
43575e9461SMike Marshall #define GOSSIP_MAX_NR                 16
44575e9461SMike Marshall #define GOSSIP_MAX_DEBUG              (((__u64)1 << GOSSIP_MAX_NR) - 1)
45575e9461SMike Marshall 
46575e9461SMike Marshall /*function prototypes*/
47575e9461SMike Marshall __u64 ORANGEFS_kmod_eventlog_to_mask(const char *event_logging);
48575e9461SMike Marshall __u64 ORANGEFS_debug_eventlog_to_mask(const char *event_logging);
49575e9461SMike Marshall char *ORANGEFS_debug_mask_to_eventlog(__u64 mask);
50575e9461SMike Marshall char *ORANGEFS_kmod_mask_to_eventlog(__u64 mask);
51575e9461SMike Marshall 
52575e9461SMike Marshall /* a private internal type */
53575e9461SMike Marshall struct __keyword_mask_s {
54575e9461SMike Marshall 	const char *keyword;
55575e9461SMike Marshall 	__u64 mask_val;
56575e9461SMike Marshall };
57575e9461SMike Marshall 
58575e9461SMike Marshall /*
59575e9461SMike Marshall  * Map all kmod keywords to kmod debug masks here. Keep this
60575e9461SMike Marshall  * structure "packed":
61575e9461SMike Marshall  *
62575e9461SMike Marshall  *   "all" is always last...
63575e9461SMike Marshall  *
64575e9461SMike Marshall  *   keyword     mask_val     index
65575e9461SMike Marshall  *     foo          1           0
66575e9461SMike Marshall  *     bar          2           1
67575e9461SMike Marshall  *     baz          4           2
68575e9461SMike Marshall  *     qux          8           3
69575e9461SMike Marshall  *      .           .           .
70575e9461SMike Marshall  */
71575e9461SMike Marshall static struct __keyword_mask_s s_kmod_keyword_mask_map[] = {
72575e9461SMike Marshall 	{"super", GOSSIP_SUPER_DEBUG},
73575e9461SMike Marshall 	{"inode", GOSSIP_INODE_DEBUG},
74575e9461SMike Marshall 	{"file", GOSSIP_FILE_DEBUG},
75575e9461SMike Marshall 	{"dir", GOSSIP_DIR_DEBUG},
76575e9461SMike Marshall 	{"utils", GOSSIP_UTILS_DEBUG},
77575e9461SMike Marshall 	{"wait", GOSSIP_WAIT_DEBUG},
78575e9461SMike Marshall 	{"acl", GOSSIP_ACL_DEBUG},
79575e9461SMike Marshall 	{"dcache", GOSSIP_DCACHE_DEBUG},
80575e9461SMike Marshall 	{"dev", GOSSIP_DEV_DEBUG},
81575e9461SMike Marshall 	{"name", GOSSIP_NAME_DEBUG},
82575e9461SMike Marshall 	{"bufmap", GOSSIP_BUFMAP_DEBUG},
83575e9461SMike Marshall 	{"cache", GOSSIP_CACHE_DEBUG},
84575e9461SMike Marshall 	{"debugfs", GOSSIP_DEBUGFS_DEBUG},
85575e9461SMike Marshall 	{"xattr", GOSSIP_XATTR_DEBUG},
86575e9461SMike Marshall 	{"init", GOSSIP_INIT_DEBUG},
87575e9461SMike Marshall 	{"sysfs", GOSSIP_SYSFS_DEBUG},
88575e9461SMike Marshall 	{"none", GOSSIP_NO_DEBUG},
89575e9461SMike Marshall 	{"all", GOSSIP_MAX_DEBUG}
90575e9461SMike Marshall };
91575e9461SMike Marshall 
92575e9461SMike Marshall static const int num_kmod_keyword_mask_map = (int)
93*296200d3SJérémy Lefaure 	(ARRAY_SIZE(s_kmod_keyword_mask_map));
94575e9461SMike Marshall 
95575e9461SMike Marshall #endif /* __ORANGEFS_DEBUG_H */
96