[ofa-general] [PATCH] Add -C <ca_name> and -P <ca_port> to ibprint[ca|rt|switch].pl

Ira Weiny weiny2 at llnl.gov
Fri Jan 18 16:37:36 PST 2008


>From 5b2317bf383d22e9ccb87d3c1d24735b3e508ab4 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Fri, 18 Jan 2008 16:21:28 -0800
Subject: [PATCH] Add -C <ca_name> and -P <ca_port> to ibprint[ca|rt|switch].pl


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/scripts/ibprintca.pl     |   16 ++++++++++++----
 infiniband-diags/scripts/ibprintrt.pl     |   16 ++++++++++++----
 infiniband-diags/scripts/ibprintswitch.pl |   16 ++++++++++++----
 3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/infiniband-diags/scripts/ibprintca.pl b/infiniband-diags/scripts/ibprintca.pl
index d311422..271b324 100755
--- a/infiniband-diags/scripts/ibprintca.pl
+++ b/infiniband-diags/scripts/ibprintca.pl
@@ -49,25 +49,33 @@ sub usage_and_exit
    print "   print only the ca specified from the ibnetdiscover output\n";
    print "   -R Recalculate ibnetdiscover information\n";
    print "   -l list cas\n";
+   print "   -C <ca_name> use selected channel adaptor name for queries\n";
+   print "   -P <ca_port> use selected channel adaptor port for queries\n";
    exit 0;
 }
 
 my $argv0 = `basename $0`;
 my $regenerate_map = undef;
 my $list_hcas = undef;
+my $ca_name = "";
+my $ca_port = "";
 chomp $argv0;
-if (!getopts("hRl")) { usage_and_exit $argv0; }
+if (!getopts("hRlC:P:")) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
 if (defined $Getopt::Std::opt_l) { $list_hcas = $Getopt::Std::opt_l; }
+if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
+if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
 
 my $target_hca = $ARGV[0];
 
-if ($regenerate_map || !(-f "$IBswcountlimits::cache_dir/ibnetdiscover.topology")) { generate_ibnetdiscover_topology; }
+my $cache_file = get_cache_file($ca_name, $ca_port);
+
+if ($regenerate_map || !(-f "$cache_file")) { generate_ibnetdiscover_topology($ca_name, $ca_port); }
 
 if ($list_hcas)
 {
-   system ("ibhosts $IBswcountlimits::cache_dir/ibnetdiscover.topology");
+   system ("ibhosts $cache_file");
    exit 1;
 }
 
@@ -81,7 +89,7 @@ if ($target_hca eq "")
 sub main
 {
    my $found_hca = undef;
-   open IBNET_TOPO, "<$IBswcountlimits::cache_dir/ibnetdiscover.topology" or die "Failed to open ibnet topology\n";
+   open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
    my $in_hca = "no";
    my %ports = undef;
    while (my $line = <IBNET_TOPO>)
diff --git a/infiniband-diags/scripts/ibprintrt.pl b/infiniband-diags/scripts/ibprintrt.pl
index d76b767..7f979e9 100755
--- a/infiniband-diags/scripts/ibprintrt.pl
+++ b/infiniband-diags/scripts/ibprintrt.pl
@@ -49,25 +49,33 @@ sub usage_and_exit
    print "   print only the rt specified from the ibnetdiscover output\n";
    print "   -R Recalculate ibnetdiscover information\n";
    print "   -l list rts\n";
+   print "   -C <ca_name> use selected channel adaptor name for queries\n";
+   print "   -P <ca_port> use selected channel adaptor port for queries\n";
    exit 0;
 }
 
 my $argv0 = `basename $0`;
 my $regenerate_map = undef;
 my $list_rts = undef;
+my $ca_name = "";
+my $ca_port = "";
 chomp $argv0;
-if (!getopts("hRl")) { usage_and_exit $argv0; }
+if (!getopts("hRlC:P:")) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
 if (defined $Getopt::Std::opt_l) { $list_rts = $Getopt::Std::opt_l; }
+if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
+if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
 
 my $target_rt = $ARGV[0];
 
-if ($regenerate_map || !(-f "$IBswcountlimits::cache_dir/ibnetdiscover.topology")) { generate_ibnetdiscover_topology; }
+my $cache_file = get_cache_file($ca_name, $ca_port);
+
+if ($regenerate_map || !(-f "$cache_file")) { generate_ibnetdiscover_topology($ca_name, $ca_port); }
 
 if ($list_rts)
 {
-   system ("ibrouters $IBswcountlimits::cache_dir/ibnetdiscover.topology");
+   system ("ibrouters $cache_file");
    exit 1;
 }
 
@@ -81,7 +89,7 @@ if ($target_rt eq "")
 sub main
 {
    my $found_rt = undef;
-   open IBNET_TOPO, "<$IBswcountlimits::cache_dir/ibnetdiscover.topology" or die "Failed to open ibnet topology\n";
+   open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
    my $in_rt = "no";
    my %ports = undef;
    while (my $line = <IBNET_TOPO>)
diff --git a/infiniband-diags/scripts/ibprintswitch.pl b/infiniband-diags/scripts/ibprintswitch.pl
index 5ab8f65..d28a839 100755
--- a/infiniband-diags/scripts/ibprintswitch.pl
+++ b/infiniband-diags/scripts/ibprintswitch.pl
@@ -48,25 +48,33 @@ sub usage_and_exit
    print "   print only the switch specified from the ibnetdiscover output\n";
    print "   -R Recalculate ibnetdiscover information\n";
    print "   -l list switches\n";
+   print "   -C <ca_name> use selected channel adaptor name for queries\n";
+   print "   -P <ca_port> use selected channel adaptor port for queries\n";
    exit 0;
 }
 
 my $argv0 = `basename $0`;
 my $regenerate_map = undef;
 my $list_switches = undef;
+my $ca_name = "";
+my $ca_port = "";
 chomp $argv0;
-if (!getopts("hRl")) { usage_and_exit $argv0; }
+if (!getopts("hRlC:P:")) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
 if (defined $Getopt::Std::opt_l) { $list_switches = $Getopt::Std::opt_l; }
+if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
+if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
 
 my $target_switch = $ARGV[0];
 
-if ($regenerate_map || !(-f "$IBswcountlimits::cache_dir/ibnetdiscover.topology")) { generate_ibnetdiscover_topology; }
+my $cache_file = get_cache_file($ca_name, $ca_port);
+
+if ($regenerate_map || !(-f "$cache_file")) { generate_ibnetdiscover_topology($ca_name, $ca_port); }
 
 if ($list_switches)
 {
-   system ("ibswitches $IBswcountlimits::cache_dir/ibnetdiscover.topology");
+   system ("ibswitches $cache_file");
    exit 1;
 }
 
@@ -80,7 +88,7 @@ if ($target_switch eq "")
 sub main
 {
    my $found_switch = undef;
-   open IBNET_TOPO, "<$IBswcountlimits::cache_dir/ibnetdiscover.topology" or die "Failed to open ibnet topology\n";
+   open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
    my $in_switch = "no";
    my %ports = undef;
    while (my $line = <IBNET_TOPO>)
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-C-ca_name-and-P-ca_port-to-ibprint-ca-rt-s.patch
Type: application/octet-stream
Size: 6561 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080118/709f0737/attachment.obj>


More information about the general mailing list