Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * lib-lnet.h
5  *
6  * Top level include for library side routines
7  */
8
9 #ifndef __LNET_LIB_LNET_H__
10 #define __LNET_LIB_LNET_H__
11
12 #if defined(__linux__)
13 #include <lnet/linux/lib-lnet.h>
14 #elif defined(__APPLE__)
15 #include <lnet/darwin/lib-lnet.h>
16 #elif defined(__WINNT__)
17 #include <lnet/winnt/lib-lnet.h>
18 #else
19 #error Unsupported Operating System
20 #endif
21
22 #include <libcfs/libcfs.h>
23 #include <lnet/types.h>
24 #include <lnet/lnet.h>
25 #include <lnet/lib-types.h>
26
27 extern lnet_t  the_lnet;                        /* THE network */
28
29 static inline int lnet_is_wire_handle_none (lnet_handle_wire_t *wh)
30 {
31         return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_NONE.wh_interface_cookie &&
32                 wh->wh_object_cookie == LNET_WIRE_HANDLE_NONE.wh_object_cookie);
33 }
34
35 static inline int lnet_md_exhausted (lnet_libmd_t *md) 
36 {
37         return (md->md_threshold == 0 ||
38                 ((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
39                  md->md_offset + md->md_max_size > md->md_length));
40 }
41
42 static inline int lnet_md_unlinkable (lnet_libmd_t *md)
43 {
44         /* Should unlink md when its refcount is 0 and either:
45          *  - md has been flagged for deletion (by auto unlink or LNetM[DE]Unlink,
46          *    in the latter case md may not be exhausted).
47          *  - auto unlink is on and md is exhausted.
48          */
49         if (md->md_refcount != 0)
50                 return 0;
51
52         if ((md->md_flags & LNET_MD_FLAG_ZOMBIE) != 0)
53                 return 1;
54
55         return ((md->md_flags & LNET_MD_FLAG_AUTO_UNLINK) != 0 &&
56                 lnet_md_exhausted(md));
57 }
58
59 #ifdef __KERNEL__
60 #define LNET_LOCK()        spin_lock(&the_lnet.ln_lock)                 
61 #define LNET_UNLOCK()      spin_unlock(&the_lnet.ln_lock)               
62 #define LNET_MUTEX_DOWN(m) mutex_down(m)
63 #define LNET_MUTEX_UP(m)   mutex_up(m)
64 #else
65 # ifndef HAVE_LIBPTHREAD
66 #define LNET_SINGLE_THREADED_LOCK(l)            \
67 do {                                            \
68         LASSERT ((l) == 0);                     \
69         (l) = 1;                                \
70 } while (0)
71
72 #define LNET_SINGLE_THREADED_UNLOCK(l)          \
73 do {                                            \
74         LASSERT ((l) == 1);                     \
75         (l) = 0;                                \
76 } while (0)
77
78 #define LNET_LOCK()        LNET_SINGLE_THREADED_LOCK(the_lnet.ln_lock)
79 #define LNET_UNLOCK()      LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_lock)
80 #define LNET_MUTEX_DOWN(m) LNET_SINGLE_THREADED_LOCK(*(m))
81 #define LNET_MUTEX_UP(m)   LNET_SINGLE_THREADED_UNLOCK(*(m))
82 # else
83 #define LNET_LOCK()        pthread_mutex_lock(&the_lnet.ln_lock)
84 #define LNET_UNLOCK()      pthread_mutex_unlock(&the_lnet.ln_lock)
85 #define LNET_MUTEX_DOWN(m) pthread_mutex_lock(m)
86 #define LNET_MUTEX_UP(m)   pthread_mutex_unlock(m)
87 # endif
88 #endif
89
90 #define MAX_PORTALS     64
91
92 #ifdef LNET_USE_LIB_FREELIST
93
94 #define MAX_MES         2048
95 #define MAX_MDS         2048
96 #define MAX_MSGS        2048    /* Outstanding messages */
97 #define MAX_EQS         512
98
99 static inline void *
100 lnet_freelist_alloc (lnet_freelist_t *fl)
101 {
102         /* ALWAYS called with liblock held */
103         lnet_freeobj_t *o;
104
105         if (list_empty (&fl->fl_list))
106                 return (NULL);
107         
108         o = list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
109         list_del (&o->fo_list);
110         return ((void *)&o->fo_contents);
111 }
112
113 static inline void
114 lnet_freelist_free (lnet_freelist_t *fl, void *obj)
115 {
116         /* ALWAYS called with liblock held */
117         lnet_freeobj_t *o = list_entry (obj, lnet_freeobj_t, fo_contents);
118         
119         list_add (&o->fo_list, &fl->fl_list);
120 }
121
122
123 static inline lnet_eq_t *
124 lnet_eq_alloc (void)
125 {
126         /* NEVER called with liblock held */
127         lnet_eq_t     *eq;
128         
129         LNET_LOCK();
130         eq = (lnet_eq_t *)lnet_freelist_alloc(&the_lnet.ln_free_eqs);
131         LNET_UNLOCK();
132
133         return (eq);
134 }
135
136 static inline void
137 lnet_eq_free (lnet_eq_t *eq)
138 {
139         /* ALWAYS called with liblock held */
140         lnet_freelist_free(&the_lnet.ln_free_eqs, eq);
141 }
142
143 static inline lnet_libmd_t *
144 lnet_md_alloc (lnet_md_t *umd)
145 {
146         /* NEVER called with liblock held */
147         lnet_libmd_t  *md;
148         
149         LNET_LOCK();
150         md = (lnet_libmd_t *)lnet_freelist_alloc(&the_lnet.ln_free_mds);
151         LNET_UNLOCK();
152
153         return (md);
154 }
155
156 static inline void
157 lnet_md_free (lnet_libmd_t *md)
158 {
159         /* ALWAYS called with liblock held */
160         lnet_freelist_free (&the_lnet.ln_free_mds, md);
161 }
162
163 static inline lnet_me_t *
164 lnet_me_alloc (void)
165 {
166         /* NEVER called with liblock held */
167         lnet_me_t     *me;
168         
169         LNET_LOCK();
170         me = (lnet_me_t *)lnet_freelist_alloc(&the_lnet.ln_free_mes);
171         LNET_UNLOCK();
172         
173         return (me);
174 }
175
176 static inline void
177 lnet_me_free (lnet_me_t *me)
178 {
179         /* ALWAYS called with liblock held */
180         lnet_freelist_free (&the_lnet.ln_free_mes, me);
181 }
182
183 static inline lnet_msg_t *
184 lnet_msg_alloc (void)
185 {
186         /* NEVER called with liblock held */
187         lnet_msg_t    *msg;
188         
189         LNET_LOCK();
190         msg = (lnet_msg_t *)lnet_freelist_alloc(&the_lnet.ln_free_msgs);
191         LNET_UNLOCK();
192
193         if (msg != NULL) {
194                 /* NULL pointers, clear flags etc */
195                 memset (msg, 0, sizeof (*msg));
196 #ifdef CRAY_XT3
197                 msg->msg_ev.uid = LNET_UID_ANY;
198 #endif
199         }
200         return(msg);
201 }
202
203 static inline void
204 lnet_msg_free (lnet_msg_t *msg)
205 {
206         /* ALWAYS called with liblock held */
207         LASSERT (!msg->msg_onactivelist);
208         lnet_freelist_free(&the_lnet.ln_free_msgs, msg);
209 }
210
211 #else
212
213 static inline lnet_eq_t *
214 lnet_eq_alloc (void)
215 {
216         /* NEVER called with liblock held */
217         lnet_eq_t *eq;
218
219         LIBCFS_ALLOC(eq, sizeof(*eq));
220         return (eq);
221 }
222
223 static inline void
224 lnet_eq_free (lnet_eq_t *eq)
225 {
226         /* ALWAYS called with liblock held */
227         LIBCFS_FREE(eq, sizeof(*eq));
228 }
229
230 static inline lnet_libmd_t *
231 lnet_md_alloc (lnet_md_t *umd)
232 {
233         /* NEVER called with liblock held */
234         lnet_libmd_t *md;
235         int           size;
236         unsigned int  niov;
237
238         if ((umd->options & LNET_MD_KIOV) != 0) {
239                 niov = umd->length;
240                 size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
241         } else {
242                 niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
243                        umd->length : 1;
244                 size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
245         }
246
247         LIBCFS_ALLOC(md, size);
248
249         if (md != NULL) {
250                 /* Set here in case of early free */
251                 md->md_options = umd->options;
252                 md->md_niov = niov;
253         }
254         
255         return (md);
256 }
257
258 static inline void 
259 lnet_md_free (lnet_libmd_t *md)
260 {
261         /* ALWAYS called with liblock held */
262         int       size;
263
264         if ((md->md_options & LNET_MD_KIOV) != 0)
265                 size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
266         else
267                 size = offsetof(lnet_libmd_t, md_iov.iov[md->md_niov]);
268
269         LIBCFS_FREE(md, size);
270 }
271
272 static inline lnet_me_t *
273 lnet_me_alloc (void)
274 {
275         /* NEVER called with liblock held */
276         lnet_me_t *me;
277
278         LIBCFS_ALLOC(me, sizeof(*me));
279         return (me);
280 }
281
282 static inline void 
283 lnet_me_free(lnet_me_t *me)
284 {
285         /* ALWAYS called with liblock held */
286         LIBCFS_FREE(me, sizeof(*me));
287 }
288
289 static inline lnet_msg_t *
290 lnet_msg_alloc(void)
291 {
292         /* NEVER called with liblock held */
293         lnet_msg_t *msg;
294
295         LIBCFS_ALLOC(msg, sizeof(*msg));
296
297         if (msg != NULL) {
298                 /* NULL pointers, clear flags etc */
299                 memset (msg, 0, sizeof (*msg));
300 #ifdef CRAY_XT3
301                 msg->msg_ev.uid = LNET_UID_ANY;
302 #endif
303         }
304         return (msg);
305 }
306
307 static inline void 
308 lnet_msg_free(lnet_msg_t *msg)
309 {
310         /* ALWAYS called with liblock held */
311         LASSERT (!msg->msg_onactivelist);
312         LIBCFS_FREE(msg, sizeof(*msg));
313 }
314 #endif
315
316 extern lnet_libhandle_t *lnet_lookup_cookie (__u64 cookie, int type);
317 extern void lnet_initialise_handle (lnet_libhandle_t *lh, int type);
318 extern void lnet_invalidate_handle (lnet_libhandle_t *lh);
319
320 static inline void
321 lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
322 {
323         if (eq == NULL) {
324                 *handle = LNET_EQ_NONE;
325                 return;
326         }
327
328         handle->cookie = eq->eq_lh.lh_cookie;
329 }
330
331 static inline lnet_eq_t *
332 lnet_handle2eq (lnet_handle_eq_t *handle)
333 {
334         /* ALWAYS called with liblock held */
335         lnet_libhandle_t *lh = lnet_lookup_cookie(handle->cookie, 
336                                                   LNET_COOKIE_TYPE_EQ);
337         if (lh == NULL)
338                 return (NULL);
339
340         return (lh_entry (lh, lnet_eq_t, eq_lh));
341 }
342
343 static inline void
344 lnet_md2handle (lnet_handle_md_t *handle, lnet_libmd_t *md)
345 {
346         handle->cookie = md->md_lh.lh_cookie;
347 }
348
349 static inline lnet_libmd_t *
350 lnet_handle2md (lnet_handle_md_t *handle)
351 {
352         /* ALWAYS called with liblock held */
353         lnet_libhandle_t *lh = lnet_lookup_cookie(handle->cookie,
354                                                   LNET_COOKIE_TYPE_MD);
355         if (lh == NULL)
356                 return (NULL);
357
358         return (lh_entry (lh, lnet_libmd_t, md_lh));
359 }
360
361 static inline lnet_libmd_t *
362 lnet_wire_handle2md (lnet_handle_wire_t *wh)
363 {
364         /* ALWAYS called with liblock held */
365         lnet_libhandle_t *lh;
366         
367         if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
368                 return (NULL);
369         
370         lh = lnet_lookup_cookie(wh->wh_object_cookie,
371                                 LNET_COOKIE_TYPE_MD);
372         if (lh == NULL)
373                 return (NULL);
374
375         return (lh_entry (lh, lnet_libmd_t, md_lh));
376 }
377
378 static inline void
379 lnet_me2handle (lnet_handle_me_t *handle, lnet_me_t *me)
380 {
381         handle->cookie = me->me_lh.lh_cookie;
382 }
383
384 static inline lnet_me_t *
385 lnet_handle2me (lnet_handle_me_t *handle)
386 {
387         /* ALWAYS called with liblock held */
388         lnet_libhandle_t *lh = lnet_lookup_cookie(handle->cookie,
389                                                   LNET_COOKIE_TYPE_ME);
390         if (lh == NULL)
391                 return (NULL);
392
393         return (lh_entry (lh, lnet_me_t, me_lh));
394 }
395
396 static inline void
397 lnet_peer_addref_locked(lnet_peer_t *lp)
398 {
399         LASSERT (lp->lp_refcount > 0);
400         lp->lp_refcount++;
401 }
402
403 extern void lnet_destroy_peer_locked(lnet_peer_t *lp);
404
405 static inline void
406 lnet_peer_decref_locked(lnet_peer_t *lp)
407 {
408         LASSERT (lp->lp_refcount > 0);
409         lp->lp_refcount--;
410         if (lp->lp_refcount == 0)
411                 lnet_destroy_peer_locked(lp);
412 }
413
414 static inline int
415 lnet_isrouter(lnet_peer_t *lp)
416 {
417         return lp->lp_rtr_refcount != 0;
418 }
419
420 static inline void
421 lnet_ni_addref_locked(lnet_ni_t *ni) 
422 {
423         LASSERT (ni->ni_refcount > 0);
424         ni->ni_refcount++;
425 }
426
427 static inline void
428 lnet_ni_addref(lnet_ni_t *ni) 
429 {
430         LNET_LOCK();
431         lnet_ni_addref_locked(ni);
432         LNET_UNLOCK();
433 }
434
435 static inline void
436 lnet_ni_decref_locked(lnet_ni_t *ni)
437 {
438         LASSERT (ni->ni_refcount > 0);
439         ni->ni_refcount--;
440         if (ni->ni_refcount == 0)
441                 list_add_tail(&ni->ni_list, &the_lnet.ln_zombie_nis);
442 }
443
444 static inline void
445 lnet_ni_decref(lnet_ni_t *ni)
446 {
447         LNET_LOCK();
448         lnet_ni_decref_locked(ni);
449         LNET_UNLOCK();
450 }
451
452 static inline lnet_nid_t
453 lnet_ptlcompat_srcnid(lnet_nid_t src, lnet_nid_t dst)
454 {
455         /* Give myself a portals srcnid if I'm sending to portals */
456         if (the_lnet.ln_ptlcompat > 0 &&   
457             LNET_NIDNET(dst) == 0)
458                 return LNET_MKNID(0, LNET_NIDADDR(src));
459         
460         return src;
461 }
462
463 static inline int
464 lnet_ptlcompat_matchnid(lnet_nid_t lnet_nid, lnet_nid_t ptl_nid) 
465 {
466         return ((ptl_nid == lnet_nid) ||
467                 (the_lnet.ln_ptlcompat > 0 &&
468                  LNET_NIDNET(ptl_nid) == 0 &&
469                  LNET_NETTYP(LNET_NIDNET(lnet_nid)) != LOLND &&
470                  LNET_NIDADDR(ptl_nid) == LNET_NIDADDR(lnet_nid)));
471 }
472
473 static inline int
474 lnet_ptlcompat_matchnet(__u32 lnet_net, __u32 ptl_net) 
475 {
476         return ((ptl_net == lnet_net) ||
477                 (the_lnet.ln_ptlcompat > 0 &&
478                  ptl_net == 0 &&
479                  LNET_NETTYP(lnet_net) != LOLND));
480 }
481
482 static inline struct list_head *
483 lnet_nid2peerhash (lnet_nid_t nid)
484 {
485         unsigned int idx = LNET_NIDADDR(nid) % LNET_PEER_HASHSIZE;
486
487         return &the_lnet.ln_peer_hash[idx];
488 }
489
490 extern lnd_t the_lolnd;
491
492 #ifndef __KERNEL__
493 /* unconditional registration */
494 #define LNET_REGISTER_ULND(lnd)                 \
495 do {                                            \
496         extern lnd_t lnd;                       \
497                                                 \
498         lnet_register_lnd(&(lnd));              \
499 } while (0)
500
501 /* conditional registration */
502 #define LNET_REGISTER_ULND_IF_PRESENT(lnd)                              \
503 do {                                                                    \
504         extern lnd_t lnd __attribute__ ((weak, alias("the_lolnd")));    \
505                                                                         \
506         if (&(lnd) != &the_lolnd)                                       \
507                 lnet_register_lnd(&(lnd));                              \
508 } while (0)
509 #endif
510
511 #ifdef CRAY_XT3
512 inline static void
513 lnet_set_msg_uid(lnet_ni_t *ni, lnet_msg_t *msg, lnet_uid_t uid)
514 {
515         LASSERT (msg->msg_ev.uid == LNET_UID_ANY);
516         msg->msg_ev.uid = uid;
517 }
518 #endif
519
520 extern lnet_ni_t *lnet_nid2ni_locked (lnet_nid_t nid);
521 extern lnet_ni_t *lnet_net2ni_locked (__u32 net);
522 static inline lnet_ni_t *
523 lnet_net2ni (__u32 net) 
524 {
525         lnet_ni_t *ni;
526
527         LNET_LOCK();
528         ni = lnet_net2ni_locked(net);
529         LNET_UNLOCK();
530
531         return ni;
532 }
533
534 int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, time_t when);
535 int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid);
536 int lnet_check_routes(void);
537 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
538 void lnet_destroy_routes(void);
539 int lnet_get_route(int idx, __u32 *net, __u32 *hops, 
540                    lnet_nid_t *gateway, __u32 *alive);
541 void lnet_proc_init(void);
542 void lnet_proc_fini(void);
543 void lnet_init_rtrpools(void);
544 int  lnet_alloc_rtrpools(int im_a_router);
545 void lnet_free_rtrpools(void);
546 lnet_remotenet_t *lnet_find_net_locked (__u32 net);
547
548 int lnet_islocalnid(lnet_nid_t nid);
549 int lnet_islocalnet(__u32 net);
550
551 void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev);
552 void lnet_enq_event_locked(lnet_eq_t *eq, lnet_event_t *ev);
553 void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
554                     unsigned int offset, unsigned int len);
555 int lnet_send(lnet_nid_t nid, lnet_msg_t *msg);
556 void lnet_return_credits_locked (lnet_msg_t *msg);
557 void lnet_match_blocked_msg(lnet_libmd_t *md);
558 int lnet_parse (lnet_ni_t *ni, lnet_hdr_t *hdr,
559                 lnet_nid_t fromnid, void *private, int rdma_req);
560 void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
561                unsigned int offset, unsigned int mlen, unsigned int rlen);
562 lnet_msg_t *lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *get_msg);
563 void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
564 void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
565
566 char *lnet_msgtyp2str (int type);
567 void lnet_print_hdr (lnet_hdr_t * hdr);
568 int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
569
570 unsigned int lnet_iov_nob (unsigned int niov, struct iovec *iov);
571 int lnet_extract_iov (int dst_niov, struct iovec *dst,
572                       int src_niov, struct iovec *src,
573                       unsigned int offset, unsigned int len);
574
575 unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
576 int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst, 
577                       int src_niov, lnet_kiov_t *src,
578                       unsigned int offset, unsigned int len);
579
580 void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov, 
581                         unsigned int doffset, 
582                         unsigned int nsiov, struct iovec *siov, 
583                         unsigned int soffset, unsigned int nob);
584 void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, 
585                          unsigned int iovoffset,
586                          unsigned int nkiov, lnet_kiov_t *kiov, 
587                          unsigned int kiovoffset, unsigned int nob);
588 void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, 
589                          unsigned int kiovoffset,
590                          unsigned int niov, struct iovec *iov, 
591                          unsigned int iovoffset, unsigned int nob);
592 void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov, 
593                           unsigned int doffset, 
594                           unsigned int nskiov, lnet_kiov_t *skiov, 
595                           unsigned int soffset, unsigned int nob);
596
597 static inline void
598 lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
599                    unsigned int nsiov, struct iovec *siov, unsigned int soffset,
600                    unsigned int nob)
601 {
602         struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
603
604         lnet_copy_iov2iov(1, &diov, doffset,
605                           nsiov, siov, soffset, nob);
606 }
607
608 static inline void
609 lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
610                     unsigned int nsiov, lnet_kiov_t *skiov, unsigned int soffset,
611                     unsigned int nob)
612 {
613         struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
614
615         lnet_copy_kiov2iov(1, &diov, doffset,
616                            nsiov, skiov, soffset, nob);
617 }
618
619 static inline void
620 lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
621                    int slen, void *src, unsigned int soffset, unsigned int nob)
622 {
623         struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
624         lnet_copy_iov2iov(ndiov, diov, doffset,
625                           1, &siov, soffset, nob);
626 }
627
628 static inline void
629 lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov, unsigned int doffset,
630                     int slen, void *src, unsigned int soffset, unsigned int nob)
631 {
632         struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
633         lnet_copy_iov2kiov(ndiov, dkiov, doffset,
634                            1, &siov, soffset, nob);
635 }
636
637 void lnet_me_unlink(lnet_me_t *me);
638
639 void lnet_md_unlink(lnet_libmd_t *md);
640 void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
641
642 void lnet_register_lnd(lnd_t *lnd);
643 void lnet_unregister_lnd(lnd_t *lnd);
644 int lnet_set_ip_niaddr (lnet_ni_t *ni);
645
646 #ifdef __KERNEL__
647 int lnet_connect(cfs_socket_t **sockp, lnet_nid_t peer_nid,
648                  __u32 local_ip, __u32 peer_ip, int peer_port);
649 void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
650                                 __u32 peer_ip, int port);
651 int lnet_count_acceptor_nis(lnet_ni_t **first_ni);
652 int lnet_accept(lnet_ni_t *blind_ni, cfs_socket_t *sock, __u32 magic);
653 int lnet_acceptor_timeout(void);
654 int lnet_acceptor_port(void);
655 #endif
656
657 #ifdef HAVE_LIBPTHREAD
658 int lnet_count_acceptor_nis(lnet_ni_t **first_ni);
659 int lnet_acceptor_port(void);
660 #endif
661
662 int lnet_acceptor_start(void);
663 void lnet_acceptor_stop(void);
664
665 int lnet_peers_start_down(void);
666 int lnet_router_checker_start(void);
667 void lnet_router_checker_stop(void);
668
669 int lnet_ping_target_init(void);
670 void lnet_ping_target_fini(void);
671 int lnet_ping(lnet_process_id_t id, int timeout_ms,
672               lnet_process_id_t *ids, int n_ids);
673
674 int lnet_parse_ip2nets (char **networksp, char *ip2nets);
675 int lnet_parse_routes (char *route_str, int *im_a_router);
676 int lnet_parse_networks (struct list_head *nilist, char *networks);
677
678 int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid);
679 lnet_peer_t *lnet_find_peer_locked (lnet_nid_t nid);
680 void lnet_clear_peer_table(void);
681 void lnet_destroy_peer_table(void);
682 int lnet_create_peer_table(void);
683 void lnet_debug_peer(lnet_nid_t nid);
684
685 #endif