Whamcloud - gitweb
Branch b1_4
[fs/lustre-release.git] / lnet / include / libcfs / kp30.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #ifndef __LIBCFS_KP30_H__
5 #define __LIBCFS_KP30_H__
6
7 /* Controlled via configure key */
8 /* #define LIBCFS_DEBUG */
9
10 #include <libcfs/libcfs.h>
11 #include <lnet/types.h>
12
13 #if defined(__linux__)
14 #include <libcfs/linux/kp30.h>
15 #elif defined(__APPLE__)
16 #include <libcfs/darwin/kp30.h>
17 #elif defined(__WINNT__)
18 #include <libcfs/winnt/kp30.h>
19 #else
20 #error Unsupported operating system
21 #endif
22
23 #ifndef DEBUG_SUBSYSTEM
24 # define DEBUG_SUBSYSTEM S_UNDEFINED
25 #endif
26
27 #ifdef __KERNEL__
28
29 #ifdef LIBCFS_DEBUG
30
31 /*
32  * When this is on, LASSERT macro includes check for assignment used instead
33  * of equality check, but doesn't have unlikely(). Turn this on from time to
34  * time to make test-builds. This shouldn't be on for production release.
35  */
36 #define LASSERT_CHECKED (0)
37
38 #if LASSERT_CHECKED
39 /*
40  * Assertion.
41  *
42  * Strange construction with empty "then" clause is used to trigger compiler
43  * warnings on the assertions of the form LASSERT(a = b);
44  *
45  * "warning: suggest parentheses around assignment used as truth value"
46  *
47  * requires -Wall. Unfortunately this rules out use of likely/unlikely.
48  */
49 #define LASSERT(cond)                                           \
50 ({                                                              \
51         if (cond)                                               \
52                 ;                                               \
53         else                                                    \
54                 libcfs_assertion_failed( #cond , __FILE__,      \
55                         __FUNCTION__, __LINE__);                \
56 })
57
58 #define LASSERTF(cond, fmt, a...)                                       \
59 ({                                                                      \
60          if (cond)                                                      \
61                  ;                                                      \
62          else {                                                         \
63                  libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_EMERG,       \
64                                   __FILE__, __FUNCTION__,__LINE__,      \
65                                   "ASSERTION(" #cond ") failed:" fmt,   \
66                                   ## a);                                \
67                  LBUG();                                                \
68          }                                                              \
69 })
70
71 /* LASSERT_CHECKED */
72 #else
73
74 #define LASSERT(cond)                                           \
75 ({                                                              \
76         if (unlikely(!(cond)))                                  \
77                 libcfs_assertion_failed(#cond , __FILE__,       \
78                         __FUNCTION__, __LINE__);                \
79 })
80
81 #define LASSERTF(cond, fmt, a...)                                       \
82 ({                                                                      \
83         if (unlikely(!(cond))) {                                        \
84                 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_EMERG,        \
85                                  __FILE__, __FUNCTION__,__LINE__,       \
86                                  "ASSERTION(" #cond ") failed:" fmt,    \
87                                  ## a);                                 \
88                 LBUG();                                                 \
89         }                                                               \
90 })
91
92 /* LASSERT_CHECKED */
93 #endif
94
95 /* LIBCFS_DEBUG */
96 #else
97 #define LASSERT(e) ((void)(0))
98 #define LASSERTF(cond, fmt...) ((void)(0))
99 #endif /* LIBCFS_DEBUG */
100
101 void lbug_with_loc(char *file, const char *func, const int line)
102         __attribute__((noreturn));
103
104 #define LBUG() lbug_with_loc(__FILE__, __FUNCTION__, __LINE__)
105
106 extern atomic_t libcfs_kmemory;
107 /*
108  * Memory
109  */
110 #ifdef LIBCFS_DEBUG
111
112 # define libcfs_kmem_inc(ptr, size)             \
113 do {                                            \
114         atomic_add(size, &libcfs_kmemory);      \
115 } while (0)
116
117 # define libcfs_kmem_dec(ptr, size) do {        \
118         atomic_sub(size, &libcfs_kmemory);      \
119 } while (0)
120
121 #else
122 # define libcfs_kmem_inc(ptr, size) do {} while (0)
123 # define libcfs_kmem_dec(ptr, size) do {} while (0)
124 #endif /* LIBCFS_DEBUG */
125
126 #define LIBCFS_VMALLOC_SIZE        16384
127
128 #define LIBCFS_ALLOC_GFP(ptr, size, mask)                                 \
129 do {                                                                      \
130         LASSERT(!in_interrupt() ||                                        \
131                (size <= LIBCFS_VMALLOC_SIZE && mask == CFS_ALLOC_ATOMIC));\
132         if (unlikely((size) > LIBCFS_VMALLOC_SIZE))                     \
133                 (ptr) = cfs_alloc_large(size);                            \
134         else                                                              \
135                 (ptr) = cfs_alloc((size), (mask));                        \
136         if (unlikely((ptr) == NULL)) {                                  \
137                 CERROR("LNET: out of memory at %s:%d (tried to alloc '"   \
138                        #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\
139                 CERROR("LNET: %d total bytes allocated by lnet\n",        \
140                        atomic_read(&libcfs_kmemory));                     \
141         } else {                                                          \
142                 libcfs_kmem_inc((ptr), (size));                           \
143                 if (!((mask) & CFS_ALLOC_ZERO))                           \
144                        memset((ptr), 0, (size));                          \
145         }                                                                 \
146         CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n",    \
147                (int)(size), (ptr), atomic_read (&libcfs_kmemory));        \
148 } while (0)
149
150 #define LIBCFS_ALLOC(ptr, size) \
151         LIBCFS_ALLOC_GFP(ptr, size, CFS_ALLOC_IO)
152
153 #define LIBCFS_ALLOC_ATOMIC(ptr, size) \
154         LIBCFS_ALLOC_GFP(ptr, size, CFS_ALLOC_ATOMIC)
155
156 #define LIBCFS_FREE(ptr, size)                                          \
157 do {                                                                    \
158         int s = (size);                                                 \
159         if (unlikely((ptr) == NULL)) {                                  \
160                 CERROR("LIBCFS: free NULL '" #ptr "' (%d bytes) at "    \
161                        "%s:%d\n", s, __FILE__, __LINE__);               \
162                 break;                                                  \
163         }                                                               \
164         if (unlikely(s > LIBCFS_VMALLOC_SIZE))                          \
165                 cfs_free_large(ptr);                                    \
166         else                                                            \
167                 cfs_free(ptr);                                          \
168         libcfs_kmem_dec((ptr), s);                                      \
169         CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
170                s, (ptr), atomic_read(&libcfs_kmemory));                 \
171 } while (0)
172
173 /******************************************************************************/
174
175 /* htonl hack - either this, or compile with -O2. Stupid byteorder/generic.h */
176 #if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__)
177 #define ___htonl(x) __cpu_to_be32(x)
178 #define ___htons(x) __cpu_to_be16(x)
179 #define ___ntohl(x) __be32_to_cpu(x)
180 #define ___ntohs(x) __be16_to_cpu(x)
181 #define htonl(x) ___htonl(x)
182 #define ntohl(x) ___ntohl(x)
183 #define htons(x) ___htons(x)
184 #define ntohs(x) ___ntohs(x)
185 #endif
186
187 void libcfs_debug_dumpstack(cfs_task_t *tsk);
188 void libcfs_run_upcall(char **argv);
189 void libcfs_run_lbug_upcall(char * file, const char *fn, const int line);
190 void libcfs_debug_dumplog(void);
191 int libcfs_debug_init(unsigned long bufsize);
192 int libcfs_debug_cleanup(void);
193 int libcfs_debug_clear_buffer(void);
194 int libcfs_debug_mark_buffer(char *text);
195
196 void libcfs_debug_set_level(unsigned int debug_level);
197
198 #else  /* !__KERNEL__ */
199 # ifdef LIBCFS_DEBUG
200 #  undef NDEBUG
201 #  include <assert.h>
202 #  define LASSERT(e)     assert(e)
203 #  define LASSERTF(cond, args...)                                              \
204 do {                                                                           \
205           if (!(cond))                                                         \
206                 CERROR(args);                                                  \
207           assert(cond);                                                        \
208 } while (0)
209 #  define LBUG()   assert(0)
210 # else
211 #  define LASSERT(e) ((void)(0))
212 #  define LASSERTF(cond, args...) do { } while (0)
213 #  define LBUG()   ((void)(0))
214 # endif /* LIBCFS_DEBUG */
215 # define printk(format, args...) printf (format, ## args)
216 # ifdef CRAY_XT3                                /* buggy calloc! */
217 #  define LIBCFS_ALLOC(ptr, size)               \
218    do {                                         \
219         (ptr) = malloc(size);                   \
220         memset(ptr, 0, size);                   \
221    } while (0)
222 # else
223 #  define LIBCFS_ALLOC(ptr, size) do { (ptr) = calloc(1,size); } while (0)
224 # endif
225 # define LIBCFS_FREE(a, b) do { free(a); } while (0)
226
227 void libcfs_debug_dumplog(void);
228 int libcfs_debug_init(unsigned long bufsize);
229 int libcfs_debug_cleanup(void);
230
231 /*
232  * Generic compiler-dependent macros required for kernel
233  * build go below this comment. Actual compiler/compiler version
234  * specific implementations come from the above header files
235  */
236
237 #define likely(x)       __builtin_expect(!!(x), 1)
238 #define unlikely(x)     __builtin_expect(!!(x), 0)
239
240 /* !__KERNEL__ */
241 #endif
242
243 /*
244  * compile-time assertions. @cond has to be constant expression.
245  * ISO C Standard:
246  *
247  *        6.8.4.2  The switch statement
248  *
249  *       ....
250  *
251  *       [#3] The expression of each case label shall be  an  integer
252  *       constant   expression  and  no  two  of  the  case  constant
253  *       expressions in the same switch statement shall have the same
254  *       value  after  conversion...
255  *
256  */
257 #define CLASSERT(cond) ({ switch(42) { case (cond): case 0: break; } })
258
259 /* support decl needed both by kernel and liblustre */
260 int         libcfs_isknown_lnd(int type);
261 char       *libcfs_lnd2modname(int type);
262 char       *libcfs_lnd2str(int type);
263 int         libcfs_str2lnd(char *str);
264 char       *libcfs_net2str(__u32 net);
265 char       *libcfs_nid2str(lnet_nid_t nid);
266 __u32       libcfs_str2net(char *str);
267 lnet_nid_t  libcfs_str2nid(char *str);
268 int         libcfs_str2anynid(lnet_nid_t *nid, char *str);
269 char       *libcfs_id2str(lnet_process_id_t id);
270 void        libcfs_setnet0alias(int type);
271
272 /* how an LNET NID encodes net:address */
273 #define LNET_NIDADDR(nid)      ((__u32)((nid) & 0xffffffff))
274 #define LNET_NIDNET(nid)       ((__u32)(((nid) >> 32)) & 0xffffffff)
275 #define LNET_MKNID(net,addr)   ((((__u64)(net))<<32)|((__u64)(addr)))
276 /* how net encodes type:number */
277 #define LNET_NETNUM(net)       ((net) & 0xffff)
278 #define LNET_NETTYP(net)       (((net) >> 16) & 0xffff)
279 #define LNET_MKNET(typ,num)    ((((__u32)(typ))<<16)|((__u32)(num)))
280
281 /* implication */
282 #define ergo(a, b) (!(a) || (b))
283 /* logical equivalence */
284 #define equi(a, b) (!!(a) == !!(b))
285
286 #ifndef CURRENT_TIME
287 # define CURRENT_TIME time(0)
288 #endif
289
290 /* --------------------------------------------------------------------
291  * Light-weight trace
292  * Support for temporary event tracing with minimal Heisenberg effect.
293  * All stuff about lwt are put in arch/kp30.h
294  * -------------------------------------------------------------------- */
295
296 struct libcfs_device_userstate
297 {
298         int           ldu_memhog_pages;
299         cfs_page_t   *ldu_memhog_root_page;
300 };
301
302 /* what used to be in portals_lib.h */
303 #ifndef MIN
304 # define MIN(a,b) (((a)<(b)) ? (a): (b))
305 #endif
306 #ifndef MAX
307 # define MAX(a,b) (((a)>(b)) ? (a): (b))
308 #endif
309
310 #define MKSTR(ptr) ((ptr))? (ptr) : ""
311
312 static inline int size_round4 (int val)
313 {
314         return (val + 3) & (~0x3);
315 }
316
317 static inline int size_round (int val)
318 {
319         return (val + 7) & (~0x7);
320 }
321
322 static inline int size_round16(int val)
323 {
324         return (val + 0xf) & (~0xf);
325 }
326
327 static inline int size_round32(int val)
328 {
329         return (val + 0x1f) & (~0x1f);
330 }
331
332 static inline int size_round0(int val)
333 {
334         if (!val)
335                 return 0;
336         return (val + 1 + 7) & (~0x7);
337 }
338
339 static inline size_t round_strlen(char *fset)
340 {
341         return (size_t)size_round((int)strlen(fset) + 1);
342 }
343
344 #define LOGL(var,len,ptr)                                       \
345 do {                                                            \
346         if (var)                                                \
347                 memcpy((char *)ptr, (const char *)var, len);    \
348         ptr += size_round(len);                                 \
349 } while (0)
350
351 #define LOGU(var,len,ptr)                                       \
352 do {                                                            \
353         if (var)                                                \
354                 memcpy((char *)var, (const char *)ptr, len);    \
355         ptr += size_round(len);                                 \
356 } while (0)
357
358 #define LOGL0(var,len,ptr)                              \
359 do {                                                    \
360         if (!len)                                       \
361                 break;                                  \
362         memcpy((char *)ptr, (const char *)var, len);    \
363         *((char *)(ptr) + len) = 0;                     \
364         ptr += size_round(len + 1);                     \
365 } while (0)
366
367 /*
368  * USER LEVEL STUFF BELOW
369  */
370
371 #define LIBCFS_IOCTL_VERSION 0x0001000a
372
373 struct libcfs_ioctl_data {
374         __u32 ioc_len;
375         __u32 ioc_version;
376
377         __u64 ioc_nid;
378         __u64 ioc_u64[1];
379
380         __u32 ioc_flags;
381         __u32 ioc_count;
382         __u32 ioc_net;
383         __u32 ioc_u32[7];
384
385         __u32 ioc_inllen1;
386         char *ioc_inlbuf1;
387         __u32 ioc_inllen2;
388         char *ioc_inlbuf2;
389
390         __u32 ioc_plen1; /* buffers in userspace */
391         char *ioc_pbuf1;
392         __u32 ioc_plen2; /* buffers in userspace */
393         char *ioc_pbuf2;
394
395         char ioc_bulk[0];
396 };
397
398
399 struct libcfs_ioctl_hdr {
400         __u32 ioc_len;
401         __u32 ioc_version;
402 };
403
404 struct libcfs_debug_ioctl_data
405 {
406         struct libcfs_ioctl_hdr hdr;
407         unsigned int subs;
408         unsigned int debug;
409 };
410
411 #define LIBCFS_IOC_INIT(data)                           \
412 do {                                                    \
413         memset(&data, 0, sizeof(data));                 \
414         data.ioc_version = LIBCFS_IOCTL_VERSION;        \
415         data.ioc_len = sizeof(data);                    \
416 } while (0)
417
418 /* FIXME check conflict with lustre_lib.h */
419 #define LIBCFS_IOC_DEBUG_MASK             _IOWR('f', 250, long)
420
421 static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
422 {
423         int len = sizeof(*data);
424         len += size_round(data->ioc_inllen1);
425         len += size_round(data->ioc_inllen2);
426         return len;
427 }
428
429 static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
430 {
431         if (data->ioc_len > (1<<30)) {
432                 CERROR ("LIBCFS ioctl: ioc_len larger than 1<<30\n");
433                 return 1;
434         }
435         if (data->ioc_inllen1 > (1<<30)) {
436                 CERROR ("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
437                 return 1;
438         }
439         if (data->ioc_inllen2 > (1<<30)) {
440                 CERROR ("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
441                 return 1;
442         }
443         if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
444                 CERROR ("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
445                 return 1;
446         }
447         if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
448                 CERROR ("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
449                 return 1;
450         }
451         if (data->ioc_pbuf1 && !data->ioc_plen1) {
452                 CERROR ("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
453                 return 1;
454         }
455         if (data->ioc_pbuf2 && !data->ioc_plen2) {
456                 CERROR ("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
457                 return 1;
458         }
459         if (data->ioc_plen1 && !data->ioc_pbuf1) {
460                 CERROR ("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
461                 return 1;
462         }
463         if (data->ioc_plen2 && !data->ioc_pbuf2) {
464                 CERROR ("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
465                 return 1;
466         }
467         if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_len ) {
468                 CERROR ("LIBCFS ioctl: packlen != ioc_len\n");
469                 return 1;
470         }
471         if (data->ioc_inllen1 &&
472             data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
473                 CERROR ("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
474                 return 1;
475         }
476         if (data->ioc_inllen2 &&
477             data->ioc_bulk[size_round(data->ioc_inllen1) +
478                            data->ioc_inllen2 - 1] != '\0') {
479                 CERROR ("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
480                 return 1;
481         }
482         return 0;
483 }
484
485 #ifndef __KERNEL__
486 static inline int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
487                                     int max)
488 {
489         char *ptr;
490         struct libcfs_ioctl_data *overlay;
491         data->ioc_len = libcfs_ioctl_packlen(data);
492         data->ioc_version = LIBCFS_IOCTL_VERSION;
493
494         if (*pbuf && libcfs_ioctl_packlen(data) > max)
495                 return 1;
496         if (*pbuf == NULL) {
497                 *pbuf = malloc(data->ioc_len);
498         }
499         if (!*pbuf)
500                 return 1;
501         overlay = (struct libcfs_ioctl_data *)*pbuf;
502         memcpy(*pbuf, data, sizeof(*data));
503
504         ptr = overlay->ioc_bulk;
505         if (data->ioc_inlbuf1)
506                 LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
507         if (data->ioc_inlbuf2)
508                 LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
509         if (libcfs_ioctl_is_invalid(overlay))
510                 return 1;
511
512         return 0;
513 }
514
515 #else
516
517 extern int libcfs_ioctl_getdata(char *buf, char *end, void *arg);
518 extern int libcfs_ioctl_popdata(void *arg, void *buf, int size);
519
520 #endif
521
522 /* ioctls for manipulating snapshots 30- */
523 #define IOC_LIBCFS_TYPE                   'e'
524 #define IOC_LIBCFS_MIN_NR                 30
525 /* libcfs ioctls */
526 #define IOC_LIBCFS_PANIC                   _IOWR('e', 30, IOCTL_LIBCFS_TYPE)
527 #define IOC_LIBCFS_CLEAR_DEBUG             _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
528 #define IOC_LIBCFS_MARK_DEBUG              _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
529 #define IOC_LIBCFS_LWT_CONTROL             _IOWR('e', 33, IOCTL_LIBCFS_TYPE)
530 #define IOC_LIBCFS_LWT_SNAPSHOT            _IOWR('e', 34, IOCTL_LIBCFS_TYPE)
531 #define IOC_LIBCFS_LWT_LOOKUP_STRING       _IOWR('e', 35, IOCTL_LIBCFS_TYPE)
532 #define IOC_LIBCFS_MEMHOG                  _IOWR('e', 36, IOCTL_LIBCFS_TYPE)
533 #define IOC_LIBCFS_PING_TEST               _IOWR('e', 37, IOCTL_LIBCFS_TYPE)
534 /* lnet ioctls */
535 #define IOC_LIBCFS_GET_NI                  _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
536 #define IOC_LIBCFS_FAIL_NID                _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
537 #define IOC_LIBCFS_ADD_ROUTE               _IOWR('e', 52, IOCTL_LIBCFS_TYPE)
538 #define IOC_LIBCFS_DEL_ROUTE               _IOWR('e', 53, IOCTL_LIBCFS_TYPE)
539 #define IOC_LIBCFS_GET_ROUTE               _IOWR('e', 54, IOCTL_LIBCFS_TYPE)
540 #define IOC_LIBCFS_NOTIFY_ROUTER           _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
541 #define IOC_LIBCFS_UNCONFIGURE             _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
542 #define IOC_LIBCFS_PORTALS_COMPATIBILITY   _IOWR('e', 57, IOCTL_LIBCFS_TYPE)
543 #define IOC_LIBCFS_LNET_DIST               _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
544 #define IOC_LIBCFS_CONFIGURE               _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
545 #define IOC_LIBCFS_TESTPROTOCOMPAT         _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
546 #define IOC_LIBCFS_PING                    _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
547 #define IOC_LIBCFS_DEBUG_PEER              _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
548 #define IOC_LIBCFS_LNETST                  _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
549 /* lnd ioctls */
550 #define IOC_LIBCFS_REGISTER_MYNID          _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
551 #define IOC_LIBCFS_CLOSE_CONNECTION        _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
552 #define IOC_LIBCFS_PUSH_CONNECTION         _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
553 #define IOC_LIBCFS_GET_CONN                _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
554 #define IOC_LIBCFS_DEL_PEER                _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
555 #define IOC_LIBCFS_ADD_PEER                _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
556 #define IOC_LIBCFS_GET_PEER                _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
557 #define IOC_LIBCFS_GET_TXDESC              _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
558 #define IOC_LIBCFS_ADD_INTERFACE           _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
559 #define IOC_LIBCFS_DEL_INTERFACE           _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
560 #define IOC_LIBCFS_GET_INTERFACE           _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
561 #define IOC_LIBCFS_GET_GMID                _IOWR('e', 81, IOCTL_LIBCFS_TYPE)
562
563 #define IOC_LIBCFS_MAX_NR                             81
564
565
566 enum {
567         /* Only add to these values (i.e. don't ever change or redefine them):
568          * network addresses depend on them... */
569         QSWLND    = 1,
570         SOCKLND   = 2,
571         GMLND     = 3,
572         PTLLND    = 4,
573         O2IBLND   = 5,
574         CIBLND    = 6,
575         OPENIBLND = 7,
576         IIBLND    = 8,
577         LOLND     = 9,
578         RALND     = 10,
579         VIBLND    = 11,
580         MXLND     = 12,
581 };
582
583 enum {
584         DEBUG_DAEMON_START       =  1,
585         DEBUG_DAEMON_STOP        =  2,
586         DEBUG_DAEMON_PAUSE       =  3,
587         DEBUG_DAEMON_CONTINUE    =  4,
588 };
589
590
591 enum cfg_record_type {
592         PORTALS_CFG_TYPE = 1,
593         LUSTRE_CFG_TYPE = 123,
594 };
595
596 typedef int (*cfg_record_cb_t)(enum cfg_record_type, int len, void *data);
597
598 /* lustre_id output helper macros */
599 #define DLID4   "%lu/%lu/%lu/%lu"
600
601 #define OLID4(id)                              \
602     (unsigned long)(id)->li_fid.lf_id,         \
603     (unsigned long)(id)->li_fid.lf_group,      \
604     (unsigned long)(id)->li_stc.u.e3s.l3s_ino, \
605     (unsigned long)(id)->li_stc.u.e3s.l3s_gen
606
607 #endif