Whamcloud - gitweb
LU-1422 lnet: eliminate obsolete Cray Catamount support
authorJames Simmons <uja.ornl@gmail.com>
Mon, 2 Jul 2012 17:18:17 +0000 (13:18 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Jul 2012 17:09:54 +0000 (13:09 -0400)
Remove the bulk of code for the no longer supported Catamount
platform on Cray. This was conditionally compiled under CRAY_XT3.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I011058fb0bc74aaf01ec34ea6385e54bdee2356f
Reviewed-on: http://review.whamcloud.com/3064
Reviewed-by: Cory Spitz <spitzcor@cray.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
30 files changed:
build/autoconf/lustre-build.m4
libcfs/include/libcfs/libcfs_private.h
lnet/autoconf/lustre-lnet.m4
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/types.h
lnet/klnds/ptllnd/Makefile.in
lnet/klnds/ptllnd/ptllnd.c
lnet/klnds/ptllnd/ptllnd.h
lnet/klnds/ptllnd/ptllnd_cb.c
lnet/klnds/ptllnd/ptllnd_modparams.c
lnet/klnds/ptllnd/ptllnd_peer.c
lnet/klnds/ptllnd/ptllnd_ptltrace.c [deleted file]
lnet/klnds/ptllnd/ptllnd_rx_buf.c
lnet/klnds/ptllnd/ptllnd_tx.c
lnet/lnet/api-ni.c
lnet/ulnds/Makefile.in
lnet/ulnds/autoMakefile.am
lnet/ulnds/ptllnd/.gitignore [deleted file]
lnet/ulnds/ptllnd/Makefile.am [deleted file]
lnet/ulnds/ptllnd/ptllnd.c [deleted file]
lnet/ulnds/ptllnd/ptllnd.h [deleted file]
lnet/ulnds/ptllnd/ptllnd_cb.c [deleted file]
lnet/utils/Makefile.am
lnet/utils/genlib.sh
lustre/include/lustre_net.h
lustre/liblustre/Makefile.am
lustre/liblustre/genlib.sh
lustre/liblustre/tests/Makefile.am
lustre/ptlrpc/events.c
lustre/ptlrpc/import.c

index b50e899..98bc950 100644 (file)
@@ -286,23 +286,6 @@ AC_SUBST(LIBCFS_INCLUDE_DIR)
 ])
 
 #
-# LB_CONFIG_CRAY_XT3
-#
-# Enable Cray XT3 features
-#
-AC_DEFUN([LB_CONFIG_CRAY_XT3],
-[AC_MSG_CHECKING([whether to build Cray XT3 features])
-AC_ARG_ENABLE([cray_xt3],
-       AC_HELP_STRING([--enable-cray-xt3],
-                       [enable building of Cray XT3 features]),
-       [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
-AC_MSG_RESULT([$enable_cray_xt3])
-if test x$enable_cray_xt3 != xno; then
-        AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
-fi
-])
-
-#
 # LB_CONFIG_BGL
 #
 # Enable BGL features
@@ -715,7 +698,6 @@ AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
-AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
 AM_CONDITIONAL(ARCH_x86, test x$target_cpu != "xpowerpc")
@@ -773,7 +755,6 @@ LB_LIBCFS_DIR
 
 LB_INCLUDE_RULES
 
-LB_CONFIG_CRAY_XT3
 LB_CONFIG_BGL
 LB_PATH_DEFAULTS
 
index 233de97..0bf8c03 100644 (file)
@@ -287,18 +287,10 @@ do {                                                                           \
 # endif /* LIBCFS_DEBUG */
 # define KLASSERT(e) ((void)0)
 # define printk printf
-# ifdef CRAY_XT3                                /* buggy calloc! */
-#  define LIBCFS_ALLOC_GFP(ptr, size, mask)    \
-   do {                                                \
-       (ptr) = malloc(size);                   \
-       memset(ptr, 0, size);                   \
-   } while (0)
-# else
-#  define LIBCFS_ALLOC_GFP(ptr, size, mask)    \
-   do {                                                \
+#define LIBCFS_ALLOC_GFP(ptr, size, mask)      \
+do {                                           \
        (ptr) = calloc(1, size);                \
-   } while (0)
-# endif
+} while (0)
 # define LIBCFS_FREE(ptr, size) do { free(ptr); } while((size) - (size))
 # define LIBCFS_ALLOC(ptr, size)                               \
         LIBCFS_ALLOC_GFP(ptr, size, 0)
index 3966bcf..4cd30eb 100644 (file)
@@ -741,7 +741,6 @@ AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
-AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
 ])
 
@@ -781,7 +780,6 @@ lnet/selftest/autoMakefile
 lnet/ulnds/Makefile
 lnet/ulnds/autoMakefile
 lnet/ulnds/socklnd/Makefile
-lnet/ulnds/ptllnd/Makefile
 lnet/utils/Makefile
 lnet/include/lnet/darwin/Makefile
 ])
index 547a4b3..90e6b32 100644 (file)
@@ -393,9 +393,6 @@ lnet_msg_alloc (void)
        if (msg != NULL) {
                /* NULL pointers, clear flags etc */
                memset(msg, 0, sizeof(*msg));
-#ifdef CRAY_XT3
-               msg->msg_ev.uid = LNET_UID_ANY;
-#endif
        }
        return msg;
 }
@@ -507,12 +504,6 @@ lnet_msg_alloc(void)
         LIBCFS_ALLOC(msg, sizeof(*msg));
 
         /* no need to zero, LIBCFS_ALLOC does for us */
-
-#ifdef CRAY_XT3
-        if (msg != NULL) {
-                msg->msg_ev.uid = LNET_UID_ANY;
-        }
-#endif
         return (msg);
 }
 
@@ -717,15 +708,6 @@ do {                                                                    \
 } while (0)
 #endif
 
-#ifdef CRAY_XT3
-inline static void
-lnet_set_msg_uid(lnet_ni_t *ni, lnet_msg_t *msg, lnet_uid_t uid)
-{
-        LASSERT (msg->msg_ev.uid == LNET_UID_ANY);
-        msg->msg_ev.uid = uid;
-}
-#endif
-
 extern int lnet_cpt_of_nid_locked(lnet_nid_t nid);
 extern int lnet_cpt_of_nid(lnet_nid_t nid);
 extern lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
index 5a0270f..b05f25a 100644 (file)
@@ -70,11 +70,6 @@ typedef __u32 lnet_pid_t;
 /** wildcard PID that matches any lnet_pid_t */
 #define LNET_PID_ANY      ((lnet_pid_t) -1)
 
-#ifdef CRAY_XT3
-typedef __u32 lnet_uid_t;
-#define LNET_UID_ANY      ((lnet_uid_t) -1)
-#endif
-
 #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
 #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
 
@@ -460,10 +455,6 @@ typedef struct {
          * \see lnet_md_t::options
          */
         unsigned int        offset;
-#ifdef CRAY_XT3
-        lnet_uid_t          uid;
-#endif
-
         /**
          * The sequence number for this event. Sequence numbers are unique
          * to each event.
index ec2f9bb..1532ab6 100755 (executable)
@@ -7,7 +7,6 @@ kptllnd-objs := ptllnd.o                \
                 ptllnd_modparams.o      \
                 ptllnd_peer.o           \
                 ptllnd_rx_buf.o         \
-                ptllnd_tx.o            \
-                ptllnd_ptltrace.o
+                ptllnd_tx.o
 
 @INCLUDE_RULES@
index 279db5a..42d82f7 100644 (file)
@@ -773,7 +773,6 @@ kptllnd_base_startup (void)
 
         cfs_rwlock_init(&kptllnd_data.kptl_peer_rw_lock);
         cfs_waitq_init(&kptllnd_data.kptl_watchdog_waitq);
-        cfs_atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
         CFS_INIT_LIST_HEAD(&kptllnd_data.kptl_closing_peers);
         CFS_INIT_LIST_HEAD(&kptllnd_data.kptl_zombie_peers);
 
index 32becf4..e019028 100644 (file)
@@ -73,9 +73,6 @@
 #include <lnet/lib-lnet.h>
 #include <lnet/lnet-sysctl.h>
 #include <portals/p30.h>
-#ifdef CRAY_XT3
-#include <portals/ptltrace.h>
-#endif
 #include <lnet/ptllnd.h>        /* Depends on portals/p30.h */
 
 /*
@@ -111,11 +108,6 @@ typedef struct
         int             *kptl_peer_hash_table_size; /* # slots in peer hash table */
         int             *kptl_reschedule_loops; /* scheduler yield loops */
         int             *kptl_ack_puts;         /* make portals ack PUTs */
-#ifdef CRAY_XT3
-        int             *kptl_ptltrace_on_timeout; /* dump pltrace on timeout? */
-        int             *kptl_ptltrace_on_fail;    /* dump pltrace on PTL_NAL_FAILED? */
-        char           **kptl_ptltrace_basename;  /* ptltrace dump file basename */
-#endif
 #ifdef PJK_DEBUGGING
         int             *kptl_simulation_bitmap;/* simulation bitmap */
 #endif
@@ -150,9 +142,6 @@ typedef struct kptl_rx                          /* receive message */
         int                     rx_nob;         /* received message size */
         unsigned long           rx_treceived;   /* time received */
         ptl_process_id_t        rx_initiator;   /* sender's address */
-#ifdef CRAY_XT3
-        ptl_uid_t               rx_uid;         /* sender's uid */
-#endif
         kptl_peer_t            *rx_peer;        /* pointer to peer */
         char                    rx_space[0];    /* copy of incoming request */
 } kptl_rx_t;
@@ -282,7 +271,6 @@ struct kptl_data
         cfs_list_t              kptl_sched_rxbq;       /* rxb requiring reposting */
 
         cfs_waitq_t             kptl_watchdog_waitq;   /* watchdog sleeps here */
-        cfs_atomic_t            kptl_needs_ptltrace;   /* watchdog thread to dump ptltrace */
 
         kptl_rx_buffer_pool_t   kptl_rx_buffer_pool;   /* rx buffer pool */
         cfs_mem_cache_t*        kptl_rx_cache;         /* rx descripter cache */
@@ -343,17 +331,6 @@ kptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
 #endif
 }
 
-static inline void
-kptllnd_schedule_ptltrace_dump (void)
-{
-#ifdef CRAY_XT3
-        if (*kptllnd_tunables.kptl_ptltrace_on_fail) {
-                cfs_atomic_inc(&kptllnd_data.kptl_needs_ptltrace);
-                cfs_waitq_signal(&kptllnd_data.kptl_watchdog_waitq);
-        }
-#endif
-}
-
 int  kptllnd_startup(lnet_ni_t *ni);
 void kptllnd_shutdown(lnet_ni_t *ni);
 int  kptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
index ff93136..d78001d 100644 (file)
@@ -299,7 +299,6 @@ kptllnd_active_rdma(kptl_rx_t *rx, lnet_msg_t *lntmsg, int type,
                 kptllnd_peer_close(peer, -EIO);
                 /* Everything (including this RDMA) queued on the peer will
                  * be completed with failure */
-                kptllnd_schedule_ptltrace_dump();
         }
 
         return 0;
@@ -545,17 +544,6 @@ kptllnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
         LASSERT (!(kiov != NULL && iov != NULL)); /* never both */
         LASSERT (niov <= PTL_MD_MAX_IOV);       /* !!! */
 
-#ifdef CRAY_XT3
-        if (lntmsg != NULL &&
-            rx->rx_uid != 0) {
-                /* Set the UID if the sender's uid isn't 0; i.e. non-root
-                 * running in userspace (e.g. a catamount node; linux kernel
-                 * senders, including routers have uid 0).  If this is a lustre
-                 * RPC request, this tells lustre not to trust the creds in the
-                 * RPC message body. */
-                lnet_set_msg_uid(ni, lntmsg, rx->rx_uid);
-        }
-#endif
         switch(rxmsg->ptlm_type)
         {
         default:
@@ -697,24 +685,7 @@ kptllnd_watchdog(void *arg)
         /* threads shut down in phase 2 after all peers have been destroyed */
         while (kptllnd_data.kptl_shutdown < 2) {
 
-                /* add a check for needs ptltrace
-                 * yes, this is blatant hijacking of this thread
-                 * we can't dump directly from tx or rx _callbacks as it
-                 * deadlocks portals and takes out the node
-                */
-
-                if (cfs_atomic_read(&kptllnd_data.kptl_needs_ptltrace)) {
-#ifdef CRAY_XT3
-                        kptllnd_dump_ptltrace();
-                        /* we only dump once, no matter how many pending */
-                        cfs_atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
-#else
-                        LBUG();
-#endif
-                }
-
                 timeout = (int)(deadline - jiffies);
-
                 if (timeout <= 0) {
                         const int n = 4;
                         const int p = 1;
index e36627e..09ca397 100644 (file)
@@ -104,19 +104,6 @@ static int ack_puts = 0;
 CFS_MODULE_PARM(ack_puts, "i", int, 0644,
                 "get portals to ack all PUTs");
 
-#ifdef CRAY_XT3
-static int ptltrace_on_timeout = 0;
-CFS_MODULE_PARM(ptltrace_on_timeout, "i", int, 0644,
-                "dump ptltrace on timeout");
-
-static int ptltrace_on_fail = 1;
-CFS_MODULE_PARM(ptltrace_on_fail, "i", int, 0644,
-                "dump ptltrace on Portals failure");
-
-static char *ptltrace_basename = "/tmp/lnet-ptltrace";
-CFS_MODULE_PARM(ptltrace_basename, "s", charp, 0644,
-                "ptltrace dump file basename");
-#endif
 #ifdef PJK_DEBUGGING
 static int simulation_bitmap = 0;
 CFS_MODULE_PARM(simulation_bitmap, "i", int, 0444,
@@ -141,11 +128,6 @@ kptl_tunables_t kptllnd_tunables = {
         .kptl_peer_hash_table_size   = &peer_hash_table_size,
         .kptl_reschedule_loops       = &reschedule_loops,
         .kptl_ack_puts               = &ack_puts,
-#ifdef CRAY_XT3
-        .kptl_ptltrace_on_timeout    = &ptltrace_on_timeout,
-        .kptl_ptltrace_on_fail       = &ptltrace_on_fail,
-        .kptl_ptltrace_basename      = &ptltrace_basename,
-#endif
 #ifdef PJK_DEBUGGING
         .kptl_simulation_bitmap      = &simulation_bitmap,
 #endif
@@ -153,17 +135,6 @@ kptl_tunables_t kptllnd_tunables = {
 
 
 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
-#ifdef CRAY_XT3
-static char ptltrace_basename_space[1024];
-
-static void
-kptllnd_init_strtunable(char **str_param, char *space, int size)
-{
-        strncpy(space, *str_param, size);
-        space[size - 1] = 0;
-        *str_param = space;
-}
-#endif
 
 #ifndef HAVE_SYSCTL_UNNUMBERED
 
@@ -332,33 +303,6 @@ static cfs_sysctl_table_t kptllnd_ctl_table[] = {
                 .mode     = 0644,
                 .proc_handler = &proc_dointvec
         },
-#ifdef CRAY_XT3
-        {
-                .ctl_name = KPTLLND_TRACETIMEOUT,
-                .procname = "ptltrace_on_timeout",
-                .data     = &ptltrace_on_timeout,
-                .maxlen   = sizeof(int),
-                .mode     = 0644,
-                .proc_handler = &proc_dointvec
-        },
-        {
-                .ctl_name = KPTLLND_TRACEFAIL,
-                .procname = "ptltrace_on_fail",
-                .data     = &ptltrace_on_fail,
-                .maxlen   = sizeof(int),
-                .mode     = 0644,
-                .proc_handler = &proc_dointvec
-        },
-        {
-                .ctl_name = KPTLLND_TRACEBASENAME,
-                .procname = "ptltrace_basename",
-                .data     = ptltrace_basename_space,
-                .maxlen   = sizeof(ptltrace_basename_space),
-                .mode     = 0644,
-                .proc_handler = &proc_dostring,
-                .strategy = &sysctl_string
-        },
-#endif
 #ifdef PJK_DEBUGGING
         {
                 .ctl_name = KPTLLND_SIMULATION_BITMAP,
@@ -388,11 +332,6 @@ static cfs_sysctl_table_t kptllnd_top_ctl_table[] = {
 int
 kptllnd_tunables_init ()
 {
-#ifdef CRAY_XT3
-        kptllnd_init_strtunable(&ptltrace_basename,
-                                ptltrace_basename_space,
-                                sizeof(ptltrace_basename_space));
-#endif
         kptllnd_tunables.kptl_sysctl =
                 cfs_register_sysctl_table(kptllnd_top_ctl_table, 0);
 
index f94a9c0..f792de7 100644 (file)
@@ -863,7 +863,6 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
         /* Nuke everything (including tx we were trying) */
         kptllnd_peer_close(peer, -EIO);
         kptllnd_tx_decref(tx);
-        kptllnd_schedule_ptltrace_dump();
 }
 
 kptl_tx_t *
@@ -999,11 +998,6 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                        (tx->tx_tposted == 0) ? 0UL : (jiffies - tx->tx_tposted),
                        *kptllnd_tunables.kptl_timeout);
 
-#ifdef CRAY_XT3
-                if (*kptllnd_tunables.kptl_ptltrace_on_timeout)
-                        kptllnd_dump_ptltrace();
-#endif
-
                 kptllnd_tx_decref(tx);
 
                 kptllnd_peer_close(peer, -ETIMEDOUT);
diff --git a/lnet/klnds/ptllnd/ptllnd_ptltrace.c b/lnet/klnds/ptllnd/ptllnd_ptltrace.c
deleted file mode 100644 (file)
index 59bcf6f..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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 (c) 2007, 2010, Oracle and/or its affiliates. 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.
- */
-
-#include "ptllnd.h"
-
-#ifdef CRAY_XT3
-static cfs_mutex_t        ptltrace_mutex;
-static cfs_waitq_t        ptltrace_debug_ctlwq;
-
-void
-kptllnd_ptltrace_to_file(char *filename)
-{
-        CFS_DECL_JOURNAL_DATA;
-        CFS_DECL_MMSPACE;
-
-        cfs_file_t *filp;
-        char       *start;
-        char       *tmpbuf;
-        int         len;
-        int         rc;
-        loff_t      offset = 0;
-        int         eof = 0;
-
-        CWARN("dumping ptltrace to %s\n", filename);
-
-        LIBCFS_ALLOC(tmpbuf, PAGE_SIZE);
-        if (tmpbuf == NULL) {
-                CERROR("Can't allocate page buffer to dump %s\n", filename);
-                return;
-        }
-        
-        CFS_PUSH_JOURNAL;
-
-        filp = cfs_filp_open(filename,
-                             O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600, &rc);
-        if (filp == NULL) {
-                if (rc != -EEXIST)
-                        CERROR("Error %d creating %s\n", rc, filename);
-                goto out;
-        }
-
-        CFS_MMSPACE_OPEN;
-
-        while (!eof) { 
-                start = NULL; 
-                len = ptl_proc_read(tmpbuf, &start, offset,
-                                    PAGE_SIZE, &eof, NULL);
-
-                /* we don't allow ptl_proc_read to mimic case 0 or 1 behavior
-                 * for a proc_read method, only #2: from proc_file_read
-                 *
-                 * 2) Set *start = an address within the buffer.
-                 *    Put the data of the requested offset at *start.
-                 *    Return the number of bytes of data placed there.
-                 *    If this number is greater than zero and you
-                 *    didn't signal eof and the reader is prepared to
-                 *    take more data you will be called again with the
-                 *    requested offset advanced by the number of bytes
-                 *    absorbed.
-                 */
-
-                if (len == 0)   /* end of file */
-                        break;
-
-                if (len < 0) {
-                        CERROR("ptl_proc_read: error %d\n", len);
-                        break;
-                }
-
-                if (start < tmpbuf || start + len > tmpbuf + PAGE_SIZE) {
-                        CERROR("ptl_proc_read bug: %p for %d not in %p for %ld\n",
-                               start, len, tmpbuf, PAGE_SIZE);
-                        break;
-                }
-
-                rc = cfs_filp_write(filp, start, len, cfs_filp_poff(filp));
-                if (rc != len) {
-                        if (rc < 0)
-                                CERROR("Error %d writing %s\n", rc, filename);
-                        else
-                                CERROR("Partial write %d(%d) to %s\n",
-                                       rc, len, filename);
-                        break;
-                }
-
-                offset += len;
-        }
-
-        CFS_MMSPACE_CLOSE;
-
-        rc = cfs_filp_fsync(filp);
-        if (rc != 0)
-                CERROR("Error %d syncing %s\n", rc, filename);
-
-        cfs_filp_close(filp);
-out:
-        CFS_POP_JOURNAL;
-        LIBCFS_FREE(tmpbuf, PAGE_SIZE);
-}
-
-int
-kptllnd_dump_ptltrace_thread(void *arg)
-{
-        static char fname[1024];
-
-        libcfs_daemonize("kpt_ptltrace_dump");
-
-        /* serialise with other instances of me */
-        cfs_mutex_lock(&ptltrace_mutex);
-
-        snprintf(fname, sizeof(fname), "%s.%ld.%ld",
-                 *kptllnd_tunables.kptl_ptltrace_basename,
-                 cfs_time_current_sec(), (long)arg);
-
-        kptllnd_ptltrace_to_file(fname);
-
-        cfs_mutex_unlock(&ptltrace_mutex);
-
-        /* unblock my creator */
-        cfs_waitq_signal(&ptltrace_debug_ctlwq);
-        return 0;
-}
-
-void
-kptllnd_dump_ptltrace(void)
-{
-        int            rc;
-        cfs_waitlink_t wait;
-        ENTRY;
-
-        /* taken from libcfs_debug_dumplog */
-        cfs_waitlink_init(&wait);
-        cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
-        cfs_waitq_add(&ptltrace_debug_ctlwq, &wait);
-
-        rc = cfs_create_thread(kptllnd_dump_ptltrace_thread,
-                               (void *)(long)cfs_curproc_pid(),
-                               CFS_DAEMON_FLAGS | CLONE_FS);
-        if (rc < 0) {
-                CERROR("Error %d starting ptltrace dump thread\n", rc);
-        } else {
-                cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE);
-        }
-
-        /* teardown if cfs_kernel_thread() failed */
-        cfs_waitq_del(&ptltrace_debug_ctlwq, &wait);
-        cfs_set_current_state(CFS_TASK_RUNNING);
-        EXIT;
-}
-
-void
-kptllnd_init_ptltrace(void)
-{
-        cfs_waitq_init(&ptltrace_debug_ctlwq);
-        cfs_mutex_init(&ptltrace_mutex);
-}
-#endif
index ff0cff1..f12be7d 100644 (file)
@@ -428,7 +428,6 @@ kptllnd_rx_buffer_callback (ptl_event_t *ev)
                        kptllnd_evtype2str(ev->type), ev->type, rxb,
                        kptllnd_errtype2str(ev->ni_fail_type),
                        ev->ni_fail_type, unlinked);
-                kptllnd_schedule_ptltrace_dump();
         } else if (ev->type == PTL_EVENT_PUT_END &&
                    !rxbp->rxbp_shutdown) {
 
@@ -475,9 +474,6 @@ kptllnd_rx_buffer_callback (ptl_event_t *ev)
 
                         rx->rx_initiator = ev->initiator;
                         rx->rx_treceived = jiffies;
-#ifdef CRAY_XT3
-                        rx->rx_uid = ev->uid;
-#endif
                         /* Queue for attention */
                         cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
                                               flags);
@@ -531,7 +527,6 @@ kptllnd_nak (ptl_process_id_t dest)
         if (rc != PTL_OK) {
                 CWARN("Can't NAK %s: put failed %s(%d)\n",
                       kptllnd_ptlid2str(dest), kptllnd_errtype2str(rc), rc);
-                kptllnd_schedule_ptltrace_dump();
         }
 }
 
index 0fa9eee..17b1d5b 100644 (file)
@@ -486,7 +486,6 @@ kptllnd_tx_callback(ptl_event_t *ev)
                        ev->ni_fail_type, unlinked);
                 tx->tx_status = -EIO; 
                 kptllnd_peer_close(peer, -EIO);
-                kptllnd_schedule_ptltrace_dump();
         }
 
         if (!unlinked)
index 41c4a64..9e344d4 100644 (file)
@@ -1351,9 +1351,6 @@ LNetInit(void)
 #else
         /* Register LNDs
          * NB the order here determines default 'networks=' order */
-# ifdef CRAY_XT3
-        LNET_REGISTER_ULND(the_ptllnd);
-# endif
 # ifdef HAVE_LIBPTHREAD
         LNET_REGISTER_ULND(the_tcplnd);
 # endif
index 78432ee..dd3c8ce 100644 (file)
@@ -1,5 +1,4 @@
 @BUILD_USOCKLND_TRUE@subdir-m += socklnd
-@BUILD_UPTLLND_TRUE@subdir-m += ptllnd
 
 @INCLUDE_RULES@
 
index 18f35ed..5917a31 100644 (file)
@@ -34,4 +34,4 @@
 # Lustre is a trademark of Sun Microsystems, Inc.
 #
 
-SUBDIRS = socklnd ptllnd
+SUBDIRS = socklnd
diff --git a/lnet/ulnds/ptllnd/.gitignore b/lnet/ulnds/ptllnd/.gitignore
deleted file mode 100644 (file)
index f53478a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/.deps
-/Makefile
-/Makefile.in
diff --git a/lnet/ulnds/ptllnd/Makefile.am b/lnet/ulnds/ptllnd/Makefile.am
deleted file mode 100644 (file)
index e48cb85..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-
-if BUILD_UPTLLND
-if LIBLUSTRE 
-noinst_LIBRARIES = libptllnd.a
-noinst_HEADERS =  ptllnd.h
-libptllnd_a_SOURCES = ptllnd.h ptllnd.c ptllnd_cb.c
-libptllnd_a_CPPFLAGS= $(LLCPPFLAGS)
-# I need $(PTLNDCPPLFLAGS) to be AFTER $(CPPFLAGS)
-# Adding them into $(AM_CFLAGS) seems wrong, but lets me get on..
-libptllnd_a_CFLAGS= $(PTLLNDCPPFLAGS) $(LLCFLAGS)
-endif
-endif
diff --git a/lnet/ulnds/ptllnd/ptllnd.c b/lnet/ulnds/ptllnd/ptllnd.c
deleted file mode 100644 (file)
index 1bf583e..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * 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 (c) 2007, 2010, Oracle and/or its affiliates. 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/ulnds/ptllnd/ptllnd.c
- *
- * Author: Eric Barton <eeb@bartonsoftware.com>
- */
-
-#include "ptllnd.h"
-
-lnd_t               the_ptllnd = {
-        .lnd_type       = PTLLND,
-        .lnd_startup    = ptllnd_startup,
-        .lnd_shutdown   = ptllnd_shutdown,
-        .lnd_ctl        = ptllnd_ctl,
-        .lnd_send       = ptllnd_send,
-        .lnd_recv       = ptllnd_recv,
-        .lnd_eager_recv = ptllnd_eager_recv,
-        .lnd_wait       = ptllnd_wait,
-        .lnd_setasync   = ptllnd_setasync,
-};
-
-static int ptllnd_ni_count = 0;
-
-static cfs_list_t ptllnd_idle_history;
-static cfs_list_t ptllnd_history_list;
-
-void
-ptllnd_history_fini(void)
-{
-        ptllnd_he_t *he;
-
-        while (!cfs_list_empty(&ptllnd_idle_history)) {
-                he = cfs_list_entry(ptllnd_idle_history.next,
-                                    ptllnd_he_t, he_list);
-
-                cfs_list_del(&he->he_list);
-                LIBCFS_FREE(he, sizeof(*he));
-        }
-
-        while (!cfs_list_empty(&ptllnd_history_list)) {
-                he = cfs_list_entry(ptllnd_history_list.next,
-                                    ptllnd_he_t, he_list);
-
-                cfs_list_del(&he->he_list);
-                LIBCFS_FREE(he, sizeof(*he));
-        }
-}
-
-int
-ptllnd_history_init(void)
-{
-        int          i;
-        ptllnd_he_t *he;
-        int          n;
-        int          rc;
-
-        CFS_INIT_LIST_HEAD(&ptllnd_idle_history);
-        CFS_INIT_LIST_HEAD(&ptllnd_history_list);
-
-        rc = ptllnd_parse_int_tunable(&n, "PTLLND_HISTORY", 0);
-        if (rc != 0)
-                return rc;
-
-        for (i = 0; i < n; i++) {
-                LIBCFS_ALLOC(he, sizeof(*he));
-                if (he == NULL) {
-                        ptllnd_history_fini();
-                        return -ENOMEM;
-                }
-
-                cfs_list_add(&he->he_list, &ptllnd_idle_history);
-        }
-
-        PTLLND_HISTORY("Init");
-
-        return 0;
-}
-
-void
-ptllnd_history(const char *fn, const char *file, const int line,
-               const char *fmt, ...)
-{
-        static int     seq;
-
-        va_list        ap;
-        ptllnd_he_t   *he;
-
-        if (!cfs_list_empty(&ptllnd_idle_history)) {
-                he = cfs_list_entry(ptllnd_idle_history.next,
-                                    ptllnd_he_t, he_list);
-        } else if (!cfs_list_empty(&ptllnd_history_list)) {
-                he = cfs_list_entry(ptllnd_history_list.next,
-                                    ptllnd_he_t, he_list);
-        } else {
-                return;
-        }
-
-        cfs_list_del(&he->he_list);
-        cfs_list_add_tail(&he->he_list, &ptllnd_history_list);
-
-        he->he_seq = seq++;
-        he->he_fn = fn;
-        he->he_file = file;
-        he->he_line = line;
-        gettimeofday(&he->he_time, NULL);
-
-        va_start(ap, fmt);
-        vsnprintf(he->he_msg, sizeof(he->he_msg), fmt, ap);
-        va_end(ap);
-}
-
-void
-ptllnd_dump_history(void)
-{
-        ptllnd_he_t    *he;
-
-        PTLLND_HISTORY("dumping...");
-
-        while (!cfs_list_empty(&ptllnd_history_list)) {
-                he = cfs_list_entry(ptllnd_history_list.next,
-                                ptllnd_he_t, he_list);
-
-                cfs_list_del(&he->he_list);
-
-                CDEBUG(D_WARNING, "%d %d.%06d (%s:%d:%s()) %s\n", he->he_seq,
-                       (int)he->he_time.tv_sec, (int)he->he_time.tv_usec,
-                       he->he_file, he->he_line, he->he_fn, he->he_msg);
-
-                cfs_list_add_tail(&he->he_list, &ptllnd_idle_history);
-        }
-
-        PTLLND_HISTORY("complete");
-}
-
-void
-ptllnd_assert_wire_constants (void)
-{
-        /* Wire protocol assertions generated by 'wirecheck'
-         * running on Linux fedora 2.6.11-co-0.6.4 #1 Mon Jun 19 05:36:13 UTC 2006 i686 i686 i386 GNU
-         * with gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) */
-
-
-        /* Constants... */
-        CLASSERT (PTL_RESERVED_MATCHBITS == 0x100);
-        CLASSERT (LNET_MSG_MATCHBITS == 0);
-        CLASSERT (PTLLND_MSG_MAGIC == 0x50746C4E);
-        CLASSERT (PTLLND_MSG_VERSION == 0x04);
-        CLASSERT (PTLLND_RDMA_OK == 0x00);
-        CLASSERT (PTLLND_RDMA_FAIL == 0x01);
-        CLASSERT (PTLLND_MSG_TYPE_INVALID == 0x00);
-        CLASSERT (PTLLND_MSG_TYPE_PUT == 0x01);
-        CLASSERT (PTLLND_MSG_TYPE_GET == 0x02);
-        CLASSERT (PTLLND_MSG_TYPE_IMMEDIATE == 0x03);
-        CLASSERT (PTLLND_MSG_TYPE_NOOP == 0x04);
-        CLASSERT (PTLLND_MSG_TYPE_HELLO == 0x05);
-        CLASSERT (PTLLND_MSG_TYPE_NAK == 0x06);
-
-        /* Checks for struct kptl_msg_t */
-        CLASSERT ((int)sizeof(kptl_msg_t) == 136);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_magic) == 0);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_magic) == 4);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_version) == 4);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_version) == 2);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_type) == 6);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_type) == 1);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_credits) == 7);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_credits) == 1);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_nob) == 8);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_nob) == 4);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_cksum) == 12);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_cksum) == 4);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcnid) == 16);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcnid) == 8);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcstamp) == 24);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcstamp) == 8);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstnid) == 32);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstnid) == 8);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dststamp) == 40);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dststamp) == 8);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcpid) == 48);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcpid) == 4);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstpid) == 52);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstpid) == 4);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.immediate) == 56);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.immediate) == 72);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.rdma) == 56);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.rdma) == 80);
-        CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.hello) == 56);
-        CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.hello) == 12);
-
-        /* Checks for struct kptl_immediate_msg_t */
-        CLASSERT ((int)sizeof(kptl_immediate_msg_t) == 72);
-        CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_hdr) == 0);
-        CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_hdr) == 72);
-        CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_payload[13]) == 85);
-        CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_payload[13]) == 1);
-
-        /* Checks for struct kptl_rdma_msg_t */
-        CLASSERT ((int)sizeof(kptl_rdma_msg_t) == 80);
-        CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_hdr) == 0);
-        CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_hdr) == 72);
-        CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_matchbits) == 72);
-        CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_matchbits) == 8);
-
-        /* Checks for struct kptl_hello_msg_t */
-        CLASSERT ((int)sizeof(kptl_hello_msg_t) == 12);
-        CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_matchbits) == 0);
-        CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_matchbits) == 8);
-        CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_max_msg_size) == 8);
-        CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_max_msg_size) == 4);
-}
-
-int
-ptllnd_parse_int_tunable(int *value, char *name, int dflt)
-{
-        char    *env = getenv(name);
-        char    *end;
-
-        if (env == NULL) {
-                *value = dflt;
-                return 0;
-        }
-
-        *value = strtoull(env, &end, 0);
-        if (*end == 0)
-                return 0;
-
-        CERROR("Can't parse tunable %s=%s\n", name, env);
-        return -EINVAL;
-}
-
-int
-ptllnd_get_tunables(lnet_ni_t *ni)
-{
-        ptllnd_ni_t *plni = ni->ni_data;
-        int          max_msg_size;
-        int          msgs_per_buffer;
-        int          rc;
-        int          temp;
-
-        /*  Other tunable defaults depend on this */
-        rc = ptllnd_parse_int_tunable(&plni->plni_debug, "PTLLND_DEBUG", 0);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_portal,
-                                      "PTLLND_PORTAL", PTLLND_PORTAL);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&temp,
-                                      "PTLLND_PID", PTLLND_PID);
-        if (rc != 0)
-                return rc;
-        plni->plni_ptllnd_pid = (ptl_pid_t)temp;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
-                                      "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
-        if (rc != 0)
-                return rc;
-        if (plni->plni_peer_credits > PTLLND_MSG_MAX_CREDITS) {
-                CERROR("PTLLND_PEERCREDITS must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
-                return -EINVAL;
-        }
-
-        rc = ptllnd_parse_int_tunable(&max_msg_size,
-                                      "PTLLND_MAX_MSG_SIZE",
-                                      PTLLND_MAX_ULND_MSG_SIZE);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
-                                      "PTLLND_MSGS_PER_BUFFER", 64);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_msgs_spare,
-                                      "PTLLND_MSGS_SPARE", 256);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_peer_hash_size,
-                                      "PTLLND_PEER_HASH_SIZE", 101);
-        if (rc != 0)
-                return rc;
-
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_eq_size,
-                                      "PTLLND_EQ_SIZE", 1024);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_checksum,
-                                      "PTLLND_CHECKSUM", 0);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_max_tx_history,
-                                      "PTLLND_TX_HISTORY",
-                                      plni->plni_debug ? 1024 : 0);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_protocol_mismatch,
-                                      "PTLLND_ABORT_ON_PROTOCOL_MISMATCH", 1);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_nak,
-                                      "PTLLND_ABORT_ON_NAK", 0);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_dump_on_nak,
-                                      "PTLLND_DUMP_ON_NAK", plni->plni_debug);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_watchdog_interval,
-                                      "PTLLND_WATCHDOG_INTERVAL", 1);
-        if (rc != 0)
-                return rc;
-        if (plni->plni_watchdog_interval <= 0)
-                plni->plni_watchdog_interval = 1;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_timeout,
-                                      "PTLLND_TIMEOUT", 50);
-        if (rc != 0)
-                return rc;
-
-        rc = ptllnd_parse_int_tunable(&plni->plni_long_wait,
-                                      "PTLLND_LONG_WAIT",
-                                      plni->plni_debug ? 5 : plni->plni_timeout);
-        if (rc != 0)
-                return rc;
-        plni->plni_long_wait *= 1000;           /* convert to mS */
-
-        plni->plni_max_msg_size = max_msg_size & ~7;
-        if (plni->plni_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
-                plni->plni_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
-        CLASSERT ((PTLLND_MIN_BUFFER_SIZE & 7) == 0);
-        CLASSERT (sizeof(kptl_msg_t) <= PTLLND_MIN_BUFFER_SIZE);
-
-        plni->plni_buffer_size = plni->plni_max_msg_size * msgs_per_buffer;
-
-        CDEBUG(D_NET, "portal          = %d\n",plni->plni_portal);
-        CDEBUG(D_NET, "ptllnd_pid      = %d\n",plni->plni_ptllnd_pid);
-        CDEBUG(D_NET, "max_msg_size    = %d\n",max_msg_size);
-        CDEBUG(D_NET, "msgs_per_buffer = %d\n",msgs_per_buffer);
-        CDEBUG(D_NET, "msgs_spare      = %d\n",plni->plni_msgs_spare);
-        CDEBUG(D_NET, "peer_hash_size  = %d\n",plni->plni_peer_hash_size);
-        CDEBUG(D_NET, "eq_size         = %d\n",plni->plni_eq_size);
-        CDEBUG(D_NET, "max_msg_size    = %d\n",plni->plni_max_msg_size);
-        CDEBUG(D_NET, "buffer_size     = %d\n",plni->plni_buffer_size);
-
-        return 0;
-}
-
-ptllnd_buffer_t *
-ptllnd_create_buffer (lnet_ni_t *ni)
-{
-        ptllnd_ni_t     *plni = ni->ni_data;
-        ptllnd_buffer_t *buf;
-
-        LIBCFS_ALLOC(buf, sizeof(*buf));
-        if (buf == NULL) {
-                CERROR("Can't allocate buffer descriptor\n");
-                return NULL;
-        }
-
-        buf->plb_ni = ni;
-        buf->plb_posted = 0;
-        CFS_INIT_LIST_HEAD(&buf->plb_list);
-
-        LIBCFS_ALLOC(buf->plb_buffer, plni->plni_buffer_size);
-        if (buf->plb_buffer == NULL) {
-                CERROR("Can't allocate buffer size %d\n",
-                       plni->plni_buffer_size);
-                LIBCFS_FREE(buf, sizeof(*buf));
-                return NULL;
-        }
-
-        cfs_list_add(&buf->plb_list, &plni->plni_buffers);
-        plni->plni_nbuffers++;
-
-        return buf;
-}
-
-void
-ptllnd_destroy_buffer (ptllnd_buffer_t *buf)
-{
-        ptllnd_ni_t     *plni = buf->plb_ni->ni_data;
-
-        LASSERT (!buf->plb_posted);
-
-        plni->plni_nbuffers--;
-        cfs_list_del(&buf->plb_list);
-        LIBCFS_FREE(buf->plb_buffer, plni->plni_buffer_size);
-        LIBCFS_FREE(buf, sizeof(*buf));
-}
-
-int
-ptllnd_size_buffers (lnet_ni_t *ni, int delta)
-{
-        ptllnd_ni_t     *plni = ni->ni_data;
-        ptllnd_buffer_t *buf;
-        int              nmsgs;
-        int              nbufs;
-        int              rc;
-
-        CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
-        CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
-
-        plni->plni_nmsgs += delta;
-        LASSERT(plni->plni_nmsgs >= 0);
-
-        nmsgs = plni->plni_nmsgs + plni->plni_msgs_spare;
-
-        nbufs = (nmsgs * plni->plni_max_msg_size + plni->plni_buffer_size - 1) /
-                plni->plni_buffer_size;
-
-        while (nbufs > plni->plni_nbuffers) {
-                buf = ptllnd_create_buffer(ni);
-
-                if (buf == NULL)
-                        return -ENOMEM;
-
-                rc = ptllnd_post_buffer(buf);
-                if (rc != 0) {
-                        /* TODO - this path seems to orpahn the buffer
-                         * in a state where its not posted and will never be
-                         * However it does not leak the buffer as it's
-                         * already been put onto the global buffer list
-                         * and will be cleaned up
-                         */
-                        return rc;
-                }
-        }
-
-        CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
-        CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
-        return 0;
-}
-
-void
-ptllnd_destroy_buffers (lnet_ni_t *ni)
-{
-        ptllnd_ni_t       *plni = ni->ni_data;
-        ptllnd_buffer_t   *buf;
-        cfs_list_t        *tmp;
-        cfs_list_t        *nxt;
-
-        CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
-        CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
-
-        cfs_list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
-                buf = cfs_list_entry(tmp, ptllnd_buffer_t, plb_list);
-
-                //CDEBUG(D_NET, "buf=%p posted=%d\n",buf,buf->plb_posted);
-
-                LASSERT (plni->plni_nbuffers > 0);
-                if (buf->plb_posted) {
-                        time_t   start = cfs_time_current_sec();
-                        int      w = plni->plni_long_wait;
-
-                        LASSERT (plni->plni_nposted_buffers > 0);
-
-#ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
-                        (void) PtlMDUnlink(buf->plb_md);
-
-                        while (buf->plb_posted) {
-                                if (w > 0 && cfs_time_current_sec() > start + w/1000) {
-                                        CWARN("Waited %ds to unlink buffer\n",
-                                              (int)(cfs_time_current_sec() - start));
-                                        w *= 2;
-                                }
-                                ptllnd_wait(ni, w);
-                        }
-#else
-                        while (buf->plb_posted) {
-                                rc = PtlMDUnlink(buf->plb_md);
-                                if (rc == PTL_OK) {
-                                        buf->plb_posted = 0;
-                                        plni->plni_nposted_buffers--;
-                                        break;
-                                }
-                                LASSERT (rc == PTL_MD_IN_USE);
-                                if (w > 0 && cfs_time_current_sec() > start + w/1000) {
-                                        CWARN("Waited %ds to unlink buffer\n",
-                                              cfs_time_current_sec() - start);
-                                        w *= 2;
-                                }
-                                ptllnd_wait(ni, w);
-                        }
-#endif
-                }
-                ptllnd_destroy_buffer(buf);
-        }
-
-        CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
-        CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
-
-        LASSERT (plni->plni_nposted_buffers == 0);
-        LASSERT (plni->plni_nbuffers == 0);
-}
-
-int
-ptllnd_create_peer_hash (lnet_ni_t *ni)
-{
-        ptllnd_ni_t *plni = ni->ni_data;
-        int          i;
-
-        plni->plni_npeers = 0;
-
-        LIBCFS_ALLOC(plni->plni_peer_hash,
-                     plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
-        if (plni->plni_peer_hash == NULL) {
-                CERROR("Can't allocate ptllnd peer hash (size %d)\n",
-                       plni->plni_peer_hash_size);
-                return -ENOMEM;
-        }
-
-        for (i = 0; i < plni->plni_peer_hash_size; i++)
-                CFS_INIT_LIST_HEAD(&plni->plni_peer_hash[i]);
-
-        return 0;
-}
-
-void
-ptllnd_destroy_peer_hash (lnet_ni_t *ni)
-{
-        ptllnd_ni_t    *plni = ni->ni_data;
-        int             i;
-
-        LASSERT( plni->plni_npeers == 0);
-
-        for (i = 0; i < plni->plni_peer_hash_size; i++)
-                LASSERT (cfs_list_empty(&plni->plni_peer_hash[i]));
-
-        LIBCFS_FREE(plni->plni_peer_hash,
-                    plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
-}
-
-void
-ptllnd_close_peers (lnet_ni_t *ni)
-{
-        ptllnd_ni_t    *plni = ni->ni_data;
-        ptllnd_peer_t  *plp;
-        int             i;
-
-        for (i = 0; i < plni->plni_peer_hash_size; i++)
-                while (!cfs_list_empty(&plni->plni_peer_hash[i])) {
-                        plp = cfs_list_entry(plni->plni_peer_hash[i].next,
-                                             ptllnd_peer_t, plp_list);
-
-                        ptllnd_close_peer(plp, 0);
-                }
-}
-
-int
-ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
-{
-        switch (cmd) {
-        case IOC_LIBCFS_DEBUG_PEER:
-                ptllnd_dump_debug(ni, *((lnet_process_id_t *)arg));
-                return 0;
-
-        default:
-                return -EINVAL;
-        }
-}
-
-__u64
-ptllnd_get_timestamp(void)
-{
-        struct timeval  tv;
-        int             rc = gettimeofday(&tv, NULL);
-
-        LASSERT (rc == 0);
-        return ((__u64)tv.tv_sec) * 1000000 + tv.tv_usec;
-}
-
-void
-ptllnd_shutdown (lnet_ni_t *ni)
-{
-        ptllnd_ni_t *plni = ni->ni_data;
-        int          rc;
-        time_t       start = cfs_time_current_sec();
-        int          w = plni->plni_long_wait;
-
-        LASSERT (ptllnd_ni_count == 1);
-        plni->plni_max_tx_history = 0;
-
-        ptllnd_cull_tx_history(plni);
-
-        ptllnd_close_peers(ni);
-        ptllnd_destroy_buffers(ni);
-
-        while (plni->plni_npeers > 0) {
-                if (w > 0 && cfs_time_current_sec() > start + w/1000) {
-                        CWARN("Waited %ds for peers to shutdown\n",
-                              (int)(cfs_time_current_sec() - start));
-                        w *= 2;
-                }
-                ptllnd_wait(ni, w);
-        }
-
-        LASSERT (plni->plni_ntxs == 0);
-        LASSERT (plni->plni_nrxs == 0);
-
-        rc = PtlEQFree(plni->plni_eqh);
-        LASSERT (rc == PTL_OK);
-
-        rc = PtlNIFini(plni->plni_nih);
-        LASSERT (rc == PTL_OK);
-
-        ptllnd_destroy_peer_hash(ni);
-        LIBCFS_FREE(plni, sizeof(*plni));
-        ptllnd_ni_count--;
-}
-
-int
-ptllnd_startup (lnet_ni_t *ni)
-{
-        ptllnd_ni_t *plni;
-        int          rc;
-
-        /* could get limits from portals I guess... */
-        ni->ni_maxtxcredits =
-        ni->ni_peertxcredits = 1000;
-
-        if (ptllnd_ni_count != 0) {
-                CERROR("Can't have > 1 instance of ptllnd\n");
-                return -EPERM;
-        }
-
-        ptllnd_ni_count++;
-
-        rc = ptllnd_history_init();
-        if (rc != 0) {
-                CERROR("Can't init history\n");
-                goto failed0;
-        }
-
-        LIBCFS_ALLOC(plni, sizeof(*plni));
-        if (plni == NULL) {
-                CERROR("Can't allocate ptllnd state\n");
-                rc = -ENOMEM;
-                goto failed0;
-        }
-
-        ni->ni_data = plni;
-
-        plni->plni_stamp = ptllnd_get_timestamp();
-        plni->plni_nrxs = 0;
-        plni->plni_ntxs = 0;
-        plni->plni_ntx_history = 0;
-        plni->plni_watchdog_peeridx = 0;
-        plni->plni_watchdog_nextt = cfs_time_current_sec();
-        CFS_INIT_LIST_HEAD(&plni->plni_zombie_txs);
-        CFS_INIT_LIST_HEAD(&plni->plni_tx_history);
-
-        /*
-         *  Initilize buffer related data structures
-         */
-        CFS_INIT_LIST_HEAD(&plni->plni_buffers);
-        plni->plni_nbuffers = 0;
-        plni->plni_nposted_buffers = 0;
-
-        rc = ptllnd_get_tunables(ni);
-        if (rc != 0)
-                goto failed1;
-
-        rc = ptllnd_create_peer_hash(ni);
-        if (rc != 0)
-                goto failed1;
-
-        /* NB I most probably won't get the PID I requested here.  It doesn't
-         * matter because I don't need a fixed PID (only connection acceptors
-         * need a "well known" PID). */
-
-        rc = PtlNIInit(PTL_IFACE_DEFAULT, plni->plni_ptllnd_pid,
-                       NULL, NULL, &plni->plni_nih);
-        if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
-                CERROR("PtlNIInit failed: %s(%d)\n",
-                       ptllnd_errtype2str(rc), rc);
-                rc = -ENODEV;
-                goto failed2;
-        }
-
-        rc = PtlEQAlloc(plni->plni_nih, plni->plni_eq_size,
-                        PTL_EQ_HANDLER_NONE, &plni->plni_eqh);
-        if (rc != PTL_OK) {
-                CERROR("PtlEQAlloc failed: %s(%d)\n",
-                       ptllnd_errtype2str(rc), rc);
-                rc = -ENODEV;
-                goto failed3;
-        }
-
-        /*
-         * Fetch the Portals NID
-         */
-        rc = PtlGetId(plni->plni_nih, &plni->plni_portals_id);
-        if (rc != PTL_OK) {
-                CERROR ("PtlGetID failed : %s(%d)\n",
-                        ptllnd_errtype2str(rc), rc);
-                rc = -EINVAL;
-                goto failed4;
-        }
-
-        /*
-         * Create the new NID.  Based on the LND network type
-         * and the lower ni's address data.
-         */
-        ni->ni_nid = ptllnd_ptl2lnetnid(ni, plni->plni_portals_id.nid);
-
-        CDEBUG(D_NET, "ptl id  =%s\n", ptllnd_ptlid2str(plni->plni_portals_id));
-        CDEBUG(D_NET, "lnet id =%s (passed back)\n",
-               libcfs_id2str((lnet_process_id_t) {
-                       .nid = ni->ni_nid, .pid = the_lnet.ln_pid}));
-
-        rc = ptllnd_size_buffers(ni, 0);
-        if (rc != 0)
-                goto failed4;
-
-        return 0;
-
- failed4:
-        ptllnd_destroy_buffers(ni);
-        PtlEQFree(plni->plni_eqh);
- failed3:
-        PtlNIFini(plni->plni_nih);
- failed2:
-        ptllnd_destroy_peer_hash(ni);
- failed1:
-        LIBCFS_FREE(plni, sizeof(*plni));
- failed0:
-        ptllnd_history_fini();
-        ptllnd_ni_count--;
-        CDEBUG(D_NET, "<<< rc=%d\n",rc);
-        return rc;
-}
-
-const char *ptllnd_evtype2str(int type)
-{
-#define DO_TYPE(x) case x: return #x;
-        switch(type)
-        {
-                DO_TYPE(PTL_EVENT_GET_START);
-                DO_TYPE(PTL_EVENT_GET_END);
-                DO_TYPE(PTL_EVENT_PUT_START);
-                DO_TYPE(PTL_EVENT_PUT_END);
-                DO_TYPE(PTL_EVENT_REPLY_START);
-                DO_TYPE(PTL_EVENT_REPLY_END);
-                DO_TYPE(PTL_EVENT_ACK);
-                DO_TYPE(PTL_EVENT_SEND_START);
-                DO_TYPE(PTL_EVENT_SEND_END);
-                DO_TYPE(PTL_EVENT_UNLINK);
-        default:
-                return "<unknown event type>";
-        }
-#undef DO_TYPE
-}
-
-const char *ptllnd_msgtype2str(int type)
-{
-#define DO_TYPE(x) case x: return #x;
-        switch(type)
-        {
-                DO_TYPE(PTLLND_MSG_TYPE_INVALID);
-                DO_TYPE(PTLLND_MSG_TYPE_PUT);
-                DO_TYPE(PTLLND_MSG_TYPE_GET);
-                DO_TYPE(PTLLND_MSG_TYPE_IMMEDIATE);
-                DO_TYPE(PTLLND_MSG_TYPE_HELLO);
-                DO_TYPE(PTLLND_MSG_TYPE_NOOP);
-                DO_TYPE(PTLLND_MSG_TYPE_NAK);
-        default:
-                return "<unknown msg type>";
-        }
-#undef DO_TYPE
-}
-
-const char *ptllnd_errtype2str(int type)
-{
-#define DO_TYPE(x) case x: return #x;
-        switch(type)
-        {
-                DO_TYPE(PTL_OK);
-                DO_TYPE(PTL_SEGV);
-                DO_TYPE(PTL_NO_SPACE);
-                DO_TYPE(PTL_ME_IN_USE);
-                DO_TYPE(PTL_NAL_FAILED);
-                DO_TYPE(PTL_NO_INIT);
-                DO_TYPE(PTL_IFACE_DUP);
-                DO_TYPE(PTL_IFACE_INVALID);
-                DO_TYPE(PTL_HANDLE_INVALID);
-                DO_TYPE(PTL_MD_INVALID);
-                DO_TYPE(PTL_ME_INVALID);
-                DO_TYPE(PTL_PROCESS_INVALID);
-                DO_TYPE(PTL_PT_INDEX_INVALID);
-                DO_TYPE(PTL_SR_INDEX_INVALID);
-                DO_TYPE(PTL_EQ_INVALID);
-                DO_TYPE(PTL_EQ_DROPPED);
-                DO_TYPE(PTL_EQ_EMPTY);
-                DO_TYPE(PTL_MD_NO_UPDATE);
-                DO_TYPE(PTL_FAIL);
-                DO_TYPE(PTL_AC_INDEX_INVALID);
-                DO_TYPE(PTL_MD_ILLEGAL);
-                DO_TYPE(PTL_ME_LIST_TOO_LONG);
-                DO_TYPE(PTL_MD_IN_USE);
-                DO_TYPE(PTL_NI_INVALID);
-                DO_TYPE(PTL_PID_INVALID);
-                DO_TYPE(PTL_PT_FULL);
-                DO_TYPE(PTL_VAL_FAILED);
-                DO_TYPE(PTL_NOT_IMPLEMENTED);
-                DO_TYPE(PTL_NO_ACK);
-                DO_TYPE(PTL_EQ_IN_USE);
-                DO_TYPE(PTL_PID_IN_USE);
-                DO_TYPE(PTL_INV_EQ_SIZE);
-                DO_TYPE(PTL_AGAIN);
-        default:
-                return "<unknown error type>";
-        }
-#undef DO_TYPE
-}
diff --git a/lnet/ulnds/ptllnd/ptllnd.h b/lnet/ulnds/ptllnd/ptllnd.h
deleted file mode 100644 (file)
index 0c8aedd..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * 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 (c) 2007, 2010, Oracle and/or its affiliates. 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/ulnds/ptllnd/ptllnd.h
- *
- * Author: Eric Barton <eeb@bartonsoftware.com>
- */
-
-
-#define DEBUG_SUBSYSTEM S_LND
-
-#include <lnet/lib-lnet.h>
-#include <lnet/ptllnd_wire.h>
-
-#include <portals/p30.h>
-#include <lnet/ptllnd.h>           /* Depends on portals/p30.h */
-#include <stdarg.h>
-
-/* Hack to record history
- * This should really be done by CDEBUG(D_NETTRACE...  */
-
-typedef struct {
-        cfs_list_t                he_list;
-        struct timeval            he_time;
-        const char               *he_fn;
-        const char               *he_file;
-        int                       he_seq;
-        int                       he_line;
-        char                      he_msg[80];
-} ptllnd_he_t;
-
-void ptllnd_dump_history();
-void ptllnd_history(const char *fn, const char *file, const int line,
-                    const char *fmt, ...);
-#define PTLLND_HISTORY(fmt, a...) \
-        ptllnd_history(__FUNCTION__, __FILE__, __LINE__, fmt, ## a)
-
-
-#define PTLLND_MD_OPTIONS        (PTL_MD_LUSTRE_COMPLETION_SEMANTICS |\
-                                  PTL_MD_EVENT_START_DISABLE)
-typedef struct
-{
-        int                        plni_portal;
-        ptl_pid_t                  plni_ptllnd_pid; /* Portals PID of peers I may connect to */
-        int                        plni_peer_credits;
-        int                        plni_max_msg_size;
-        int                        plni_buffer_size;
-        int                        plni_msgs_spare;
-        int                        plni_peer_hash_size;
-        int                        plni_eq_size;
-        int                        plni_checksum;
-        int                        plni_max_tx_history;
-        int                        plni_abort_on_protocol_mismatch;
-        int                        plni_abort_on_nak;
-        int                        plni_dump_on_nak;
-        int                        plni_debug;
-        int                        plni_long_wait;
-        int                        plni_watchdog_interval;
-        int                        plni_timeout;
-
-        __u64                      plni_stamp;
-        cfs_list_t                 plni_active_txs;
-        cfs_list_t                 plni_zombie_txs;
-        int                        plni_ntxs;
-        int                        plni_nrxs;
-
-        ptl_handle_ni_t            plni_nih;
-        ptl_handle_eq_t            plni_eqh;
-        ptl_process_id_t           plni_portals_id;   /* Portals ID of interface */
-
-        cfs_list_t                *plni_peer_hash;
-        int                        plni_npeers;
-
-        int                        plni_watchdog_nextt;
-        int                        plni_watchdog_peeridx;
-
-        cfs_list_t                 plni_tx_history;
-        int                        plni_ntx_history;
-
-        cfs_list_t                 plni_buffers;
-        int                        plni_nbuffers;
-        int                        plni_nposted_buffers;
-        int                        plni_nmsgs;
-} ptllnd_ni_t;
-
-#define PTLLND_CREDIT_HIGHWATER(plni) ((plni)->plni_peer_credits - 1)
-
-typedef struct
-{
-        cfs_list_t                 plp_list;
-        lnet_ni_t                 *plp_ni;
-        lnet_process_id_t          plp_id;
-        ptl_process_id_t           plp_ptlid;
-        int                        plp_credits; /* # msg buffers reserved for me at peer */
-
-        /* credits for msg buffers I've posted for this peer...
-         * outstanding - free buffers I've still to inform my peer about
-         * sent        - free buffers I've told my peer about
-         * lazy        - additional buffers (over and above plni_peer_credits)
-         *               posted to prevent peer blocking on sending a non-RDMA
-         *               messages to me when LNET isn't eagerly responsive to
-         *               the network (i.e. liblustre doesn't have control). 
-         * extra_lazy  - lazy credits not required any more. */
-        int                        plp_outstanding_credits;
-        int                        plp_sent_credits;
-        int                        plp_lazy_credits;
-        int                        plp_extra_lazy_credits;
-
-        int                        plp_max_msg_size;
-        int                        plp_refcount;
-        int                        plp_sent_hello:1;
-        int                        plp_recvd_hello:1;
-        int                        plp_closing:1;
-        __u64                      plp_match;
-        __u64                      plp_stamp;
-        cfs_list_t                 plp_txq;
-        cfs_list_t                 plp_noopq;
-        cfs_list_t                 plp_activeq;
-} ptllnd_peer_t;
-
-typedef struct
-{
-        cfs_list_t                 plb_list;
-        lnet_ni_t                 *plb_ni;
-        int                        plb_posted;
-        ptl_handle_md_t            plb_md;
-        char                      *plb_buffer;
-} ptllnd_buffer_t;
-
-typedef struct
-{
-        ptllnd_peer_t             *rx_peer;
-        kptl_msg_t                *rx_msg;
-        int                        rx_nob;
-} ptllnd_rx_t;
-
-typedef struct
-{
-        cfs_list_t                 tx_list;
-        int                        tx_type;
-        int                        tx_status;
-        ptllnd_peer_t             *tx_peer;
-        lnet_msg_t                *tx_lnetmsg;
-        lnet_msg_t                *tx_lnetreplymsg;
-        unsigned int               tx_niov;
-        ptl_md_iovec_t            *tx_iov;
-        ptl_handle_md_t            tx_bulkmdh;
-        ptl_handle_md_t            tx_reqmdh;
-        struct timeval             tx_bulk_posted;
-        struct timeval             tx_bulk_done;
-        struct timeval             tx_req_posted;
-        struct timeval             tx_req_done;
-        int                        tx_completing; /* someone already completing */
-        int                        tx_msgsize;  /* # bytes in tx_msg */
-        time_t                     tx_deadline; /* time to complete by */
-        kptl_msg_t                 tx_msg;      /* message to send */
-} ptllnd_tx_t;
-
-#define PTLLND_RDMA_WRITE           0x100       /* pseudo message type */
-#define PTLLND_RDMA_READ            0x101       /* (no msg actually sent) */
-
-/* Hack to extract object type from event's user_ptr relies on (and checks)
- * that structs are somewhat aligned. */
-#define PTLLND_EVENTARG_TYPE_TX     0x1
-#define PTLLND_EVENTARG_TYPE_BUF    0x2
-#define PTLLND_EVENTARG_TYPE_MASK   0x3
-
-static inline void *
-ptllnd_obj2eventarg (void *obj, int type)
-{
-        unsigned long ptr = (unsigned long)obj;
-
-        LASSERT ((ptr & PTLLND_EVENTARG_TYPE_MASK) == 0);
-        LASSERT ((type & ~PTLLND_EVENTARG_TYPE_MASK) == 0);
-
-        return (void *)(ptr | type);
-}
-
-static inline int
-ptllnd_eventarg2type (void *arg)
-{
-        unsigned long ptr = (unsigned long)arg;
-
-        return (ptr & PTLLND_EVENTARG_TYPE_MASK);
-}
-
-static inline void *
-ptllnd_eventarg2obj (void *arg)
-{
-        unsigned long ptr = (unsigned long)arg;
-
-        return (void *)(ptr & ~PTLLND_EVENTARG_TYPE_MASK);
-}
-
-int ptllnd_parse_int_tunable(int *value, char *name, int dflt);
-void ptllnd_cull_tx_history(ptllnd_ni_t *plni);
-int ptllnd_startup(lnet_ni_t *ni);
-void ptllnd_shutdown(lnet_ni_t *ni);
-int ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
-int ptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *msg);
-int ptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
-                int delayed, unsigned int niov,
-                struct iovec *iov, lnet_kiov_t *kiov,
-                unsigned int offset, unsigned int mlen, unsigned int rlen);
-int ptllnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
-                      void **new_privatep);
-
-ptllnd_tx_t *ptllnd_new_tx(ptllnd_peer_t *peer, int type, int payload_nob);
-int  ptllnd_setasync(lnet_ni_t *ni, lnet_process_id_t id, int n);
-void ptllnd_wait(lnet_ni_t *ni, int milliseconds);
-void ptllnd_check_sends(ptllnd_peer_t *peer);
-void ptllnd_debug_peer(lnet_ni_t *ni, lnet_process_id_t id);
-void ptllnd_destroy_peer(ptllnd_peer_t *peer);
-void ptllnd_close_peer(ptllnd_peer_t *peer, int error);
-int ptllnd_post_buffer(ptllnd_buffer_t *buf);
-int ptllnd_size_buffers (lnet_ni_t *ni, int delta);
-const char *ptllnd_evtype2str(int type);
-const char *ptllnd_msgtype2str(int type);
-const char *ptllnd_errtype2str(int type);
-char *ptllnd_ptlid2str(ptl_process_id_t id);
-void ptllnd_dump_debug(lnet_ni_t *ni, lnet_process_id_t id);
-
-
-static inline void
-ptllnd_peer_addref (ptllnd_peer_t *peer)
-{
-        LASSERT (peer->plp_refcount > 0);
-        peer->plp_refcount++;
-}
-
-static inline void
-ptllnd_peer_decref (ptllnd_peer_t *peer)
-{
-        LASSERT (peer->plp_refcount > 0);
-        peer->plp_refcount--;
-        if (peer->plp_refcount == 0)
-                ptllnd_destroy_peer(peer);
-}
-
-static inline lnet_nid_t
-ptllnd_ptl2lnetnid(lnet_ni_t *ni, ptl_nid_t portals_nid)
-{
-        return LNET_MKNID(LNET_NIDNET(ni->ni_nid), portals_nid);
-}
-
-static inline ptl_nid_t
-ptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
-{
-        return LNET_NIDADDR(lnet_nid);
-}
-
-/*
- * A note about lprintf():
- *  Normally printf() is redirected to stdout of the console
- *  from which yod launched the catamount application.  However
- *  there is a lot of initilziation code that runs before this
- *  redirection is hooked up, and printf() seems to go to the bit bucket
- *
- *  To get any kind of debug output and init time lprintf() can
- *  be used to output to the console from which bookqk was used to
- *  boot the catamount node.  This works for debugging some simple
- *  cases.
- */
diff --git a/lnet/ulnds/ptllnd/ptllnd_cb.c b/lnet/ulnds/ptllnd/ptllnd_cb.c
deleted file mode 100644 (file)
index ff78144..0000000
+++ /dev/null
@@ -1,1939 +0,0 @@
-/*
- * 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 (c) 2007, 2010, Oracle and/or its affiliates. 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/ulnds/ptllnd/ptllnd_cb.c
- *
- * Author: Eric Barton <eeb@bartonsoftware.com>
- */
-
-#include "ptllnd.h"
-
-void
-ptllnd_set_tx_deadline(ptllnd_tx_t *tx)
-{
-        ptllnd_peer_t  *peer = tx->tx_peer;
-        lnet_ni_t      *ni = peer->plp_ni;
-        ptllnd_ni_t    *plni = ni->ni_data;
-
-        tx->tx_deadline = cfs_time_current_sec() + plni->plni_timeout;
-}
-
-void
-ptllnd_post_tx(ptllnd_tx_t *tx)
-{
-        ptllnd_peer_t  *peer = tx->tx_peer;
-
-        LASSERT (tx->tx_type != PTLLND_MSG_TYPE_NOOP);
-
-        ptllnd_set_tx_deadline(tx);
-        cfs_list_add_tail(&tx->tx_list, &peer->plp_txq);
-        ptllnd_check_sends(peer);
-}
-
-char *
-ptllnd_ptlid2str(ptl_process_id_t id)
-{
-        static char strs[8][32];
-        static int  idx = 0;
-
-        char   *str = strs[idx++];
-
-        if (idx >= sizeof(strs)/sizeof(strs[0]))
-                idx = 0;
-
-        snprintf(str, sizeof(strs[0]), FMT_PTLID, id.pid, id.nid);
-        return str;
-}
-
-void
-ptllnd_destroy_peer(ptllnd_peer_t *peer)
-{
-        lnet_ni_t         *ni = peer->plp_ni;
-        ptllnd_ni_t       *plni = ni->ni_data;
-        int                nmsg = peer->plp_lazy_credits +
-                                  plni->plni_peer_credits;
-
-        ptllnd_size_buffers(ni, -nmsg);
-
-        LASSERT (peer->plp_closing);
-        LASSERT (plni->plni_npeers > 0);
-        LASSERT (cfs_list_empty(&peer->plp_txq));
-        LASSERT (cfs_list_empty(&peer->plp_noopq));
-        LASSERT (cfs_list_empty(&peer->plp_activeq));
-        plni->plni_npeers--;
-        LIBCFS_FREE(peer, sizeof(*peer));
-}
-
-void
-ptllnd_abort_txs(ptllnd_ni_t *plni, cfs_list_t *q)
-{
-        while (!cfs_list_empty(q)) {
-                ptllnd_tx_t *tx = cfs_list_entry(q->next, ptllnd_tx_t, tx_list);
-
-                tx->tx_status = -ESHUTDOWN;
-                cfs_list_del(&tx->tx_list);
-                cfs_list_add_tail(&tx->tx_list, &plni->plni_zombie_txs);
-        }
-}
-
-void
-ptllnd_close_peer(ptllnd_peer_t *peer, int error)
-{
-        lnet_ni_t   *ni = peer->plp_ni;
-        ptllnd_ni_t *plni = ni->ni_data;
-
-        if (peer->plp_closing)
-                return;
-
-        peer->plp_closing = 1;
-
-        if (!cfs_list_empty(&peer->plp_txq) ||
-            !cfs_list_empty(&peer->plp_noopq) ||
-            !cfs_list_empty(&peer->plp_activeq) ||
-            error != 0) {
-                CWARN("Closing %s: %d\n", libcfs_id2str(peer->plp_id), error);
-                if (plni->plni_debug)
-                        ptllnd_dump_debug(ni, peer->plp_id);
-        }
-
-        ptllnd_abort_txs(plni, &peer->plp_txq);
-        ptllnd_abort_txs(plni, &peer->plp_noopq);
-        ptllnd_abort_txs(plni, &peer->plp_activeq);
-
-        cfs_list_del(&peer->plp_list);
-        ptllnd_peer_decref(peer);
-}
-
-ptllnd_peer_t *
-ptllnd_find_peer(lnet_ni_t *ni, lnet_process_id_t id, int create)
-{
-        ptllnd_ni_t       *plni = ni->ni_data;
-        unsigned int       hash = LNET_NIDADDR(id.nid) % plni->plni_peer_hash_size;
-        ptllnd_peer_t     *plp;
-        ptllnd_tx_t       *tx;
-        int                rc;
-
-        LASSERT (LNET_NIDNET(id.nid) == LNET_NIDNET(ni->ni_nid));
-
-        cfs_list_for_each_entry (plp, &plni->plni_peer_hash[hash], plp_list) {
-                if (plp->plp_id.nid == id.nid &&
-                    plp->plp_id.pid == id.pid) {
-                        ptllnd_peer_addref(plp);
-                        return plp;
-                }
-        }
-
-        if (!create)
-                return NULL;
-
-        /* New peer: check first for enough posted buffers */
-        plni->plni_npeers++;
-        rc = ptllnd_size_buffers(ni, plni->plni_peer_credits);
-        if (rc != 0) {
-                plni->plni_npeers--;
-                return NULL;
-        }
-
-        LIBCFS_ALLOC(plp, sizeof(*plp));
-        if (plp == NULL) {
-                CERROR("Can't allocate new peer %s\n", libcfs_id2str(id));
-                plni->plni_npeers--;
-                ptllnd_size_buffers(ni, -plni->plni_peer_credits);
-                return NULL;
-        }
-
-        plp->plp_ni = ni;
-        plp->plp_id = id;
-        plp->plp_ptlid.nid = LNET_NIDADDR(id.nid);
-        plp->plp_ptlid.pid = plni->plni_ptllnd_pid;
-        plp->plp_credits = 1; /* add more later when she gives me credits */
-        plp->plp_max_msg_size = plni->plni_max_msg_size; /* until I hear from her */
-        plp->plp_sent_credits = 1;              /* Implicit credit for HELLO */
-        plp->plp_outstanding_credits = plni->plni_peer_credits - 1;
-        plp->plp_lazy_credits = 0;
-        plp->plp_extra_lazy_credits = 0;
-        plp->plp_match = 0;
-        plp->plp_stamp = 0;
-        plp->plp_sent_hello = 0;
-        plp->plp_recvd_hello = 0;
-        plp->plp_closing = 0;
-        plp->plp_refcount = 1;
-        CFS_INIT_LIST_HEAD(&plp->plp_list);
-        CFS_INIT_LIST_HEAD(&plp->plp_txq);
-        CFS_INIT_LIST_HEAD(&plp->plp_noopq);
-        CFS_INIT_LIST_HEAD(&plp->plp_activeq);
-
-        ptllnd_peer_addref(plp);
-        cfs_list_add_tail(&plp->plp_list, &plni->plni_peer_hash[hash]);
-
-        tx = ptllnd_new_tx(plp, PTLLND_MSG_TYPE_HELLO, 0);
-        if (tx == NULL) {
-                CERROR("Can't send HELLO to %s\n", libcfs_id2str(id));
-                ptllnd_close_peer(plp, -ENOMEM);
-                ptllnd_peer_decref(plp);
-                return NULL;
-        }
-
-        tx->tx_msg.ptlm_u.hello.kptlhm_matchbits = PTL_RESERVED_MATCHBITS;
-        tx->tx_msg.ptlm_u.hello.kptlhm_max_msg_size = plni->plni_max_msg_size;
-
-        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: post hello %p", libcfs_id2str(id),
-                       tx->tx_peer->plp_credits,
-                       tx->tx_peer->plp_outstanding_credits,
-                       tx->tx_peer->plp_sent_credits,
-                       plni->plni_peer_credits + 
-                       tx->tx_peer->plp_lazy_credits, tx);
-        ptllnd_post_tx(tx);
-
-        return plp;
-}
-
-int
-ptllnd_count_q(cfs_list_t *q)
-{
-        cfs_list_t *e;
-        int         n = 0;
-
-        cfs_list_for_each(e, q) {
-                n++;
-        }
-
-        return n;
-}
-
-const char *
-ptllnd_tx_typestr(int type)
-{
-        switch (type) {
-        case PTLLND_RDMA_WRITE:
-                return "rdma_write";
-
-        case PTLLND_RDMA_READ:
-                return "rdma_read";
-
-        case PTLLND_MSG_TYPE_PUT:
-                return "put_req";
-
-        case PTLLND_MSG_TYPE_GET:
-                return "get_req";
-
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                return "immediate";
-
-        case PTLLND_MSG_TYPE_NOOP:
-                return "noop";
-
-        case PTLLND_MSG_TYPE_HELLO:
-                return "hello";
-
-        default:
-                return "<unknown>";
-        }
-}
-
-void
-ptllnd_debug_tx(ptllnd_tx_t *tx)
-{
-        CDEBUG(D_WARNING, "%s %s b %ld.%06ld/%ld.%06ld"
-               " r %ld.%06ld/%ld.%06ld status %d\n",
-               ptllnd_tx_typestr(tx->tx_type),
-               libcfs_id2str(tx->tx_peer->plp_id),
-               tx->tx_bulk_posted.tv_sec, tx->tx_bulk_posted.tv_usec,
-               tx->tx_bulk_done.tv_sec, tx->tx_bulk_done.tv_usec,
-               tx->tx_req_posted.tv_sec, tx->tx_req_posted.tv_usec,
-               tx->tx_req_done.tv_sec, tx->tx_req_done.tv_usec,
-               tx->tx_status);
-}
-
-void
-ptllnd_debug_peer(lnet_ni_t *ni, lnet_process_id_t id)
-{
-        ptllnd_peer_t    *plp = ptllnd_find_peer(ni, id, 0);
-        ptllnd_ni_t      *plni = ni->ni_data;
-        ptllnd_tx_t      *tx;
-
-        if (plp == NULL) {
-                CDEBUG(D_WARNING, "No peer %s\n", libcfs_id2str(id));
-                return;
-        }
-
-        CWARN("%s %s%s [%d] "LPU64".%06d m "LPU64" q %d/%d/%d c %d/%d+%d(%d)\n",
-              libcfs_id2str(id),
-              plp->plp_recvd_hello ? "H" : "_",
-              plp->plp_closing     ? "C" : "_",
-              plp->plp_refcount,
-              plp->plp_stamp / 1000000, (int)(plp->plp_stamp % 1000000),
-              plp->plp_match,
-              ptllnd_count_q(&plp->plp_txq),
-              ptllnd_count_q(&plp->plp_noopq),
-              ptllnd_count_q(&plp->plp_activeq),
-              plp->plp_credits, plp->plp_outstanding_credits, plp->plp_sent_credits,
-              plni->plni_peer_credits + plp->plp_lazy_credits);
-
-        CDEBUG(D_WARNING, "txq:\n");
-        cfs_list_for_each_entry (tx, &plp->plp_txq, tx_list) {
-                ptllnd_debug_tx(tx);
-        }
-
-        CDEBUG(D_WARNING, "noopq:\n");
-        cfs_list_for_each_entry (tx, &plp->plp_noopq, tx_list) {
-                ptllnd_debug_tx(tx);
-        }
-
-        CDEBUG(D_WARNING, "activeq:\n");
-        cfs_list_for_each_entry (tx, &plp->plp_activeq, tx_list) {
-                ptllnd_debug_tx(tx);
-        }
-
-        CDEBUG(D_WARNING, "zombies:\n");
-        cfs_list_for_each_entry (tx, &plni->plni_zombie_txs, tx_list) {
-                if (tx->tx_peer->plp_id.nid == id.nid &&
-                    tx->tx_peer->plp_id.pid == id.pid)
-                        ptllnd_debug_tx(tx);
-        }
-
-        CDEBUG(D_WARNING, "history:\n");
-        cfs_list_for_each_entry (tx, &plni->plni_tx_history, tx_list) {
-                if (tx->tx_peer->plp_id.nid == id.nid &&
-                    tx->tx_peer->plp_id.pid == id.pid)
-                        ptllnd_debug_tx(tx);
-        }
-
-        ptllnd_peer_decref(plp);
-}
-
-void
-ptllnd_dump_debug(lnet_ni_t *ni, lnet_process_id_t id)
-{
-        ptllnd_debug_peer(ni, id);
-        ptllnd_dump_history();
-}
-
-int
-ptllnd_setasync(lnet_ni_t *ni, lnet_process_id_t id, int nasync)
-{
-        ptllnd_peer_t *peer = ptllnd_find_peer(ni, id, nasync > 0);
-        int            rc;
-
-        if (peer == NULL)
-                return -ENOMEM;
-
-        LASSERT (peer->plp_lazy_credits >= 0);
-        LASSERT (peer->plp_extra_lazy_credits >= 0);
-
-        /* If nasync < 0, we're being told we can reduce the total message
-         * headroom.  We can't do this right now because our peer might already
-         * have credits for the extra buffers, so we just account the extra
-         * headroom in case we need it later and only destroy buffers when the
-         * peer closes.
-         *
-         * Note that the following condition handles this case, where it
-         * actually increases the extra lazy credit counter. */
-
-        if (nasync <= peer->plp_extra_lazy_credits) {
-                peer->plp_extra_lazy_credits -= nasync;
-                return 0;
-        }
-
-        LASSERT (nasync > 0);
-
-        nasync -= peer->plp_extra_lazy_credits;
-        peer->plp_extra_lazy_credits = 0;
-
-        rc = ptllnd_size_buffers(ni, nasync);
-        if (rc == 0) {
-                peer->plp_lazy_credits += nasync;
-                peer->plp_outstanding_credits += nasync;
-        }
-
-        return rc;
-}
-
-__u32
-ptllnd_cksum (void *ptr, int nob)
-{
-        char  *c  = ptr;
-        __u32  sum = 0;
-
-        while (nob-- > 0)
-                sum = ((sum << 1) | (sum >> 31)) + *c++;
-
-        /* ensure I don't return 0 (== no checksum) */
-        return (sum == 0) ? 1 : sum;
-}
-
-ptllnd_tx_t *
-ptllnd_new_tx(ptllnd_peer_t *peer, int type, int payload_nob)
-{
-        lnet_ni_t   *ni = peer->plp_ni;
-        ptllnd_ni_t *plni = ni->ni_data;
-        ptllnd_tx_t *tx;
-        int          msgsize;
-
-        CDEBUG(D_NET, "peer=%p type=%d payload=%d\n", peer, type, payload_nob);
-
-        switch (type) {
-        default:
-                LBUG();
-
-        case PTLLND_RDMA_WRITE:
-        case PTLLND_RDMA_READ:
-                LASSERT (payload_nob == 0);
-                msgsize = 0;
-                break;
-
-        case PTLLND_MSG_TYPE_PUT:
-        case PTLLND_MSG_TYPE_GET:
-                LASSERT (payload_nob == 0);
-                msgsize = offsetof(kptl_msg_t, ptlm_u) + 
-                          sizeof(kptl_rdma_msg_t);
-                break;
-
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                msgsize = offsetof(kptl_msg_t,
-                                   ptlm_u.immediate.kptlim_payload[payload_nob]);
-                break;
-
-        case PTLLND_MSG_TYPE_NOOP:
-                LASSERT (payload_nob == 0);
-                msgsize = offsetof(kptl_msg_t, ptlm_u);
-                break;
-
-        case PTLLND_MSG_TYPE_HELLO:
-                LASSERT (payload_nob == 0);
-                msgsize = offsetof(kptl_msg_t, ptlm_u) +
-                          sizeof(kptl_hello_msg_t);
-                break;
-        }
-
-        msgsize = (msgsize + 7) & ~7;
-        LASSERT (msgsize <= peer->plp_max_msg_size);
-
-        LIBCFS_ALLOC(tx, offsetof(ptllnd_tx_t, tx_msg) + msgsize);
-
-        if (tx == NULL) {
-                CERROR("Can't allocate msg type %d for %s\n",
-                       type, libcfs_id2str(peer->plp_id));
-                return NULL;
-        }
-
-        CFS_INIT_LIST_HEAD(&tx->tx_list);
-        tx->tx_peer = peer;
-        tx->tx_type = type;
-        tx->tx_lnetmsg = tx->tx_lnetreplymsg = NULL;
-        tx->tx_niov = 0;
-        tx->tx_iov = NULL;
-        tx->tx_reqmdh = PTL_INVALID_HANDLE;
-        tx->tx_bulkmdh = PTL_INVALID_HANDLE;
-        tx->tx_msgsize = msgsize;
-        tx->tx_completing = 0;
-        tx->tx_status = 0;
-
-        memset(&tx->tx_bulk_posted, 0, sizeof(tx->tx_bulk_posted));
-        memset(&tx->tx_bulk_done, 0, sizeof(tx->tx_bulk_done));
-        memset(&tx->tx_req_posted, 0, sizeof(tx->tx_req_posted));
-        memset(&tx->tx_req_done, 0, sizeof(tx->tx_req_done));
-
-        if (msgsize != 0) {
-                tx->tx_msg.ptlm_magic = PTLLND_MSG_MAGIC;
-                tx->tx_msg.ptlm_version = PTLLND_MSG_VERSION;
-                tx->tx_msg.ptlm_type = type;
-                tx->tx_msg.ptlm_credits = 0;
-                tx->tx_msg.ptlm_nob = msgsize;
-                tx->tx_msg.ptlm_cksum = 0;
-                tx->tx_msg.ptlm_srcnid = ni->ni_nid;
-                tx->tx_msg.ptlm_srcstamp = plni->plni_stamp;
-                tx->tx_msg.ptlm_dstnid = peer->plp_id.nid;
-                tx->tx_msg.ptlm_dststamp = peer->plp_stamp;
-                tx->tx_msg.ptlm_srcpid = the_lnet.ln_pid;
-                tx->tx_msg.ptlm_dstpid = peer->plp_id.pid;
-        }
-
-        ptllnd_peer_addref(peer);
-        plni->plni_ntxs++;
-
-        CDEBUG(D_NET, "tx=%p\n", tx);
-
-        return tx;
-}
-
-void
-ptllnd_abort_tx(ptllnd_tx_t *tx, ptl_handle_md_t *mdh)
-{
-        ptllnd_peer_t   *peer = tx->tx_peer;
-        lnet_ni_t       *ni = peer->plp_ni;
-        int              rc;
-        time_t           start = cfs_time_current_sec();
-        ptllnd_ni_t     *plni = ni->ni_data;
-        int              w = plni->plni_long_wait;
-
-        while (!PtlHandleIsEqual(*mdh, PTL_INVALID_HANDLE)) {
-                rc = PtlMDUnlink(*mdh);
-#ifndef LUSTRE_PORTALS_UNLINK_SEMANTICS
-                if (rc == PTL_OK) /* unlink successful => no unlinked event */
-                        return;
-                LASSERT (rc == PTL_MD_IN_USE);
-#endif
-                if (w > 0 && cfs_time_current_sec() > start + w/1000) {
-                        CWARN("Waited %ds to abort tx to %s\n",
-                              (int)(cfs_time_current_sec() - start),
-                              libcfs_id2str(peer->plp_id));
-                        w *= 2;
-                }
-                /* Wait for ptllnd_tx_event() to invalidate */
-                ptllnd_wait(ni, w);
-        }
-}
-
-void
-ptllnd_cull_tx_history(ptllnd_ni_t *plni)
-{
-        int max = plni->plni_max_tx_history;
-
-        while (plni->plni_ntx_history > max) {
-                ptllnd_tx_t *tx = cfs_list_entry(plni->plni_tx_history.next,
-                                                 ptllnd_tx_t, tx_list);
-                cfs_list_del(&tx->tx_list);
-
-                ptllnd_peer_decref(tx->tx_peer);
-
-                LIBCFS_FREE(tx, offsetof(ptllnd_tx_t, tx_msg) + tx->tx_msgsize);
-
-                LASSERT (plni->plni_ntxs > 0);
-                plni->plni_ntxs--;
-                plni->plni_ntx_history--;
-        }
-}
-
-void
-ptllnd_tx_done(ptllnd_tx_t *tx)
-{
-        ptllnd_peer_t   *peer = tx->tx_peer;
-        lnet_ni_t       *ni = peer->plp_ni;
-        ptllnd_ni_t     *plni = ni->ni_data;
-
-        /* CAVEAT EMPTOR: If this tx is being aborted, I'll continue to get
-         * events for this tx until it's unlinked.  So I set tx_completing to
-         * flag the tx is getting handled */
-
-        if (tx->tx_completing)
-                return;
-
-        tx->tx_completing = 1;
-
-        if (!cfs_list_empty(&tx->tx_list))
-                cfs_list_del_init(&tx->tx_list);
-
-        if (tx->tx_status != 0) {
-                if (plni->plni_debug) {
-                        CERROR("Completing tx for %s with error %d\n",
-                               libcfs_id2str(peer->plp_id), tx->tx_status);
-                        ptllnd_debug_tx(tx);
-                }
-                ptllnd_close_peer(peer, tx->tx_status);
-        }
-
-        ptllnd_abort_tx(tx, &tx->tx_reqmdh);
-        ptllnd_abort_tx(tx, &tx->tx_bulkmdh);
-
-        if (tx->tx_niov > 0) {
-                LIBCFS_FREE(tx->tx_iov, tx->tx_niov * sizeof(*tx->tx_iov));
-                tx->tx_niov = 0;
-        }
-
-        if (tx->tx_lnetreplymsg != NULL) {
-                LASSERT (tx->tx_type == PTLLND_MSG_TYPE_GET);
-                LASSERT (tx->tx_lnetmsg != NULL);
-                /* Simulate GET success always  */
-                lnet_finalize(ni, tx->tx_lnetmsg, 0);
-                CDEBUG(D_NET, "lnet_finalize(tx_lnetreplymsg=%p)\n",tx->tx_lnetreplymsg);
-                lnet_finalize(ni, tx->tx_lnetreplymsg, tx->tx_status);
-        } else if (tx->tx_lnetmsg != NULL) {
-                lnet_finalize(ni, tx->tx_lnetmsg, tx->tx_status);
-        }
-
-        plni->plni_ntx_history++;
-        cfs_list_add_tail(&tx->tx_list, &plni->plni_tx_history);
-
-        ptllnd_cull_tx_history(plni);
-}
-
-int
-ptllnd_set_txiov(ptllnd_tx_t *tx,
-                 unsigned int niov, struct iovec *iov,
-                 unsigned int offset, unsigned int len)
-{
-        ptl_md_iovec_t *piov;
-        int             npiov;
-
-        if (len == 0) {
-                tx->tx_niov = 0;
-                return 0;
-        }
-
-        /*
-         * Remove iovec's at the beginning that
-         * are skipped because of the offset.
-         * Adjust the offset accordingly
-         */
-        for (;;) {
-                LASSERT (niov > 0);
-                if (offset < iov->iov_len)
-                        break;
-                offset -= iov->iov_len;
-                niov--;
-                iov++;
-        }
-
-        for (;;) {
-                int temp_offset = offset;
-                int resid = len;
-                LIBCFS_ALLOC(piov, niov * sizeof(*piov));
-                if (piov == NULL)
-                        return -ENOMEM;
-
-                for (npiov = 0;; npiov++) {
-                        LASSERT (npiov < niov);
-                        LASSERT (iov->iov_len >= temp_offset);
-
-                        piov[npiov].iov_base = iov[npiov].iov_base + temp_offset;
-                        piov[npiov].iov_len = iov[npiov].iov_len - temp_offset;
-
-                        if (piov[npiov].iov_len >= resid) {
-                                piov[npiov].iov_len = resid;
-                                npiov++;
-                                break;
-                        }
-                        resid -= piov[npiov].iov_len;
-                        temp_offset = 0;
-                }
-
-                if (npiov == niov) {
-                        tx->tx_niov = niov;
-                        tx->tx_iov = piov;
-                        return 0;
-                }
-
-                /* Dang! The piov I allocated was too big and it's a drag to
-                 * have to maintain separate 'allocated' and 'used' sizes, so
-                 * I'll just do it again; NB this doesn't happen normally... */
-                LIBCFS_FREE(piov, niov * sizeof(*piov));
-                niov = npiov;
-        }
-}
-
-void
-ptllnd_set_md_buffer(ptl_md_t *md, ptllnd_tx_t *tx)
-{
-        unsigned int    niov = tx->tx_niov;
-        ptl_md_iovec_t *iov = tx->tx_iov;
-
-        LASSERT ((md->options & PTL_MD_IOVEC) == 0);
-
-        if (niov == 0) {
-                md->start = NULL;
-                md->length = 0;
-        } else if (niov == 1) {
-                md->start = iov[0].iov_base;
-                md->length = iov[0].iov_len;
-        } else {
-                md->start = iov;
-                md->length = niov;
-                md->options |= PTL_MD_IOVEC;
-        }
-}
-
-int
-ptllnd_post_buffer(ptllnd_buffer_t *buf)
-{
-        lnet_ni_t        *ni = buf->plb_ni;
-        ptllnd_ni_t      *plni = ni->ni_data;
-        ptl_process_id_t  anyid = {
-                .nid       = PTL_NID_ANY,
-                .pid       = PTL_PID_ANY};
-        ptl_md_t          md = {
-                .start     = buf->plb_buffer,
-                .length    = plni->plni_buffer_size,
-                .threshold = PTL_MD_THRESH_INF,
-                .max_size  = plni->plni_max_msg_size,
-                .options   = (PTLLND_MD_OPTIONS |
-                              PTL_MD_OP_PUT | PTL_MD_MAX_SIZE | 
-                              PTL_MD_LOCAL_ALIGN8),
-                .user_ptr  = ptllnd_obj2eventarg(buf, PTLLND_EVENTARG_TYPE_BUF),
-                .eq_handle = plni->plni_eqh};
-        ptl_handle_me_t meh;
-        int             rc;
-
-        LASSERT (!buf->plb_posted);
-
-        rc = PtlMEAttach(plni->plni_nih, plni->plni_portal,
-                         anyid, LNET_MSG_MATCHBITS, 0,
-                         PTL_UNLINK, PTL_INS_AFTER, &meh);
-        if (rc != PTL_OK) {
-                CERROR("PtlMEAttach failed: %s(%d)\n",
-                       ptllnd_errtype2str(rc), rc);
-                return -ENOMEM;
-        }
-
-        buf->plb_posted = 1;
-        plni->plni_nposted_buffers++;
-
-        rc = PtlMDAttach(meh, md, LNET_UNLINK, &buf->plb_md);
-        if (rc == PTL_OK)
-                return 0;
-
-        CERROR("PtlMDAttach failed: %s(%d)\n",
-               ptllnd_errtype2str(rc), rc);
-
-        buf->plb_posted = 0;
-        plni->plni_nposted_buffers--;
-
-        rc = PtlMEUnlink(meh);
-        LASSERT (rc == PTL_OK);
-
-        return -ENOMEM;
-}
-
-static inline int
-ptllnd_peer_send_noop (ptllnd_peer_t *peer)
-{
-        ptllnd_ni_t *plni = peer->plp_ni->ni_data;
-
-        if (!peer->plp_sent_hello ||
-            peer->plp_credits == 0 ||
-            !cfs_list_empty(&peer->plp_noopq) ||
-            peer->plp_outstanding_credits < PTLLND_CREDIT_HIGHWATER(plni))
-                return 0;
-
-        /* No tx to piggyback NOOP onto or no credit to send a tx */
-        return (cfs_list_empty(&peer->plp_txq) || peer->plp_credits == 1);
-}
-
-void
-ptllnd_check_sends(ptllnd_peer_t *peer)
-{
-        ptllnd_ni_t    *plni = peer->plp_ni->ni_data;
-        ptllnd_tx_t    *tx;
-        ptl_md_t        md;
-        ptl_handle_md_t mdh;
-        int             rc;
-
-        CDEBUG(D_NET, "%s: [%d/%d+%d(%d)\n",
-               libcfs_id2str(peer->plp_id), peer->plp_credits,
-               peer->plp_outstanding_credits, peer->plp_sent_credits,
-               plni->plni_peer_credits + peer->plp_lazy_credits);
-
-        if (ptllnd_peer_send_noop(peer)) {
-                tx = ptllnd_new_tx(peer, PTLLND_MSG_TYPE_NOOP, 0);
-                CDEBUG(D_NET, "NOOP tx=%p\n",tx);
-                if (tx == NULL) {
-                        CERROR("Can't return credits to %s\n",
-                               libcfs_id2str(peer->plp_id));
-                } else {
-                        ptllnd_set_tx_deadline(tx);
-                        cfs_list_add_tail(&tx->tx_list, &peer->plp_noopq);
-                }
-        }
-
-        for (;;) {
-                if (!cfs_list_empty(&peer->plp_noopq)) {
-                        LASSERT (peer->plp_sent_hello);
-                        tx = cfs_list_entry(peer->plp_noopq.next,
-                                            ptllnd_tx_t, tx_list);
-                } else if (!cfs_list_empty(&peer->plp_txq)) {
-                        tx = cfs_list_entry(peer->plp_txq.next,
-                                            ptllnd_tx_t, tx_list);
-                } else {
-                        /* nothing to send right now */
-                        break;
-                }
-
-                LASSERT (tx->tx_msgsize > 0);
-
-                LASSERT (peer->plp_outstanding_credits >= 0);
-                LASSERT (peer->plp_sent_credits >= 0);
-                LASSERT (peer->plp_outstanding_credits + peer->plp_sent_credits
-                         <= plni->plni_peer_credits + peer->plp_lazy_credits);
-                LASSERT (peer->plp_credits >= 0);
-
-                /* say HELLO first */
-                if (!peer->plp_sent_hello) {
-                        LASSERT (cfs_list_empty(&peer->plp_noopq));
-                        LASSERT (tx->tx_type == PTLLND_MSG_TYPE_HELLO);
-
-                        peer->plp_sent_hello = 1;
-                }
-
-                if (peer->plp_credits == 0) {   /* no credits */
-                        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: no creds for %p",
-                                       libcfs_id2str(peer->plp_id),
-                                       peer->plp_credits,
-                                       peer->plp_outstanding_credits,
-                                       peer->plp_sent_credits,
-                                       plni->plni_peer_credits +
-                                       peer->plp_lazy_credits, tx);
-                        break;
-                }
-
-                /* Last/Initial credit reserved for NOOP/HELLO */
-                if (peer->plp_credits == 1 &&
-                    tx->tx_type != PTLLND_MSG_TYPE_NOOP &&
-                    tx->tx_type != PTLLND_MSG_TYPE_HELLO) {
-                        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: too few creds for %p",
-                                       libcfs_id2str(peer->plp_id),
-                                       peer->plp_credits,
-                                       peer->plp_outstanding_credits,
-                                       peer->plp_sent_credits,
-                                       plni->plni_peer_credits +
-                                       peer->plp_lazy_credits, tx);
-                        break;
-                }
-
-                cfs_list_del(&tx->tx_list);
-                cfs_list_add_tail(&tx->tx_list, &peer->plp_activeq);
-
-                CDEBUG(D_NET, "Sending at TX=%p type=%s (%d)\n",tx,
-                       ptllnd_msgtype2str(tx->tx_type),tx->tx_type);
-
-                if (tx->tx_type == PTLLND_MSG_TYPE_NOOP &&
-                    !ptllnd_peer_send_noop(peer)) {
-                        /* redundant NOOP */
-                        ptllnd_tx_done(tx);
-                        continue;
-                }
-
-                /* Set stamp at the last minute; on a new peer, I don't know it
-                 * until I receive the HELLO back */
-                tx->tx_msg.ptlm_dststamp = peer->plp_stamp;
-
-                /*
-                 * Return all the credits we have
-                 */
-                tx->tx_msg.ptlm_credits = MIN(PTLLND_MSG_MAX_CREDITS,
-                                              peer->plp_outstanding_credits);
-                peer->plp_sent_credits += tx->tx_msg.ptlm_credits;
-                peer->plp_outstanding_credits -= tx->tx_msg.ptlm_credits;
-
-                /*
-                 * One less credit
-                 */
-                peer->plp_credits--;
-
-                if (plni->plni_checksum)
-                        tx->tx_msg.ptlm_cksum = 
-                                ptllnd_cksum(&tx->tx_msg,
-                                             offsetof(kptl_msg_t, ptlm_u));
-
-                md.user_ptr = ptllnd_obj2eventarg(tx, PTLLND_EVENTARG_TYPE_TX);
-                md.eq_handle = plni->plni_eqh;
-                md.threshold = 1;
-                md.options = PTLLND_MD_OPTIONS;
-                md.start = &tx->tx_msg;
-                md.length = tx->tx_msgsize;
-
-                rc = PtlMDBind(plni->plni_nih, md, LNET_UNLINK, &mdh);
-                if (rc != PTL_OK) {
-                        CERROR("PtlMDBind for %s failed: %s(%d)\n",
-                               libcfs_id2str(peer->plp_id),
-                               ptllnd_errtype2str(rc), rc);
-                        tx->tx_status = -EIO;
-                        ptllnd_tx_done(tx);
-                        break;
-                }
-
-                LASSERT (tx->tx_type != PTLLND_RDMA_WRITE &&
-                         tx->tx_type != PTLLND_RDMA_READ);
-
-                tx->tx_reqmdh = mdh;
-                gettimeofday(&tx->tx_req_posted, NULL);
-
-                PTLLND_HISTORY("%s[%d/%d+%d(%d)]: %s %p c %d",
-                               libcfs_id2str(peer->plp_id),
-                               peer->plp_credits,
-                               peer->plp_outstanding_credits,
-                               peer->plp_sent_credits,
-                               plni->plni_peer_credits +
-                               peer->plp_lazy_credits,
-                               ptllnd_msgtype2str(tx->tx_type), tx,
-                               tx->tx_msg.ptlm_credits);
-
-                rc = PtlPut(mdh, PTL_NOACK_REQ, peer->plp_ptlid,
-                            plni->plni_portal, 0, LNET_MSG_MATCHBITS, 0, 0);
-                if (rc != PTL_OK) {
-                        CERROR("PtlPut for %s failed: %s(%d)\n",
-                               libcfs_id2str(peer->plp_id),
-                               ptllnd_errtype2str(rc), rc);
-                        tx->tx_status = -EIO;
-                        ptllnd_tx_done(tx);
-                        break;
-                }
-        }
-}
-
-int
-ptllnd_passive_rdma(ptllnd_peer_t *peer, int type, lnet_msg_t *msg,
-                    unsigned int niov, struct iovec *iov,
-                    unsigned int offset, unsigned int len)
-{
-        lnet_ni_t      *ni = peer->plp_ni;
-        ptllnd_ni_t    *plni = ni->ni_data;
-        ptllnd_tx_t    *tx = ptllnd_new_tx(peer, type, 0);
-        __u64           matchbits;
-        ptl_md_t        md;
-        ptl_handle_md_t mdh;
-        ptl_handle_me_t meh;
-        int             rc;
-        int             rc2;
-        time_t          start;
-        int             w;
-
-        CDEBUG(D_NET, "niov=%d offset=%d len=%d\n",niov,offset,len);
-
-        LASSERT (type == PTLLND_MSG_TYPE_GET ||
-                 type == PTLLND_MSG_TYPE_PUT);
-
-        if (tx == NULL) {
-                CERROR("Can't allocate %s tx for %s\n",
-                       ptllnd_msgtype2str(type), libcfs_id2str(peer->plp_id));
-                return -ENOMEM;
-        }
-
-        rc = ptllnd_set_txiov(tx, niov, iov, offset, len);
-        if (rc != 0) {
-                CERROR("Can't allocate iov %d for %s\n",
-                       niov, libcfs_id2str(peer->plp_id));
-                rc = -ENOMEM;
-                goto failed;
-        }
-
-        md.user_ptr = ptllnd_obj2eventarg(tx, PTLLND_EVENTARG_TYPE_TX);
-        md.eq_handle = plni->plni_eqh;
-        md.threshold = 1;
-        md.max_size = 0;
-        md.options = PTLLND_MD_OPTIONS;
-        if(type == PTLLND_MSG_TYPE_GET)
-                md.options |= PTL_MD_OP_PUT | PTL_MD_ACK_DISABLE;
-        else
-                md.options |= PTL_MD_OP_GET;
-        ptllnd_set_md_buffer(&md, tx);
-
-        start = cfs_time_current_sec();
-        w = plni->plni_long_wait;
-        ptllnd_set_tx_deadline(tx);
-
-        while (!peer->plp_recvd_hello) {    /* wait to validate plp_match */
-                if (peer->plp_closing) {
-                        rc = -EIO;
-                        goto failed;
-                }
-
-                /* NB must check here to avoid unbounded wait - tx not yet
-                 * on peer->plp_txq, so ptllnd_watchdog can't expire it */
-                if (tx->tx_deadline < cfs_time_current_sec()) {
-                        CERROR("%s tx for %s timed out\n",
-                               ptllnd_msgtype2str(type),
-                               libcfs_id2str(peer->plp_id));
-                        rc = -ETIMEDOUT;
-                        goto failed;
-                }
-
-                if (w > 0 && cfs_time_current_sec() > start + w/1000) {
-                        CWARN("Waited %ds to connect to %s\n",
-                              (int)(cfs_time_current_sec() - start),
-                              libcfs_id2str(peer->plp_id));
-                        w *= 2;
-                }
-                ptllnd_wait(ni, w);
-        }
-
-        if (peer->plp_match < PTL_RESERVED_MATCHBITS)
-                peer->plp_match = PTL_RESERVED_MATCHBITS;
-        matchbits = peer->plp_match++;
-
-        rc = PtlMEAttach(plni->plni_nih, plni->plni_portal, peer->plp_ptlid,
-                         matchbits, 0, PTL_UNLINK, PTL_INS_BEFORE, &meh);
-        if (rc != PTL_OK) {
-                CERROR("PtlMEAttach for %s failed: %s(%d)\n",
-                       libcfs_id2str(peer->plp_id),
-                       ptllnd_errtype2str(rc), rc);
-                rc = -EIO;
-                goto failed;
-        }
-
-        gettimeofday(&tx->tx_bulk_posted, NULL);
-
-        rc = PtlMDAttach(meh, md, LNET_UNLINK, &mdh);
-        if (rc != PTL_OK) {
-                CERROR("PtlMDAttach for %s failed: %s(%d)\n",
-                       libcfs_id2str(peer->plp_id),
-                       ptllnd_errtype2str(rc), rc);
-                rc2 = PtlMEUnlink(meh);
-                LASSERT (rc2 == PTL_OK);
-                rc = -EIO;
-                goto failed;
-        }
-        tx->tx_bulkmdh = mdh;
-
-        /*
-         * We need to set the stamp here because it
-         * we could have received a HELLO above that set
-         * peer->plp_stamp
-         */
-        tx->tx_msg.ptlm_dststamp = peer->plp_stamp;
-
-        tx->tx_msg.ptlm_u.rdma.kptlrm_hdr = msg->msg_hdr;
-        tx->tx_msg.ptlm_u.rdma.kptlrm_matchbits = matchbits;
-
-        if (type == PTLLND_MSG_TYPE_GET) {
-                tx->tx_lnetreplymsg = lnet_create_reply_msg(ni, msg);
-                if (tx->tx_lnetreplymsg == NULL) {
-                        CERROR("Can't create reply for GET to %s\n",
-                               libcfs_id2str(msg->msg_target));
-                        rc = -ENOMEM;
-                        goto failed;
-                }
-        }
-
-        tx->tx_lnetmsg = msg;
-        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: post passive %s p %d %p",
-                       libcfs_id2str(msg->msg_target),
-                       peer->plp_credits, peer->plp_outstanding_credits,
-                       peer->plp_sent_credits,
-                       plni->plni_peer_credits + peer->plp_lazy_credits,
-                       lnet_msgtyp2str(msg->msg_type),
-                       (le32_to_cpu(msg->msg_type) == LNET_MSG_PUT) ? 
-                       le32_to_cpu(msg->msg_hdr.msg.put.ptl_index) :
-                       (le32_to_cpu(msg->msg_type) == LNET_MSG_GET) ? 
-                       le32_to_cpu(msg->msg_hdr.msg.get.ptl_index) : -1,
-                       tx);
-        ptllnd_post_tx(tx);
-        return 0;
-
- failed:
-        tx->tx_status = rc;
-        ptllnd_tx_done(tx);
-        return rc;
-}
-
-int
-ptllnd_active_rdma(ptllnd_peer_t *peer, int type,
-                   lnet_msg_t *msg, __u64 matchbits,
-                   unsigned int niov, struct iovec *iov,
-                   unsigned int offset, unsigned int len)
-{
-        lnet_ni_t       *ni = peer->plp_ni;
-        ptllnd_ni_t     *plni = ni->ni_data;
-        ptllnd_tx_t     *tx = ptllnd_new_tx(peer, type, 0);
-        ptl_md_t         md;
-        ptl_handle_md_t  mdh;
-        int              rc;
-
-        LASSERT (type == PTLLND_RDMA_READ ||
-                 type == PTLLND_RDMA_WRITE);
-
-        if (tx == NULL) {
-                CERROR("Can't allocate tx for RDMA %s with %s\n",
-                       (type == PTLLND_RDMA_WRITE) ? "write" : "read",
-                       libcfs_id2str(peer->plp_id));
-                ptllnd_close_peer(peer, -ENOMEM);
-                return -ENOMEM;
-        }
-
-        rc = ptllnd_set_txiov(tx, niov, iov, offset, len);
-        if (rc != 0) {
-                CERROR("Can't allocate iov %d for %s\n",
-                       niov, libcfs_id2str(peer->plp_id));
-                rc = -ENOMEM;
-                goto failed;
-        }
-
-        md.user_ptr = ptllnd_obj2eventarg(tx, PTLLND_EVENTARG_TYPE_TX);
-        md.eq_handle = plni->plni_eqh;
-        md.max_size = 0;
-        md.options = PTLLND_MD_OPTIONS;
-        md.threshold = (type == PTLLND_RDMA_READ) ? 2 : 1;
-
-        ptllnd_set_md_buffer(&md, tx);
-
-        rc = PtlMDBind(plni->plni_nih, md, LNET_UNLINK, &mdh);
-        if (rc != PTL_OK) {
-                CERROR("PtlMDBind for %s failed: %s(%d)\n",
-                       libcfs_id2str(peer->plp_id),
-                       ptllnd_errtype2str(rc), rc);
-                rc = -EIO;
-                goto failed;
-        }
-
-        tx->tx_bulkmdh = mdh;
-        tx->tx_lnetmsg = msg;
-
-        ptllnd_set_tx_deadline(tx);
-        cfs_list_add_tail(&tx->tx_list, &peer->plp_activeq);
-        gettimeofday(&tx->tx_bulk_posted, NULL);
-
-        if (type == PTLLND_RDMA_READ)
-                rc = PtlGet(mdh, peer->plp_ptlid,
-                            plni->plni_portal, 0, matchbits, 0);
-        else
-                rc = PtlPut(mdh, PTL_NOACK_REQ, peer->plp_ptlid,
-                            plni->plni_portal, 0, matchbits, 0, 
-                            (msg == NULL) ? PTLLND_RDMA_FAIL : PTLLND_RDMA_OK);
-
-        if (rc == PTL_OK)
-                return 0;
-
-        CERROR("Can't initiate RDMA with %s: %s(%d)\n",
-               libcfs_id2str(peer->plp_id),
-               ptllnd_errtype2str(rc), rc);
-
-        tx->tx_lnetmsg = NULL;
- failed:
-        tx->tx_status = rc;
-        ptllnd_tx_done(tx);    /* this will close peer */
-        return rc;
-}
-
-int
-ptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *msg)
-{
-        ptllnd_ni_t    *plni = ni->ni_data;
-        ptllnd_peer_t  *plp;
-        ptllnd_tx_t    *tx;
-        int             nob;
-        int             rc;
-
-        LASSERT (!msg->msg_routing);
-        LASSERT (msg->msg_kiov == NULL);
-
-        LASSERT (msg->msg_niov <= PTL_MD_MAX_IOV); /* !!! */
-
-        CDEBUG(D_NET, "%s [%d]+%d,%d -> %s%s\n",
-               lnet_msgtyp2str(msg->msg_type),
-               msg->msg_niov, msg->msg_offset, msg->msg_len,
-               libcfs_nid2str(msg->msg_target.nid),
-               msg->msg_target_is_router ? "(rtr)" : "");
-
-        if ((msg->msg_target.pid & LNET_PID_USERFLAG) != 0) {
-                CERROR("Can't send to non-kernel peer %s\n",
-                       libcfs_id2str(msg->msg_target));
-                return -EHOSTUNREACH;
-        }
-
-        plp = ptllnd_find_peer(ni, msg->msg_target, 1);
-        if (plp == NULL)
-                return -ENOMEM;
-
-        switch (msg->msg_type) {
-        default:
-                LBUG();
-
-        case LNET_MSG_ACK:
-                LASSERT (msg->msg_len == 0);
-                break;                          /* send IMMEDIATE */
-
-        case LNET_MSG_GET:
-                if (msg->msg_target_is_router)
-                        break;                  /* send IMMEDIATE */
-
-                nob = msg->msg_md->md_length;
-                nob = offsetof(kptl_msg_t, ptlm_u.immediate.kptlim_payload[nob]);
-                if (nob <= plni->plni_max_msg_size)
-                        break;
-
-                LASSERT ((msg->msg_md->md_options & LNET_MD_KIOV) == 0);
-                rc = ptllnd_passive_rdma(plp, PTLLND_MSG_TYPE_GET, msg,
-                                         msg->msg_md->md_niov,
-                                         msg->msg_md->md_iov.iov,
-                                         0, msg->msg_md->md_length);
-                ptllnd_peer_decref(plp);
-                return rc;
-
-        case LNET_MSG_REPLY:
-        case LNET_MSG_PUT:
-                nob = msg->msg_len;
-                nob = offsetof(kptl_msg_t, ptlm_u.immediate.kptlim_payload[nob]);
-                if (nob <= plp->plp_max_msg_size)
-                        break;                  /* send IMMEDIATE */
-
-                rc = ptllnd_passive_rdma(plp, PTLLND_MSG_TYPE_PUT, msg,
-                                         msg->msg_niov, msg->msg_iov,
-                                         msg->msg_offset, msg->msg_len);
-                ptllnd_peer_decref(plp);
-                return rc;
-        }
-
-        /* send IMMEDIATE
-         * NB copy the payload so we don't have to do a fragmented send */
-
-        tx = ptllnd_new_tx(plp, PTLLND_MSG_TYPE_IMMEDIATE, msg->msg_len);
-        if (tx == NULL) {
-                CERROR("Can't allocate tx for lnet type %d to %s\n",
-                       msg->msg_type, libcfs_id2str(msg->msg_target));
-                ptllnd_peer_decref(plp);
-                return -ENOMEM;
-        }
-
-        lnet_copy_iov2flat(tx->tx_msgsize, &tx->tx_msg,
-                           offsetof(kptl_msg_t, ptlm_u.immediate.kptlim_payload),
-                           msg->msg_niov, msg->msg_iov, msg->msg_offset,
-                           msg->msg_len);
-        tx->tx_msg.ptlm_u.immediate.kptlim_hdr = msg->msg_hdr;
-
-        tx->tx_lnetmsg = msg;
-        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: post immediate %s p %d %p",
-                       libcfs_id2str(msg->msg_target),
-                       plp->plp_credits, plp->plp_outstanding_credits,
-                       plp->plp_sent_credits,
-                       plni->plni_peer_credits + plp->plp_lazy_credits,
-                       lnet_msgtyp2str(msg->msg_type),
-                       (le32_to_cpu(msg->msg_type) == LNET_MSG_PUT) ? 
-                       le32_to_cpu(msg->msg_hdr.msg.put.ptl_index) :
-                       (le32_to_cpu(msg->msg_type) == LNET_MSG_GET) ? 
-                       le32_to_cpu(msg->msg_hdr.msg.get.ptl_index) : -1,
-                       tx);
-        ptllnd_post_tx(tx);
-        ptllnd_peer_decref(plp);
-        return 0;
-}
-
-void
-ptllnd_rx_done(ptllnd_rx_t *rx)
-{
-        ptllnd_peer_t *plp = rx->rx_peer;
-        ptllnd_ni_t   *plni = plp->plp_ni->ni_data;
-
-        plp->plp_outstanding_credits++;
-
-        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: rx=%p done\n",
-                       libcfs_id2str(plp->plp_id),
-                       plp->plp_credits, plp->plp_outstanding_credits, 
-                       plp->plp_sent_credits,
-                       plni->plni_peer_credits + plp->plp_lazy_credits, rx);
-
-        ptllnd_check_sends(plp);
-
-        LASSERT (plni->plni_nrxs > 0);
-        plni->plni_nrxs--;
-}
-
-int
-ptllnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
-                  void **new_privatep)
-{
-        /* Shouldn't get here; recvs only block for router buffers */
-        LBUG();
-        return 0;
-}
-
-int
-ptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
-            int delayed, unsigned int niov,
-            struct iovec *iov, lnet_kiov_t *kiov,
-            unsigned int offset, unsigned int mlen, unsigned int rlen)
-{
-        ptllnd_rx_t    *rx = private;
-        int             rc = 0;
-        int             nob;
-
-        LASSERT (kiov == NULL);
-        LASSERT (niov <= PTL_MD_MAX_IOV);       /* !!! */
-
-        switch (rx->rx_msg->ptlm_type) {
-        default:
-                LBUG();
-
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                nob = offsetof(kptl_msg_t, ptlm_u.immediate.kptlim_payload[mlen]);
-                if (nob > rx->rx_nob) {
-                        CERROR("Immediate message from %s too big: %d(%d)\n",
-                               libcfs_id2str(rx->rx_peer->plp_id),
-                               nob, rx->rx_nob);
-                        rc = -EPROTO;
-                        break;
-                }
-                lnet_copy_flat2iov(niov, iov, offset,
-                                   rx->rx_nob, rx->rx_msg,
-                                   offsetof(kptl_msg_t, ptlm_u.immediate.kptlim_payload),
-                                   mlen);
-                lnet_finalize(ni, msg, 0);
-                break;
-
-        case PTLLND_MSG_TYPE_PUT:
-                rc = ptllnd_active_rdma(rx->rx_peer, PTLLND_RDMA_READ, msg,
-                                        rx->rx_msg->ptlm_u.rdma.kptlrm_matchbits,
-                                        niov, iov, offset, mlen);
-                break;
-
-        case PTLLND_MSG_TYPE_GET:
-                if (msg != NULL)
-                        rc = ptllnd_active_rdma(rx->rx_peer, PTLLND_RDMA_WRITE, msg,
-                                                rx->rx_msg->ptlm_u.rdma.kptlrm_matchbits,
-                                                msg->msg_niov, msg->msg_iov,
-                                                msg->msg_offset, msg->msg_len);
-                else
-                        rc = ptllnd_active_rdma(rx->rx_peer, PTLLND_RDMA_WRITE, NULL,
-                                                rx->rx_msg->ptlm_u.rdma.kptlrm_matchbits,
-                                                0, NULL, 0, 0);
-                break;
-        }
-
-        ptllnd_rx_done(rx);
-        return rc;
-}
-
-void
-ptllnd_parse_request(lnet_ni_t *ni, ptl_process_id_t initiator,
-                     kptl_msg_t *msg, unsigned int nob)
-{
-        ptllnd_ni_t      *plni = ni->ni_data;
-        const int         basenob = offsetof(kptl_msg_t, ptlm_u);
-        lnet_process_id_t srcid;
-        ptllnd_rx_t       rx;
-        int               flip;
-        __u16             msg_version;
-        __u32             msg_cksum;
-        ptllnd_peer_t    *plp;
-        int               rc;
-
-        if (nob < 6) {
-                CERROR("Very short receive from %s\n",
-                       ptllnd_ptlid2str(initiator));
-                return;
-        }
-
-        /* I can at least read MAGIC/VERSION */
-
-        flip = msg->ptlm_magic == __swab32(PTLLND_MSG_MAGIC);
-        if (!flip && msg->ptlm_magic != PTLLND_MSG_MAGIC) {
-                CERROR("Bad protocol magic %08x from %s\n", 
-                       msg->ptlm_magic, ptllnd_ptlid2str(initiator));
-                return;
-        }
-
-        msg_version = flip ? __swab16(msg->ptlm_version) : msg->ptlm_version;
-
-        if (msg_version != PTLLND_MSG_VERSION) {
-                CERROR("Bad protocol version %04x from %s: %04x expected\n",
-                       (__u32)msg_version, ptllnd_ptlid2str(initiator), PTLLND_MSG_VERSION);
-
-                if (plni->plni_abort_on_protocol_mismatch)
-                        abort();
-
-                return;
-        }
-
-        if (nob < basenob) {
-                CERROR("Short receive from %s: got %d, wanted at least %d\n",
-                       ptllnd_ptlid2str(initiator), nob, basenob);
-                return;
-        }
-
-        /* checksum must be computed with
-         * 1) ptlm_cksum zero and
-         * 2) BEFORE anything gets modified/flipped
-         */
-        msg_cksum = flip ? __swab32(msg->ptlm_cksum) : msg->ptlm_cksum;
-        msg->ptlm_cksum = 0;
-        if (msg_cksum != 0 &&
-            msg_cksum != ptllnd_cksum(msg, offsetof(kptl_msg_t, ptlm_u))) {
-                CERROR("Bad checksum from %s\n", ptllnd_ptlid2str(initiator));
-                return;
-        }
-
-        msg->ptlm_version = msg_version;
-        msg->ptlm_cksum = msg_cksum;
-
-        if (flip) {
-                /* NB stamps are opaque cookies */
-                __swab32s(&msg->ptlm_nob);
-                __swab64s(&msg->ptlm_srcnid);
-                __swab64s(&msg->ptlm_dstnid);
-                __swab32s(&msg->ptlm_srcpid);
-                __swab32s(&msg->ptlm_dstpid);
-        }
-
-        srcid.nid = msg->ptlm_srcnid;
-        srcid.pid = msg->ptlm_srcpid;
-
-        if (LNET_NIDNET(msg->ptlm_srcnid) != LNET_NIDNET(ni->ni_nid)) {
-                CERROR("Bad source id %s from %s\n",
-                       libcfs_id2str(srcid),
-                       ptllnd_ptlid2str(initiator));
-                return;
-        }
-
-        if (msg->ptlm_type == PTLLND_MSG_TYPE_NAK) {
-                CERROR("NAK from %s (%s)\n",
-                       libcfs_id2str(srcid),
-                       ptllnd_ptlid2str(initiator));
-
-                if (plni->plni_dump_on_nak)
-                        ptllnd_dump_debug(ni, srcid);
-
-                if (plni->plni_abort_on_nak)
-                        abort();
-
-                plp = ptllnd_find_peer(ni, srcid, 0);
-                if (plp == NULL) {
-                        CERROR("Ignore NAK from %s: no peer\n", libcfs_id2str(srcid));
-                        return;
-                }
-                ptllnd_close_peer(plp, -EPROTO);
-                ptllnd_peer_decref(plp);
-                return;
-        }
-
-        if (msg->ptlm_dstnid != ni->ni_nid ||
-            msg->ptlm_dstpid != the_lnet.ln_pid) {
-                CERROR("Bad dstid %s (%s expected) from %s\n",
-                       libcfs_id2str((lnet_process_id_t) {
-                               .nid = msg->ptlm_dstnid,
-                               .pid = msg->ptlm_dstpid}),
-                       libcfs_id2str((lnet_process_id_t) {
-                               .nid = ni->ni_nid,
-                               .pid = the_lnet.ln_pid}),
-                       libcfs_id2str(srcid));
-                return;
-        }
-
-        if (msg->ptlm_dststamp != plni->plni_stamp) {
-                CERROR("Bad dststamp "LPX64"("LPX64" expected) from %s\n",
-                       msg->ptlm_dststamp, plni->plni_stamp,
-                       libcfs_id2str(srcid));
-                return;
-        }
-
-        PTLLND_HISTORY("RX %s: %s %d %p", libcfs_id2str(srcid), 
-                       ptllnd_msgtype2str(msg->ptlm_type),
-                       msg->ptlm_credits, &rx);
-
-        switch (msg->ptlm_type) {
-        case PTLLND_MSG_TYPE_PUT:
-        case PTLLND_MSG_TYPE_GET:
-                if (nob < basenob + sizeof(kptl_rdma_msg_t)) {
-                        CERROR("Short rdma request from %s(%s)\n",
-                               libcfs_id2str(srcid),
-                               ptllnd_ptlid2str(initiator));
-                        return;
-                }
-                if (flip)
-                        __swab64s(&msg->ptlm_u.rdma.kptlrm_matchbits);
-                break;
-
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                if (nob < offsetof(kptl_msg_t,
-                                   ptlm_u.immediate.kptlim_payload)) {
-                        CERROR("Short immediate from %s(%s)\n",
-                               libcfs_id2str(srcid),
-                               ptllnd_ptlid2str(initiator));
-                        return;
-                }
-                break;
-
-        case PTLLND_MSG_TYPE_HELLO:
-                if (nob < basenob + sizeof(kptl_hello_msg_t)) {
-                        CERROR("Short hello from %s(%s)\n",
-                               libcfs_id2str(srcid),
-                               ptllnd_ptlid2str(initiator));
-                        return;
-                }
-                if(flip){
-                        __swab64s(&msg->ptlm_u.hello.kptlhm_matchbits);
-                        __swab32s(&msg->ptlm_u.hello.kptlhm_max_msg_size);
-                }
-                break;
-
-        case PTLLND_MSG_TYPE_NOOP:
-                break;
-
-        default:
-                CERROR("Bad message type %d from %s(%s)\n", msg->ptlm_type,
-                       libcfs_id2str(srcid),
-                       ptllnd_ptlid2str(initiator));
-                return;
-        }
-
-        plp = ptllnd_find_peer(ni, srcid, 0);
-        if (plp == NULL) {
-                CERROR("Can't find peer %s\n", libcfs_id2str(srcid));
-                return;
-        }
-
-        if (msg->ptlm_type == PTLLND_MSG_TYPE_HELLO) {
-                if (plp->plp_recvd_hello) {
-                        CERROR("Unexpected HELLO from %s\n",
-                               libcfs_id2str(srcid));
-                        ptllnd_peer_decref(plp);
-                        return;
-                }
-
-                plp->plp_max_msg_size = msg->ptlm_u.hello.kptlhm_max_msg_size;
-                plp->plp_match = msg->ptlm_u.hello.kptlhm_matchbits;
-                plp->plp_stamp = msg->ptlm_srcstamp;
-                plp->plp_recvd_hello = 1;
-
-        } else if (!plp->plp_recvd_hello) {
-
-                CERROR("Bad message type %d (HELLO expected) from %s\n",
-                       msg->ptlm_type, libcfs_id2str(srcid));
-                ptllnd_peer_decref(plp);
-                return;
-
-        } else if (msg->ptlm_srcstamp != plp->plp_stamp) {
-
-                CERROR("Bad srcstamp "LPX64"("LPX64" expected) from %s\n",
-                       msg->ptlm_srcstamp, plp->plp_stamp,
-                       libcfs_id2str(srcid));
-                ptllnd_peer_decref(plp);
-                return;
-        }
-
-        /* Check peer only sends when I've sent her credits */
-        if (plp->plp_sent_credits == 0) {
-                CERROR("%s[%d/%d+%d(%d)]: unexpected message\n",
-                       libcfs_id2str(plp->plp_id),
-                       plp->plp_credits, plp->plp_outstanding_credits,
-                       plp->plp_sent_credits,
-                       plni->plni_peer_credits + plp->plp_lazy_credits);
-                return;
-        }
-        plp->plp_sent_credits--;
-
-        /* No check for credit overflow - the peer may post new buffers after
-         * the startup handshake. */
-        plp->plp_credits += msg->ptlm_credits;
-
-        /* All OK so far; assume the message is good... */
-
-        rx.rx_peer      = plp;
-        rx.rx_msg       = msg;
-        rx.rx_nob       = nob;
-        plni->plni_nrxs++;
-
-        switch (msg->ptlm_type) {
-        default: /* message types have been checked already */
-                ptllnd_rx_done(&rx);
-                break;
-
-        case PTLLND_MSG_TYPE_PUT:
-        case PTLLND_MSG_TYPE_GET:
-                rc = lnet_parse(ni, &msg->ptlm_u.rdma.kptlrm_hdr,
-                                msg->ptlm_srcnid, &rx, 1);
-                if (rc < 0)
-                        ptllnd_rx_done(&rx);
-                break;
-
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                rc = lnet_parse(ni, &msg->ptlm_u.immediate.kptlim_hdr,
-                                msg->ptlm_srcnid, &rx, 0);
-                if (rc < 0)
-                        ptllnd_rx_done(&rx);
-                break;
-        }
-
-        if (msg->ptlm_credits > 0)
-                ptllnd_check_sends(plp);
-
-        ptllnd_peer_decref(plp);
-}
-
-void
-ptllnd_buf_event (lnet_ni_t *ni, ptl_event_t *event)
-{
-        ptllnd_buffer_t *buf = ptllnd_eventarg2obj(event->md.user_ptr);
-        ptllnd_ni_t     *plni = ni->ni_data;
-        char            *msg = &buf->plb_buffer[event->offset];
-        int              repost;
-        int              unlinked = event->type == PTL_EVENT_UNLINK;
-
-        LASSERT (buf->plb_ni == ni);
-        LASSERT (event->type == PTL_EVENT_PUT_END ||
-                 event->type == PTL_EVENT_UNLINK);
-
-        if (event->ni_fail_type != PTL_NI_OK) {
-
-                CERROR("event type %s(%d), status %s(%d) from %s\n",
-                       ptllnd_evtype2str(event->type), event->type,
-                       ptllnd_errtype2str(event->ni_fail_type), 
-                       event->ni_fail_type,
-                       ptllnd_ptlid2str(event->initiator));
-
-        } else if (event->type == PTL_EVENT_PUT_END) {
-#if (PTL_MD_LOCAL_ALIGN8 == 0)
-                /* Portals can't force message alignment - someone sending an
-                 * odd-length message could misalign subsequent messages */
-                if ((event->mlength & 7) != 0) {
-                        CERROR("Message from %s has odd length "LPU64
-                               " probable version incompatibility\n",
-                               ptllnd_ptlid2str(event->initiator),
-                               event->mlength);
-                        LBUG();
-                }
-#endif
-                LASSERT ((event->offset & 7) == 0);
-
-                ptllnd_parse_request(ni, event->initiator,
-                                     (kptl_msg_t *)msg, event->mlength);
-        }
-
-#ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
-        /* UNLINK event only on explicit unlink */
-        repost = (event->unlinked && event->type != PTL_EVENT_UNLINK);
-        if (event->unlinked)
-                unlinked = 1;
-#else
-        /* UNLINK event only on implicit unlink */
-        repost = (event->type == PTL_EVENT_UNLINK);
-#endif
-
-        if (unlinked) {
-                LASSERT(buf->plb_posted);
-                buf->plb_posted = 0;
-                plni->plni_nposted_buffers--;
-        }
-
-        if (repost)
-                (void) ptllnd_post_buffer(buf);
-}
-
-void
-ptllnd_tx_event (lnet_ni_t *ni, ptl_event_t *event)
-{
-        ptllnd_ni_t *plni = ni->ni_data;
-        ptllnd_tx_t *tx = ptllnd_eventarg2obj(event->md.user_ptr);
-        int          error = (event->ni_fail_type != PTL_NI_OK);
-        int          isreq;
-        int          isbulk;
-#ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
-        int          unlinked = event->unlinked;
-#else
-        int          unlinked = (event->type == PTL_EVENT_UNLINK);
-#endif
-
-        if (error)
-                CERROR("Error %s(%d) event %s(%d) unlinked %d, %s(%d) for %s\n",
-                       ptllnd_errtype2str(event->ni_fail_type),
-                       event->ni_fail_type,
-                       ptllnd_evtype2str(event->type), event->type,
-                       unlinked, ptllnd_msgtype2str(tx->tx_type), tx->tx_type,
-                       libcfs_id2str(tx->tx_peer->plp_id));
-
-        LASSERT (!PtlHandleIsEqual(event->md_handle, PTL_INVALID_HANDLE));
-
-        isreq = PtlHandleIsEqual(event->md_handle, tx->tx_reqmdh);
-        if (isreq) {
-                LASSERT (event->md.start == (void *)&tx->tx_msg);
-                if (unlinked) {
-                        tx->tx_reqmdh = PTL_INVALID_HANDLE;
-                        gettimeofday(&tx->tx_req_done, NULL);
-                }
-        }
-
-        isbulk = PtlHandleIsEqual(event->md_handle, tx->tx_bulkmdh);
-        if ( isbulk && unlinked ) {
-                tx->tx_bulkmdh = PTL_INVALID_HANDLE;
-                gettimeofday(&tx->tx_bulk_done, NULL);
-        }
-
-        LASSERT (!isreq != !isbulk);            /* always one and only 1 match */
-
-        PTLLND_HISTORY("%s[%d/%d+%d(%d)]: TX done %p %s%s",
-                       libcfs_id2str(tx->tx_peer->plp_id),
-                       tx->tx_peer->plp_credits,
-                       tx->tx_peer->plp_outstanding_credits,
-                       tx->tx_peer->plp_sent_credits,
-                       plni->plni_peer_credits + tx->tx_peer->plp_lazy_credits,
-                       tx, isreq ? "REQ" : "BULK", unlinked ? "(unlinked)" : "");
-
-        LASSERT (!isreq != !isbulk);            /* always one and only 1 match */
-        switch (tx->tx_type) {
-        default:
-                LBUG();
-
-        case PTLLND_MSG_TYPE_NOOP:
-        case PTLLND_MSG_TYPE_HELLO:
-        case PTLLND_MSG_TYPE_IMMEDIATE:
-                LASSERT (event->type == PTL_EVENT_UNLINK ||
-                         event->type == PTL_EVENT_SEND_END);
-                LASSERT (isreq);
-                break;
-
-        case PTLLND_MSG_TYPE_GET:
-                LASSERT (event->type == PTL_EVENT_UNLINK ||
-                         (isreq && event->type == PTL_EVENT_SEND_END) ||
-                         (isbulk && event->type == PTL_EVENT_PUT_END));
-
-                if (isbulk && !error && event->type == PTL_EVENT_PUT_END) {
-                        /* Check GET matched */
-                        if (event->hdr_data == PTLLND_RDMA_OK) {
-                                lnet_set_reply_msg_len(ni, 
-                                                       tx->tx_lnetreplymsg,
-                                                       event->mlength);
-                        } else {
-                                CERROR ("Unmatched GET with %s\n",
-                                        libcfs_id2str(tx->tx_peer->plp_id));
-                                tx->tx_status = -EIO;
-                        }
-                }
-                break;
-
-        case PTLLND_MSG_TYPE_PUT:
-                LASSERT (event->type == PTL_EVENT_UNLINK ||
-                         (isreq && event->type == PTL_EVENT_SEND_END) ||
-                         (isbulk && event->type == PTL_EVENT_GET_END));
-                break;
-
-        case PTLLND_RDMA_READ:
-                LASSERT (event->type == PTL_EVENT_UNLINK ||
-                         event->type == PTL_EVENT_SEND_END ||
-                         event->type == PTL_EVENT_REPLY_END);
-                LASSERT (isbulk);
-                break;
-
-        case PTLLND_RDMA_WRITE:
-                LASSERT (event->type == PTL_EVENT_UNLINK ||
-                         event->type == PTL_EVENT_SEND_END);
-                LASSERT (isbulk);
-        }
-
-        /* Schedule ptllnd_tx_done() on error or last completion event */
-        if (error ||
-            (PtlHandleIsEqual(tx->tx_bulkmdh, PTL_INVALID_HANDLE) &&
-             PtlHandleIsEqual(tx->tx_reqmdh, PTL_INVALID_HANDLE))) {
-                if (error)
-                        tx->tx_status = -EIO;
-                cfs_list_del(&tx->tx_list);
-                cfs_list_add_tail(&tx->tx_list, &plni->plni_zombie_txs);
-        }
-}
-
-ptllnd_tx_t *
-ptllnd_find_timed_out_tx(ptllnd_peer_t *peer)
-{
-        time_t            now = cfs_time_current_sec();
-        ptllnd_tx_t *tx;
-
-        cfs_list_for_each_entry (tx, &peer->plp_txq, tx_list) {
-                if (tx->tx_deadline < now)
-                        return tx;
-        }
-
-        cfs_list_for_each_entry (tx, &peer->plp_noopq, tx_list) {
-                if (tx->tx_deadline < now)
-                        return tx;
-        }
-
-        cfs_list_for_each_entry (tx, &peer->plp_activeq, tx_list) {
-                if (tx->tx_deadline < now)
-                        return tx;
-        }
-
-        return NULL;
-}
-
-void
-ptllnd_check_peer(ptllnd_peer_t *peer)
-{
-        ptllnd_tx_t *tx = ptllnd_find_timed_out_tx(peer);
-
-        if (tx == NULL)
-                return;
-
-        CERROR("%s (sent %d recvd %d, credits %d/%d/%d/%d/%d): timed out %p %p\n",
-               libcfs_id2str(peer->plp_id), peer->plp_sent_hello, peer->plp_recvd_hello,
-               peer->plp_credits, peer->plp_outstanding_credits,
-               peer->plp_sent_credits, peer->plp_lazy_credits,
-               peer->plp_extra_lazy_credits, tx, tx->tx_lnetmsg);
-        ptllnd_debug_tx(tx);
-        ptllnd_close_peer(peer, -ETIMEDOUT);
-}
-
-void
-ptllnd_watchdog (lnet_ni_t *ni, time_t now)
-{
-        ptllnd_ni_t      *plni = ni->ni_data;
-        const int         n = 4;
-        int               p = plni->plni_watchdog_interval;
-        int               chunk = plni->plni_peer_hash_size;
-        int               interval = now - (plni->plni_watchdog_nextt - p);
-        int               i;
-        cfs_list_t       *hashlist;
-        cfs_list_t       *tmp;
-        cfs_list_t       *nxt;
-
-        /* Time to check for RDMA timeouts on a few more peers:
-         * I try to do checks every 'p' seconds on a proportion of the peer
-         * table and I need to check every connection 'n' times within a
-         * timeout interval, to ensure I detect a timeout on any connection
-         * within (n+1)/n times the timeout interval. */
-
-        LASSERT (now >= plni->plni_watchdog_nextt);
-
-        if (plni->plni_timeout > n * interval) { /* Scan less than the whole table? */
-                chunk = (chunk * n * interval) / plni->plni_timeout;
-                if (chunk == 0)
-                        chunk = 1;
-        }
-
-        for (i = 0; i < chunk; i++) {
-                hashlist = &plni->plni_peer_hash[plni->plni_watchdog_peeridx];
-
-                cfs_list_for_each_safe(tmp, nxt, hashlist) {
-                        ptllnd_check_peer(cfs_list_entry(tmp, ptllnd_peer_t,
-                                          plp_list));
-                }
-
-                plni->plni_watchdog_peeridx = (plni->plni_watchdog_peeridx + 1) %
-                                              plni->plni_peer_hash_size;
-        }
-
-        plni->plni_watchdog_nextt = now + p;
-}
-
-void
-ptllnd_wait (lnet_ni_t *ni, int milliseconds)
-{
-        static struct timeval  prevt;
-        static int             prevt_count;
-        static int             call_count;
-
-        struct timeval         start;
-        struct timeval         then;
-        struct timeval         now;
-        struct timeval         deadline;
-
-        ptllnd_ni_t   *plni = ni->ni_data;
-        ptllnd_tx_t   *tx;
-        ptl_event_t    event;
-        int            which;
-        int            rc;
-        int            found = 0;
-        int            timeout = 0;
-
-        /* Handle any currently queued events, returning immediately if any.
-         * Otherwise block for the timeout and handle all events queued
-         * then. */
-
-        gettimeofday(&start, NULL);
-        call_count++;
-
-        if (milliseconds <= 0) {
-                deadline = start;
-        } else {
-                deadline.tv_sec  = start.tv_sec  +  milliseconds/1000;
-                deadline.tv_usec = start.tv_usec + (milliseconds % 1000)*1000;
-
-                if (deadline.tv_usec >= 1000000) {
-                        start.tv_usec -= 1000000;
-                        start.tv_sec++;
-                }
-        }
-
-        for (;;) {
-                gettimeofday(&then, NULL);
-
-                rc = PtlEQPoll(&plni->plni_eqh, 1, timeout, &event, &which);
-
-                gettimeofday(&now, NULL);
-
-                if ((now.tv_sec*1000 + now.tv_usec/1000) - 
-                    (then.tv_sec*1000 + then.tv_usec/1000) > timeout + 1000) {
-                        /* 1000 mS grace...........................^ */
-                        CERROR("SLOW PtlEQPoll(%d): %dmS elapsed\n", timeout,
-                               (int)(now.tv_sec*1000 + now.tv_usec/1000) - 
-                               (int)(then.tv_sec*1000 + then.tv_usec/1000));
-                }
-
-                if (rc == PTL_EQ_EMPTY) {
-                        if (found)              /* handled some events */
-                                break;
-
-                        if (now.tv_sec >= plni->plni_watchdog_nextt) { /* check timeouts? */
-                                ptllnd_watchdog(ni, now.tv_sec);
-                                LASSERT (now.tv_sec < plni->plni_watchdog_nextt);
-                        }
-
-                        if (now.tv_sec > deadline.tv_sec || /* timeout expired */
-                            (now.tv_sec == deadline.tv_sec &&
-                             now.tv_usec >= deadline.tv_usec))
-                                break;
-
-                        if (milliseconds < 0 ||
-                            plni->plni_watchdog_nextt <= deadline.tv_sec)  {
-                                timeout = (plni->plni_watchdog_nextt - now.tv_sec)*1000;
-                        } else {
-                                timeout = (deadline.tv_sec - now.tv_sec)*1000 +
-                                          (deadline.tv_usec - now.tv_usec)/1000;
-                        }
-
-                        continue;
-                }
-
-                LASSERT (rc == PTL_OK || rc == PTL_EQ_DROPPED);
-
-                if (rc == PTL_EQ_DROPPED)
-                        CERROR("Event queue: size %d is too small\n",
-                               plni->plni_eq_size);
-
-                timeout = 0;
-                found = 1;
-
-                switch (ptllnd_eventarg2type(event.md.user_ptr)) {
-                default:
-                        LBUG();
-
-                case PTLLND_EVENTARG_TYPE_TX:
-                        ptllnd_tx_event(ni, &event);
-                        break;
-
-                case PTLLND_EVENTARG_TYPE_BUF:
-                        ptllnd_buf_event(ni, &event);
-                        break;
-                }
-        }
-
-        while (!cfs_list_empty(&plni->plni_zombie_txs)) {
-                tx = cfs_list_entry(plni->plni_zombie_txs.next,
-                                ptllnd_tx_t, tx_list);
-                cfs_list_del_init(&tx->tx_list);
-                ptllnd_tx_done(tx);
-        }
-
-        if (prevt.tv_sec == 0 ||
-            prevt.tv_sec != now.tv_sec) {
-                PTLLND_HISTORY("%d wait entered at %d.%06d - prev %d %d.%06d", 
-                               call_count, (int)start.tv_sec, (int)start.tv_usec,
-                               prevt_count, (int)prevt.tv_sec, (int)prevt.tv_usec);
-                prevt = now;
-        }
-}
index 5bccdf8..ce257d2 100644 (file)
@@ -86,9 +86,6 @@ LND_LIBS =
 if BUILD_USOCKLND
 LND_LIBS +=    $(top_builddir)/lnet/ulnds/socklnd/libsocklnd.a
 endif
-if BUILD_UPTLLND
-LND_LIBS +=   $(top_builddir)/lnet/ulnds/ptllnd/libptllnd.a
-endif
 
 if LIBLUSTRE
 LIB_SELFTEST = $(top_builddir)/libcfs/libcfs/libcfs.a $(top_builddir)/lnet/lnet/liblnet.a $(top_builddir)/lnet/selftest/libselftest.a
index 4cb1bfc..031640d 100755 (executable)
@@ -30,9 +30,6 @@ build_obj_list ../../libcfs/libcfs libcfsutil.a
 if $(echo "$LND_LIBS" | grep "socklnd" >/dev/null) ; then
        build_obj_list ../../lnet/ulnds/socklnd libsocklnd.a
 fi
-if $(echo "$LND_LIBS" | grep "ptllnd" >/dev/null) ; then
-       build_obj_list ../../lnet/ulnds/ptllnd libptllnd.a
-fi
 build_obj_list ../../lnet/lnet liblnet.a
 build_obj_list ../../lnet/selftest libselftest.a
 
index 85ea98d..77f1a98 100644 (file)
@@ -832,9 +832,6 @@ struct ptlrpc_request {
         struct ptlrpc_reply_state *rq_reply_state;
         /** incoming request buffer */
         struct ptlrpc_request_buffer_desc *rq_rqbd;
-#ifdef CRAY_XT3
-        __u32                rq_uid;            /* peer uid, used in MDS only */
-#endif
 
         /** client-only incoming reply */
         lnet_handle_md_t     rq_reply_md_h;
index 9b6d69b..34fe48d 100644 (file)
@@ -26,9 +26,6 @@ LND_LIBS =
 if BUILD_USOCKLND
 LND_LIBS +=    $(top_builddir)/lnet/ulnds/socklnd/libsocklnd.a
 endif
-if BUILD_UPTLLND
-LND_LIBS +=   $(top_builddir)/lnet/ulnds/ptllnd/libptllnd.a
-endif
 
 LNET_LIBS =   $(top_builddir)/lnet/utils/libuptlctl.a \
               $(top_builddir)/lnet/lnet/liblnet.a \
index 5059892..d056825 100755 (executable)
@@ -84,9 +84,6 @@ build_obj_list ../../libcfs/libcfs libcfsutil.a
 if $(echo "$LND_LIBS" | grep "socklnd" >/dev/null) ; then
        build_obj_list ../../lnet/ulnds/socklnd libsocklnd.a
 fi
-if $(echo "$LND_LIBS" | grep "ptllnd" >/dev/null) ; then
-       build_obj_list ../../lnet/ulnds/ptllnd libptllnd.a
-fi
 build_obj_list ../../lnet/lnet liblnet.a
 
 # create static lib lsupport
index 07726dd..5381c57 100644 (file)
@@ -16,9 +16,7 @@ endif # MPITESTS
 
 noinst_PROGRAMS = sanity
 
-if !CRAY_XT3
 noinst_PROGRAMS += recovery_small replay_single replay_ost_single
-endif # !CRAY_XT3
 
 liblustre_testdir=$(libdir)/lustre/liblustre/tests
 liblustre_test_PROGRAMS = $(noinst_PROGRAMS)
index a35e3c5..6de9c20 100644 (file)
@@ -332,9 +332,6 @@ void request_in_callback(lnet_event_t *ev)
         req->rq_self = ev->target.nid;
         req->rq_rqbd = rqbd;
         req->rq_phase = RQ_PHASE_NEW;
-#ifdef CRAY_XT3
-        req->rq_uid = ev->uid;
-#endif
         cfs_spin_lock_init(&req->rq_lock);
         CFS_INIT_LIST_HEAD(&req->rq_timed_list);
         cfs_atomic_set(&req->rq_refcount, 1);
index 4ef4afe..9d2aa7c 100644 (file)
@@ -1432,17 +1432,10 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
                  * if the client doesn't know the server is gone yet. */
                 req->rq_no_resend = 1;
 
-#ifndef CRAY_XT3
                 /* We want client umounts to happen quickly, no matter the
                    server state... */
                 req->rq_timeout = min_t(int, req->rq_timeout,
                                         INITIAL_CONNECT_TIMEOUT);
-#else
-                /* ... but we always want liblustre clients to nicely
-                   disconnect, so only use the adaptive value. */
-                if (AT_OFF)
-                        req->rq_timeout = obd_timeout / 3;
-#endif
 
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
                 req->rq_send_state =  LUSTRE_IMP_CONNECTING;