4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/include/lnet/lib-lnet.h
36 * Top level include for library side routines
39 #ifndef __LNET_LIB_LNET_H__
40 #define __LNET_LIB_LNET_H__
42 #if defined(__linux__)
43 #include <lnet/linux/lib-lnet.h>
44 #elif defined(__APPLE__)
45 #include <lnet/darwin/lib-lnet.h>
46 #elif defined(__WINNT__)
47 #include <lnet/winnt/lib-lnet.h>
49 #error Unsupported Operating System
52 #include <libcfs/libcfs.h>
53 #include <lnet/types.h>
54 #include <lnet/lnet.h>
55 #include <lnet/lib-types.h>
57 extern lnet_t the_lnet; /* THE network */
59 #if !defined(__KERNEL__) || defined(LNET_USE_LIB_FREELIST)
60 /* 1 CPT, simplify implementation... */
61 # define LNET_CPT_MAX_BITS 0
63 #else /* KERNEL and no freelist */
65 # if (BITS_PER_LONG == 32)
66 /* 2 CPTs, allowing more CPTs might make us under memory pressure */
67 # define LNET_CPT_MAX_BITS 1
69 # else /* 64-bit system */
71 * 256 CPTs for thousands of CPUs, allowing more CPTs might make us
72 * under risk of consuming all lh_cooke.
74 # define LNET_CPT_MAX_BITS 8
75 # endif /* BITS_PER_LONG == 32 */
78 /* max allowed CPT number */
79 #define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
81 #define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
82 #define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
83 #define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
86 #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
88 static inline int lnet_is_wire_handle_none (lnet_handle_wire_t *wh)
90 return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE &&
91 wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE);
94 static inline int lnet_md_exhausted (lnet_libmd_t *md)
96 return (md->md_threshold == 0 ||
97 ((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
98 md->md_offset + md->md_max_size > md->md_length));
101 static inline int lnet_md_unlinkable (lnet_libmd_t *md)
103 /* Should unlink md when its refcount is 0 and either:
104 * - md has been flagged for deletion (by auto unlink or LNetM[DE]Unlink,
105 * in the latter case md may not be exhausted).
106 * - auto unlink is on and md is exhausted.
108 if (md->md_refcount != 0)
111 if ((md->md_flags & LNET_MD_FLAG_ZOMBIE) != 0)
114 return ((md->md_flags & LNET_MD_FLAG_AUTO_UNLINK) != 0 &&
115 lnet_md_exhausted(md));
118 #define lnet_cpt_table() (the_lnet.ln_cpt_table)
119 #define lnet_cpt_current() cfs_cpt_current(the_lnet.ln_cpt_table, 1)
122 lnet_cpt_of_cookie(__u64 cookie)
124 unsigned int cpt = (cookie >> LNET_COOKIE_TYPE_BITS) & LNET_CPT_MASK;
126 /* LNET_CPT_NUMBER doesn't have to be power2, which means we can
127 * get illegal cpt from it's invalid cookie */
128 return cpt < LNET_CPT_NUMBER ? cpt : cpt % LNET_CPT_NUMBER;
132 lnet_res_lock(int cpt)
134 cfs_percpt_lock(the_lnet.ln_res_lock, cpt);
138 lnet_res_unlock(int cpt)
140 cfs_percpt_unlock(the_lnet.ln_res_lock, cpt);
144 lnet_res_lock_current(void)
146 int cpt = lnet_cpt_current();
154 #define lnet_ptl_lock(ptl) cfs_spin_lock(&(ptl)->ptl_lock)
155 #define lnet_ptl_unlock(ptl) cfs_spin_unlock(&(ptl)->ptl_lock)
156 #define lnet_eq_wait_lock() cfs_spin_lock(&the_lnet.ln_eq_wait_lock)
157 #define lnet_eq_wait_unlock() cfs_spin_unlock(&the_lnet.ln_eq_wait_lock)
158 #define LNET_LOCK() cfs_spin_lock(&the_lnet.ln_lock)
159 #define LNET_UNLOCK() cfs_spin_unlock(&the_lnet.ln_lock)
160 #define LNET_MUTEX_LOCK(m) cfs_mutex_lock(m)
161 #define LNET_MUTEX_UNLOCK(m) cfs_mutex_unlock(m)
163 #else /* !__KERNEL__ */
165 # ifndef HAVE_LIBPTHREAD
166 #define LNET_SINGLE_THREADED_LOCK(l) \
168 LASSERT ((l) == 0); \
172 #define LNET_SINGLE_THREADED_UNLOCK(l) \
174 LASSERT ((l) == 1); \
178 #define LNET_LOCK() LNET_SINGLE_THREADED_LOCK(the_lnet.ln_lock)
179 #define LNET_UNLOCK() LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_lock)
180 #define LNET_MUTEX_LOCK(m) LNET_SINGLE_THREADED_LOCK(*(m))
181 #define LNET_MUTEX_UNLOCK(m) LNET_SINGLE_THREADED_UNLOCK(*(m))
183 #define lnet_ptl_lock(ptl) \
184 LNET_SINGLE_THREADED_LOCK((ptl)->ptl_lock)
185 #define lnet_ptl_unlock(ptl) \
186 LNET_SINGLE_THREADED_UNLOCK((ptl)->ptl_lock)
188 #define lnet_eq_wait_lock() \
189 LNET_SINGLE_THREADED_LOCK(the_lnet.ln_eq_wait_lock)
190 #define lnet_eq_wait_unlock() \
191 LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_eq_wait_lock)
193 # else /* HAVE_LIBPTHREAD */
195 #define LNET_LOCK() pthread_mutex_lock(&the_lnet.ln_lock)
196 #define LNET_UNLOCK() pthread_mutex_unlock(&the_lnet.ln_lock)
197 #define LNET_MUTEX_LOCK(m) pthread_mutex_lock(m)
198 #define LNET_MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
200 #define lnet_ptl_lock(ptl) pthread_mutex_lock(&(ptl)->ptl_lock)
201 #define lnet_ptl_unlock(ptl) pthread_mutex_unlock(&(ptl)->ptl_lock)
203 #define lnet_eq_wait_lock() pthread_mutex_lock(&the_lnet.ln_eq_wait_lock)
204 #define lnet_eq_wait_unlock() pthread_mutex_unlock(&the_lnet.ln_eq_wait_lock)
206 # endif /* HAVE_LIBPTHREAD */
207 #endif /* __KERNEL__ */
209 #define MAX_PORTALS 64
211 /* these are only used by code with LNET_USE_LIB_FREELIST, but we still
212 * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */
213 #define LNET_FL_MAX_MES 2048
214 #define LNET_FL_MAX_MDS 2048
215 #define LNET_FL_MAX_EQS 512
216 #define LNET_FL_MAX_MSGS 2048 /* Outstanding messages */
218 #ifdef LNET_USE_LIB_FREELIST
220 int lnet_freelist_init(lnet_freelist_t *fl, int n, int size);
221 void lnet_freelist_fini(lnet_freelist_t *fl);
224 lnet_freelist_alloc (lnet_freelist_t *fl)
226 /* ALWAYS called with liblock held */
229 if (cfs_list_empty (&fl->fl_list))
232 o = cfs_list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
233 cfs_list_del (&o->fo_list);
234 return ((void *)&o->fo_contents);
238 lnet_freelist_free (lnet_freelist_t *fl, void *obj)
240 /* ALWAYS called with liblock held */
241 lnet_freeobj_t *o = cfs_list_entry (obj, lnet_freeobj_t, fo_contents);
243 cfs_list_add (&o->fo_list, &fl->fl_list);
247 static inline lnet_eq_t *
250 /* NEVER called with resource lock held */
251 struct lnet_res_container *rec = &the_lnet.ln_eq_container;
254 LASSERT(LNET_CPT_NUMBER == 1);
257 eq = (lnet_eq_t *)lnet_freelist_alloc(&rec->rec_freelist);
264 lnet_eq_free_locked(lnet_eq_t *eq)
266 /* ALWAYS called with resource lock held */
267 struct lnet_res_container *rec = &the_lnet.ln_eq_container;
269 LASSERT(LNET_CPT_NUMBER == 1);
270 lnet_freelist_free(&rec->rec_freelist, eq);
274 lnet_eq_free(lnet_eq_t *eq)
277 lnet_eq_free_locked(eq);
281 static inline lnet_libmd_t *
282 lnet_md_alloc (lnet_md_t *umd)
284 /* NEVER called with resource lock held */
285 struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
288 LASSERT(LNET_CPT_NUMBER == 1);
291 md = (lnet_libmd_t *)lnet_freelist_alloc(&rec->rec_freelist);
295 CFS_INIT_LIST_HEAD(&md->md_list);
301 lnet_md_free_locked(lnet_libmd_t *md)
303 /* ALWAYS called with resource lock held */
304 struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
306 LASSERT(LNET_CPT_NUMBER == 1);
307 lnet_freelist_free(&rec->rec_freelist, md);
311 lnet_md_free(lnet_libmd_t *md)
314 lnet_md_free_locked(md);
318 static inline lnet_me_t *
321 /* NEVER called with resource lock held */
322 struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
325 LASSERT(LNET_CPT_NUMBER == 1);
328 me = (lnet_me_t *)lnet_freelist_alloc(&rec->rec_freelist);
335 lnet_me_free_locked(lnet_me_t *me)
337 /* ALWAYS called with resource lock held */
338 struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
340 LASSERT(LNET_CPT_NUMBER == 1);
341 lnet_freelist_free(&rec->rec_freelist, me);
345 lnet_me_free(lnet_me_t *me)
348 lnet_me_free_locked(me);
352 static inline lnet_msg_t *
353 lnet_msg_alloc (void)
355 /* NEVER called with network lock held */
356 struct lnet_msg_container *msc = &the_lnet.ln_msg_container;
360 msg = (lnet_msg_t *)lnet_freelist_alloc(&msc->msc_freelist);
364 /* NULL pointers, clear flags etc */
365 memset(msg, 0, sizeof(*msg));
367 msg->msg_ev.uid = LNET_UID_ANY;
374 lnet_msg_free_locked(lnet_msg_t *msg)
376 /* ALWAYS called with network lock held */
377 struct lnet_msg_container *msc = &the_lnet.ln_msg_container;
379 LASSERT(!msg->msg_onactivelist);
380 lnet_freelist_free(&msc->msc_freelist, msg);
384 lnet_msg_free (lnet_msg_t *msg)
387 lnet_msg_free_locked(msg);
391 #else /* !LNET_USE_LIB_FREELIST */
393 static inline lnet_eq_t *
396 /* NEVER called with liblock held */
399 LIBCFS_ALLOC(eq, sizeof(*eq));
404 lnet_eq_free(lnet_eq_t *eq)
406 /* ALWAYS called with resource lock held */
407 LIBCFS_FREE(eq, sizeof(*eq));
410 static inline lnet_libmd_t *
411 lnet_md_alloc (lnet_md_t *umd)
413 /* NEVER called with liblock held */
418 if ((umd->options & LNET_MD_KIOV) != 0) {
420 size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
422 niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
424 size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
427 LIBCFS_ALLOC(md, size);
430 /* Set here in case of early free */
431 md->md_options = umd->options;
433 CFS_INIT_LIST_HEAD(&md->md_list);
440 lnet_md_free(lnet_libmd_t *md)
442 /* ALWAYS called with resource lock held */
445 if ((md->md_options & LNET_MD_KIOV) != 0)
446 size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
448 size = offsetof(lnet_libmd_t, md_iov.iov[md->md_niov]);
450 LIBCFS_FREE(md, size);
453 static inline lnet_me_t *
456 /* NEVER called with liblock held */
459 LIBCFS_ALLOC(me, sizeof(*me));
464 lnet_me_free(lnet_me_t *me)
466 /* ALWAYS called with resource lock held */
467 LIBCFS_FREE(me, sizeof(*me));
470 static inline lnet_msg_t *
473 /* NEVER called with liblock held */
476 LIBCFS_ALLOC(msg, sizeof(*msg));
478 /* no need to zero, LIBCFS_ALLOC does for us */
482 msg->msg_ev.uid = LNET_UID_ANY;
489 lnet_msg_free(lnet_msg_t *msg)
491 /* ALWAYS called with network lock held */
492 LASSERT(!msg->msg_onactivelist);
493 LIBCFS_FREE(msg, sizeof(*msg));
496 #define lnet_eq_free_locked(eq) lnet_eq_free(eq)
497 #define lnet_md_free_locked(md) lnet_md_free(md)
498 #define lnet_me_free_locked(me) lnet_me_free(me)
499 #define lnet_msg_free_locked(msg) lnet_msg_free(msg)
501 #endif /* LNET_USE_LIB_FREELIST */
503 lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec,
505 void lnet_res_lh_initialize(struct lnet_res_container *rec,
506 lnet_libhandle_t *lh);
508 lnet_res_lh_invalidate(lnet_libhandle_t *lh)
510 /* ALWAYS called with resource lock held */
511 /* NB: cookie is still useful, don't reset it */
512 cfs_list_del(&lh->lh_hash_chain);
516 lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
519 LNetInvalidateHandle(handle);
523 handle->cookie = eq->eq_lh.lh_cookie;
526 static inline lnet_eq_t *
527 lnet_handle2eq(lnet_handle_eq_t *handle)
529 /* ALWAYS called with resource lock held */
530 lnet_libhandle_t *lh;
532 lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie);
536 return lh_entry(lh, lnet_eq_t, eq_lh);
540 lnet_md2handle (lnet_handle_md_t *handle, lnet_libmd_t *md)
542 handle->cookie = md->md_lh.lh_cookie;
545 static inline lnet_libmd_t *
546 lnet_handle2md(lnet_handle_md_t *handle)
548 /* ALWAYS called with resource lock held */
549 lnet_libhandle_t *lh;
552 cpt = lnet_cpt_of_cookie(handle->cookie);
553 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
558 return lh_entry(lh, lnet_libmd_t, md_lh);
561 static inline lnet_libmd_t *
562 lnet_wire_handle2md(lnet_handle_wire_t *wh)
564 /* ALWAYS called with resource lock held */
565 lnet_libhandle_t *lh;
568 if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
571 cpt = lnet_cpt_of_cookie(wh->wh_object_cookie);
572 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
573 wh->wh_object_cookie);
577 return lh_entry(lh, lnet_libmd_t, md_lh);
581 lnet_me2handle (lnet_handle_me_t *handle, lnet_me_t *me)
583 handle->cookie = me->me_lh.lh_cookie;
586 static inline lnet_me_t *
587 lnet_handle2me(lnet_handle_me_t *handle)
589 /* ALWAYS called with resource lock held */
590 lnet_libhandle_t *lh;
593 cpt = lnet_cpt_of_cookie(handle->cookie);
594 lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt],
599 return lh_entry(lh, lnet_me_t, me_lh);
603 lnet_peer_addref_locked(lnet_peer_t *lp)
605 LASSERT (lp->lp_refcount > 0);
609 extern void lnet_destroy_peer_locked(lnet_peer_t *lp);
612 lnet_peer_decref_locked(lnet_peer_t *lp)
614 LASSERT (lp->lp_refcount > 0);
616 if (lp->lp_refcount == 0)
617 lnet_destroy_peer_locked(lp);
621 lnet_isrouter(lnet_peer_t *lp)
623 return lp->lp_rtr_refcount != 0;
627 lnet_ni_addref_locked(lnet_ni_t *ni)
629 LASSERT (ni->ni_refcount > 0);
634 lnet_ni_addref(lnet_ni_t *ni)
637 lnet_ni_addref_locked(ni);
642 lnet_ni_decref_locked(lnet_ni_t *ni)
644 LASSERT (ni->ni_refcount > 0);
646 if (ni->ni_refcount == 0)
647 cfs_list_add_tail(&ni->ni_list, &the_lnet.ln_zombie_nis);
651 lnet_ni_decref(lnet_ni_t *ni)
654 lnet_ni_decref_locked(ni);
659 lnet_nid2peerhash(lnet_nid_t nid)
661 return cfs_hash_long(nid, LNET_PEER_HASH_BITS);
664 extern lnd_t the_lolnd;
667 /* unconditional registration */
668 #define LNET_REGISTER_ULND(lnd) \
672 lnet_register_lnd(&(lnd)); \
675 /* conditional registration */
676 #define LNET_REGISTER_ULND_IF_PRESENT(lnd) \
678 extern lnd_t lnd __attribute__ ((weak, alias("the_lolnd"))); \
680 if (&(lnd) != &the_lolnd) \
681 lnet_register_lnd(&(lnd)); \
687 lnet_set_msg_uid(lnet_ni_t *ni, lnet_msg_t *msg, lnet_uid_t uid)
689 LASSERT (msg->msg_ev.uid == LNET_UID_ANY);
690 msg->msg_ev.uid = uid;
694 extern int lnet_cpt_of_nid(lnet_nid_t nid);
695 extern lnet_ni_t *lnet_nid2ni_locked (lnet_nid_t nid);
696 extern lnet_ni_t *lnet_net2ni_locked (__u32 net);
697 static inline lnet_ni_t *
698 lnet_net2ni (__u32 net)
703 ni = lnet_net2ni_locked(net);
709 int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, cfs_time_t when);
710 void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when);
711 int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid);
712 int lnet_check_routes(void);
713 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
714 void lnet_destroy_routes(void);
715 int lnet_get_route(int idx, __u32 *net, __u32 *hops,
716 lnet_nid_t *gateway, __u32 *alive);
717 void lnet_proc_init(void);
718 void lnet_proc_fini(void);
719 void lnet_init_rtrpools(void);
720 int lnet_alloc_rtrpools(int im_a_router);
721 void lnet_free_rtrpools(void);
722 lnet_remotenet_t *lnet_find_net_locked (__u32 net);
724 int lnet_islocalnid(lnet_nid_t nid);
725 int lnet_islocalnet(__u32 net);
727 void lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md,
728 unsigned int offset, unsigned int mlen);
729 void lnet_msg_detach_md(lnet_msg_t *msg, int status);
730 void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev);
731 void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type);
732 void lnet_msg_commit(lnet_msg_t *msg, int sending);
733 void lnet_msg_decommit(lnet_msg_t *msg, int status);
735 void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev);
736 void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
737 unsigned int offset, unsigned int len);
738 int lnet_send(lnet_nid_t nid, lnet_msg_t *msg);
739 void lnet_return_tx_credits_locked(lnet_msg_t *msg);
740 void lnet_return_rx_credits_locked(lnet_msg_t *msg);
742 /* portals functions */
743 /* portals attributes */
745 lnet_ptl_is_lazy(lnet_portal_t *ptl)
747 return !!(ptl->ptl_options & LNET_PTL_LAZY);
751 lnet_ptl_is_unique(lnet_portal_t *ptl)
753 return !!(ptl->ptl_options & LNET_PTL_MATCH_UNIQUE);
757 lnet_ptl_is_wildcard(lnet_portal_t *ptl)
759 return !!(ptl->ptl_options & LNET_PTL_MATCH_WILDCARD);
763 lnet_ptl_setopt(lnet_portal_t *ptl, int opt)
765 ptl->ptl_options |= opt;
769 lnet_ptl_unsetopt(lnet_portal_t *ptl, int opt)
771 ptl->ptl_options &= ~opt;
774 /* match-table functions */
775 cfs_list_t *lnet_mt_match_head(struct lnet_match_table *mtable,
776 lnet_process_id_t id, __u64 mbits);
777 struct lnet_match_table *lnet_mt_of_attach(unsigned int index,
778 lnet_process_id_t id, __u64 mbits,
781 struct lnet_match_table *lnet_mt_of_match(unsigned int index,
782 lnet_process_id_t id, __u64 mbits);
783 int lnet_mt_match_md(struct lnet_match_table *mtable,
784 struct lnet_match_info *info, struct lnet_msg *msg);
786 /* portals match/attach functions */
787 void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
788 cfs_list_t *matches, cfs_list_t *drops);
789 void lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md);
790 int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg);
792 /* initialized and finalize portals */
793 int lnet_portals_create(void);
794 void lnet_portals_destroy(void);
796 /* message functions */
797 int lnet_parse (lnet_ni_t *ni, lnet_hdr_t *hdr,
798 lnet_nid_t fromnid, void *private, int rdma_req);
799 void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
800 unsigned int offset, unsigned int mlen, unsigned int rlen);
801 lnet_msg_t *lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *get_msg);
802 void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
803 void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
804 void lnet_drop_delayed_msg_list(cfs_list_t *head, char *reason);
805 void lnet_recv_delayed_msg_list(cfs_list_t *head);
807 int lnet_msg_container_setup(struct lnet_msg_container *container);
808 void lnet_msg_container_cleanup(struct lnet_msg_container *container);
810 char *lnet_msgtyp2str (int type);
811 void lnet_print_hdr (lnet_hdr_t * hdr);
812 int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
814 unsigned int lnet_iov_nob (unsigned int niov, struct iovec *iov);
815 int lnet_extract_iov (int dst_niov, struct iovec *dst,
816 int src_niov, struct iovec *src,
817 unsigned int offset, unsigned int len);
819 unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
820 int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
821 int src_niov, lnet_kiov_t *src,
822 unsigned int offset, unsigned int len);
824 void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
825 unsigned int doffset,
826 unsigned int nsiov, struct iovec *siov,
827 unsigned int soffset, unsigned int nob);
828 void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
829 unsigned int iovoffset,
830 unsigned int nkiov, lnet_kiov_t *kiov,
831 unsigned int kiovoffset, unsigned int nob);
832 void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
833 unsigned int kiovoffset,
834 unsigned int niov, struct iovec *iov,
835 unsigned int iovoffset, unsigned int nob);
836 void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
837 unsigned int doffset,
838 unsigned int nskiov, lnet_kiov_t *skiov,
839 unsigned int soffset, unsigned int nob);
842 lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
843 unsigned int nsiov, struct iovec *siov, unsigned int soffset,
846 struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
848 lnet_copy_iov2iov(1, &diov, doffset,
849 nsiov, siov, soffset, nob);
853 lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
854 unsigned int nsiov, lnet_kiov_t *skiov, unsigned int soffset,
857 struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
859 lnet_copy_kiov2iov(1, &diov, doffset,
860 nsiov, skiov, soffset, nob);
864 lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
865 int slen, void *src, unsigned int soffset, unsigned int nob)
867 struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
868 lnet_copy_iov2iov(ndiov, diov, doffset,
869 1, &siov, soffset, nob);
873 lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov, unsigned int doffset,
874 int slen, void *src, unsigned int soffset, unsigned int nob)
876 struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
877 lnet_copy_iov2kiov(ndiov, dkiov, doffset,
878 1, &siov, soffset, nob);
881 void lnet_me_unlink(lnet_me_t *me);
883 void lnet_md_unlink(lnet_libmd_t *md);
884 void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
886 void lnet_register_lnd(lnd_t *lnd);
887 void lnet_unregister_lnd(lnd_t *lnd);
888 int lnet_set_ip_niaddr (lnet_ni_t *ni);
891 int lnet_connect(cfs_socket_t **sockp, lnet_nid_t peer_nid,
892 __u32 local_ip, __u32 peer_ip, int peer_port);
893 void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
894 __u32 peer_ip, int port);
895 int lnet_count_acceptor_nis(void);
896 int lnet_acceptor_timeout(void);
897 int lnet_acceptor_port(void);
899 void lnet_router_checker(void);
902 #ifdef HAVE_LIBPTHREAD
903 int lnet_count_acceptor_nis(void);
904 int lnet_acceptor_port(void);
907 int lnet_acceptor_start(void);
908 void lnet_acceptor_stop(void);
910 void lnet_get_tunables(void);
911 int lnet_peers_start_down(void);
912 int lnet_peer_buffer_credits(lnet_ni_t *ni);
914 int lnet_router_checker_start(void);
915 void lnet_router_checker_stop(void);
916 void lnet_swap_pinginfo(lnet_ping_info_t *info);
918 int lnet_ping_target_init(void);
919 void lnet_ping_target_fini(void);
920 int lnet_ping(lnet_process_id_t id, int timeout_ms,
921 lnet_process_id_t *ids, int n_ids);
923 int lnet_parse_ip2nets (char **networksp, char *ip2nets);
924 int lnet_parse_routes (char *route_str, int *im_a_router);
925 int lnet_parse_networks (cfs_list_t *nilist, char *networks);
927 int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid);
928 lnet_peer_t *lnet_find_peer_locked (lnet_nid_t nid);
929 void lnet_peer_table_cleanup(void);
930 void lnet_peer_table_destroy(void);
931 int lnet_peer_table_create(void);
932 void lnet_debug_peer(lnet_nid_t nid);
936 lnet_parse_int_tunable(int *value, char *name)
938 char *env = getenv(name);
944 *value = strtoull(env, &end, 0);
948 CERROR("Can't parse tunable %s=%s\n", name, env);