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();
153 lnet_net_lock(int cpt)
155 cfs_percpt_lock(the_lnet.ln_net_lock, cpt);
159 lnet_net_unlock(int cpt)
161 cfs_percpt_unlock(the_lnet.ln_net_lock, cpt);
165 lnet_net_lock_current(void)
167 int cpt = lnet_cpt_current();
173 #define LNET_LOCK() lnet_net_lock(LNET_LOCK_EX)
174 #define LNET_UNLOCK() lnet_net_unlock(LNET_LOCK_EX)
178 #define lnet_ptl_lock(ptl) cfs_spin_lock(&(ptl)->ptl_lock)
179 #define lnet_ptl_unlock(ptl) cfs_spin_unlock(&(ptl)->ptl_lock)
180 #define lnet_eq_wait_lock() cfs_spin_lock(&the_lnet.ln_eq_wait_lock)
181 #define lnet_eq_wait_unlock() cfs_spin_unlock(&the_lnet.ln_eq_wait_lock)
182 #define lnet_ni_lock(ni) cfs_spin_lock(&(ni)->ni_lock)
183 #define lnet_ni_unlock(ni) cfs_spin_unlock(&(ni)->ni_lock)
184 #define LNET_MUTEX_LOCK(m) cfs_mutex_lock(m)
185 #define LNET_MUTEX_UNLOCK(m) cfs_mutex_unlock(m)
187 #else /* !__KERNEL__ */
189 # ifndef HAVE_LIBPTHREAD
190 #define LNET_SINGLE_THREADED_LOCK(l) \
192 LASSERT ((l) == 0); \
196 #define LNET_SINGLE_THREADED_UNLOCK(l) \
198 LASSERT ((l) == 1); \
202 #define LNET_MUTEX_LOCK(m) LNET_SINGLE_THREADED_LOCK(*(m))
203 #define LNET_MUTEX_UNLOCK(m) LNET_SINGLE_THREADED_UNLOCK(*(m))
205 #define lnet_ptl_lock(ptl) \
206 LNET_SINGLE_THREADED_LOCK((ptl)->ptl_lock)
207 #define lnet_ptl_unlock(ptl) \
208 LNET_SINGLE_THREADED_UNLOCK((ptl)->ptl_lock)
210 #define lnet_eq_wait_lock() \
211 LNET_SINGLE_THREADED_LOCK(the_lnet.ln_eq_wait_lock)
212 #define lnet_eq_wait_unlock() \
213 LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_eq_wait_lock)
215 #define lnet_ni_lock(ni) \
216 LNET_SINGLE_THREADED_LOCK((ni)->ni_lock)
217 #define lnet_ni_unlock(ni) \
218 LNET_SINGLE_THREADED_UNLOCK((ni)->ni_lock)
220 # else /* HAVE_LIBPTHREAD */
222 #define LNET_MUTEX_LOCK(m) pthread_mutex_lock(m)
223 #define LNET_MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
225 #define lnet_ptl_lock(ptl) pthread_mutex_lock(&(ptl)->ptl_lock)
226 #define lnet_ptl_unlock(ptl) pthread_mutex_unlock(&(ptl)->ptl_lock)
228 #define lnet_eq_wait_lock() pthread_mutex_lock(&the_lnet.ln_eq_wait_lock)
229 #define lnet_eq_wait_unlock() pthread_mutex_unlock(&the_lnet.ln_eq_wait_lock)
231 #define lnet_ni_lock(ni) pthread_mutex_lock(&(ni)->ni_lock)
232 #define lnet_ni_unlock(ni) pthread_mutex_unlock(&(ni)->ni_lock)
234 # endif /* HAVE_LIBPTHREAD */
235 #endif /* __KERNEL__ */
237 #define MAX_PORTALS 64
239 /* these are only used by code with LNET_USE_LIB_FREELIST, but we still
240 * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */
241 #define LNET_FL_MAX_MES 2048
242 #define LNET_FL_MAX_MDS 2048
243 #define LNET_FL_MAX_EQS 512
244 #define LNET_FL_MAX_MSGS 2048 /* Outstanding messages */
246 #ifdef LNET_USE_LIB_FREELIST
248 int lnet_freelist_init(lnet_freelist_t *fl, int n, int size);
249 void lnet_freelist_fini(lnet_freelist_t *fl);
252 lnet_freelist_alloc (lnet_freelist_t *fl)
254 /* ALWAYS called with liblock held */
257 if (cfs_list_empty (&fl->fl_list))
260 o = cfs_list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
261 cfs_list_del (&o->fo_list);
262 return ((void *)&o->fo_contents);
266 lnet_freelist_free (lnet_freelist_t *fl, void *obj)
268 /* ALWAYS called with liblock held */
269 lnet_freeobj_t *o = cfs_list_entry (obj, lnet_freeobj_t, fo_contents);
271 cfs_list_add (&o->fo_list, &fl->fl_list);
275 static inline lnet_eq_t *
278 /* NEVER called with resource lock held */
279 struct lnet_res_container *rec = &the_lnet.ln_eq_container;
282 LASSERT(LNET_CPT_NUMBER == 1);
285 eq = (lnet_eq_t *)lnet_freelist_alloc(&rec->rec_freelist);
292 lnet_eq_free_locked(lnet_eq_t *eq)
294 /* ALWAYS called with resource lock held */
295 struct lnet_res_container *rec = &the_lnet.ln_eq_container;
297 LASSERT(LNET_CPT_NUMBER == 1);
298 lnet_freelist_free(&rec->rec_freelist, eq);
302 lnet_eq_free(lnet_eq_t *eq)
305 lnet_eq_free_locked(eq);
309 static inline lnet_libmd_t *
310 lnet_md_alloc (lnet_md_t *umd)
312 /* NEVER called with resource lock held */
313 struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
316 LASSERT(LNET_CPT_NUMBER == 1);
319 md = (lnet_libmd_t *)lnet_freelist_alloc(&rec->rec_freelist);
323 CFS_INIT_LIST_HEAD(&md->md_list);
329 lnet_md_free_locked(lnet_libmd_t *md)
331 /* ALWAYS called with resource lock held */
332 struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
334 LASSERT(LNET_CPT_NUMBER == 1);
335 lnet_freelist_free(&rec->rec_freelist, md);
339 lnet_md_free(lnet_libmd_t *md)
342 lnet_md_free_locked(md);
346 static inline lnet_me_t *
349 /* NEVER called with resource lock held */
350 struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
353 LASSERT(LNET_CPT_NUMBER == 1);
356 me = (lnet_me_t *)lnet_freelist_alloc(&rec->rec_freelist);
363 lnet_me_free_locked(lnet_me_t *me)
365 /* ALWAYS called with resource lock held */
366 struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
368 LASSERT(LNET_CPT_NUMBER == 1);
369 lnet_freelist_free(&rec->rec_freelist, me);
373 lnet_me_free(lnet_me_t *me)
376 lnet_me_free_locked(me);
380 static inline lnet_msg_t *
381 lnet_msg_alloc (void)
383 /* NEVER called with network lock held */
384 struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0];
387 LASSERT(LNET_CPT_NUMBER == 1);
390 msg = (lnet_msg_t *)lnet_freelist_alloc(&msc->msc_freelist);
394 /* NULL pointers, clear flags etc */
395 memset(msg, 0, sizeof(*msg));
397 msg->msg_ev.uid = LNET_UID_ANY;
404 lnet_msg_free_locked(lnet_msg_t *msg)
406 /* ALWAYS called with network lock held */
407 struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0];
409 LASSERT(LNET_CPT_NUMBER == 1);
410 LASSERT(!msg->msg_onactivelist);
411 lnet_freelist_free(&msc->msc_freelist, msg);
415 lnet_msg_free (lnet_msg_t *msg)
418 lnet_msg_free_locked(msg);
422 #else /* !LNET_USE_LIB_FREELIST */
424 static inline lnet_eq_t *
427 /* NEVER called with liblock held */
430 LIBCFS_ALLOC(eq, sizeof(*eq));
435 lnet_eq_free(lnet_eq_t *eq)
437 /* ALWAYS called with resource lock held */
438 LIBCFS_FREE(eq, sizeof(*eq));
441 static inline lnet_libmd_t *
442 lnet_md_alloc (lnet_md_t *umd)
444 /* NEVER called with liblock held */
449 if ((umd->options & LNET_MD_KIOV) != 0) {
451 size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
453 niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
455 size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
458 LIBCFS_ALLOC(md, size);
461 /* Set here in case of early free */
462 md->md_options = umd->options;
464 CFS_INIT_LIST_HEAD(&md->md_list);
471 lnet_md_free(lnet_libmd_t *md)
473 /* ALWAYS called with resource lock held */
476 if ((md->md_options & LNET_MD_KIOV) != 0)
477 size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
479 size = offsetof(lnet_libmd_t, md_iov.iov[md->md_niov]);
481 LIBCFS_FREE(md, size);
484 static inline lnet_me_t *
487 /* NEVER called with liblock held */
490 LIBCFS_ALLOC(me, sizeof(*me));
495 lnet_me_free(lnet_me_t *me)
497 /* ALWAYS called with resource lock held */
498 LIBCFS_FREE(me, sizeof(*me));
501 static inline lnet_msg_t *
504 /* NEVER called with liblock held */
507 LIBCFS_ALLOC(msg, sizeof(*msg));
509 /* no need to zero, LIBCFS_ALLOC does for us */
513 msg->msg_ev.uid = LNET_UID_ANY;
520 lnet_msg_free(lnet_msg_t *msg)
522 /* ALWAYS called with network lock held */
523 LASSERT(!msg->msg_onactivelist);
524 LIBCFS_FREE(msg, sizeof(*msg));
527 #define lnet_eq_free_locked(eq) lnet_eq_free(eq)
528 #define lnet_md_free_locked(md) lnet_md_free(md)
529 #define lnet_me_free_locked(me) lnet_me_free(me)
530 #define lnet_msg_free_locked(msg) lnet_msg_free(msg)
532 #endif /* LNET_USE_LIB_FREELIST */
534 lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec,
536 void lnet_res_lh_initialize(struct lnet_res_container *rec,
537 lnet_libhandle_t *lh);
539 lnet_res_lh_invalidate(lnet_libhandle_t *lh)
541 /* ALWAYS called with resource lock held */
542 /* NB: cookie is still useful, don't reset it */
543 cfs_list_del(&lh->lh_hash_chain);
547 lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
550 LNetInvalidateHandle(handle);
554 handle->cookie = eq->eq_lh.lh_cookie;
557 static inline lnet_eq_t *
558 lnet_handle2eq(lnet_handle_eq_t *handle)
560 /* ALWAYS called with resource lock held */
561 lnet_libhandle_t *lh;
563 lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie);
567 return lh_entry(lh, lnet_eq_t, eq_lh);
571 lnet_md2handle (lnet_handle_md_t *handle, lnet_libmd_t *md)
573 handle->cookie = md->md_lh.lh_cookie;
576 static inline lnet_libmd_t *
577 lnet_handle2md(lnet_handle_md_t *handle)
579 /* ALWAYS called with resource lock held */
580 lnet_libhandle_t *lh;
583 cpt = lnet_cpt_of_cookie(handle->cookie);
584 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
589 return lh_entry(lh, lnet_libmd_t, md_lh);
592 static inline lnet_libmd_t *
593 lnet_wire_handle2md(lnet_handle_wire_t *wh)
595 /* ALWAYS called with resource lock held */
596 lnet_libhandle_t *lh;
599 if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
602 cpt = lnet_cpt_of_cookie(wh->wh_object_cookie);
603 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
604 wh->wh_object_cookie);
608 return lh_entry(lh, lnet_libmd_t, md_lh);
612 lnet_me2handle (lnet_handle_me_t *handle, lnet_me_t *me)
614 handle->cookie = me->me_lh.lh_cookie;
617 static inline lnet_me_t *
618 lnet_handle2me(lnet_handle_me_t *handle)
620 /* ALWAYS called with resource lock held */
621 lnet_libhandle_t *lh;
624 cpt = lnet_cpt_of_cookie(handle->cookie);
625 lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt],
630 return lh_entry(lh, lnet_me_t, me_lh);
634 lnet_peer_addref_locked(lnet_peer_t *lp)
636 LASSERT (lp->lp_refcount > 0);
640 extern void lnet_destroy_peer_locked(lnet_peer_t *lp);
643 lnet_peer_decref_locked(lnet_peer_t *lp)
645 LASSERT (lp->lp_refcount > 0);
647 if (lp->lp_refcount == 0)
648 lnet_destroy_peer_locked(lp);
652 lnet_isrouter(lnet_peer_t *lp)
654 return lp->lp_rtr_refcount != 0;
658 lnet_ni_addref_locked(lnet_ni_t *ni, int cpt)
660 LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER);
661 LASSERT(*ni->ni_refs[cpt] >= 0);
663 (*ni->ni_refs[cpt])++;
667 lnet_ni_addref(lnet_ni_t *ni)
670 lnet_ni_addref_locked(ni, 0);
675 lnet_ni_decref_locked(lnet_ni_t *ni, int cpt)
677 LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER);
678 LASSERT(*ni->ni_refs[cpt] > 0);
680 (*ni->ni_refs[cpt])--;
684 lnet_ni_decref(lnet_ni_t *ni)
687 lnet_ni_decref_locked(ni, 0);
691 void lnet_ni_free(lnet_ni_t *ni);
694 lnet_nid2peerhash(lnet_nid_t nid)
696 return cfs_hash_long(nid, LNET_PEER_HASH_BITS);
699 extern lnd_t the_lolnd;
702 /* unconditional registration */
703 #define LNET_REGISTER_ULND(lnd) \
707 lnet_register_lnd(&(lnd)); \
710 /* conditional registration */
711 #define LNET_REGISTER_ULND_IF_PRESENT(lnd) \
713 extern lnd_t lnd __attribute__ ((weak, alias("the_lolnd"))); \
715 if (&(lnd) != &the_lolnd) \
716 lnet_register_lnd(&(lnd)); \
722 lnet_set_msg_uid(lnet_ni_t *ni, lnet_msg_t *msg, lnet_uid_t uid)
724 LASSERT (msg->msg_ev.uid == LNET_UID_ANY);
725 msg->msg_ev.uid = uid;
729 extern int lnet_cpt_of_nid_locked(lnet_nid_t nid);
730 extern int lnet_cpt_of_nid(lnet_nid_t nid);
731 extern lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
732 extern lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt);
733 static inline lnet_ni_t *
734 lnet_net2ni(__u32 net)
739 ni = lnet_net2ni_locked(net, 0);
745 int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, cfs_time_t when);
746 void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when);
747 int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid);
748 int lnet_check_routes(void);
749 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
750 void lnet_destroy_routes(void);
751 int lnet_get_route(int idx, __u32 *net, __u32 *hops,
752 lnet_nid_t *gateway, __u32 *alive);
753 void lnet_proc_init(void);
754 void lnet_proc_fini(void);
755 int lnet_rtrpools_alloc(int im_a_router);
756 void lnet_rtrpools_free(void);
757 lnet_remotenet_t *lnet_find_net_locked (__u32 net);
759 int lnet_islocalnid(lnet_nid_t nid);
760 int lnet_islocalnet(__u32 net);
762 void lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md,
763 unsigned int offset, unsigned int mlen);
764 void lnet_msg_detach_md(lnet_msg_t *msg, int status);
765 void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev);
766 void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type);
767 void lnet_msg_commit(lnet_msg_t *msg, int cpt);
768 void lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status);
770 void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev);
771 void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
772 unsigned int offset, unsigned int len);
773 int lnet_send(lnet_nid_t nid, lnet_msg_t *msg, lnet_nid_t rtr_nid);
774 void lnet_return_tx_credits_locked(lnet_msg_t *msg);
775 void lnet_return_rx_credits_locked(lnet_msg_t *msg);
777 /* portals functions */
778 /* portals attributes */
780 lnet_ptl_is_lazy(lnet_portal_t *ptl)
782 return !!(ptl->ptl_options & LNET_PTL_LAZY);
786 lnet_ptl_is_unique(lnet_portal_t *ptl)
788 return !!(ptl->ptl_options & LNET_PTL_MATCH_UNIQUE);
792 lnet_ptl_is_wildcard(lnet_portal_t *ptl)
794 return !!(ptl->ptl_options & LNET_PTL_MATCH_WILDCARD);
798 lnet_ptl_setopt(lnet_portal_t *ptl, int opt)
800 ptl->ptl_options |= opt;
804 lnet_ptl_unsetopt(lnet_portal_t *ptl, int opt)
806 ptl->ptl_options &= ~opt;
809 /* match-table functions */
810 cfs_list_t *lnet_mt_match_head(struct lnet_match_table *mtable,
811 lnet_process_id_t id, __u64 mbits);
812 struct lnet_match_table *lnet_mt_of_attach(unsigned int index,
813 lnet_process_id_t id, __u64 mbits,
816 struct lnet_match_table *lnet_mt_of_match(unsigned int index,
817 lnet_process_id_t id, __u64 mbits);
818 int lnet_mt_match_md(struct lnet_match_table *mtable,
819 struct lnet_match_info *info, struct lnet_msg *msg);
821 /* portals match/attach functions */
822 void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
823 cfs_list_t *matches, cfs_list_t *drops);
824 void lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md);
825 int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg);
827 /* initialized and finalize portals */
828 int lnet_portals_create(void);
829 void lnet_portals_destroy(void);
831 /* message functions */
832 int lnet_parse (lnet_ni_t *ni, lnet_hdr_t *hdr,
833 lnet_nid_t fromnid, void *private, int rdma_req);
834 void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
835 unsigned int offset, unsigned int mlen, unsigned int rlen);
836 lnet_msg_t *lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *get_msg);
837 void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
838 void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
839 void lnet_drop_delayed_msg_list(cfs_list_t *head, char *reason);
840 void lnet_recv_delayed_msg_list(cfs_list_t *head);
842 int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt);
843 void lnet_msg_container_cleanup(struct lnet_msg_container *container);
844 void lnet_msg_containers_destroy(void);
845 int lnet_msg_containers_create(void);
847 char *lnet_msgtyp2str (int type);
848 void lnet_print_hdr (lnet_hdr_t * hdr);
849 int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
851 void lnet_counters_get(lnet_counters_t *counters);
852 void lnet_counters_reset(void);
854 unsigned int lnet_iov_nob (unsigned int niov, struct iovec *iov);
855 int lnet_extract_iov (int dst_niov, struct iovec *dst,
856 int src_niov, struct iovec *src,
857 unsigned int offset, unsigned int len);
859 unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
860 int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
861 int src_niov, lnet_kiov_t *src,
862 unsigned int offset, unsigned int len);
864 void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
865 unsigned int doffset,
866 unsigned int nsiov, struct iovec *siov,
867 unsigned int soffset, unsigned int nob);
868 void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
869 unsigned int iovoffset,
870 unsigned int nkiov, lnet_kiov_t *kiov,
871 unsigned int kiovoffset, unsigned int nob);
872 void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
873 unsigned int kiovoffset,
874 unsigned int niov, struct iovec *iov,
875 unsigned int iovoffset, unsigned int nob);
876 void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
877 unsigned int doffset,
878 unsigned int nskiov, lnet_kiov_t *skiov,
879 unsigned int soffset, unsigned int nob);
882 lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
883 unsigned int nsiov, struct iovec *siov, unsigned int soffset,
886 struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
888 lnet_copy_iov2iov(1, &diov, doffset,
889 nsiov, siov, soffset, nob);
893 lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
894 unsigned int nsiov, lnet_kiov_t *skiov, unsigned int soffset,
897 struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
899 lnet_copy_kiov2iov(1, &diov, doffset,
900 nsiov, skiov, soffset, nob);
904 lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
905 int slen, void *src, unsigned int soffset, unsigned int nob)
907 struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
908 lnet_copy_iov2iov(ndiov, diov, doffset,
909 1, &siov, soffset, nob);
913 lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov, unsigned int doffset,
914 int slen, void *src, unsigned int soffset, unsigned int nob)
916 struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
917 lnet_copy_iov2kiov(ndiov, dkiov, doffset,
918 1, &siov, soffset, nob);
921 void lnet_me_unlink(lnet_me_t *me);
923 void lnet_md_unlink(lnet_libmd_t *md);
924 void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
926 void lnet_register_lnd(lnd_t *lnd);
927 void lnet_unregister_lnd(lnd_t *lnd);
928 int lnet_set_ip_niaddr (lnet_ni_t *ni);
931 int lnet_connect(cfs_socket_t **sockp, lnet_nid_t peer_nid,
932 __u32 local_ip, __u32 peer_ip, int peer_port);
933 void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
934 __u32 peer_ip, int port);
935 int lnet_count_acceptor_nis(void);
936 int lnet_acceptor_timeout(void);
937 int lnet_acceptor_port(void);
939 void lnet_router_checker(void);
942 #ifdef HAVE_LIBPTHREAD
943 int lnet_count_acceptor_nis(void);
944 int lnet_acceptor_port(void);
947 int lnet_acceptor_start(void);
948 void lnet_acceptor_stop(void);
950 void lnet_get_tunables(void);
951 int lnet_peers_start_down(void);
952 int lnet_peer_buffer_credits(lnet_ni_t *ni);
954 int lnet_router_checker_start(void);
955 void lnet_router_checker_stop(void);
956 void lnet_swap_pinginfo(lnet_ping_info_t *info);
958 int lnet_ping_target_init(void);
959 void lnet_ping_target_fini(void);
960 int lnet_ping(lnet_process_id_t id, int timeout_ms,
961 lnet_process_id_t *ids, int n_ids);
963 int lnet_parse_ip2nets (char **networksp, char *ip2nets);
964 int lnet_parse_routes (char *route_str, int *im_a_router);
965 int lnet_parse_networks (cfs_list_t *nilist, char *networks);
967 int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt);
968 lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable,
970 void lnet_peer_tables_cleanup(void);
971 void lnet_peer_tables_destroy(void);
972 int lnet_peer_tables_create(void);
973 void lnet_debug_peer(lnet_nid_t nid);
977 lnet_parse_int_tunable(int *value, char *name)
979 char *env = getenv(name);
985 *value = strtoull(env, &end, 0);
989 CERROR("Can't parse tunable %s=%s\n", name, env);