/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * lib-lnet.h
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/include/lnet/lib-lnet.h
*
* Top level include for library side routines
*/
#error Unsupported Operating System
#endif
+#include <libcfs/libcfs.h>
#include <lnet/types.h>
-#include <libcfs/kp30.h>
#include <lnet/lnet.h>
#include <lnet/lib-types.h>
static inline int lnet_is_wire_handle_none (lnet_handle_wire_t *wh)
{
- return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_NONE.wh_interface_cookie &&
- wh->wh_object_cookie == LNET_WIRE_HANDLE_NONE.wh_object_cookie);
+ return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE &&
+ wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE);
}
-static inline int lnet_md_exhausted (lnet_libmd_t *md)
+static inline int lnet_md_exhausted (lnet_libmd_t *md)
{
return (md->md_threshold == 0 ||
((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
}
#ifdef __KERNEL__
-#define LNET_LOCK() spin_lock(&the_lnet.ln_lock)
-#define LNET_UNLOCK() spin_unlock(&the_lnet.ln_lock)
+#define LNET_LOCK() spin_lock(&the_lnet.ln_lock)
+#define LNET_UNLOCK() spin_unlock(&the_lnet.ln_lock)
#define LNET_MUTEX_DOWN(m) mutex_down(m)
#define LNET_MUTEX_UP(m) mutex_up(m)
#else
if (list_empty (&fl->fl_list))
return (NULL);
-
+
o = list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
list_del (&o->fo_list);
return ((void *)&o->fo_contents);
{
/* ALWAYS called with liblock held */
lnet_freeobj_t *o = list_entry (obj, lnet_freeobj_t, fo_contents);
-
+
list_add (&o->fo_list, &fl->fl_list);
}
{
/* NEVER called with liblock held */
lnet_eq_t *eq;
-
+
LNET_LOCK();
eq = (lnet_eq_t *)lnet_freelist_alloc(&the_lnet.ln_free_eqs);
LNET_UNLOCK();
{
/* NEVER called with liblock held */
lnet_libmd_t *md;
-
+
LNET_LOCK();
md = (lnet_libmd_t *)lnet_freelist_alloc(&the_lnet.ln_free_mds);
LNET_UNLOCK();
+ if (md != NULL)
+ CFS_INIT_LIST_HEAD(&md->md_list);
+
return (md);
}
{
/* NEVER called with liblock held */
lnet_me_t *me;
-
+
LNET_LOCK();
me = (lnet_me_t *)lnet_freelist_alloc(&the_lnet.ln_free_mes);
LNET_UNLOCK();
-
+
return (me);
}
{
/* NEVER called with liblock held */
lnet_msg_t *msg;
-
+
LNET_LOCK();
msg = (lnet_msg_t *)lnet_freelist_alloc(&the_lnet.ln_free_msgs);
LNET_UNLOCK();
{
/* NEVER called with liblock held */
lnet_libmd_t *md;
- int size;
+ unsigned int size;
unsigned int niov;
if ((umd->options & LNET_MD_KIOV) != 0) {
/* Set here in case of early free */
md->md_options = umd->options;
md->md_niov = niov;
+ CFS_INIT_LIST_HEAD(&md->md_list);
}
-
+
return (md);
}
-static inline void
+static inline void
lnet_md_free (lnet_libmd_t *md)
{
/* ALWAYS called with liblock held */
- int size;
+ unsigned int size;
if ((md->md_options & LNET_MD_KIOV) != 0)
size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
return (me);
}
-static inline void
+static inline void
lnet_me_free(lnet_me_t *me)
{
/* ALWAYS called with liblock held */
return (msg);
}
-static inline void
+static inline void
lnet_msg_free(lnet_msg_t *msg)
{
/* ALWAYS called with liblock held */
lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
{
if (eq == NULL) {
- *handle = LNET_EQ_NONE;
+ LNetInvalidateHandle(handle);
return;
}
lnet_handle2eq (lnet_handle_eq_t *handle)
{
/* ALWAYS called with liblock held */
- lnet_libhandle_t *lh = lnet_lookup_cookie(handle->cookie,
+ lnet_libhandle_t *lh = lnet_lookup_cookie(handle->cookie,
LNET_COOKIE_TYPE_EQ);
if (lh == NULL)
return (NULL);
{
/* ALWAYS called with liblock held */
lnet_libhandle_t *lh;
-
+
if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
return (NULL);
-
+
lh = lnet_lookup_cookie(wh->wh_object_cookie,
LNET_COOKIE_TYPE_MD);
if (lh == NULL)
}
static inline void
-lnet_ni_addref_locked(lnet_ni_t *ni)
+lnet_ni_addref_locked(lnet_ni_t *ni)
{
LASSERT (ni->ni_refcount > 0);
ni->ni_refcount++;
}
static inline void
-lnet_ni_addref(lnet_ni_t *ni)
+lnet_ni_addref(lnet_ni_t *ni)
{
LNET_LOCK();
lnet_ni_addref_locked(ni);
LNET_UNLOCK();
}
-static inline lnet_nid_t
-lnet_ptlcompat_srcnid(lnet_nid_t src, lnet_nid_t dst)
-{
- /* Give myself a portals srcnid if I'm sending to portals */
- if (the_lnet.ln_ptlcompat > 0 &&
- LNET_NIDNET(dst) == 0)
- return LNET_MKNID(0, LNET_NIDADDR(src));
-
- return src;
-}
-
-static inline int
-lnet_ptlcompat_matchnid(lnet_nid_t lnet_nid, lnet_nid_t ptl_nid)
-{
- return ((ptl_nid == lnet_nid) ||
- (the_lnet.ln_ptlcompat > 0 &&
- LNET_NIDNET(ptl_nid) == 0 &&
- LNET_NETTYP(LNET_NIDNET(lnet_nid)) != LOLND &&
- LNET_NIDADDR(ptl_nid) == LNET_NIDADDR(lnet_nid)));
-}
-
-static inline int
-lnet_ptlcompat_matchnet(__u32 lnet_net, __u32 ptl_net)
-{
- return ((ptl_net == lnet_net) ||
- (the_lnet.ln_ptlcompat > 0 &&
- ptl_net == 0 &&
- LNET_NETTYP(lnet_net) != LOLND));
-}
-
static inline struct list_head *
lnet_nid2peerhash (lnet_nid_t nid)
{
- unsigned int idx = LNET_NIDADDR(nid) % LNET_PEER_HASHSIZE;
+ unsigned int idx = LNET_NIDADDR(nid) % LNET_PEER_HASHSIZE;
return &the_lnet.ln_peer_hash[idx];
}
extern lnet_ni_t *lnet_nid2ni_locked (lnet_nid_t nid);
extern lnet_ni_t *lnet_net2ni_locked (__u32 net);
static inline lnet_ni_t *
-lnet_net2ni (__u32 net)
+lnet_net2ni (__u32 net)
{
lnet_ni_t *ni;
int lnet_check_routes(void);
int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
void lnet_destroy_routes(void);
-int lnet_get_route(int idx, __u32 *net, __u32 *hops,
+int lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive);
void lnet_proc_init(void);
void lnet_proc_fini(void);
int lnet_islocalnid(lnet_nid_t nid);
int lnet_islocalnet(__u32 net);
+void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev);
void lnet_enq_event_locked(lnet_eq_t *eq, lnet_event_t *ev);
void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
unsigned int offset, unsigned int len);
unsigned int offset, unsigned int len);
unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
-int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
+int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
int src_niov, lnet_kiov_t *src,
unsigned int offset, unsigned int len);
-void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
- unsigned int doffset,
- unsigned int nsiov, struct iovec *siov,
+void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
+ unsigned int doffset,
+ unsigned int nsiov, struct iovec *siov,
unsigned int soffset, unsigned int nob);
-void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
+void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
unsigned int iovoffset,
- unsigned int nkiov, lnet_kiov_t *kiov,
+ unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset, unsigned int nob);
-void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
+void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset,
- unsigned int niov, struct iovec *iov,
+ unsigned int niov, struct iovec *iov,
unsigned int iovoffset, unsigned int nob);
-void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
- unsigned int doffset,
- unsigned int nskiov, lnet_kiov_t *skiov,
+void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
+ unsigned int doffset,
+ unsigned int nskiov, lnet_kiov_t *skiov,
unsigned int soffset, unsigned int nob);
static inline void
__u32 local_ip, __u32 peer_ip, int peer_port);
void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
__u32 peer_ip, int port);
-int lnet_count_acceptor_nis(lnet_ni_t **first_ni);
-int lnet_accept(lnet_ni_t *blind_ni, cfs_socket_t *sock, __u32 magic);
+int lnet_count_acceptor_nis(void);
int lnet_acceptor_timeout(void);
int lnet_acceptor_port(void);
#endif
#ifdef HAVE_LIBPTHREAD
-int lnet_count_acceptor_nis(lnet_ni_t **first_ni);
+int lnet_count_acceptor_nis(void);
int lnet_acceptor_port(void);
#endif
int lnet_create_peer_table(void);
void lnet_debug_peer(lnet_nid_t nid);
+#ifndef __KERNEL__
+static inline int
+lnet_parse_int_tunable(int *value, char *name)
+{
+ char *env = getenv(name);
+ char *end;
+
+ if (env == NULL)
+ return 0;
+
+ *value = strtoull(env, &end, 0);
+ if (*end == 0)
+ return 0;
+
+ CERROR("Can't parse tunable %s=%s\n", name, env);
+ return -EINVAL;
+}
+#endif
+
#endif