1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 #ifndef __LIBCFS_LINUX_LIBCFS_H__
5 #define __LIBCFS_LINUX_LIBCFS_H__
7 #ifndef __LIBCFS_LIBCFS_H__
8 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
11 #include <libcfs/linux/linux-mem.h>
12 #include <libcfs/linux/linux-time.h>
13 #include <libcfs/linux/linux-prim.h>
14 #include <libcfs/linux/linux-lock.h>
15 #include <libcfs/linux/linux-fs.h>
17 #ifdef HAVE_ASM_TYPES_H
18 #include <asm/types.h>
20 /* this is actually coming from within lustre, a layering violation.
21 * we may not even need it, as libuptlctl (the dependency for which it
22 * is needed in liblustre building on catamount, bug 6923) shows no
23 * apparent need to be included in liblustre AFAICS. The change of
24 * include to lustre/types.h only makes this explicit instead of implicit.
25 * To be resolved. For now, make it CRAY_PORTALS only, to avoid breaking
26 * non-b1_4 branches that don't have this file.
29 # include <lustre/types.h>
37 # include <linux/types.h>
38 # include <linux/time.h>
39 # include <asm/timex.h>
41 # include <sys/types.h>
42 # include <sys/time.h>
43 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
44 typedef unsigned long long cycles_t;
48 /* Userpace byte flipping */
50 # include <byteswap.h>
51 # define __swab16(x) bswap_16(x)
52 # define __swab32(x) bswap_32(x)
53 # define __swab64(x) bswap_64(x)
54 # define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
55 # define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
56 # define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
57 # if __BYTE_ORDER == __LITTLE_ENDIAN
58 # define le16_to_cpu(x) (x)
59 # define cpu_to_le16(x) (x)
60 # define le32_to_cpu(x) (x)
61 # define cpu_to_le32(x) (x)
62 # define le64_to_cpu(x) (x)
63 # define cpu_to_le64(x) (x)
65 # if __BYTE_ORDER == __BIG_ENDIAN
66 # define le16_to_cpu(x) bswap_16(x)
67 # define cpu_to_le16(x) bswap_16(x)
68 # define le32_to_cpu(x) bswap_32(x)
69 # define cpu_to_le32(x) bswap_32(x)
70 # define le64_to_cpu(x) bswap_64(x)
71 # define cpu_to_le64(x) bswap_64(x)
73 # error "Unknown byte order"
74 # endif /* __BIG_ENDIAN */
75 # endif /* __LITTLE_ENDIAN */
76 #endif /* ! __KERNEL__ */
78 struct ptldebug_header {
90 } __attribute__((packed));
93 # include <linux/sched.h> /* THREAD_SIZE */
95 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
96 # define THREAD_SIZE 8192
100 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
104 # define CDEBUG_STACK (THREAD_SIZE - \
105 ((unsigned long)__builtin_dwarf_cfa() & \
108 # define CDEBUG_STACK (THREAD_SIZE - \
109 ((unsigned long)__builtin_frame_address(0) & \
111 # endif /* __ia64__ */
113 #define CHECK_STACK(stack) \
115 if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \
116 portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \
117 __FILE__, __FUNCTION__, __LINE__, \
118 (stack),"maximum lustre stack %u\n",\
119 portal_stack = (stack)); \
123 #else /* !__KERNEL__ */
124 #define CHECK_STACK(stack) do { } while(0)
125 #define CDEBUG_STACK (0L)
126 #endif /* __KERNEL__ */
131 * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this
134 * 2) the implementation of ernal in cray portals further restricts the pid
135 * space that may be used to 0 <= pid <= 255 (an 8 bit value). Returns
136 * an error at nal init time for any pid outside this range. Other nals
137 * in cray portals don't have this restriction.
139 #define LUSTRE_PTL_PID 9
141 #define LUSTRE_PTL_PID 12345
144 #define ENTRY_NESTING_SUPPORT (0)
145 #define ENTRY_NESTING do {;} while (0)
146 #define EXIT_NESTING do {;} while (0)
147 #define __current_nesting_level() (0)
150 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
152 * Implementation is in linux-curproc.c
154 #define CFS_CURPROC_COMM_MAX (sizeof ((struct task_struct *)0)->comm)
156 #if defined(__KERNEL__)
157 #include <linux/capability.h>
158 typedef kernel_cap_t cfs_kernel_cap_t;
160 typedef __u32 cfs_kernel_cap_t;
163 #endif /* _LINUX_LIBCFS_H */