1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
9 /* I think this beast is just trying to get cycles_t and get_cycles().
10 * this should be in its own header. */
12 # include <asm/types.h>
13 # if defined(__powerpc__) && !defined(__KERNEL__)
15 # include <asm/timex.h>
18 # if defined(__KERNEL__)
19 # include <asm/timex.h>
21 # include <sys/time.h>
22 # define cycles_t unsigned long
23 static inline cycles_t get_cycles(void)
26 gettimeofday(&tv, NULL);
27 return (tv.tv_sec * 100000) + tv.tv_usec;
32 # include <sys/types.h>
33 typedef u_int32_t __u32;
34 typedef u_int64_t __u64;
38 # include <linux/time.h>
40 # include <sys/time.h>
41 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
45 # define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb)))
48 #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
53 extern unsigned int portal_subsystem_debug;
54 extern unsigned int portal_stack;
55 extern unsigned int portal_debug;
56 extern unsigned int portal_printk;
57 extern unsigned int portal_cerror;
58 /* Debugging subsystems (32 bits, non-overlapping) */
59 #define S_UNDEFINED 0x00000001
60 #define S_MDC 0x00000002
61 #define S_MDS 0x00000004
62 #define S_OSC 0x00000008
63 #define S_OST 0x00000010
64 #define S_CLASS 0x00000020
65 #define S_LOG 0x00000040
66 #define S_LLITE 0x00000080
67 #define S_RPC 0x00000100
68 #define S_MGMT 0x00000200
69 #define S_PORTALS 0x00000400
70 #define S_SOCKNAL 0x00000800
71 #define S_QSWNAL 0x00001000
72 #define S_PINGER 0x00002000
73 #define S_FILTER 0x00004000
74 #define S_PTLBD 0x00008000
75 #define S_ECHO 0x00010000
76 #define S_LDLM 0x00020000
77 #define S_LOV 0x00040000
78 #define S_GMNAL 0x00080000
79 #define S_PTLROUTER 0x00100000
80 #define S_COBD 0x00200000
81 #define S_IBNAL 0x00400000
83 /* If you change these values, please keep portals/utils/debug.c
86 /* Debugging masks (32 bits, non-overlapping) */
87 #define D_TRACE 0x00000001 /* ENTRY/EXIT markers */
88 #define D_INODE 0x00000002
89 #define D_SUPER 0x00000004
90 #define D_EXT2 0x00000008 /* anything from ext2_debug */
91 #define D_MALLOC 0x00000010 /* print malloc, free information */
92 #define D_CACHE 0x00000020 /* cache-related items */
93 #define D_INFO 0x00000040 /* general information */
94 #define D_IOCTL 0x00000080 /* ioctl related information */
95 #define D_BLOCKS 0x00000100 /* ext2 block allocation */
96 #define D_NET 0x00000200 /* network communications */
97 #define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
98 #define D_BUFFS 0x00000800
99 #define D_OTHER 0x00001000
100 #define D_DENTRY 0x00002000
101 #define D_PORTALS 0x00004000 /* ENTRY/EXIT markers */
102 #define D_PAGE 0x00008000 /* bulk page handling */
103 #define D_DLMTRACE 0x00010000
104 #define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
105 #define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
106 #define D_HA 0x00080000 /* recovery and failover */
107 #define D_RPCTRACE 0x00100000 /* for distributed debugging */
108 #define D_VFSTRACE 0x00200000
109 #define D_READA 0x00400000 /* read-ahead */
112 # include <linux/sched.h> /* THREAD_SIZE */
114 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
115 # define THREAD_SIZE 8192
119 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
123 # define CDEBUG_STACK (THREAD_SIZE - \
124 ((unsigned long)__builtin_dwarf_cfa() & \
127 # define CDEBUG_STACK (THREAD_SIZE - \
128 ((unsigned long)__builtin_frame_address(0) & \
132 #define CHECK_STACK(stack) \
134 if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \
135 portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \
136 __FILE__, __FUNCTION__, __LINE__, \
137 (stack),"maximum lustre stack %u\n",\
138 portal_stack = (stack)); \
142 #else /* __KERNEL__ */
143 #define CHECK_STACK(stack) do { } while(0)
144 #define CDEBUG_STACK (0L)
145 #endif /* __KERNEL__ */
148 #define CDEBUG(mask, format, a...) \
150 if (portal_cerror == 0) \
152 CHECK_STACK(CDEBUG_STACK); \
153 if (((mask) & (D_ERROR | D_EMERG | D_WARNING)) || \
154 (portal_debug & (mask) && \
155 portal_subsystem_debug & DEBUG_SUBSYSTEM)) \
156 portals_debug_msg(DEBUG_SUBSYSTEM, mask, \
157 __FILE__, __FUNCTION__, __LINE__, \
158 CDEBUG_STACK, format, ## a); \
161 #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
162 #define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
163 #define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a)
165 #define GOTO(label, rc) \
167 long GOTO__ret = (long)(rc); \
168 CDEBUG(D_TRACE,"Process leaving via %s (rc=%lu : %ld : %lx)\n", \
169 #label, (unsigned long)GOTO__ret, (signed long)GOTO__ret,\
170 (signed long)GOTO__ret); \
176 typeof(rc) RETURN__ret = (rc); \
177 CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \
178 (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\
179 return RETURN__ret; \
184 CDEBUG(D_TRACE, "Process entered\n"); \
189 CDEBUG(D_TRACE, "Process leaving\n"); \
192 #define CDEBUG(mask, format, a...) do { } while (0)
193 #define CWARN(format, a...) do { } while (0)
194 #define CERROR(format, a...) printk("<3>" format, ## a)
195 #define CEMERG(format, a...) printk("<0>" format, ## a)
196 #define GOTO(label, rc) do { (void)(rc); goto label; } while (0)
197 #define RETURN(rc) return (rc)
198 #define ENTRY do { } while (0)
199 #define EXIT do { } while (0)
202 #define PORTALS_CFG_VERSION 0x00010001;
222 __u32 pcfg_plen1; /* buffers in userspace */
224 __u32 pcfg_plen2; /* buffers in userspace */
228 #define PCFG_INIT(pcfg, cmd) \
230 memset(&pcfg, 0, sizeof(pcfg)); \
231 pcfg.pcfg_version = PORTALS_CFG_VERSION; \
232 pcfg.pcfg_command = (cmd); \
236 typedef int (nal_cmd_handler_fn)(struct portals_cfg *, void *);
237 int libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *arg);
238 int libcfs_nal_cmd(struct portals_cfg *pcfg);
239 void libcfs_nal_cmd_unregister(int nal);
241 struct portal_ioctl_data {
265 __u32 ioc_plen1; /* buffers in userspace */
267 __u32 ioc_plen2; /* buffers in userspace */
276 #include <linux/list.h>
278 struct libcfs_ioctl_handler {
279 struct list_head item;
280 int (*handle_ioctl)(struct portal_ioctl_data *data,
281 unsigned int cmd, unsigned long args);
284 #define DECLARE_IOCTL_HANDLER(ident, func) \
285 struct libcfs_ioctl_handler ident = { \
286 .item = LIST_HEAD_INIT(ident.item), \
287 .handle_ioctl = func \
290 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
291 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
297 #endif /* _LIBCFS_H */