Hi Ira,

On 16:38 Thu 20 Nov     , Ira Weiny wrote:
> From e2b8bac5d651c2278719d511dee2ab2e8ad05706 Mon Sep 17 00:00:00 2001
> From: Ira Weiny <[EMAIL PROTECTED]>
> Date: Thu, 20 Nov 2008 09:29:57 -0800
> Subject: [PATCH] Convert ibnetdiscover to use new ibnetdisc library.
> 
>    Removed -e and -v since they were somewhat redundant with the -d option.

I think it would be better to preserve an options for backward
compatibility. At least '-v' is used in dump_ftts.sh. It can be used in
other scripts...

Sasha

> 
>    All other functionality is preserved
> 
> Signed-off-by: Ira Weiny <[EMAIL PROTECTED]>
> ---
>  infiniband-diags/Makefile.am         |    4 +-
>  infiniband-diags/man/ibnetdiscover.8 |   10 +-
>  infiniband-diags/src/ibnetdiscover.c |  910 
> ++++++++++------------------------
>  3 files changed, 254 insertions(+), 670 deletions(-)
> 
> diff --git a/infiniband-diags/Makefile.am b/infiniband-diags/Makefile.am
> index 8f26749..420c69e 100644
> --- a/infiniband-diags/Makefile.am
> +++ b/infiniband-diags/Makefile.am
> @@ -35,9 +35,9 @@ sbin_SCRIPTS = scripts/ibcheckerrs scripts/ibchecknet 
> scripts/ibchecknode \
>  src_ibaddr_SOURCES = src/ibaddr.c src/ibdiag_common.c
>  src_ibaddr_CFLAGS = -Wall $(DBGFLAGS)
>  
> -src_ibnetdiscover_SOURCES = src/ibnetdiscover.c src/grouping.c 
> src/ibdiag_common.c
> +src_ibnetdiscover_SOURCES = src/ibnetdiscover.c src/ibdiag_common.c
>  src_ibnetdiscover_CFLAGS = -Wall $(DBGFLAGS)
> -src_ibnetdiscover_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
> +src_ibnetdiscover_LDFLAGS = -Wl,--rpath -Wl,$(libdir) -libnetdisc
>  
>  src_iblinkinfo_pl_SOURCES = src/iblinkinfo.c
>  src_iblinkinfo_pl_CFLAGS = -Wall $(DBGFLAGS)
> diff --git a/infiniband-diags/man/ibnetdiscover.8 
> b/infiniband-diags/man/ibnetdiscover.8
> index 958efa9..768d392 100644
> --- a/infiniband-diags/man/ibnetdiscover.8
> +++ b/infiniband-diags/man/ibnetdiscover.8
> @@ -5,7 +5,7 @@ ibnetdiscover \- discover InfiniBand topology
>  
>  .SH SYNOPSIS
>  .B ibnetdiscover
> -[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-s(how)] [\-l(ist)] 
> [\-g(rouping)] [\-H(ca_list)] [\-S(witch_list)] [\-R(outer_list)] [\-C 
> ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] 
> [\--node-name-map <node-name-map>] [\-p(orts)] [\-h(elp)] [<topology-file>]
> +[\-d(ebug)] [\-s(how)] [\-l(ist)] [\-g(rouping)] [\-H(ca_list)] 
> [\-S(witch_list)] [\-R(outer_list)] [\-C ca_name] [\-P ca_port] [\-t(imeout) 
> timeout_ms] [\-V(ersion)] [\--node-name-map <node-name-map>] [\-p(orts)] 
> [\-h(elp)] [<topology-file>]
>  
>  .SH DESCRIPTION
>  .PP
> @@ -37,7 +37,7 @@ List of connected switches
>  List of connected routers
>  .TP
>  \fB\-s\fR, \fB\-\-show\fR
> -Show more information
> +Show progress information during discovery.
>  .TP
>  \fB\-\-node\-name\-map\fR <node-name-map>
>  Specify a node name map.  The node name map file maps GUIDs to more user 
> friendly
> @@ -57,15 +57,9 @@ using the util_name -h syntax.
>  # Debugging flags
>  .PP
>  \-d      raise the IB debugging level.
> -        May be used several times (-ddd or -d -d -d).
> -.PP
> -\-e      show send and receive errors (timeouts and others)
>  .PP
>  \-h      show the usage message
>  .PP
> -\-v      increase the application verbosity level.
> -        May be used several times (-vv or -v -v -v)
> -.PP
>  \-V      show the version info.
>  
>  # Other common flags:
> diff --git a/infiniband-diags/src/ibnetdiscover.c 
> b/infiniband-diags/src/ibnetdiscover.c
> index 2cfaa8a..d8ead48 100644
> --- a/infiniband-diags/src/ibnetdiscover.c
> +++ b/infiniband-diags/src/ibnetdiscover.c
> @@ -1,6 +1,7 @@
>  /*
>   * Copyright (c) 2004-2008 Voltaire Inc.  All rights reserved.
>   * Copyright (c) 2007 Xsigo Systems Inc.  All rights reserved.
> + * Copyright (c) 2008 Lawrence Livermore National Lab.  All rights reserved.
>   *
>   * This software is available to you under a choice of one of two
>   * licenses.  You may choose to be licensed under the terms of the GNU
> @@ -47,483 +48,108 @@
>  #include <errno.h>
>  #include <inttypes.h>
>  
> -#include <infiniband/common.h>
> -#include <infiniband/umad.h>
> -#include <infiniband/mad.h>
>  #include <infiniband/complib/cl_nodenamemap.h>
> +#include <infiniband/ibnetdisc.h>
> +#include <infiniband/common.h>
>  
> -#include "ibnetdiscover.h"
> -#include "grouping.h"
>  #include "ibdiag_common.h"
>  
> -static char *node_type_str[] = {
> -     "???",
> -     "ca",
> -     "switch",
> -     "router",
> -     "iwarp rnic"
> -};
> -
> -static char *linkwidth_str[] = {
> -     "??",
> -     "1x",
> -     "4x",
> -     "??",
> -     "8x",
> -     "??",
> -     "??",
> -     "??",
> -     "12x"
> -};
> -
> -static char *linkspeed_str[] = {
> -     "???",
> -     "SDR",
> -     "DDR",
> -     "???",
> -     "QDR"
> -};
> -
> -static int timeout = 2000;           /* ms */
> -static int dumplevel = 0;
> +static int debug;
>  static int verbose;
> -static FILE *f;
> +#define LIST_CA_NODE  (1 << IBND_CA_NODE)
> +#define LIST_SWITCH_NODE (1 << IBND_SWITCH_NODE)
> +#define LIST_ROUTER_NODE (1 << IBND_ROUTER_NODE)
>  
>  char *argv0 = "ibnetdiscover";
> +static FILE *f;
>  
>  static char *node_name_map_file = NULL;
>  static nn_map_t *node_name_map = NULL;
>  
> -Node *nodesdist[MAXHOPS+1];     /* last is Ca list */
> -Node *mynode;
> -int maxhops_discovered = 0;
> -
> -struct ChassisList *chassis = NULL;
> -
> -static char *
> -get_linkwidth_str(int linkwidth)
> -{
> -     if (linkwidth > 8)
> -             return linkwidth_str[0];
> -     else
> -             return linkwidth_str[linkwidth];
> -}
> -
> -static char *
> -get_linkspeed_str(int linkspeed)
> -{
> -     if (linkspeed > 4)
> -             return linkspeed_str[0];
> -     else
> -             return linkspeed_str[linkspeed];
> -}
> -
> -static inline const char*
> -node_type_str2(Node *node)
> -{
> -     switch(node->type) {
> -     case SWITCH_NODE: return "SW";
> -     case CA_NODE:     return "CA";
> -     case ROUTER_NODE: return "RT";
> -     }
> -     return "??";
> -}
> -
> -void
> -decode_port_info(void *pi, Port *port)
> -{
> -     mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
> -     mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
> -     mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
> -     mad_decode_field(pi, IB_PORT_PHYS_STATE_F, &port->physstate);
> -     mad_decode_field(pi, IB_PORT_LINK_WIDTH_ACTIVE_F, &port->linkwidth);
> -     mad_decode_field(pi, IB_PORT_LINK_SPEED_ACTIVE_F, &port->linkspeed);
> -}
> -
> -
> -int
> -get_port(Port *port, int portnum, ib_portid_t *portid)
> -{
> -     char portinfo[64];
> -     void *pi = portinfo;
> -
> -     port->portnum = portnum;
> -
> -     if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout))
> -             return -1;
> -     decode_port_info(pi, port);
> -
> -     DEBUG("portid %s portnum %d: lid %d state %d physstate %d %s %s",
> -             portid2str(portid), portnum, port->lid, port->state, 
> port->physstate, get_linkwidth_str(port->linkwidth), 
> get_linkspeed_str(port->linkspeed));
> -     return 1;
> -}
> -/*
> - * Returns 0 if non switch node is found, 1 if switch is found, -1 if error.
> - */
> -int
> -get_node(Node *node, Port *port, ib_portid_t *portid)
> -{
> -     char portinfo[64];
> -     char switchinfo[64];
> -     void *pi = portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
> -     void *si = switchinfo;
> -
> -     if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, timeout))
> -             return -1;
> -
> -     mad_decode_field(ni, IB_NODE_GUID_F, &node->nodeguid);
> -     mad_decode_field(ni, IB_NODE_TYPE_F, &node->type);
> -     mad_decode_field(ni, IB_NODE_NPORTS_F, &node->numports);
> -     mad_decode_field(ni, IB_NODE_DEVID_F, &node->devid);
> -     mad_decode_field(ni, IB_NODE_VENDORID_F, &node->vendid);
> -     mad_decode_field(ni, IB_NODE_SYSTEM_GUID_F, &node->sysimgguid);
> -     mad_decode_field(ni, IB_NODE_PORT_GUID_F, &node->portguid);
> -     mad_decode_field(ni, IB_NODE_LOCAL_PORT_F, &node->localport);
> -     port->portnum = node->localport;
> -     port->portguid = node->portguid;
> -
> -     if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, timeout))
> -             return -1;
> -
> -     if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, 0, timeout))
> -             return -1;
> -     decode_port_info(pi, port);
> -
> -     if (node->type != SWITCH_NODE)
> -             return 0;
> -
> -     node->smalid = port->lid;
> -     node->smalmc = port->lmc;
> -
> -     /* after we have the sma information find out the real PortInfo for 
> this port */
> -     if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, node->localport, timeout))
> -             return -1;
> -     decode_port_info(pi, port);
> -
> -        if (!smp_query(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout))
> -                node->smaenhsp0 = 0; /* assume base SP0 */
> -     else
> -             mad_decode_field(si, IB_SW_ENHANCED_PORT0_F, &node->smaenhsp0);
> -
> -     DEBUG("portid %s: got switch node %" PRIx64 " '%s'",
> -           portid2str(portid), node->nodeguid, node->nodedesc);
> -     return 1;
> -}
> -
> -static int
> -extend_dpath(ib_dr_path_t *path, int nextport)
> -{
> -     if (path->cnt+2 >= sizeof(path->p))
> -             return -1;
> -     ++path->cnt;
> -     if (path->cnt > maxhops_discovered)
> -             maxhops_discovered = path->cnt;
> -     path->p[path->cnt] = nextport;
> -     return path->cnt;
> -}
> -
> -static void
> -dump_endnode(ib_portid_t *path, char *prompt, Node *node, Port *port)
> -{
> -     if (!dumplevel)
> -             return;
> -
> -     fprintf(f, "%s -> %s %s {%016" PRIx64 "} portnum %d lid %d-%d\"%s\"\n",
> -             portid2str(path), prompt,
> -             (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
> -             node->nodeguid, node->type == SWITCH_NODE ? 0 : port->portnum,
> -             port->lid, port->lid + (1 << port->lmc) - 1,
> -             clean_nodedesc(node->nodedesc));
> -}
> -
> -#define HASHGUID(guid)               ((uint32_t)(((uint32_t)(guid) * 101) ^ 
> ((uint32_t)((guid) >> 32) * 103)))
> -#define HTSZ 137
> -
> -static Node *nodestbl[HTSZ];
> -
> -static Node *
> -find_node(Node *new)
> -{
> -     int hash = HASHGUID(new->nodeguid) % HTSZ;
> -     Node *node;
> -
> -     for (node = nodestbl[hash]; node; node = node->htnext)
> -             if (node->nodeguid == new->nodeguid)
> -                     return node;
> -
> -     return NULL;
> -}
> -
> -static Node *
> -create_node(Node *temp, ib_portid_t *path, int dist)
> -{
> -     Node *node;
> -     int hash = HASHGUID(temp->nodeguid) % HTSZ;
> -
> -     node = malloc(sizeof(*node));
> -     if (!node)
> -             return NULL;
> -
> -     memcpy(node, temp, sizeof(*node));
> -     node->dist = dist;
> -     node->path = *path;
> -
> -     node->htnext = nodestbl[hash];
> -     nodestbl[hash] = node;
> -
> -     if (node->type != SWITCH_NODE)
> -             dist = MAXHOPS;         /* special Ca list */
> -
> -     node->dnext = nodesdist[dist];
> -     nodesdist[dist] = node;
> -
> -     return node;
> -}
> -
> -static Port *
> -find_port(Node *node, Port *port)
> -{
> -     Port *old;
> -
> -     for (old = node->ports; old; old = old->next)
> -             if (old->portnum == port->portnum)
> -                     return old;
> -
> -     return NULL;
> -}
> -
> -static Port *
> -create_port(Node *node, Port *temp)
> -{
> -     Port *port;
> -
> -     port = malloc(sizeof(*port));
> -     if (!port)
> -             return NULL;
> -
> -     memcpy(port, temp, sizeof(*port));
> -     port->node = node;
> -     port->next = node->ports;
> -     node->ports = port;
> -
> -     return port;
> -}
> -
> -static void
> -link_ports(Node *node, Port *port, Node *remotenode, Port *remoteport)
> -{
> -     DEBUG("linking: 0x%" PRIx64 " %p->%p:%u and 0x%" PRIx64 " %p->%p:%u",
> -             node->nodeguid, node, port, port->portnum,
> -             remotenode->nodeguid, remotenode, remoteport, 
> remoteport->portnum);
> -     if (port->remoteport)
> -             port->remoteport->remoteport = NULL;
> -     if (remoteport->remoteport)
> -             remoteport->remoteport->remoteport = NULL;
> -     port->remoteport = remoteport;
> -     remoteport->remoteport = port;
> -}
> -
> -static int
> -handle_port(Node *node, Port *port, ib_portid_t *path, int portnum, int dist)
> -{
> -     Node node_buf;
> -     Port port_buf;
> -     Node *remotenode, *oldnode;
> -     Port *remoteport, *oldport;
> -
> -     memset(&node_buf, 0, sizeof(node_buf));
> -     memset(&port_buf, 0, sizeof(port_buf));
> -
> -     DEBUG("handle node %p port %p:%d dist %d", node, port, portnum, dist);
> -     if (port->physstate != 5)       /* LinkUp */
> -             return -1;
> -
> -     if (extend_dpath(&path->drpath, portnum) < 0)
> -             return -1;
> -
> -     if (get_node(&node_buf, &port_buf, path) < 0) {
> -             IBWARN("NodeInfo on %s failed, skipping port",
> -                     portid2str(path));
> -             path->drpath.cnt--;     /* restore path */
> -             return -1;
> -     }
> -
> -     oldnode = find_node(&node_buf);
> -     if (oldnode)
> -             remotenode = oldnode;
> -     else if (!(remotenode = create_node(&node_buf, path, dist + 1)))
> -             IBERROR("no memory");
> -
> -     oldport = find_port(remotenode, &port_buf);
> -     if (oldport) {
> -             remoteport = oldport;
> -             if (node != remotenode || port != remoteport)
> -                     IBWARN("port moving...");
> -     } else if (!(remoteport = create_port(remotenode, &port_buf)))
> -             IBERROR("no memory");
> -
> -     dump_endnode(path, oldnode ? "known remote" : "new remote",
> -                  remotenode, remoteport);
> -
> -     link_ports(node, port, remotenode, remoteport);
> -
> -     path->drpath.cnt--;     /* restore path */
> -     return 0;
> -}
> -
> -/*
> - * Return 1 if found, 0 if not, -1 on errors.
> - */
> -static int
> -discover(ib_portid_t *from)
> -{
> -     Node node_buf;
> -     Port port_buf;
> -     Node *node;
> -     Port *port;
> -     int i;
> -     int dist = 0;
> -     ib_portid_t *path;
> -
> -     DEBUG("from %s", portid2str(from));
> -
> -     memset(&node_buf, 0, sizeof(node_buf));
> -     memset(&port_buf, 0, sizeof(port_buf));
> -
> -     if (get_node(&node_buf, &port_buf, from) < 0) {
> -             IBWARN("can't reach node %s", portid2str(from));
> -             return -1;
> -     }
> -
> -     node = create_node(&node_buf, from, 0);
> -     if (!node)
> -             IBERROR("out of memory");
> -
> -     mynode = node;
> -
> -     port = create_port(node, &port_buf);
> -     if (!port)
> -             IBERROR("out of memory");
> -
> -     if (node->type != SWITCH_NODE &&
> -         handle_port(node, port, from, node->localport, 0) < 0)
> -             return 0;
> -
> -     for (dist = 0; dist < MAXHOPS; dist++) {
> -
> -             for (node = nodesdist[dist]; node; node = node->dnext) {
> -
> -                     path = &node->path;
> -
> -                     DEBUG("dist %d node %p", dist, node);
> -                     dump_endnode(path, "processing", node, port);
> -
> -                     for (i = 1; i <= node->numports; i++) {
> -                             if (i == node->localport)
> -                                     continue;
> -
> -                             if (get_port(&port_buf, i, path) < 0) {
> -                                     IBWARN("can't reach node %s port %d", 
> portid2str(path), i);
> -                                     continue;
> -                             }
> -
> -                             port = find_port(node, &port_buf);
> -                             if (port)
> -                                     continue;
> -
> -                             port = create_port(node, &port_buf);
> -                             if (!port)
> -                                     IBERROR("out of memory");
> -
> -                             /* If switch, set port GUID to node GUID */
> -                             if (node->type == SWITCH_NODE)
> -                                     port->portguid = node->portguid;
> -
> -                             handle_port(node, port, path, i, dist);
> -                     }
> -             }
> -     }
> +static int timeout_ms = 2000;
> +static int dumplevel = 0;
>  
> -     return 0;
> -}
>  
>  char *
> -node_name(Node *node)
> +node_name(ibnd_node_t *node)
>  {
>       static char buf[256];
>  
> -     switch(node->type) {
> -     case SWITCH_NODE:
> -             sprintf(buf, "\"%s", "S");
> -             break;
> -     case CA_NODE:
> +     switch(node->info.type) {
> +     case IBND_CA_NODE:
>               sprintf(buf, "\"%s", "H");
>               break;
> -     case ROUTER_NODE:
> +     case IBND_SWITCH_NODE:
> +             sprintf(buf, "\"%s", "S");
> +             break;
> +     case IBND_ROUTER_NODE:
>               sprintf(buf, "\"%s", "R");
>               break;
>       default:
>               sprintf(buf, "\"%s", "?");
>               break;
>       }
> -     sprintf(buf+2, "-%016" PRIx64 "\"", node->nodeguid);
> +     sprintf(buf+2, "-%016" PRIx64 "\"", node->info.nodeguid);
>  
>       return buf;
>  }
>  
>  void
> -list_node(Node *node)
> +list_node(ibnd_node_t *node, void *user_data)
>  {
> -     char *node_type;
> -     char *nodename = remap_node_name(node_name_map, node->nodeguid,
> +     char *nodename = remap_node_name(node_name_map, node->info.nodeguid,
>                                             node->nodedesc);
>  
> -     switch(node->type) {
> -     case SWITCH_NODE:
> -             node_type = "Switch";
> -             break;
> -     case CA_NODE:
> -             node_type = "Ca";
> -             break;
> -     case ROUTER_NODE:
> -             node_type = "Router";
> -             break;
> -     default:
> -             node_type = "???";
> -             break;
> -     }
>       fprintf(f, "%s\t : 0x%016" PRIx64 " ports %d devid 0x%x vendid 0x%x 
> \"%s\"\n",
> -             node_type,
> -             node->nodeguid, node->numports, node->devid, node->vendid,
> +             ibnd_node_type_str(node),
> +             node->info.nodeguid, node->info.numports, node->info.devid,
> +             node->info.vendid,
>               nodename);
>  
>       free(nodename);
>  }
>  
>  void
> -out_ids(Node *node, int group, char *chname)
> +list_nodes(ibnd_fabric_t *fabric, int list)
> +{
> +     if (list & LIST_CA_NODE) {
> +             ibnd_iter_nodes_type(fabric, list_node, IBND_CA_NODE, NULL);
> +     }
> +     if (list & LIST_SWITCH_NODE) {
> +             ibnd_iter_nodes_type(fabric, list_node, IBND_SWITCH_NODE, NULL);
> +     }
> +     if (list & LIST_ROUTER_NODE) {
> +             ibnd_iter_nodes_type(fabric, list_node, IBND_ROUTER_NODE, NULL);
> +     }
> +}
> +
> +void
> +out_ids(ibnd_node_t *node, int group, char *chname)
>  {
> -     fprintf(f, "\nvendid=0x%x\ndevid=0x%x\n", node->vendid, node->devid);
> -     if (node->sysimgguid)
> -             fprintf(f, "sysimgguid=0x%" PRIx64, node->sysimgguid);
> +     fprintf(f, "\nvendid=0x%x\ndevid=0x%x\n", node->info.vendid, 
> node->info.devid);
> +     if (node->info.sysimgguid)
> +             fprintf(f, "sysimgguid=0x%" PRIx64, node->info.sysimgguid);
>       if (group
>           && node->chrecord && node->chrecord->chassisnum) {
>               fprintf(f, "\t\t# Chassis %d", node->chrecord->chassisnum);
>               if (chname)
> -                     fprintf(f, " (%s)", chname);
> -             if (is_xsigo_tca(node->nodeguid) && node->ports->remoteport)
> -                     fprintf(f, " slot %d", 
> node->ports->remoteport->portnum);
> +                     fprintf(f, " (%s)", clean_nodedesc(chname));
> +             if (ibnd_is_xsigo_tca(node->info.nodeguid)
> +                             && node->ports[1]
> +                             && node->ports[1]->remoteport)
> +                     fprintf(f, " slot %d", 
> node->ports[1]->remoteport->portnum);
>       }
>       fprintf(f, "\n");
>  }
>  
> +
>  uint64_t
> -out_chassis(int chassisnum)
> +out_chassis(ibnd_fabric_t *fabric, int chassisnum)
>  {
>       uint64_t guid;
>  
>       fprintf(f, "\nChassis %d", chassisnum);
> -     guid = get_chassis_guid(chassisnum);
> +     guid = ibnd_get_chassis_guid(fabric, chassisnum);
>       if (guid)
>               fprintf(f, " (guid 0x%" PRIx64 ")", guid);
>       fprintf(f, "\n");
> @@ -531,54 +157,49 @@ out_chassis(int chassisnum)
>  }
>  
>  void
> -out_switch(Node *node, int group, char *chname)
> +out_switch(ibnd_node_t *node, int group, char *chname)
>  {
>       char *str;
> +     char  str2[256];
>       char *nodename = NULL;
>  
>       out_ids(node, group, chname);
> -     fprintf(f, "switchguid=0x%" PRIx64, node->nodeguid);
> -     fprintf(f, "(%" PRIx64 ")", node->portguid);
> -     /* Currently, only if Voltaire chassis */
> -     if (group
> -         && node->chrecord && node->chrecord->chassisnum
> -         && node->vendid == VTR_VENDOR_ID) {
> -             str = get_chassis_type(node->chrecord->chassistype);
> +     fprintf(f, "switchguid=0x%" PRIx64, node->info.nodeguid);
> +     fprintf(f, "(%" PRIx64 ")", node->info.nodeportguid);
> +     if (group) {
> +             str = ibnd_get_chassis_type(node);
>               if (str)
>                       fprintf(f, "%s ", str);
> -             str = get_chassis_slot(node->chrecord->chassisslot);
> +             str = ibnd_get_chassis_slot_str(node, str2, 256);
>               if (str)
> -                     fprintf(f, "%s ", str);
> -             fprintf(f, "%d Chip %d", node->chrecord->slotnum, 
> node->chrecord->anafanum);
> +                     fprintf(f, "%s", str);
>       }
>  
> -     nodename = remap_node_name(node_name_map, node->nodeguid,
> +     nodename = remap_node_name(node_name_map, node->info.nodeguid,
>                               node->nodedesc);
>  
>       fprintf(f, "\nSwitch\t%d %s\t\t# \"%s\" %s port 0 lid %d lmc %d\n",
> -             node->numports, node_name(node),
> +             node->info.numports, node_name(node),
>               nodename,
> -             node->smaenhsp0 ? "enhanced" : "base",
> +             node->sw_info.smaenhsp0 ? "enhanced" : "base",
>               node->smalid, node->smalmc);
>  
>       free(nodename);
>  }
>  
>  void
> -out_ca(Node *node, int group, char *chname)
> +out_ca(ibnd_node_t *node, int group, char *chname)
>  {
>       char *node_type;
>       char *node_type2;
> -     char *nodename = remap_node_name(node_name_map, node->nodeguid,
> -                                           node->nodedesc);
>  
>       out_ids(node, group, chname);
> -     switch(node->type) {
> -     case CA_NODE:
> +     switch(node->info.type) {
> +     case IBND_CA_NODE:
>               node_type = "ca";
>               node_type2 = "Ca";
>               break;
> -     case ROUTER_NODE:
> +     case IBND_ROUTER_NODE:
>               node_type = "rt";
>               node_type2 = "Rt";
>               break;
> @@ -588,37 +209,37 @@ out_ca(Node *node, int group, char *chname)
>               break;
>       }
>  
> -     fprintf(f, "%sguid=0x%" PRIx64 "\n", node_type, node->nodeguid);
> +     fprintf(f, "%sguid=0x%" PRIx64 "\n", node_type, node->info.nodeguid);
>       fprintf(f, "%s\t%d %s\t\t# \"%s\"",
> -             node_type2, node->numports, node_name(node),
> -             nodename);
> -     if (group && is_xsigo_hca(node->nodeguid))
> +             node_type2, node->info.numports, node_name(node),
> +             clean_nodedesc(node->nodedesc));
> +     if (group && ibnd_is_xsigo_hca(node->info.nodeguid))
>               fprintf(f, " (scp)");
>       fprintf(f, "\n");
> -
> -     free(nodename);
>  }
>  
> +#define OUT_BUFFER_SIZE 16
>  static char *
> -out_ext_port(Port *port, int group)
> +out_ext_port(ibnd_port_t *port, int group)
>  {
> -     char *str = NULL;
> +     static char mapping[OUT_BUFFER_SIZE];
>  
> -     /* Currently, only if Voltaire chassis */
> -     if (group
> -         && port->node->chrecord && port->node->vendid == VTR_VENDOR_ID)
> -             str = portmapstring(port);
> +     if (group && port->ext_portnum != 0) {
> +             snprintf(mapping, OUT_BUFFER_SIZE,
> +                     "[ext %d]", port->ext_portnum);
> +             return (mapping);
> +     }
>  
> -     return (str);
> +     return (NULL);
>  }
>  
>  void
> -out_switch_port(Port *port, int group)
> +out_switch_port(ibnd_port_t *port, int group)
>  {
>       char *ext_port_str = NULL;
>       char *rem_nodename = NULL;
>  
> -     DEBUG("port %p:%d remoteport %p", port, port->portnum, 
> port->remoteport);
> +     DEBUG("port %p:%d remoteport %p\n", port, port->portnum, 
> port->remoteport);
>       fprintf(f, "[%d]", port->portnum);
>  
>       ext_port_str = out_ext_port(port, group);
> @@ -626,7 +247,7 @@ out_switch_port(Port *port, int group)
>               fprintf(f, "%s", ext_port_str);
>  
>       rem_nodename = remap_node_name(node_name_map,
> -                             port->remoteport->node->nodeguid,
> +                             port->remoteport->node->info.nodeguid,
>                               port->remoteport->node->nodedesc);
>  
>       ext_port_str = out_ext_port(port->remoteport, group);
> @@ -634,17 +255,17 @@ out_switch_port(Port *port, int group)
>               node_name(port->remoteport->node),
>               port->remoteport->portnum,
>               ext_port_str ? ext_port_str : "");
> -     if (port->remoteport->node->type != SWITCH_NODE)
> -             fprintf(f, "(%" PRIx64 ") ", port->remoteport->portguid);
> +     if (port->remoteport->node->info.type != IBND_SWITCH_NODE)
> +             fprintf(f, "(%" PRIx64 ") ", port->remoteport->guid);
>       fprintf(f, "\t\t# \"%s\" lid %d %s%s",
>               rem_nodename,
> -             port->remoteport->node->type == SWITCH_NODE ? 
> port->remoteport->node->smalid : port->remoteport->lid,
> -             get_linkwidth_str(port->linkwidth),
> -             get_linkspeed_str(port->linkspeed));
> +             port->remoteport->node->info.type == IBND_SWITCH_NODE ?  
> port->remoteport->node->smalid : port->remoteport->info.lid,
> +             ibnd_linkwidth_str(port->info.link_width_active),
> +             ibnd_linkspeed_str(port->info.link_speed_active));
>  
> -     if (is_xsigo_tca(port->remoteport->portguid))
> +     if (ibnd_is_xsigo_tca(port->remoteport->guid))
>               fprintf(f, " slot %d", port->portnum);
> -     else if (is_xsigo_hca(port->remoteport->portguid))
> +     else if (ibnd_is_xsigo_hca(port->remoteport->guid))
>               fprintf(f, " (scp)");
>       fprintf(f, "\n");
>  
> @@ -652,68 +273,80 @@ out_switch_port(Port *port, int group)
>  }
>  
>  void
> -out_ca_port(Port *port, int group)
> +out_ca_port(ibnd_port_t *port, int group)
>  {
>       char *str = NULL;
>       char *rem_nodename = NULL;
>  
>       fprintf(f, "[%d]", port->portnum);
> -     if (port->node->type != SWITCH_NODE)
> -             fprintf(f, "(%" PRIx64 ") ", port->portguid);
> +     if (port->node->info.type != IBND_SWITCH_NODE)
> +             fprintf(f, "(%" PRIx64 ") ", port->guid);
>       fprintf(f, "\t%s[%d]",
>               node_name(port->remoteport->node),
>               port->remoteport->portnum);
>       str = out_ext_port(port->remoteport, group);
>       if (str)
>               fprintf(f, "%s", str);
> -     if (port->remoteport->node->type != SWITCH_NODE)
> -             fprintf(f, " (%" PRIx64 ") ", port->remoteport->portguid);
> +     if (port->remoteport->node->info.type != IBND_SWITCH_NODE)
> +             fprintf(f, " (%" PRIx64 ") ", port->remoteport->guid);
>  
>       rem_nodename = remap_node_name(node_name_map,
> -                             port->remoteport->node->nodeguid,
> +                             port->remoteport->node->info.nodeguid,
>                               port->remoteport->node->nodedesc);
>  
>       fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s\n",
> -             port->lid, port->lmc, rem_nodename,
> -             port->remoteport->node->type == SWITCH_NODE ? 
> port->remoteport->node->smalid : port->remoteport->lid,
> -             get_linkwidth_str(port->linkwidth),
> -             get_linkspeed_str(port->linkspeed));
> +             port->info.lid, port->info.lmc, rem_nodename,
> +             port->remoteport->node->info.type == IBND_SWITCH_NODE ?  
> port->remoteport->node->smalid : port->remoteport->info.lid,
> +             ibnd_linkwidth_str(port->info.link_width_active),
> +             ibnd_linkspeed_str(port->info.link_speed_active));
>  
>       free(rem_nodename);
>  }
>  
>  int
> -dump_topology(int listtype, int group)
> +dump_topology(int group, ibnd_fabric_t *fabric)
>  {
> -     Node *node;
> -     Port *port;
> -     int i = 0, dist = 0;
> +     ibnd_node_t *node;
> +     ibnd_port_t *port;
> +     int i = 0, dist = 0, p = 0;
>       time_t t = time(0);
>       uint64_t chguid;
>       char *chname = NULL;
>  
> -     if (!listtype) {
> -             fprintf(f, "#\n# Topology file: generated on %s#\n", ctime(&t));
> -             fprintf(f, "# Max of %d hops discovered\n", maxhops_discovered);
> -             fprintf(f, "# Initiated from node %016" PRIx64 " port %016" 
> PRIx64 "\n", mynode->nodeguid, mynode->portguid);
> -     }
> +     fprintf(f, "#\n# Topology file: generated on %s#\n", ctime(&t));
> +     fprintf(f, "# Max of %d hops discovered\n", fabric->maxhops_discovered);
> +     fprintf(f, "# Initiated from node %016" PRIx64 " port %016" PRIx64 "\n",
> +             fabric->from_node->info.nodeguid, 
> fabric->from_node->info.nodeportguid);
>  
>       /* Make pass on switches */
> -     if (group && !listtype) {
> -             ChassisList *ch = NULL;
> +     if (group) {
> +             ibnd_chassis_list_t *ch = NULL;
>  
>               /* Chassis based switches first */
> -             for (ch = chassis; ch; ch = ch->next) {
> +             for (ch = fabric->chassis; ch; ch = ch->next) {
>                       int n = 0;
>  
>                       if (!ch->chassisnum)
>                               continue;
> -                     chguid = out_chassis(ch->chassisnum);
> -                     if (chname)
> -                             free(chname);
> +                     chguid = out_chassis(fabric, ch->chassisnum);
> +
>                       chname = NULL;
> -                     if (is_xsigo_guid(chguid)) {
> -                             for (node = nodesdist[MAXHOPS]; node; node = 
> node->dnext) {
> +/**
> + * Hal will this work for Xsigo?
> + */
> +                     if (ibnd_is_xsigo_guid(chguid)) {
> +                             for (node = ch->nodes; node; node = 
> node->chassis_next) {
> +                                     if 
> (ibnd_is_xsigo_hca(node->info.nodeguid)) {
> +                                             chname = node->nodedesc;
> +                                             fprintf(f, "Hostname: %s\n", 
> clean_nodedesc(node->nodedesc));
> +                                     }
> +                             }
> +
> +#if 0
> +/**
> + * vs. this?
> + */
> +                             for (node = fabric->nodesdist[MAXHOPS]; node; 
> node = node->dnext) {
>                                       if (!node->chrecord ||
>                                           !node->chrecord->chassisnum)
>                                               continue;
> @@ -721,209 +354,171 @@ dump_topology(int listtype, int group)
>                                       if (node->chrecord->chassisnum != 
> ch->chassisnum)
>                                               continue;
>  
> -                                     if (is_xsigo_hca(node->nodeguid)) {
> -                                             chname = 
> remap_node_name(node_name_map,
> -                                                             node->nodeguid,
> -                                                             node->nodedesc);
> -                                             fprintf(f, "Hostname: %s\n", 
> chname);
> +                                     if (ibnd_is_xsigo_hca(node->nodeguid)) {
> +                                             chname = node->nodedesc;
> +                                             fprintf(f, "Hostname: %s\n", 
> clean_nodedesc(node->nodedesc));
>                                       }
>                               }
> +#endif
>                       }
>  
>                       fprintf(f, "\n# Spine Nodes");
> -                     for (n = 1; n <= (SPINES_MAX_NUM+1); n++) {
> +                     for (n = 1; n <= SPINES_MAX_NUM; n++) {
>                               if (ch->spinenode[n]) {
>                                       out_switch(ch->spinenode[n], group, 
> chname);
> -                                     for (port = ch->spinenode[n]->ports; 
> port; port = port->next, i++)
> -                                             if (port->remoteport)
> +                                     for (p = 1; p <= 
> ch->spinenode[n]->info.numports; p++) {
> +                                             port = 
> ch->spinenode[n]->ports[p];
> +                                             if (port && port->remoteport)
>                                                       out_switch_port(port, 
> group);
> +                                     }
>                               }
>                       }
>                       fprintf(f, "\n# Line Nodes");
> -                     for (n = 1; n <= (LINES_MAX_NUM+1); n++) {
> +                     for (n = 1; n <= LINES_MAX_NUM; n++) {
>                               if (ch->linenode[n]) {
>                                       out_switch(ch->linenode[n], group, 
> chname);
> -                                     for (port = ch->linenode[n]->ports; 
> port; port = port->next, i++)
> -                                             if (port->remoteport)
> +                                     for (p = 1; p <= 
> ch->linenode[n]->info.numports; p++) {
> +                                             port = 
> ch->linenode[n]->ports[p];
> +                                             if (port && port->remoteport)
>                                                       out_switch_port(port, 
> group);
> +                                     }
>                               }
>                       }
>  
>                       fprintf(f, "\n# Chassis Switches");
> -                     for (dist = 0; dist <= maxhops_discovered; dist++) {
> -
> -                             for (node = nodesdist[dist]; node; node = 
> node->dnext) {
> -
> -                                     /* Non Voltaire chassis */
> -                                     if (node->vendid == VTR_VENDOR_ID)
> -                                             continue;
> -                                     if (!node->chrecord ||
> -                                         !node->chrecord->chassisnum)
> -                                             continue;
> -
> -                                     if (node->chrecord->chassisnum != 
> ch->chassisnum)
> -                                             continue;
> -
> +                     for (node = ch->nodes; node; node = node->chassis_next) 
> {
> +                             if (node->info.type == IBND_SWITCH_NODE) {
>                                       out_switch(node, group, chname);
> -                                     for (port = node->ports; port; port = 
> port->next, i++)
> -                                             if (port->remoteport)
> +                                     for (p = 1; p <= node->info.numports; 
> p++) {
> +                                             port = node->ports[p];
> +                                             if (port && port->remoteport)
>                                                       out_switch_port(port, 
> group);
> -
> +                                     }
>                               }
> -
>                       }
>  
>                       fprintf(f, "\n# Chassis CAs");
> -                     for (node = nodesdist[MAXHOPS]; node; node = 
> node->dnext) {
> -                             if (!node->chrecord ||
> -                                 !node->chrecord->chassisnum)
> -                                     continue;
> -
> -                             if (node->chrecord->chassisnum != 
> ch->chassisnum)
> -                                     continue;
> -
> -                             out_ca(node, group, chname);
> -                             for (port = node->ports; port; port = 
> port->next, i++)
> -                                     if (port->remoteport)
> -                                             out_ca_port(port, group);
> -
> +                     for (node = ch->nodes; node; node = node->chassis_next) 
> {
> +                             if (node->info.type == IBND_CA_NODE) {
> +                                     out_ca(node, group, chname);
> +                                     for (p = 1; p <= node->info.numports; 
> p++) {
> +                                             port = node->ports[p];
> +                                             if (port && port->remoteport)
> +                                                     out_ca_port(port, 
> group);
> +                                     }
> +                             }
>                       }
>  
>               }
>  
> -     } else {
> -             for (dist = 0; dist <= maxhops_discovered; dist++) {
> -
> -                     for (node = nodesdist[dist]; node; node = node->dnext) {
> -
> -                             DEBUG("SWITCH: dist %d node %p", dist, node);
> -                             if (!listtype)
> -                                     out_switch(node, group, chname);
> -                             else {
> -                                     if (listtype & LIST_SWITCH_NODE)
> -                                             list_node(node);
> -                                     continue;
> -                             }
> -
> -                             for (port = node->ports; port; port = 
> port->next, i++)
> -                                     if (port->remoteport)
> +     } else { /* !group */
> +             for (node = fabric->switches; node; node = node->type_next) {
> +                             DEBUG("SWITCH: dist %d node %p\n", dist, node);
> +                             out_switch(node, group, chname);
> +                             for (p = 1; p <= node->info.numports; p++) {
> +                                     port = node->ports[p];
> +                                     if (port && port->remoteport)
>                                               out_switch_port(port, group);
> -                     }
> +                             }
>               }
>       }
>  
> -     if (chname)
> -             free(chname);
>       chname = NULL;
> -     if (group && !listtype) {
> -
> +     if (group) {
>               fprintf(f, "\nNon-Chassis Nodes\n");
> -
> -             for (dist = 0; dist <= maxhops_discovered; dist++) {
> -
> -                     for (node = nodesdist[dist]; node; node = node->dnext) {
> -
> -                             DEBUG("SWITCH: dist %d node %p", dist, node);
> +             for (node = fabric->switches; node; node = node->type_next) {
> +                             DEBUG("SWITCH: dist %d node %p\n", dist, node);
>                               /* Now, skip chassis based switches */
>                               if (node->chrecord &&
>                                   node->chrecord->chassisnum)
>                                       continue;
>                               out_switch(node, group, chname);
>  
> -                             for (port = node->ports; port; port = 
> port->next, i++)
> -                                     if (port->remoteport)
> +                             for (p = 1; p <= node->info.numports; p++) {
> +                                     port = node->ports[p];
> +                                     if (port && port->remoteport)
>                                               out_switch_port(port, group);
> -                     }
> -
> +                             }
>               }
>  
>       }
>  
>       /* Make pass on CAs */
> -     for (node = nodesdist[MAXHOPS]; node; node = node->dnext) {
> -
> -             DEBUG("CA: dist %d node %p", dist, node);
> -             if (!listtype) {
> -                     /* Now, skip chassis based CAs */
> -                     if (group && node->chrecord &&
> -                         node->chrecord->chassisnum)
> -                             continue;
> -                     out_ca(node, group, chname);
> -             } else {
> -                     if (((listtype & LIST_CA_NODE) && (node->type == 
> CA_NODE)) ||
> -                         ((listtype & LIST_ROUTER_NODE) && (node->type == 
> ROUTER_NODE)))
> -                             list_node(node);
> +     for (node = fabric->ch_adapters; node; node = node->type_next) {
> +             DEBUG("CA: dist %d node %p\n", dist, node);
> +             /* Now, skip chassis based CAs */
> +             if (group && node->chrecord &&
> +                 node->chrecord->chassisnum)
>                       continue;
> -             }
> +             out_ca(node, group, chname);
>  
> -             for (port = node->ports; port; port = port->next, i++)
> -                     if (port->remoteport)
> +             for (p = 1; p <= node->info.numports; p++) {
> +                     port = node->ports[p];
> +                     if (port && port->remoteport)
>                               out_ca_port(port, group);
> +             }
>       }
>  
> -     if (chname)
> -             free(chname);
> +     /* make pass on routers */
> +     for (node = fabric->routers; node; node = node->type_next) {
> +             DEBUG("RT: dist %d node %p\n", dist, node);
> +             /* Now, skip chassis based CAs */
> +             if (group && node->chrecord &&
> +                 node->chrecord->chassisnum)
> +                     continue;
> +             out_ca(node, group, chname);
> +             for (p = 1; p <= node->info.numports; p++) {
> +                     port = node->ports[p];
> +                     if (port && port->remoteport)
> +                             out_ca_port(port, group);
> +             }
> +     }
>  
>       return i;
>  }
>  
> -void dump_ports_report ()
> +
> +void dump_ports_report (ibnd_node_t *node, void *user_data)
>  {
> -     int b, n = 0, p;
> -     Node *node;
> -     Port *port;
> -
> -     // If switch and LID == 0, search of other switch ports with
> -     // valid LID and assign it to all ports of that switch
> -     for (b = 0; b <= MAXHOPS; b++)
> -             for (node = nodesdist[b]; node; node = node->dnext)
> -                     if (node->type == SWITCH_NODE) {
> -                             int swlid = 0;
> -                             for (p = 0, port = node->ports;
> -                                  p < node->numports && port && !swlid;
> -                                  port = port->next)
> -                                     if (port->lid != 0)
> -                                             swlid = port->lid;
> -                             for (p = 0, port = node->ports;
> -                                  p < node->numports && port;
> -                                  port = port->next)
> -                                     port->lid = swlid;
> -                     }
> +     int p = 0;
> +     ibnd_port_t *port = NULL;
> +
> +     /* for each port */
> +     for (p = node->info.numports, port = node->ports[p];
> +          p > 0;
> +          port = node->ports[--p]) {
> +             if (port == NULL)
> +                     continue;
>  
> -     for (b = 0; b <= MAXHOPS; b++)
> -             for (node = nodesdist[b]; node; node = node->dnext) {
> -                     for (p = 0, port = node->ports;
> -                          p < node->numports && port;
> -                          p++, port = port->next) {
> -                             fprintf(stdout,
> -                                     "%2s %5d %2d 0x%016" PRIx64 " %s %s",
> -                                     node_type_str2(port->node), port->lid,
> -                                     port->portnum,
> -                                     port->portguid,
> -                                     get_linkwidth_str(port->linkwidth),
> -                                     get_linkspeed_str(port->linkspeed));
> -                             if (port->remoteport)
> -                                     fprintf(stdout,
> -                                             " - %2s %5d %2d 0x%016" PRIx64
> -                                             " ( '%s' - '%s' )\n",
> -                                             
> node_type_str2(port->remoteport->node),
> -                                             port->remoteport->lid,
> -                                             port->remoteport->portnum,
> -                                             port->remoteport->portguid,
> -                                             port->node->nodedesc,
> -                                             
> port->remoteport->node->nodedesc);
> -                             else
> -                                     fprintf(stdout, "%36s'%s'\n", "",
> -                                             port->node->nodedesc);
> -                     }
> -                     n++;
> -             }
> +             fprintf(stdout,
> +                     "%2s %5d %2d 0x%016" PRIx64 " %s %s",
> +                     ibnd_node_type_str_short(node),
> +                     node->info.type == IBND_SWITCH_NODE ? node->smalid : 
> port->info.lid,
> +                     port->portnum,
> +                     port->guid,
> +                     ibnd_linkwidth_str(port->info.link_width_active),
> +                     ibnd_linkspeed_str(port->info.link_speed_active));
> +             if (port->remoteport)
> +                     fprintf(stdout,
> +                             " - %2s %5d %2d 0x%016" PRIx64
> +                             " ( '%s' - '%s' )\n",
> +                             
> ibnd_node_type_str_short(port->remoteport->node),
> +                             port->remoteport->node->info.type == 
> IBND_SWITCH_NODE ?
> +                                     port->remoteport->node->smalid : 
> port->remoteport->info.lid,
> +                             port->remoteport->portnum,
> +                             port->remoteport->guid,
> +                             port->node->nodedesc,
> +                             port->remoteport->node->nodedesc);
> +             else
> +                     fprintf(stdout, "%36s'%s'\n", "",
> +                             port->node->nodedesc);
> +     }
>  }
>  
>  void
>  usage(void)
>  {
> -     fprintf(stderr, "Usage: %s [-d(ebug)] -e(rr_show) -v(erbose) -s(how) 
> -l(ist) -g(rouping) -H(ca_list) -S(witch_list) -R(outer_list) -V(ersion) -C 
> ca_name -P ca_port "
> +     fprintf(stderr, "Usage: %s [-d(ebug)] -s(how) -l(ist) -g(rouping) 
> -H(ca_list) -S(witch_list) -R(outer_list) -V(ersion) -C ca_name -P ca_port "
>                       "-t(imeout) timeout_ms --node-name-map node-name-map] 
> -p(orts) [<topology-file>]\n",
>                       argv0);
>       fprintf(stderr, "       --node-name-map <node-name-map> specify a node 
> name map file\n");
> @@ -933,20 +528,18 @@ usage(void)
>  int
>  main(int argc, char **argv)
>  {
> -     int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS};
> -     ib_portid_t my_portid = {0};
> -     int udebug = 0, list = 0;
> +     int list = 0;
>       char *ca = 0;
>       int ca_port = 0;
>       int group = 0;
>       int ports_report = 0;
> +     ibnd_fabric_t *fabric = NULL;
>  
>       static char const str_opts[] = "C:P:t:devslgHSRpVhu";
>       static const struct option long_opts[] = {
>               { "C", 1, 0, 'C'},
>               { "P", 1, 0, 'P'},
>               { "debug", 0, 0, 'd'},
> -             { "err_show", 0, 0, 'e'},
>               { "verbose", 0, 0, 'v'},
>               { "show", 0, 0, 's'},
>               { "list", 0, 0, 'l'},
> @@ -982,23 +575,17 @@ main(int argc, char **argv)
>                       ca_port = strtoul(optarg, 0, 0);
>                       break;
>               case 'd':
> -                     ibdebug++;
> -                     madrpc_show_errors(1);
> -                     umad_debug(udebug);
> -                     udebug++;
> +                     debug = 1;
> +                     ibnd_debug(1);
>                       break;
>               case 't':
> -                     timeout = strtoul(optarg, 0, 0);
> +                     timeout_ms = strtoul(optarg, 0, 0);
>                       break;
>               case 'v':
>                       verbose++;
> -                     dumplevel++;
>                       break;
>               case 's':
> -                     dumplevel = 1;
> -                     break;
> -             case 'e':
> -                     madrpc_show_errors(1);
> +                     ibnd_show_progress(1);
>                       break;
>               case 'l':
>                       list = LIST_CA_NODE | LIST_SWITCH_NODE | 
> LIST_ROUTER_NODE;
> @@ -1007,13 +594,13 @@ main(int argc, char **argv)
>                       group = 1;
>                       break;
>               case 'S':
> -                     list = LIST_SWITCH_NODE;
> +                     list |= LIST_SWITCH_NODE;
>                       break;
>               case 'H':
> -                     list = LIST_CA_NODE;
> +                     list |= LIST_CA_NODE;
>                       break;
>               case 'R':
> -                     list = LIST_ROUTER_NODE;
> +                     list |= LIST_ROUTER_NODE;
>                       break;
>               case 'V':
>                       fprintf(stderr, "%s %s\n", argv0, get_build_version() );
> @@ -1030,22 +617,25 @@ main(int argc, char **argv)
>       argv += optind;
>  
>       if (argc && !(f = fopen(argv[0], "w")))
> -             IBERROR("can't open file %s for writing", argv[0]);
> +             fprintf(stderr, "can't open file %s for writing", argv[0]);
>  
> -     madrpc_init(ca, ca_port, mgmt_classes, 2);
>       node_name_map = open_node_name_map(node_name_map_file);
>  
> -     if (discover(&my_portid) < 0)
> -             IBERROR("discover");
> -
> -     if (group)
> -             chassis = group_nodes();
> +     if ((fabric = ibnd_discover_fabric(ca, ca_port, timeout_ms, NULL, -1)) 
> == NULL) {
> +             fprintf(stderr, "discover failed\n");
> +             exit(1);
> +     }
>  
>       if (ports_report)
> -             dump_ports_report();
> +             ibnd_iter_nodes(fabric,
> +                             dump_ports_report,
> +                             NULL);
> +     else if (list)
> +             list_nodes(fabric, list);
>       else
> -             dump_topology(list, group);
> +             dump_topology(group, fabric);
>  
> +     ibnd_destroy_fabric(fabric);
>       close_node_name_map(node_name_map);
>       exit(0);
>  }
> -- 
> 1.5.4.5
> 
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to