Whamcloud - gitweb
b_release braches are tagged for build/ too
[fs/lustre-release.git] / lnet / lnet / lib-ni.c
index aa959fc..e45859a 100644 (file)
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * lib/lib-ni.c
- * Network status registers and distance functions.
- *
- *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
- *  Copyright (c) 2001-2002 Sandia National Laboratories
- *
- *   This file is part of Lustre, http://www.sf.net/projects/lustre/
- *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   Lustre 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 for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *   This file is part of Lustre, http://www.lustre.org
+ *   This file is not subject to copyright protection.
  */
 
 #define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/lib-p30.h>
-#include <portals/arg-blocks.h>
-
-#define MAX_DIST 18446744073709551615ULL
 
-int do_PtlNIStatus(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
+int lib_api_ni_status (nal_t *apinal, ptl_sr_index_t sr_idx,
+                       ptl_sr_value_t *status)
 {
-        /*
-         * Incoming:
-         *      ptl_handle_ni_t interface_in
-         *      ptl_sr_index_t register_in
-         *
-         * Outgoing:
-         *      ptl_sr_value_t          * status_out
-         */
-
-        PtlNIStatus_in *args = v_args;
-        PtlNIStatus_out *ret = v_ret;
-        lib_ni_t *ni = &nal->ni;
-        lib_counters_t *count = &ni->counters;
-
-        if (!args)
-                return ret->rc = PTL_SEGV;
-
-        ret->rc = PTL_OK;
-        ret->status_out = 0;
-
-        /*
-         * I hate this sort of code....  Hash tables, offset lists?
-         * Treat the counters as an array of ints?
-         */
-        if (args->register_in == PTL_SR_DROP_COUNT)
-                ret->status_out = count->drop_count;
-
-        else if (args->register_in == PTL_SR_DROP_LENGTH)
-                ret->status_out = count->drop_length;
-
-        else if (args->register_in == PTL_SR_RECV_COUNT)
-                ret->status_out = count->recv_count;
-
-        else if (args->register_in == PTL_SR_RECV_LENGTH)
-                ret->status_out = count->recv_length;
-
-        else if (args->register_in == PTL_SR_SEND_COUNT)
-                ret->status_out = count->send_count;
-
-        else if (args->register_in == PTL_SR_SEND_LENGTH)
-                ret->status_out = count->send_length;
-
-        else if (args->register_in == PTL_SR_MSGS_MAX)
-                ret->status_out = count->msgs_max;
-        else
-                ret->rc = PTL_SR_INDEX_INVALID;
-
-        return ret->rc;
+        return PTL_FAIL;
 }
 
 
-int do_PtlNIDist(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
+int lib_api_ni_dist (nal_t *apinal, ptl_process_id_t *pid, unsigned long *dist)
 {
-        /*
-         * Incoming:
-         *      ptl_handle_ni_t interface_in
-         *      ptl_process_id_t process_in
-
-         *
-         * Outgoing:
-         *      unsigned long   * distance_out
+        lib_nal_t *nal = apinal->nal_data;
 
-         */
-
-        PtlNIDist_in *args = v_args;
-        PtlNIDist_out *ret = v_ret;
-
-        unsigned long dist;
-        ptl_process_id_t id_in = args->process_in;
-        ptl_nid_t nid;
-        int rc;
-
-        nid = id_in.nid;
-
-        if ((rc = nal->cb_dist(nal, nid, &dist)) != 0) {
-                ret->distance_out = (unsigned long) MAX_DIST;
-                return PTL_PROCESS_INVALID;
+        if (nal->libnal_ni.ni_loopback &&
+            pid->nid == nal->libnal_ni.ni_pid.nid) {
+                *dist = 0;
+                return PTL_OK;
         }
-
-        ret->distance_out = dist;
-
-        return ret->rc = PTL_OK;
+        
+        return (nal->libnal_dist(nal, pid->nid, dist));
 }