[ofa-general] [PATCH] ibnetdiscover - ports report
Erez Strauss
erezs at voltaire.com
Thu Dec 20 20:38:00 PST 2007
Hello IB developers and users,
I would like to get feedback on the following patch to ibnetdiscover.
The patch introduce additional output mode for ibnetdiscover which is
focused on the ports, and print one line for each port with the needed
port information.
The output looks like:
SW 4 18 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 17 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 16 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 15 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 14 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 13 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 9 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 8 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 7 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 6 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 5 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 4 0x0008f104003f0838 4x SDR
'ISR9288/ISR9096 Voltaire sLB-24'
SW 4 1 0x0008f104003f0838 4x SDR - SW 6 3 0x0008f104004005f5 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
SW 4 2 0x0008f104003f0838 4x SDR - SW 7 3 0x0008f104004005f6 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
SW 4 3 0x0008f104003f0838 4x SDR - SW 1 3 0x0008f104004005f7 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
SW 4 10 0x0008f104003f0838 4x SDR - SW 8 3 0x0008f104004006f5 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
SW 4 11 0x0008f104003f0838 4x SDR - SW 9 3 0x0008f104004006f6 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
SW 4 12 0x0008f104003f0838 4x SDR - SW 10 3 0x0008f104004006f7 (
'ISR9288/ISR9096 Voltaire sLB-24' - 'ISR9288 Voltaire sFB-12' )
CA 14 1 0x0008f10403960091 4x SDR - SW 4 20 0x0008f104003f0838 (
'Voltaire HCA400' - 'ISR9288/ISR9096 Voltaire sLB-24' )
CA 11 1 0x0002c90107a4e431 4x SDR - SW 4 19 0x0008f104003f0838 (
'Voltaire HCA400' - 'ISR9288/ISR9096 Voltaire sLB-24' )
CA 2 1 0x0008f1000102d801 4x SDR - SW 1 15 0x0008f104004005f7 (
'Voltaire IB-to-TCP/IP Router' - 'ISR9288 Voltaire
Thanks,
Erez Strauss
Voltaire.
-------------
Date: Thu Dec 20 19:36:14 2007 -0500
Added the -p(orts) option, to generate ports reports
Signed-off-by: Erez Strauss <erezs _at_ voltaire.com>
---
infiniband-diags/src/ibnetdiscover.c | 64
++++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/infiniband-diags/src/ibnetdiscover.c
b/infiniband-diags/src/ibnetdiscover.c
index 8b229c1..3c2e6b6 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -119,6 +119,17 @@ get_linkspeed_str(int linkspeed)
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 "??";
+}
+
int
get_port(Port *port, int portnum, ib_portid_t *portid)
{
@@ -839,11 +850,50 @@ dump_topology(int listtype, int group)
return i;
}
+void dump_ports_report ()
+{
+ 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;
+ }
+ 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%016llx
%s %s",
+ node_type_str2 (port->node),
port->lid, port->portnum,
+ (unsigned long
long)port->portguid,
+
get_linkwidth_str(port->linkwidth), get_linkspeed_str(port->linkspeed));
+ if (port->remoteport)
+ fprintf (stdout, " - %2s %5d %2d
0x%016llx ( '%s' - '%s' )\n",
+ node_type_str2
(port->remoteport->node),
+ port->remoteport->lid,
+
port->remoteport->portnum,
+ (unsigned long
long)port->remoteport->portguid,
+ port->node->nodedesc,
+
port->remoteport->node->nodedesc);
+ else
+ fprintf (stdout, "%36s'%s'\n",
"", port->node->nodedesc);
+ }
+ n++;
+ }
+}
+
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 "
- "-t(imeout) timeout_ms --node-name-map
node-name-map] [<topology-file>]\n",
+ "-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");
exit(-1);
@@ -858,8 +908,9 @@ main(int argc, char **argv)
char *ca = 0;
int ca_port = 0;
int group = 0;
+ int ports_report = 0;
- static char const str_opts[] = "C:P:t:devslgHSRVhu";
+ static char const str_opts[] = "C:P:t:devslgHSRpVhu";
static const struct option long_opts[] = {
{ "C", 1, 0, 'C'},
{ "P", 1, 0, 'P'},
@@ -874,6 +925,7 @@ main(int argc, char **argv)
{ "Router_list", 0, 0, 'R'},
{ "timeout", 1, 0, 't'},
{ "node-name-map", 1, 0, 1},
+ { "ports", 0, 0, 'p'},
{ "Version", 0, 0, 'V'},
{ "help", 0, 0, 'h'},
{ "usage", 0, 0, 'u'},
@@ -935,6 +987,9 @@ main(int argc, char **argv)
case 'V':
fprintf(stderr, "%s %s\n", argv0,
get_build_version() );
exit(-1);
+ case 'p':
+ ports_report = 1;
+ break;
default:
usage();
break;
@@ -955,7 +1010,10 @@ main(int argc, char **argv)
if (group)
chassis = group_nodes();
- dump_topology(list, group);
+ if (ports_report)
+ dump_ports_report ();
+ else
+ dump_topology(list, group);
close_node_name_map(node_name_map);
exit(0);
-------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071220/b30e6788/attachment.html>
More information about the general
mailing list