1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
10 # include <asm/types.h>
11 # if defined(__powerpc__) && !defined(__KERNEL__)
13 # include <asm/timex.h>
16 # include <asm/timex.h>
19 # include <sys/types.h>
20 typedef u_int32_t __u32;
21 typedef u_int64_t __u64;
25 # include <linux/time.h>
27 # include <sys/time.h>
28 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
32 # define offsetof(typ,memb) ((int)((char *)&(((typ *)0)->memb)))
35 #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
40 extern unsigned int portal_subsystem_debug;
41 extern unsigned int portal_stack;
42 extern unsigned int portal_debug;
43 extern unsigned int portal_printk;
44 extern unsigned int portal_cerror;
45 /* Debugging subsystems (32 bits, non-overlapping) */
46 #define S_UNDEFINED 0x00000001
47 #define S_MDC 0x00000002
48 #define S_MDS 0x00000004
49 #define S_OSC 0x00000008
50 #define S_OST 0x00000010
51 #define S_CLASS 0x00000020
52 #define S_LOG 0x00000040
53 #define S_LLITE 0x00000080
54 #define S_RPC 0x00000100
55 #define S_MGMT 0x00000200
56 #define S_PORTALS 0x00000400
57 #define S_SOCKNAL 0x00000800
58 #define S_QSWNAL 0x00001000
59 #define S_PINGER 0x00002000
60 #define S_FILTER 0x00004000
61 #define S_PTLBD 0x00008000
62 #define S_ECHO 0x00010000
63 #define S_LDLM 0x00020000
64 #define S_LOV 0x00040000
65 #define S_GMNAL 0x00080000
66 #define S_PTLROUTER 0x00100000
67 #define S_COBD 0x00200000
68 #define S_IBNAL 0x00400000
70 /* If you change these values, please keep portals/utils/debug.c
73 /* Debugging masks (32 bits, non-overlapping) */
74 #define D_TRACE 0x00000001 /* ENTRY/EXIT markers */
75 #define D_INODE 0x00000002
76 #define D_SUPER 0x00000004
77 #define D_EXT2 0x00000008 /* anything from ext2_debug */
78 #define D_MALLOC 0x00000010 /* print malloc, free information */
79 #define D_CACHE 0x00000020 /* cache-related items */
80 #define D_INFO 0x00000040 /* general information */
81 #define D_IOCTL 0x00000080 /* ioctl related information */
82 #define D_BLOCKS 0x00000100 /* ext2 block allocation */
83 #define D_NET 0x00000200 /* network communications */
84 #define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
85 #define D_BUFFS 0x00000800
86 #define D_OTHER 0x00001000
87 #define D_DENTRY 0x00002000
88 #define D_PORTALS 0x00004000 /* ENTRY/EXIT markers */
89 #define D_PAGE 0x00008000 /* bulk page handling */
90 #define D_DLMTRACE 0x00010000
91 #define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
92 #define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
93 #define D_HA 0x00080000 /* recovery and failover */
94 #define D_RPCTRACE 0x00100000 /* for distributed debugging */
95 #define D_VFSTRACE 0x00200000
96 #define D_READA 0x00400000 /* read-ahead */
99 # include <linux/sched.h> /* THREAD_SIZE */
101 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
102 # define THREAD_SIZE 8192
106 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
110 # define CDEBUG_STACK (THREAD_SIZE - \
111 ((unsigned long)__builtin_dwarf_cfa() & \
114 # define CDEBUG_STACK (THREAD_SIZE - \
115 ((unsigned long)__builtin_frame_address(0) & \
119 #define CHECK_STACK(stack) \
121 if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \
122 portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \
123 __FILE__, __FUNCTION__, __LINE__, \
124 (stack),"maximum lustre stack %u\n",\
125 portal_stack = (stack)); \
129 #else /* __KERNEL__ */
130 #define CHECK_STACK(stack) do { } while(0)
131 #define CDEBUG_STACK (0L)
132 #endif /* __KERNEL__ */
135 #define CDEBUG(mask, format, a...) \
137 if (portal_cerror == 0) \
139 CHECK_STACK(CDEBUG_STACK); \
140 if (((mask) & (D_ERROR | D_EMERG | D_WARNING)) || \
141 (portal_debug & (mask) && \
142 portal_subsystem_debug & DEBUG_SUBSYSTEM)) \
143 portals_debug_msg(DEBUG_SUBSYSTEM, mask, \
144 __FILE__, __FUNCTION__, __LINE__, \
145 CDEBUG_STACK, format, ## a); \
148 #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
149 #define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
150 #define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a)
152 #define GOTO(label, rc) \
154 long GOTO__ret = (long)(rc); \
155 CDEBUG(D_TRACE,"Process leaving via %s (rc=%lu : %ld : %lx)\n", \
156 #label, (unsigned long)GOTO__ret, (signed long)GOTO__ret,\
157 (signed long)GOTO__ret); \
163 typeof(rc) RETURN__ret = (rc); \
164 CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \
165 (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\
166 return RETURN__ret; \
171 CDEBUG(D_TRACE, "Process entered\n"); \
176 CDEBUG(D_TRACE, "Process leaving\n"); \
179 #define CDEBUG(mask, format, a...) do { } while (0)
180 #define CWARN(format, a...) do { } while (0)
181 #define CERROR(format, a...) printk("<3>" format, ## a)
182 #define CEMERG(format, a...) printk("<0>" format, ## a)
183 #define GOTO(label, rc) do { (void)(rc); goto label; } while (0)
184 #define RETURN(rc) return (rc)
185 #define ENTRY do { } while (0)
186 #define EXIT do { } while (0)
189 #define PORTALS_CFG_VERSION 0x00010001;
209 __u32 pcfg_plen1; /* buffers in userspace */
211 __u32 pcfg_plen2; /* buffers in userspace */
215 #define PCFG_INIT(pcfg, cmd) \
217 memset(&pcfg, 0, sizeof(pcfg)); \
218 pcfg.pcfg_version = PORTALS_CFG_VERSION; \
219 pcfg.pcfg_command = (cmd); \
223 typedef int (nal_cmd_handler_fn)(struct portals_cfg *, void *);
224 int libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *arg);
225 int libcfs_nal_cmd(struct portals_cfg *pcfg);
226 void libcfs_nal_cmd_unregister(int nal);
228 struct portal_ioctl_data {
252 __u32 ioc_plen1; /* buffers in userspace */
254 __u32 ioc_plen2; /* buffers in userspace */
263 #include <linux/list.h>
265 struct libcfs_ioctl_handler {
266 struct list_head item;
267 int (*handle_ioctl)(struct portal_ioctl_data *data,
268 unsigned int cmd, unsigned long args);
271 #define DECLARE_IOCTL_HANDLER(ident, func) \
272 struct libcfs_ioctl_handler ident = { \
273 .item = LIST_HEAD_INIT(ident.item), \
274 .handle_ioctl = func \
277 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
278 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
284 #endif /* _LIBCFS_H */