[openib-general] [PATCH] Diags: Add initial support for IB routers
Hal Rosenstock
halr at voltaire.com
Tue Oct 10 05:37:07 PDT 2006
Diags: Add initial support for IB routers
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: src/ibtracert.c
===================================================================
--- src/ibtracert.c (revision 9767)
+++ src/ibtracert.c (working copy)
@@ -51,6 +51,14 @@
#define MAXHOPS 63
+static char *node_type_str[] = {
+ "???",
+ "ca",
+ "switch",
+ "router",
+ "iwarp rnic"
+};
+
static int timeout = 0; /* ms */
static int verbose;
static int force;
@@ -219,13 +227,15 @@ dump_endnode(int dump, char *prompt, Nod
}
#if __WORDSIZE == 64
fprintf(f, "%s %s {%016lx} portnum %d lid 0x%x-0x%x \"%s\"\n",
- prompt, node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ prompt,
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->type == IB_NODE_SWITCH ? 0 : port->portnum,
port->lid, port->lid + (1 << port->lmc) - 1,
node->nodedesc);
#else
fprintf(f, "%s %s {%016Lx} portnum %d lid 0x%x-0x%x \"%s\"\n",
- prompt, node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ prompt,
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->type == IB_NODE_SWITCH ? 0 : port->portnum,
port->lid, port->lid + (1 << port->lmc) - 1,
node->nodedesc);
@@ -243,7 +253,8 @@ dump_route(int dump, Node *node, int out
outport, port->portguid, port->portnum);
else
fprintf(f, "[%d] -> %s port {%016lx}[%d] lid 0x%x-0x%x \"%s\"\n",
- outport, node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ outport,
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
port->portguid, port->portnum,
port->lid, port->lid + (1 << port->lmc) - 1,
node->nodedesc);
@@ -253,7 +264,8 @@ dump_route(int dump, Node *node, int out
outport, port->portguid, port->portnum);
else
fprintf(f, "[%d] -> %s port {%016Lx}[%d] lid 0x%x-0x%x \"%s\"\n",
- outport, node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ outport,
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
port->portguid, port->portnum,
port->lid, port->lid + (1 << port->lmc) - 1,
node->nodedesc);
@@ -314,17 +326,19 @@ find_route(ib_portid_t *from, ib_portid_
else
break; /* found SMA port */
}
- } else if (node->type == IB_NODE_CA) {
+ } else if ((node->type == IB_NODE_CA) ||
+ (node->type == IB_NODE_ROUTER)) {
int ca_src = 0;
- DEBUG("ca node");
+
+ DEBUG("ca or router node");
if (!sameport(port, &fromport)) {
- IBWARN("can't continue: reached CA port %Lx, lid %d",
+ IBWARN("can't continue: reached CA or router port %Lx, lid %d",
port->portguid, port->lid);
return -1;
}
- /* we are at CA "from" - go one hop back to (hopefully) a switch */
+ /* we are at CA or router "from" - go one hop back to (hopefully) a switch */
if (from->drpath.cnt > 0) {
- DEBUG("ca node - return back 1 hop");
+ DEBUG("ca or router node - return back 1 hop");
from->drpath.cnt--;
} else {
ca_src = 1;
@@ -332,15 +346,14 @@ find_route(ib_portid_t *from, ib_portid_
goto badpath;
}
/*
- * else - we are running on a CA! that is impressive -
- * when this code was written CAs were not supported...
+ * else - we are running on a CA or router! that is impressive -
+ * when this code was written, CAs and routers were not supported...
*/
-
if (get_node(&nextnode, &nextport, from) < 0) {
IBWARN("can't reach port at %s", portid2str(from));
return -1;
}
- /* fix port num to be seen from the CA side */
+ /* fix port num to be seen from the CA or router side */
if (!ca_src)
nextport.portnum = from->drpath.p[from->drpath.cnt+1];
}
@@ -660,13 +673,13 @@ dump_mcpath(Node *node, int dumplevel)
if (!node->dist) {
#if __WORDSIZE == 64
printf("From %s 0x%lx port %d lid 0x%x-0x%x \"%s\"\n",
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->ports->portnum, node->ports->lid,
node->ports->lid + (1 << node->ports->lmc) - 1,
node->nodedesc);
#else
printf("From %s 0x%Lx port %d lid 0x%x-0x%x \"%s\"\n",
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->ports->portnum, node->ports->lid,
node->ports->lid + (1 << node->ports->lmc) - 1,
node->nodedesc);
@@ -679,24 +692,24 @@ dump_mcpath(Node *node, int dumplevel)
if (dumplevel == 1)
printf("[%d] -> %s {%016lx}[%d]\n",
node->ports->remoteport->portnum,
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->upport);
else
printf("[%d] -> %s 0x%lx[%d] lid 0x%x \"%s\"\n",
node->ports->remoteport->portnum,
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->upport,
node->ports->lid, node->nodedesc);
#else
if (dumplevel == 1)
printf("[%d] -> %s {%016Lx}[%d]\n",
node->ports->remoteport->portnum,
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->upport);
else
printf("[%d] -> %s 0x%Lx[%d] lid 0x%x \"%s\"\n",
node->ports->remoteport->portnum,
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->upport,
node->ports->lid, node->nodedesc);
#endif
@@ -706,13 +719,13 @@ dump_mcpath(Node *node, int dumplevel)
/* target node */
#if __WORDSIZE == 64
printf("To %s 0x%lx port %d lid 0x%x-0x%x \"%s\"\n",
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->ports->portnum, node->ports->lid,
node->ports->lid + (1 << node->ports->lmc) - 1,
node->nodedesc);
#else
printf("To %s 0x%Lx port %d lid 0x%x-0x%x \"%s\"\n",
- node->type == IB_NODE_SWITCH ? "switch" : "ca",
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
node->nodeguid, node->ports->portnum, node->ports->lid,
node->ports->lid + (1 << node->ports->lmc) - 1,
node->nodedesc);
Index: src/ibnetdiscover.c
===================================================================
--- src/ibnetdiscover.c (revision 9748)
+++ src/ibnetdiscover.c (working copy)
@@ -52,6 +52,14 @@
#include "ibnetdiscover.h"
+static char *node_type_str[] = {
+ "???",
+ "ca",
+ "switch",
+ "router",
+ "iwarp rnic"
+};
+
static int timeout = 2000; /* ms */
static int dumplevel = 0;
static int chassisnum = 0;
@@ -207,13 +215,15 @@ dump_endnode(ib_portid_t *path, char *pr
#if __WORDSIZE == 64
fprintf(f, "%s -> %s %s {%016lx} portnum %d lid %d-%d\"%s\"\n",
- portid2str(path), prompt, node->type == SWITCH_NODE ? "switch" : "ca",
+ 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));
#else
fprintf(f, "%s -> %s %s {%016Lx} portnum %d lid %d-%d\"%s\"\n",
- portid2str(path), prompt, node->type == SWITCH_NODE ? "switch" : "ca",
+ 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));
More information about the general
mailing list