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