Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index 37dc5d4..8d836f3 100644 (file)
@@ -1,7 +1,39 @@
 /* -*- 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
  */
@@ -19,8 +51,8 @@
 #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>
 
@@ -28,8 +60,8 @@ extern lnet_t  the_lnet;                        /* THE network */
 
 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) 
@@ -150,6 +182,9 @@ lnet_md_alloc (lnet_md_t *umd)
         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);
 }
 
@@ -232,7 +267,7 @@ lnet_md_alloc (lnet_md_t *umd)
 {
         /* NEVER called with liblock held */
         lnet_libmd_t *md;
-        int           size;
+        unsigned int  size;
         unsigned int  niov;
 
         if ((umd->options & LNET_MD_KIOV) != 0) {
@@ -250,6 +285,7 @@ lnet_md_alloc (lnet_md_t *umd)
                 /* 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);
@@ -259,7 +295,7 @@ 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]);
@@ -321,7 +357,7 @@ static inline void
 lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
 {
         if (eq == NULL) {
-                *handle = LNET_EQ_NONE;
+                LNetInvalidateHandle(handle);
                 return;
         }
 
@@ -449,36 +485,6 @@ lnet_ni_decref(lnet_ni_t *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)
 {
@@ -548,6 +554,7 @@ lnet_remotenet_t *lnet_find_net_locked (__u32 net);
 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);
@@ -647,14 +654,13 @@ int lnet_connect(cfs_socket_t **sockp, lnet_nid_t peer_nid,
                  __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