[ofa-general] [PATCH] opensm: diags add DR path support to some utils

Timothy A. Meier meier3 at llnl.gov
Thu Jan 24 14:59:18 PST 2008


Sasha,

At LLNL, we find these -D options useful (some diagnostic messages give us only direct paths).

 From 3c681566514f0c948cfb5002f7536af9ca563e33 Mon Sep 17 00:00:00 2001
From: Tim Meier <meier3 at llnl.gov>
Date: Thu, 24 Jan 2008 14:49:02 -0800
Subject: [PATCH] opensm: diags add DR path support to some utils

Added direct route support to iblinkinfo.pl and ibqueryerrors.pl.

Signed-off-by: Tim Meier <meier3 at llnl.gov>
---
  infiniband-diags/scripts/IBswcountlimits.pm |   51 +++++++++++++++++++++++++++
  infiniband-diags/scripts/iblinkinfo.pl      |   12 +++++-
  infiniband-diags/scripts/ibqueryerrors.pl   |   12 +++++-
  3 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/infiniband-diags/scripts/IBswcountlimits.pm b/infiniband-diags/scripts/IBswcountlimits.pm
index 6985750..1ada8a8 100755
--- a/infiniband-diags/scripts/IBswcountlimits.pm
+++ b/infiniband-diags/scripts/IBswcountlimits.pm
@@ -373,3 +373,54 @@ sub get_num_ports
          return ($num_ports);
  }

+# =========================================================================
+# convert_dr_to_guid(direct_route)
+#
+sub convert_dr_to_guid
+{
+        my $guid = undef;
+
+        my $data = `smpquery nodeinfo -D $_[0]`;
+        my @lines = split("\n", $data);
+        foreach my $line (@lines) {
+                if ($line =~ /^PortGuid:\.+(.*)/) { $guid = $1; }
+        }
+        $guid;
+}
+
+# =========================================================================
+# get_node_type(guid_or_direct_route)
+#
+sub get_node_type
+{
+    my $type = undef;
+       my $query_arg = "smpquery nodeinfo ";
+    if($_[0] =~ /x/)
+       {
+         # assume arg is a guid if contains an x
+         $query_arg .= "-G " . $_[0];
+       }
+       else
+       {
+      # assume arg is a direct path
+         $query_arg .= "-D " . $_[0];
+       }
+
+    my $data = `$query_arg`;
+    my @lines = split("\n", $data);
+    foreach my $line (@lines)
+    {
+       if ($line =~ /^NodeType:\.+(.*)/) { $type = $1; }
+    }
+    $type;
+}
+
+# =========================================================================
+# is_switch(guid_or_direct_route)
+#
+sub is_switch
+{
+       my $node_type = &get_node_type($_[0]);
+    ($node_type =~ /Switch/);
+}
+
diff --git a/infiniband-diags/scripts/iblinkinfo.pl b/infiniband-diags/scripts/iblinkinfo.pl
index 6d02eac..f21c31c 100755
--- a/infiniband-diags/scripts/iblinkinfo.pl
+++ b/infiniband-diags/scripts/iblinkinfo.pl
@@ -43,10 +43,11 @@ use IBswcountlimits;
  sub usage_and_exit
  {
     my $prog = $_[0];
-   print "Usage: $prog [-Rhclp -S <guid> -C <ca_name> -P <ca_port>]\n";
+   print "Usage: $prog [-Rhclp -S <guid> -D <direct route> -C <ca_name> -P <ca_port>]\n";
     print "   Report link speed and connection for each port of each switch which is active\n";
     print "   -h This help message\n";
     print "   -R Recalculate ibnetdiscover information (Default is to reuse ibnetdiscover output)\n";
+   print "   -D <direct route> output only the switch specified by direct route path\n";
     print "   -S <guid> output only the switch specified by guid\n";
     print "   -d print only down links\n";
     print "   -l (line mode) print all information for each link on each line\n";
@@ -60,6 +61,7 @@ sub usage_and_exit
  my $argv0 = `basename $0`;
  my $regenerate_map = undef;
  my $single_switch = undef;
+my $direct_route = undef;
  my $line_mode = undef;
  my $print_add_switch = undef;
  my $print_extended_cap = undef;
@@ -68,8 +70,9 @@ my $ca_name = "";
  my $ca_port = "";
  chomp $argv0;

-if (!getopts("hcpldRS:C:P:")) { usage_and_exit $argv0; }
+if (!getopts("hcpldRS:D:C:P:")) { usage_and_exit $argv0; }
  if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
+if (defined $Getopt::Std::opt_D) { $direct_route = $Getopt::Std::opt_D; }
  if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
  if (defined $Getopt::Std::opt_S) { $single_switch = $Getopt::Std::opt_S; }
  if (defined $Getopt::Std::opt_d) { $only_down_links = $Getopt::Std::opt_d; }
@@ -84,6 +87,11 @@ my $extra_smpquery_params = get_ca_name_port_param_string($ca_name, $ca_port);
  sub main
  {
     get_link_ends($regenerate_map, $ca_name, $ca_port);
+   if ($direct_route)
+   {
+       # convert DR to guid, then use original single_switch option
+       $single_switch = $IBswcountlimits::convert_dr_to_guid{$direct_route};
+   }
     foreach my $switch (sort (keys (%IBswcountlimits::link_ends))) {
        if ($single_switch && $switch ne $single_switch)
        {
diff --git a/infiniband-diags/scripts/ibqueryerrors.pl b/infiniband-diags/scripts/ibqueryerrors.pl
index bdb458d..ca899c7 100755
--- a/infiniband-diags/scripts/ibqueryerrors.pl
+++ b/infiniband-diags/scripts/ibqueryerrors.pl
@@ -136,13 +136,14 @@ sub get_switches
  sub usage_and_exit
  {
     my $prog = $_[0];
-   print "Usage: $prog [-a -c -r -R -s <err1,err2,...> -S <switch_guid> -d -C <ca_name> -P <ca_port>]\n";
+   print "Usage: $prog [-a -c -r -R -s <err1,err2,...> -S <switch_guid> -D <direct route> -d -C <ca_name> -P <ca_port>]\n";
     print "   Report counters on all switches in subnet\n";
     print "   -a Report an action to take\n";
     print "   -c suppress some of the common counters\n";
     print "   -r report port configuration information\n";
     print "   -R Recalculate ibnetdiscover information\n";
     print "   -s <err1,err2,...> suppress errors listed\n";
+   print "   -D <direct route> output only the switch specified by direct route path\n";
     print "   -S <switch_guid> query only <switch_guid>\n";
     print "   -d include the data counters in the output\n";
     print "   -C <ca_name> use selected Channel Adaptor name for queries\n";
@@ -153,11 +154,12 @@ sub usage_and_exit
  my $argv0 = `basename $0`;
  my $regenerate_map = undef;
  my $single_switch = undef;
+my $direct_route = undef;
  my $ca_name = "";
  my $ca_port = "";

  chomp $argv0;
-if (!getopts("has:crRS:dC:P:")) { usage_and_exit $argv0; }
+if (!getopts("has:crRS:D:dC:P:")) { usage_and_exit $argv0; }
  if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
  if (defined $Getopt::Std::opt_a) { $print_action = "yes"; }
  if (defined $Getopt::Std::opt_s) { @IBswcountlimits::suppress_errors = split (",", $Getopt::Std::opt_s); }
@@ -167,6 +169,7 @@ if (defined $Getopt::Std::opt_c)
  }
  if (defined $Getopt::Std::opt_r) { $report_port_info = $Getopt::Std::opt_r; }
  if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
+if (defined $Getopt::Std::opt_D) { $direct_route = $Getopt::Std::opt_D; }
  if (defined $Getopt::Std::opt_S) { $single_switch = $Getopt::Std::opt_S; }
  if (defined $Getopt::Std::opt_d) { $include_data_counters = $Getopt::Std::opt_d; }
  if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
@@ -183,6 +186,11 @@ sub main
     }
     get_link_ends($regenerate_map, $ca_name, $ca_port);
     get_switches;
+   if ($direct_route)
+   {
+       # convert DR to guid, then use original single_switch option
+       $single_switch = $IBswcountlimits::convert_dr_to_guid{$direct_route};
+   }
     foreach my $sw_addr (keys %switches) {
        if ($single_switch && $sw_addr ne "$single_switch") { next; }

--
1.5.1



-- 
Timothy A. Meier
Computer Scientist
ICCD/High Performance Computing
925.422.3341
meier3 at llnl.gov
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0002-opensm-diags-add-DR-path-support-to-some-utils.patch
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080124/58941412/attachment.ksh>


More information about the general mailing list