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