[ofa-general] [PATCH] infiniband-diags: Add common flags -P, -C, and -t

davem at systemfabricworks.com davem at systemfabricworks.com
Tue Jul 31 13:39:27 PDT 2007



   Add common flags -P, -C, and -t to infiniband-diags programs and scripts to
   allow specifying the HCA port number, HCA device name, and query timeout.
   These diagnostic programs can now be directed to either different fabrics
   attached to the system, or forced to use different ports should the fabric
   fail and comparisons are needed.

   Two of these had conflicting prior use of the flags.  For the ibcheckerrs
   script, -T is now used to specify the threshold file.  In the saquery
   program, -p and -c are now used to specify getting the PathRecord info
   and getting the SA's class port info.

   Other than the resolution of the three conflicts, all comands behave exactly
   the same as they did before the change if these common flags are not used.

Signed-off-by: David A. McMillen <davem at systemfabricworks.com>
---
 infiniband-diags/man/dump_lfts.8             |   12 +++++-
 infiniband-diags/man/dump_mfts.8             |   13 ++++++-
 infiniband-diags/man/ibcheckerrors.8         |    9 ++++-
 infiniband-diags/man/ibcheckerrs.8           |   15 ++++++-
 infiniband-diags/man/ibchecknet.8            |    9 ++++-
 infiniband-diags/man/ibchecknode.8           |    9 ++++-
 infiniband-diags/man/ibcheckport.8           |    9 ++++-
 infiniband-diags/man/ibcheckportstate.8      |    9 ++++-
 infiniband-diags/man/ibcheckportwidth.8      |    9 ++++-
 infiniband-diags/man/ibcheckstate.8          |    9 ++++-
 infiniband-diags/man/ibcheckwidth.8          |   12 +++++-
 infiniband-diags/man/ibclearcounters.8       |   11 ++++-
 infiniband-diags/man/ibclearerrors.8         |   11 ++++-
 infiniband-diags/man/ibdatacounters.8        |    8 +++-
 infiniband-diags/man/ibdatacounts.8          |    9 ++++-
 infiniband-diags/man/ibhosts.8               |   12 +++++-
 infiniband-diags/man/ibnodes.8               |   12 +++++-
 infiniband-diags/man/ibrouters.8             |   12 +++++-
 infiniband-diags/man/ibswitches.8            |   12 +++++-
 infiniband-diags/man/saquery.8               |   15 ++++++-
 infiniband-diags/scripts/dump_lfts.sh        |   49 ++++++++++++++++++----
 infiniband-diags/scripts/dump_mfts.sh        |   49 ++++++++++++++++++----
 infiniband-diags/scripts/ibcheckerrors.in    |   34 ++++++++++++----
 infiniband-diags/scripts/ibcheckerrs.in      |   27 ++++++++++---
 infiniband-diags/scripts/ibchecknet.in       |   36 ++++++++++++----
 infiniband-diags/scripts/ibchecknode.in      |   22 ++++++++--
 infiniband-diags/scripts/ibcheckport.in      |   22 ++++++++--
 infiniband-diags/scripts/ibcheckportstate.in |   22 ++++++++--
 infiniband-diags/scripts/ibcheckportwidth.in |   22 ++++++++--
 infiniband-diags/scripts/ibcheckstate.in     |   32 +++++++++++---
 infiniband-diags/scripts/ibcheckwidth.in     |   32 +++++++++++---
 infiniband-diags/scripts/ibclearcounters.in  |   32 +++++++++++---
 infiniband-diags/scripts/ibclearerrors.in    |   30 +++++++++++---
 infiniband-diags/scripts/ibdatacounters.in   |   34 ++++++++++++----
 infiniband-diags/scripts/ibdatacounts.in     |   25 +++++++++--
 infiniband-diags/scripts/ibhosts.in          |   30 +++++++++++--
 infiniband-diags/scripts/ibnodes.in          |    2 +-
 infiniband-diags/scripts/ibrouters.in        |   30 +++++++++++--
 infiniband-diags/scripts/ibswitches.in       |   30 +++++++++++--
 infiniband-diags/src/saquery.c               |   56 ++++++++++++++++++++------
 40 files changed, 680 insertions(+), 153 deletions(-)

diff --git a/infiniband-diags/man/dump_lfts.8 b/infiniband-diags/man/dump_lfts.8
index c1458b3..091de41 100644
--- a/infiniband-diags/man/dump_lfts.8
+++ b/infiniband-diags/man/dump_lfts.8
@@ -5,7 +5,8 @@ dump_lfts.sh \- dump InfiniBand unicast forwarding tables
 
 .SH SYNOPSIS
 .B dump_lfts.sh
-[\-h] [\-D] [>/path/to/dump-file]
+[\-h] [\-D] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [>/path/to/dump-file]
+
 
 .SH DESCRIPTION
 .PP
@@ -24,6 +25,15 @@ dump forwarding tables using direct routed rather than LID routed SMPs
 .TP
 \fB\-h\fR
 show help
+.TP
+\fB\-C\fR <ca_name>
+use the specified ca_name.
+.TP
+\fB\-P\fR <ca_port>
+use the specified ca_port.
+.TP
+\fB\-t\fR <timeout_ms>
+override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR dump_mfts(8),
diff --git a/infiniband-diags/man/dump_mfts.8 b/infiniband-diags/man/dump_mfts.8
index fc8bc2e..90dd2ac 100644
--- a/infiniband-diags/man/dump_mfts.8
+++ b/infiniband-diags/man/dump_mfts.8
@@ -5,7 +5,8 @@ dump_lfts.sh \- dump InfiniBand multicast forwarding tables
 
 .SH SYNOPSIS
 .B dump_mfts.sh
-[\-h] [\-D] [>/path/to/file]
+[\-h] [\-D] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms]
+[>/path/to/file]
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +22,16 @@ dump forwarding tables using direct routed rather than LID routed SMPs
 .TP
 \fB\-h\fR
 show help
+.TP
+\fB\-C\fR <ca_name>
+use the specified ca_name.
+.TP
+\fB\-P\fR <ca_port>
+use the specified ca_port.
+.TP
+\fB\-t\fR <timeout_ms>
+override the default timeout for the solicited mads.
+
 
 .SH SEE ALSO
 .BR dump_lfts(8),
diff --git a/infiniband-diags/man/ibcheckerrors.8 b/infiniband-diags/man/ibcheckerrors.8
index 489d531..15b646f 100644
--- a/infiniband-diags/man/ibcheckerrors.8
+++ b/infiniband-diags/man/ibcheckerrors.8
@@ -5,7 +5,8 @@ ibcheckerrors \- validate IB subnet and report errors
 
 .SH SYNOPSIS
 .B ibcheckerrors
-[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name
+\-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +22,12 @@ errors (from port counters).
      not what they are.
 .PP
 \-N | \-nocolor	use mono rather than color mode
+.PP
+\-C <ca_name>   use the specified ca_name.
+.PP
+\-P <ca_port>   use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibcheckerrs.8 b/infiniband-diags/man/ibcheckerrs.8
index 7b22163..f901889 100644
--- a/infiniband-diags/man/ibcheckerrs.8
+++ b/infiniband-diags/man/ibcheckerrs.8
@@ -5,7 +5,10 @@ ibcheckerrs \- validate IB port (or node) and report errors in counters above th
 
 .SH SYNOPSIS
 .B ibcheckerrs
-[\-h] [\-b] [\-v] [\-G] [\-t <threshold_file>] [\-s(how_thresholds)] [\-N | \-nocolor] <lid|guid> <port>
+[\-h] [\-b] [\-v] [\-G] [\-T <threshold_file>] [\-s(how_thresholds)]
+[\-N | \-nocolor] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms]
+<lid|guid> <port>
+
 
 .SH DESCRIPTION
 .PP
@@ -23,7 +26,7 @@ specified using the -t <file> option.
 .PP
 \-s      show predefined thresholds
 .PP
-\-t      use specified threshold file
+\-T      use specified threshold file
 .PP
 \-v      increase the verbosity level
 .PP
@@ -31,6 +34,12 @@ specified using the -t <file> option.
         present, not what they are.
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
@@ -38,7 +47,7 @@ ibcheckerrs 2           # check aggregated node counter for lid 2
 .PP
 ibcheckerrs 2   4       # check port counters for lid 2 port 4
 .PP
-ibcheckerrs -t xxx 2    # check node using xxx threshold file
+ibcheckerrs -T xxx 2    # check node using xxx threshold file
 
 .SH SEE ALSO
 .BR perfquery(8),
diff --git a/infiniband-diags/man/ibchecknet.8 b/infiniband-diags/man/ibchecknet.8
index ddeccc8..375427b 100644
--- a/infiniband-diags/man/ibchecknet.8
+++ b/infiniband-diags/man/ibchecknet.8
@@ -5,7 +5,8 @@ ibchecknet \- validate IB subnet and report errors
 
 .SH SYNOPSIS
 .B ibchecknet
-[\-h] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
+\-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -16,6 +17,12 @@ reports errors (from port counters).
 .SH OPTIONS
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibchecknode.8 b/infiniband-diags/man/ibchecknode.8
index ad1e88b..ecd8bf9 100644
--- a/infiniband-diags/man/ibchecknode.8
+++ b/infiniband-diags/man/ibchecknode.8
@@ -5,7 +5,8 @@ ibchecknode \- validate IB node and report errors
 
 .SH SYNOPSIS
 .B ibchecknode
-[\-h] [\-v] [\-N | \-nocolor] [\-G] <lid|guid>
+[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
+[\-t(imeout) timeout_ms] <lid|guid>
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +22,12 @@ Port address is a lid unless -G option is used to specify a GUID address.
 \-v      increase the verbosity level
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
diff --git a/infiniband-diags/man/ibcheckport.8 b/infiniband-diags/man/ibcheckport.8
index 3a18f21..08166c3 100644
--- a/infiniband-diags/man/ibcheckport.8
+++ b/infiniband-diags/man/ibcheckport.8
@@ -5,7 +5,8 @@ ibcheckport \- validate IB port and report errors
 
 .SH SYNOPSIS
 .B ibcheckport
-[\-h] [\-v] [\-N | \-nocolor] [\-G] <lid|guid> <port>
+[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
+[\-t(imeout) timeout_ms]  <lid|guid> <port>
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +22,12 @@ Port address is a lid unless -G option is used to specify a GUID address.
 \-v      increase the verbosity level
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
diff --git a/infiniband-diags/man/ibcheckportstate.8 b/infiniband-diags/man/ibcheckportstate.8
index 139da57..4c70f16 100644
--- a/infiniband-diags/man/ibcheckportstate.8
+++ b/infiniband-diags/man/ibcheckportstate.8
@@ -5,7 +5,8 @@ ibcheckportstate \- validate IB port for LinkUp and not Active state
 
 .SH SYNOPSIS
 .B ibcheckportstate
-[\-h] [\-v] [\-N | \-nocolor] [\-G] <lid|guid> <port>
+[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
+[\-t(imeout) timeout_ms] <lid|guid> <port>
 
 .SH DESCRIPTION
 .PP
@@ -22,6 +23,12 @@ Port address is a lid unless -G option is used to specify a GUID address.
 \-v      increase the verbosity level
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
diff --git a/infiniband-diags/man/ibcheckportwidth.8 b/infiniband-diags/man/ibcheckportwidth.8
index 304e345..541be8a 100644
--- a/infiniband-diags/man/ibcheckportwidth.8
+++ b/infiniband-diags/man/ibcheckportwidth.8
@@ -5,7 +5,8 @@ ibcheckportwidth \- validate IB port for 1x link width
 
 .SH SYNOPSIS
 .B ibcheckport
-[\-h] [\-v] [\-N | \-nocolor] [\-G] <lid|guid> <port>
+[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
+[\-t(imeout) timeout_ms]  <lid|guid> <port>
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +22,12 @@ Port address is a lid unless -G option is used to specify a GUID address.
 \-v      increase the verbosity level
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
diff --git a/infiniband-diags/man/ibcheckstate.8 b/infiniband-diags/man/ibcheckstate.8
index 5cb41c9..e718979 100644
--- a/infiniband-diags/man/ibcheckstate.8
+++ b/infiniband-diags/man/ibcheckstate.8
@@ -5,7 +5,8 @@ ibcheckstate \- find ports in IB subnet which are link up but not active
 
 .SH SYNOPSIS
 .B ibcheckstate
-[\-h] [\-v] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
+\-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -17,6 +18,12 @@ a port physical state other than LinkUp.
 .SH OPTIONS
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibcheckwidth.8 b/infiniband-diags/man/ibcheckwidth.8
index 5a3b1df..da9a70b 100644
--- a/infiniband-diags/man/ibcheckwidth.8
+++ b/infiniband-diags/man/ibcheckwidth.8
@@ -5,7 +5,9 @@ ibcheckwidth \- find 1x links in IB subnet
 
 .SH SYNOPSIS
 .B ibcheckwidth
-[\-h] [\-v] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name
+\-P ca_port \-t(imeout) timeout_ms]
+
 
 .SH DESCRIPTION
 .PP
@@ -15,7 +17,13 @@ reports any 1x links.
 
 .SH OPTIONS
 .PP
-\-N | \-nocolor use mono rather than color mode
+\-N | \-nocolor  use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibclearcounters.8 b/infiniband-diags/man/ibclearcounters.8
index 96ed8fa..d14e038 100644
--- a/infiniband-diags/man/ibclearcounters.8
+++ b/infiniband-diags/man/ibclearcounters.8
@@ -5,7 +5,8 @@ ibclearcounters \- clear port counters in IB subnet
 
 .SH SYNOPSIS
 .B ibclearcounters
-[\-h] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-N | \-nocolor] [<topology-file> | \-C ca_name
+\-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -14,7 +15,13 @@ the IB subnet topology or using an already saved topology file.
 
 .SH OPTIONS
 .PP
-\-N | \-nocolor use mono rather than color mode
+\-N | \-nocolor  use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibclearerrors.8 b/infiniband-diags/man/ibclearerrors.8
index 6479f9c..58f73d9 100644
--- a/infiniband-diags/man/ibclearerrors.8
+++ b/infiniband-diags/man/ibclearerrors.8
@@ -5,7 +5,8 @@ ibclearerrors \- clear error counters in IB subnet
 
 .SH SYNOPSIS
 .B ibclearerrors
-[\-h] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
+\-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -15,7 +16,13 @@ file.
 
 .SH OPTIONS
 .PP
-\-N | \-nocolor use mono rather than color mode
+\-N | \-nocolor  use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibdatacounters.8 b/infiniband-diags/man/ibdatacounters.8
index 7d562a0..309a8f2 100644
--- a/infiniband-diags/man/ibdatacounters.8
+++ b/infiniband-diags/man/ibdatacounters.8
@@ -5,7 +5,7 @@ ibdatacounters \- query IB subnet for data counters
 
 .SH SYNOPSIS
 .B ibdatacounters
-[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file>]
+[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
@@ -21,6 +21,12 @@ the data counters (from port counters).
      not what they are.
 .PP
 \-N | \-nocolor	use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH SEE ALSO
 .BR ibnetdiscover(8),
diff --git a/infiniband-diags/man/ibdatacounts.8 b/infiniband-diags/man/ibdatacounts.8
index 8a731a6..8b995f8 100644
--- a/infiniband-diags/man/ibdatacounts.8
+++ b/infiniband-diags/man/ibdatacounts.8
@@ -5,7 +5,8 @@ ibdatacounts \- get IB port data counters
 
 .SH SYNOPSIS
 .B ibdatacounts
-[\-h] [\-b] [\-v] [\-G] [\-N | \-nocolor] <lid|guid> [<port>]
+[\-h] [\-b] [\-v] [\-G] [\-N | \-nocolor] [\-C ca_name] [\-P ca_port]
+[\-t(imeout) timeout_ms] <lid|guid> [<port>]
 
 .SH DESCRIPTION
 .PP
@@ -24,6 +25,12 @@ address.
 \-b      brief mode
 .PP
 \-N | \-nocolor use mono rather than color mode
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 
 .SH EXAMPLE
 .PP
diff --git a/infiniband-diags/man/ibhosts.8 b/infiniband-diags/man/ibhosts.8
index 31788fc..9d7fe9a 100644
--- a/infiniband-diags/man/ibhosts.8
+++ b/infiniband-diags/man/ibhosts.8
@@ -5,13 +5,23 @@ ibhosts \- show InfiniBand host nodes in topology
 
 .SH SYNOPSIS
 .B ibhosts
-[\-h] [<topology-file>]
+[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
 ibhosts is a script which either walks the IB subnet topology or uses an 
 already saved topology file and extracts the CA nodes.
 
+.SH OPTIONS
+.PP
+\-h      show the usage message
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
+
 .SH SEE ALSO
 .BR ibnetdiscover(8)
 
diff --git a/infiniband-diags/man/ibnodes.8 b/infiniband-diags/man/ibnodes.8
index fdd394c..dc59ca2 100644
--- a/infiniband-diags/man/ibnodes.8
+++ b/infiniband-diags/man/ibnodes.8
@@ -5,14 +5,24 @@ ibnodes \- show InfiniBand nodes in topology
 
 .SH SYNOPSIS
 .B ibnodes
-[<topology-file>]
+[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
 ibnodes is a script which either walks the IB subnet topology or uses an 
 already saved topology file and extracts the IB nodes (CAs and switches).
 
+.SH OPTIONS
+.PP
+\-h      show the usage message
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
 .SH SEE ALSO
+
 .BR ibnetdiscover(8)
 
 .SH AUTHOR
diff --git a/infiniband-diags/man/ibrouters.8 b/infiniband-diags/man/ibrouters.8
index 068a2d9..698e0ee 100644
--- a/infiniband-diags/man/ibrouters.8
+++ b/infiniband-diags/man/ibrouters.8
@@ -5,13 +5,23 @@ ibrouters \- show InfiniBand router nodes in topology
 
 .SH SYNOPSIS
 .B ibrouters
-[\-h] [<topology-file>]
+[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
 ibrouters is a script which either walks the IB subnet topology or uses an 
 already saved topology file and extracts the Rt nodes.
 
+.SH OPTIONS
+.PP
+\-h      show the usage message
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
+
 .SH SEE ALSO
 .BR ibnetdiscover(8)
 
diff --git a/infiniband-diags/man/ibswitches.8 b/infiniband-diags/man/ibswitches.8
index c9d3650..0929240 100644
--- a/infiniband-diags/man/ibswitches.8
+++ b/infiniband-diags/man/ibswitches.8
@@ -5,13 +5,23 @@ ibswitches\- show InfiniBand switch nodes in topology
 
 .SH SYNOPSIS
 .B ibswitches
-[\-h] [<topology-file>]
+[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
 
 .SH DESCRIPTION
 .PP
 ibswitches is a script which either walks the IB subnet topology or uses an 
 already saved topology file and extracts the switch nodes.
 
+.SH OPTIONS
+.PP
+\-h      show the usage message
+.PP
+\-C <ca_name>    use the specified ca_name.
+.PP
+\-P <ca_port>    use the specified ca_port.
+.PP
+\-t <timeout_ms> override the default timeout for the solicited mads.
+
 .SH SEE ALSO
 .BR ibnetdiscover(8)
 
diff --git a/infiniband-diags/man/saquery.8 b/infiniband-diags/man/saquery.8
index 535851f..5558cc9 100644
--- a/infiniband-diags/man/saquery.8
+++ b/infiniband-diags/man/saquery.8
@@ -5,7 +5,10 @@ saquery \- query InfiniBand subnet administration attributes
 
 .SH SYNOPSIS
 .B saquery 
-[\-h] [\-d] [\-P] [\-N] [\-\-list | \-D] [\-S] [\-I] [\-L] [\-l] [\-G] [\-C] [\-s] [\-g] [\-m] [--src-to-dst <src:dst>] [\-t(imeout) <msec>] [\-\-switch\-map <switch-map>] [<name> | <lid> | <guid>]
+[\-h] [\-d] [\-p] [\-N] [\-\-list | \-D] [\-S] [\-I] [\-L] [\-l] [\-G] [\-O]
+[\-U] [\-c] [\-s] [\-g] [\-m] [--src-to-dst <src:dst>] [\-C ca_name]
+[\-P ca_port] [\-t(imeout) <msec>] [\-\-switch\-map <switch-map>]
+[<name> | <lid> | <guid>]
 
 .SH DESCRIPTION
 .PP
@@ -15,7 +18,7 @@ saquery issues the selected SA query. Node records are queried by default.
 
 .PP
 .TP
-\fB\-P\fR
+\fB\-p\fR
 get PathRecord info
 .TP
 \fB\-N\fR
@@ -45,7 +48,7 @@ return the name for the Lid specified
 \fB\-U\fR
 return the name for the Guid specified
 .TP
-\fB\-C\fR
+\fB\-c\fR
 get the SA's class port info
 .TP
 \fB\-s\fR
@@ -63,6 +66,12 @@ description for each entry. Example: saquery -m 0xc000
 get a PathRecord for <src:dst>
 where src and dst are either node names or LIDs
 .TP
+\fB\-C\fR <ca_name>
+use the specified ca_name.
+.TP
+\fB\-P\fR <ca_port>
+use the specified ca_port.
+.TP
 \fB\-t\fR, \fB\-timeout\fR <msec>
 Specify SA query response timeout in milliseconds.
 Default is 100 milliseconds. You may want to use
diff --git a/infiniband-diags/scripts/dump_lfts.sh b/infiniband-diags/scripts/dump_lfts.sh
index 49e86da..67a307c 100755
--- a/infiniband-diags/scripts/dump_lfts.sh
+++ b/infiniband-diags/scripts/dump_lfts.sh
@@ -7,35 +7,66 @@
 
 usage ()
 {
-	echo "usage: $0 [-D]"
+	echo Usage: `basename $0` "[-h] [-D] [-C ca_name]" \
+	    "[-P ca_port] [-t(imeout) timeout_ms]"
 	exit 2
 }
 
 dump_by_lid ()
 {
-for sw_lid in `ibswitches \
+for sw_lid in `ibswitches $ca_info \
 		| sed -ne 's/^.* lid \([0-9a-f]*\) .*$/\1/p'` ; do
-	ibroute $sw_lid
+	ibroute $ca_info $sw_lid
 done
 }
 
 dump_by_dr_path ()
 {
-for sw_dr in `ibnetdiscover -v \
+for sw_dr in `ibnetdiscover $ca_info -v \
 		| sed -ne '/^DR path .* switch /s/^DR path \[\(.*\)\].*$/\1/p' \
 		| sed -e 's/\]\[/,/g' \
 		| sort -u` ; do
-	ibroute -D ${sw_dr}
+	ibroute $ca_info -D ${sw_dr}
 done
 }
 
+use_d=""
+ca_info=""
 
-if [ "$1" = "-D" ] ; then
+while [ "$1" ]; do
+	case $1 in
+	-D)
+		use_d="-D"
+		;;
+	-h)
+		usage
+		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
+	-*)
+		usage
+		;;
+	*)
+		usage
+		;;
+	esac
+	shift
+done
+
+if [ "$use_d" = "-D" ] ; then
 	dump_by_dr_path
-elif [ -z "$1" ] ; then
-	dump_by_lid
 else
-	usage
+	dump_by_lid
 fi
 
 exit
diff --git a/infiniband-diags/scripts/dump_mfts.sh b/infiniband-diags/scripts/dump_mfts.sh
index 20281e8..39fc5fb 100755
--- a/infiniband-diags/scripts/dump_mfts.sh
+++ b/infiniband-diags/scripts/dump_mfts.sh
@@ -7,35 +7,66 @@
 
 usage ()
 {
-	echo "usage: $0 [-D]"
+	echo Usage: `basename $0` "[-h] [-D] [-C ca_name]" \
+	    "[-P ca_port] [-t(imeout) timeout_ms]"
 	exit 2
 }
 
 dump_by_lid ()
 {
-for sw_lid in `ibswitches \
+for sw_lid in `ibswitches $ca_info \
 		| sed -ne 's/^.* lid \([0-9a-f]*\) .*$/\1/p'` ; do
-	ibroute -M $sw_lid
+	ibroute $ca_info -M $sw_lid
 done
 }
 
 dump_by_dr_path ()
 {
-for sw_dr in `ibnetdiscover -v \
+for sw_dr in `ibnetdiscover $ca_info -v \
 		| sed -ne '/^DR path .* switch /s/^DR path \[\(.*\)\].*$/\1/p' \
 		| sed -e 's/\]\[/,/g' \
 		| sort -u` ; do
-	ibroute -D ${sw_dr}
+	ibroute $ca_info -M -D ${sw_dr}
 done
 }
 
+use_d=""
+ca_info=""
 
-if [ "$1" = "-D" ] ; then
+while [ "$1" ]; do
+	case $1 in
+	-D)
+		use_d="-D"
+		;;
+	-h)
+		usage
+		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
+	-*)
+		usage
+		;;
+	*)
+		usage
+		;;
+	esac
+	shift
+done
+
+if [ "$use_d" = "-D" ] ; then
 	dump_by_dr_path
-elif [ -z "$1" ] ; then
-	dump_by_lid
 else
-	usage
+	dump_by_lid
 fi
 
 exit
diff --git a/infiniband-diags/scripts/ibcheckerrors.in b/infiniband-diags/scripts/ibcheckerrors.in
index e08eba3..01c7a99 100644
--- a/infiniband-diags/scripts/ibcheckerrors.in
+++ b/infiniband-diags/scripts/ibcheckerrors.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-b] [-v] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-b] [-v] [-N | -nocolor]"\
+	    "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -21,6 +22,8 @@ v=0
 ntype=""
 nodeguid=""
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -39,20 +42,35 @@ while [ "$1" ]; do
 		brief=-b
 		verbose=""
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -62,12 +80,12 @@ BEGIN {
 function check_node(lid)
 {
 	nodechecked=1
-	if (system("'$IBPATH'/ibchecknode '$gflags' '$verbose' " lid)) {
+	if (system("'$IBPATH'/ibchecknode '"$ca_info"' '$gflags' '$verbose' " lid)) {
 		ne++
 		badnode=1
 		return
 	}
-	if (system("'$IBPATH'/ibcheckerrs '$gflags' '$verbose' '$brief' " lid " 255"))
+	if (system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " 255"))
 		nodeerr=1;
 }
 
@@ -102,7 +120,7 @@ function check_node(lid)
 		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (nodeerr)
-			if (system("'$IBPATH'/ibcheckerrs '$gflags' '$verbose' '$brief' " lid " " port)) {
+			if (system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port)) {
 				if (!'$v' && oldlid != lid) {
 					print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 					oldlid = lid
diff --git a/infiniband-diags/scripts/ibcheckerrs.in b/infiniband-diags/scripts/ibcheckerrs.in
index ff3256b..99d45cd 100644
--- a/infiniband-diags/scripts/ibcheckerrs.in
+++ b/infiniband-diags/scripts/ibcheckerrs.in
@@ -3,7 +3,9 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-t <threshold_file>] [-s(how_thresholds)] [-N \| -nocolor] <lid|guid> [<port>]"
+	echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-T <threshold_file>]" \
+	    "[-s(how_thresholds)] [-N \| -nocolor] [-C ca_name] [-P ca_port]" \
+	    "[-t(imeout) timeout_ms] <lid|guid> [<port>]"
 	exit -1
 }
 
@@ -64,6 +66,7 @@ guid_addr=""
 bw=""
 verbose=""
 brief=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -81,7 +84,7 @@ while [ "$1" ]; do
 		brief=yes
 		verbose=""
 		;;
-	-t)
+	-T)
 		if ! [ -r $2 ]; then
 			echo "Can't use threshold file '$2'"
 			usage
@@ -93,6 +96,18 @@ while [ "$1" ]; do
 		show_thresholds
 		exit 0
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -121,7 +136,7 @@ else
 fi
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -129,16 +144,16 @@ if [ "$guid_addr" ]; then
 	guid=$1
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
 	fi
 fi
 
-nodename=`smpquery nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
+nodename=`smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
 
-if $IBPATH/perfquery $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
+if $IBPATH/perfquery $ca_info $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
 function blue(s)
 {
 	if (brief == "yes") {
diff --git a/infiniband-diags/scripts/ibchecknet.in b/infiniband-diags/scripts/ibchecknet.in
index 9f36742..e2f7fb8 100644
--- a/infiniband-diags/scripts/ibchecknet.in
+++ b/infiniband-diags/scripts/ibchecknet.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-v] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
+	    "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -18,6 +19,8 @@ gflags=""
 verbose=""
 v=0
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -31,20 +34,35 @@ while [ "$1" ]; do
 		verbose=-v
 		v=0
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -55,12 +73,12 @@ BEGIN {
 function check_node(lid)
 {
 	nodechecked=1
-	if (system("'$IBPATH'/ibchecknode '$gflags' '$verbose' " lid)) {
+	if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
 		ne++
 		badnode=1
 		return
 	}
-	if (system("'$IBPATH'/ibcheckerrs '$gflags' '$verbose' " lid " 255"))
+	if (system("'$IBPATH'/ibcheckerrs'"$ca_info"' '$gflags' '$verbose' " lid " 255"))
 		nodeerr=1;
 }
 
@@ -94,7 +112,7 @@ function check_node(lid)
 		}
 		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
-		if (system("'$IBPATH'/ibcheckport '$gflags' '$verbose' " lid " " port)) {
+		if (system("'$IBPATH'/ibcheckport'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
 				print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 				oldlid = lid
@@ -103,7 +121,7 @@ function check_node(lid)
 		}
 
 		if (nodeerr)
-			if (system("'$IBPATH'/ibcheckerrs '$gflags' '$verbose' " lid " " port)) {
+			if (system("'$IBPATH'/ibcheckerrs'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
 				if (!'$v' && oldlid != lid) {
 					print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 					oldlid = lid
diff --git a/infiniband-diags/scripts/ibchecknode.in b/infiniband-diags/scripts/ibchecknode.in
index 9d3aaba..5eea7b5 100644
--- a/infiniband-diags/scripts/ibchecknode.in
+++ b/infiniband-diags/scripts/ibchecknode.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-v] [-N \| -nocolor] [-G] <lid|guid>"
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
+	    "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid>"
 	exit -1
 }
 
@@ -30,6 +31,7 @@ function red() {
 guid_addr=""
 bw=""
 verbose=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -42,6 +44,18 @@ while [ "$1" ]; do
 	-v)
 		verbose=yes
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -57,14 +71,14 @@ if [ -z "$1" ]; then
 fi
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
 	fi
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -73,7 +87,7 @@ fi
 
 ## For now, check node only checks if node info is replied
 
-if $IBPATH/smpquery nodeinfo $lid > /dev/null 2>&1 ; then
+if $IBPATH/smpquery $ca_info nodeinfo $lid > /dev/null 2>&1 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Node check lid $lid: "
 		green OK
diff --git a/infiniband-diags/scripts/ibcheckport.in b/infiniband-diags/scripts/ibcheckport.in
index f910fdc..3c7c396 100644
--- a/infiniband-diags/scripts/ibcheckport.in
+++ b/infiniband-diags/scripts/ibcheckport.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-v] [-N \| -nocolor] [-G] <lid|guid> <port>"
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
+	   "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
 	exit -1
 }
 
@@ -30,6 +31,7 @@ function red() {
 guid_addr=""
 bw=""
 verbose=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -42,6 +44,18 @@ while [ "$1" ]; do
 	-v)
 		verbose=yes
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -59,7 +73,7 @@ fi
 portnum=$2
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -67,7 +81,7 @@ if [ "$guid_addr" ]; then
 	guid=$1
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -75,7 +89,7 @@ else
 fi
 
 
-if $IBPATH/smpquery portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
diff --git a/infiniband-diags/scripts/ibcheckportstate.in b/infiniband-diags/scripts/ibcheckportstate.in
index 3c36601..f3a5f05 100644
--- a/infiniband-diags/scripts/ibcheckportstate.in
+++ b/infiniband-diags/scripts/ibcheckportstate.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-v] [-N \| -nocolor] [-G] <lid|guid> <port>"
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
+	   "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
 	exit -1
 }
 
@@ -30,6 +31,7 @@ function red() {
 guid_addr=""
 bw=""
 verbose=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -42,6 +44,18 @@ while [ "$1" ]; do
 	-v)
 		verbose=yes
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -59,7 +73,7 @@ fi
 portnum=$2
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -67,7 +81,7 @@ if [ "$guid_addr" ]; then
 	guid=$1
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -75,7 +89,7 @@ else
 fi
 
 
-if $IBPATH/smpquery portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
diff --git a/infiniband-diags/scripts/ibcheckportwidth.in b/infiniband-diags/scripts/ibcheckportwidth.in
index 5f6762e..fdc75d1 100644
--- a/infiniband-diags/scripts/ibcheckportwidth.in
+++ b/infiniband-diags/scripts/ibcheckportwidth.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-v] [-N \| -nocolor] [-G] <lid|guid> <port>"
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
+	   "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
 	exit -1
 }
 
@@ -30,6 +31,7 @@ function red() {
 guid_addr=""
 bw=""
 verbose=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -42,6 +44,18 @@ while [ "$1" ]; do
 	-v)
 		verbose=yes
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -59,7 +73,7 @@ fi
 portnum=$2
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -67,7 +81,7 @@ if [ "$guid_addr" ]; then
 	guid=$1
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -75,7 +89,7 @@ else
 fi
 
 
-if $IBPATH/smpquery portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
diff --git a/infiniband-diags/scripts/ibcheckstate.in b/infiniband-diags/scripts/ibcheckstate.in
index 30b5513..944e139 100644
--- a/infiniband-diags/scripts/ibcheckstate.in
+++ b/infiniband-diags/scripts/ibcheckstate.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-v] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
+	    "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -20,6 +21,8 @@ v=0
 ntype=""
 nodeguid=""
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -33,20 +36,35 @@ while [ "$1" ]; do
 		verbose=-v
 		v=1
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -57,7 +75,7 @@ BEGIN {
 function check_node(lid)
 {
 	nodechecked=1
-	if (system("'$IBPATH'/ibchecknode '$gflags' '$verbose' " lid)) {
+	if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
 		ne++
 		badnode=1
 		return
@@ -93,7 +111,7 @@ function check_node(lid)
 		}
 		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
-		if (system("'$IBPATH'/ibcheckportstate '$gflags' '$verbose' " lid " " port)) {
+		if (system("'$IBPATH'/ibcheckportstate'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
 				print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 				oldlid = lid
diff --git a/infiniband-diags/scripts/ibcheckwidth.in b/infiniband-diags/scripts/ibcheckwidth.in
index 072d433..8ad0f7f 100644
--- a/infiniband-diags/scripts/ibcheckwidth.in
+++ b/infiniband-diags/scripts/ibcheckwidth.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-v] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
+	    "[<topology-file> \| -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -20,6 +21,8 @@ v=0
 ntype=""
 nodeguid=""
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -33,20 +36,35 @@ while [ "$1" ]; do
 		verbose="-v"
 		v=1
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -57,7 +75,7 @@ BEGIN {
 function check_node(lid)
 {
 	nodechecked=1
-	if (system("'$IBPATH'/ibchecknode '$gflags' '$verbose' " lid)) {
+	if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
 		ne++
 		badnode=1
 		return
@@ -93,7 +111,7 @@ function check_node(lid)
 		}
 		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
-		if (system("'$IBPATH'/ibcheckportwidth '$gflags' '$verbose' " lid " " port)) {
+		if (system("'$IBPATH'/ibcheckportwidth'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
 				print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 				oldlid = lid
diff --git a/infiniband-diags/scripts/ibclearcounters.in b/infiniband-diags/scripts/ibclearcounters.in
index 54551b3..b3c009e 100644
--- a/infiniband-diags/scripts/ibclearcounters.in
+++ b/infiniband-diags/scripts/ibclearcounters.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-N | -nocolor] [<topology-file>" \
+	    "| -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -18,6 +19,8 @@ gflags=""
 verbose=""
 v=0
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -27,20 +30,35 @@ while [ "$1" ]; do
 	-N|-nocolor)
 		gflags=-N
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -48,14 +66,14 @@ eval $netcmd | awk '
 function clear_counters(lid)
 {
 	nodecleared=1
-	if (system("'$IBPATH'/perfquery '$gflags' -R -a " lid))
+	if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R -a " lid))
 		nodeerr++
 }
 
 function clear_port_counters(lid, port)
 {
 	nodecleared=1
-	if (system("'$IBPATH'/perfquery '$gflags' -R " lid " " port))
+	if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R " lid " " port))
 		nodeerr++
 }
 
diff --git a/infiniband-diags/scripts/ibclearerrors.in b/infiniband-diags/scripts/ibclearerrors.in
index 4a086ae..097c3fe 100644
--- a/infiniband-diags/scripts/ibclearerrors.in
+++ b/infiniband-diags/scripts/ibclearerrors.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-N | -nocolor] [<topology-file>" \
+	    "| -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -18,6 +19,8 @@ gflags=""
 verbose=""
 v=0
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -27,20 +30,35 @@ while [ "$1" ]; do
 	-N|-nocolor)
 		gflags=-N
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -48,7 +66,7 @@ eval $netcmd | awk '
 function clear_errors(lid, port)
 {
 	nodecleared=1
-	if (system("'$IBPATH'/perfquery '$gflags' -R " lid " " port " 0x0fff"))
+	if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R " lid " " port " 0x0fff"))
 		nodeerr++
 }
 
diff --git a/infiniband-diags/scripts/ibdatacounters.in b/infiniband-diags/scripts/ibdatacounters.in
index d27149e..bee9bd8 100644
--- a/infiniband-diags/scripts/ibdatacounters.in
+++ b/infiniband-diags/scripts/ibdatacounters.in
@@ -3,7 +3,8 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [-b] [-v] [-N \| -nocolor] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [-b] [-v] [-N | -nocolor]" \
+	    "[<topology-file> \| -C ca_name -P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
@@ -21,6 +22,8 @@ v=0
 ntype=""
 nodeguid=""
 oldlid=""
+topofile=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -39,20 +42,35 @@ while [ "$1" ]; do
 		brief=-b
 		verbose=""
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
 	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
@@ -62,12 +80,12 @@ BEGIN {
 function check_node(lid)
 {
 	nodechecked=1
-	if (system("'$IBPATH'/ibchecknode '$gflags' '$verbose' " lid)) {
+	if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
 		ne++
 		badnode=1
 		return
 	}
-	if (system("'$IBPATH'/ibdatacounts'$gflags' '$verbose' '$brief' " lid " 255"))
+	if (system("'$IBPATH'/ibdatacounts'"$ca_info"' '$gflags' '$verbose' '$brief' " lid " 255"))
 		nodeerr=1;
 }
 
@@ -102,7 +120,7 @@ function check_node(lid)
 		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (nodeerr)
-			if (system("'$IBPATH'/ibdatacounts'$gflags' '$verbose' '$brief' " lid " " port)) {
+			if (system("'$IBPATH'/ibdatacounts'"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port)) {
 				if (!'$v' && oldlid != lid) {
 					print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
 					oldlid = lid
diff --git a/infiniband-diags/scripts/ibdatacounts.in b/infiniband-diags/scripts/ibdatacounts.in
index 668558f..927a978 100644
--- a/infiniband-diags/scripts/ibdatacounts.in
+++ b/infiniband-diags/scripts/ibdatacounts.in
@@ -3,7 +3,9 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-N \| -nocolor] <lid|guid> [<port>]"
+	echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-N | -nocolor]" \
+	    "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid>" \
+	    "[<port>]"
 	exit -1
 }
 
@@ -31,6 +33,7 @@ guid_addr=""
 bw=""
 verbose=""
 brief=""
+ca_info=""
 
 while [ "$1" ]; do
 	case $1 in
@@ -48,6 +51,18 @@ while [ "$1" ]; do
 		brief=yes
 		verbose=""
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -76,7 +91,7 @@ else
 fi
 
 if [ "$guid_addr" ]; then
-	if ! lid=`$IBPATH/ibaddr -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
+	if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
 		echo -n "guid $1 address resolution: "
 		red "FAILED"
 		exit -1
@@ -84,16 +99,16 @@ if [ "$guid_addr" ]; then
 	guid=$1
 else
 	lid=$1
-	if ! temp=`$IBPATH/ibaddr -L $1 | awk '/failed/{exit -1} {print $1}'`; then
+	if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
 		echo -n "lid $1 address resolution: "
 		red "FAILED"
 		exit -1
 	fi
 fi
 
-nodename=`smpquery nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
+nodename=`smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
 
-if $IBPATH/perfquery $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
+if $IBPATH/perfquery $ca_info $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
 function blue(s)
 {
 	if (brief == "yes") {
diff --git a/infiniband-diags/scripts/ibhosts.in b/infiniband-diags/scripts/ibhosts.in
index b9aadc1..0d6b1bc 100644
--- a/infiniband-diags/scripts/ibhosts.in
+++ b/infiniband-diags/scripts/ibhosts.in
@@ -3,28 +3,48 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
+	    "-P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
+topofile=""
+ca_info=""
+
 while [ "$1" ]; do
 	case $1 in
 	-h)
 		usage
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
+	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
diff --git a/infiniband-diags/scripts/ibnodes.in b/infiniband-diags/scripts/ibnodes.in
index 32acd9c..5871da8 100644
--- a/infiniband-diags/scripts/ibnodes.in
+++ b/infiniband-diags/scripts/ibnodes.in
@@ -2,4 +2,4 @@
 
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
-$IBPATH/ibhosts; $IBPATH/ibswitches
+$IBPATH/ibhosts $@; $IBPATH/ibswitches $@
diff --git a/infiniband-diags/scripts/ibrouters.in b/infiniband-diags/scripts/ibrouters.in
index 96ebfe0..fea72bb 100644
--- a/infiniband-diags/scripts/ibrouters.in
+++ b/infiniband-diags/scripts/ibrouters.in
@@ -3,28 +3,48 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
+	    "-P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
+topofile=""
+ca_info=""
+
 while [ "$1" ]; do
 	case $1 in
 	-h)
 		usage
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
+	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
diff --git a/infiniband-diags/scripts/ibswitches.in b/infiniband-diags/scripts/ibswitches.in
index 2a92360..859aacd 100644
--- a/infiniband-diags/scripts/ibswitches.in
+++ b/infiniband-diags/scripts/ibswitches.in
@@ -3,28 +3,48 @@
 IBPATH=${IBPATH:- at IBSCRIPTPATH@}
 
 function usage() {
-	echo Usage: `basename $0` [-h] [\<topology-file\>]
+	echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
+	    "-P ca_port -t(imeout) timeout_ms]"
 	exit -1
 }
 
+topofile=""
+ca_info=""
+
 while [ "$1" ]; do
 	case $1 in
 	-h)
 		usage
 		;;
+	-P | -C | -t | -timeout)
+		case $2 in
+		-*)
+			usage
+			;;
+		esac
+		if [ x$2 = x ] ; then
+			usage
+		fi
+		ca_info="$ca_info $1 $2"
+		shift
+		;;
 	-*)
 		usage
 		;;
 	*)
-		break
+		if [ "$topofile" ]; then
+			usage
+		fi
+		topofile="$1"
 		;;
 	esac
+	shift
 done
 
-if [ "$1" ]; then
-	netcmd="cat $1"
+if [ "$topofile" ]; then
+	netcmd="cat $topofile"
 else
-	netcmd="$IBPATH/ibnetdiscover"
+	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
 eval $netcmd | awk '
diff --git a/infiniband-diags/src/saquery.c b/infiniband-diags/src/saquery.c
index daff824..522399e 100644
--- a/infiniband-diags/src/saquery.c
+++ b/infiniband-diags/src/saquery.c
@@ -73,6 +73,8 @@ osm_mad_pool_t     mad_pool;
 osm_vendor_t      *vendor = NULL;
 int                osm_debug = 0;
 uint32_t           sa_timeout_ms = DEFAULT_SA_TIMEOUT_MS;
+char		  *sa_hca_name = NULL;
+uint32_t           sa_port_num = 0;
 
 enum {
 	ALL,
@@ -137,7 +139,7 @@ print_node_record(ib_node_record_t *node_record)
 		if (p_ni->node_type == IB_NODE_TYPE_SWITCH)
 			name = lookup_switch_name(switch_map_fp,
 						  cl_ntoh64(p_ni->node_guid),
-						  p_nd->description);
+						  (char *)p_nd->description);
 		else
 			name = clean_nodedesc((char *)p_nd->description);
 		printf("%s\n", name);
@@ -956,6 +958,7 @@ get_bind_handle(void)
 	ib_api_status_t    status;
 	ib_port_attr_t     attr_array[MAX_PORTS];
 	uint32_t           num_ports = MAX_PORTS;
+	uint32_t           ca_name_index = 0;
 
 	complib_init();
 
@@ -985,6 +988,16 @@ get_bind_handle(void)
 	}
 
 	for (i = 0; i < num_ports; i++) {
+		if (i > 1 && cl_ntoh64(attr_array[i].port_guid)
+				!= (cl_ntoh64(attr_array[i-1].port_guid) + 1))
+			ca_name_index++;
+		if (sa_port_num && sa_port_num != attr_array[i].port_num)
+			continue;
+		if (sa_hca_name && i == 0)
+			continue;
+		if (sa_hca_name
+		 && strcmp(sa_hca_name, vendor->ca_names[ca_name_index]) != 0)
+			continue;
 		if (attr_array[i].link_state == IB_LINK_ACTIVE)
 			port_guid = attr_array[i].port_guid;
 	}
@@ -1029,10 +1042,13 @@ clean_up(void)
 static void
 usage(void)
 {
-	fprintf(stderr, "Usage: %s [-h -d -P -N] [--list | -D] [-S -I -L -l -G -O -U -C -s -g -m --src-to-dst <src:dst> -t(imeout) <msec>] [<name> | <lid> | <guid>]\n", argv0);
+	fprintf(stderr, "Usage: %s [-h -d -p -N] [--list | -D] [-S -I -L -l -G"
+		" -O -U -c -s -g -m --src-to-dst <src:dst> -C <ca_name> "
+		"-P <ca_port> -t(imeout) <msec>] [<name> | <lid> | <guid>]\n",
+		argv0);
 	fprintf(stderr, "   Queries node records by default\n");
 	fprintf(stderr, "   -d enable debugging\n");
-	fprintf(stderr, "   -P get PathRecord info\n");
+	fprintf(stderr, "   -p get PathRecord info\n");
 	fprintf(stderr, "   -N get NodeRecord info\n");
 	fprintf(stderr, "   --list | -D the node desc of the CA's\n");
 	fprintf(stderr, "   -S get ServiceRecord info\n");
@@ -1042,15 +1058,21 @@ usage(void)
 	fprintf(stderr, "   -G return the Guids of the name specified\n");
 	fprintf(stderr, "   -O return name for the Lid specified\n");
 	fprintf(stderr, "   -U return name for the Guid specified\n");
-	fprintf(stderr, "   -C get the SA's class port info\n");
-	fprintf(stderr, "   -s return the PortInfoRecords with isSM or isSMdisabled capability mask bit on\n");
+	fprintf(stderr, "   -c get the SA's class port info\n");
+	fprintf(stderr, "   -s return the PortInfoRecords with isSM or "
+				"isSMdisabled capability mask bit on\n");
 	fprintf(stderr, "   -g get multicast group info\n");
 	fprintf(stderr, "   -m get multicast member info\n");
-	fprintf(stderr, "      (if multicast group specified, list member GIDs only for group specified\n");
+	fprintf(stderr, "      (if multicast group specified, list member GIDs"
+				" only for group specified\n");
 	fprintf(stderr, "      specified, for example 'saquery -m 0xC000')\n");
 	fprintf(stderr, "   --src-to-dst get a PathRecord for <src:dst>\n"
-			"                where src amd dst are either node names or LIDs\n");
-	fprintf(stderr, "   -t | --timeout <msec> specify the SA query response timeout (default %u msec)\n",
+			"                where src amd dst are either node "
+				"names or LIDs\n");
+	fprintf(stderr, "   -C <ca_name> specify the SA query HCA\n");
+	fprintf(stderr, "   -P <ca_port> specify the SA query port\n");
+	fprintf(stderr, "   -t | --timeout <msec> specify the SA query "
+				"response timeout (default %u msec)\n",
 			DEFAULT_SA_TIMEOUT_MS);
 	fprintf(stderr, "   --switch-map <switch-map> specify a switch map\n");
 	exit(-1);
@@ -1068,9 +1090,9 @@ main(int argc, char **argv)
 	ib_net16_t         dst_lid;
 	ib_api_status_t    status;
 
-	static char const str_opts[] = "PVNDLlGOUCSIsgmdht:";
+	static char const str_opts[] = "pVNDLlGOUcSIsgmdhP:C:t:";
 	static const struct option long_opts [] = {
-	   {"P", 0, 0, 'P'},
+	   {"p", 0, 0, 'p'},
 	   {"Version", 0, 0, 'V'},
 	   {"N", 0, 0, 'N'},
 	   {"L", 0, 0, 'L'},
@@ -1082,9 +1104,11 @@ main(int argc, char **argv)
 	   {"g", 0, 0, 'g'},
 	   {"m", 0, 0, 'm'},
 	   {"d", 0, 0, 'd'},
-	   {"C", 0, 0, 'C'},
+	   {"c", 0, 0, 'c'},
 	   {"S", 0, 0, 'S'},
 	   {"I", 0, 0, 'I'},
+	   {"P", 1, 0, 'P'},
+	   {"C", 1, 0, 'C'},
 	   {"help", 0, 0, 'h'},
 	   {"list", 0, 0, 'D'},
 	   {"src-to-dst", 1, 0, 1},
@@ -1118,7 +1142,7 @@ main(int argc, char **argv)
 		case 2:
 			switch_map = strdup(optarg);
 			break;
-		case 'P':
+		case 'p':
 			query_type = IB_MAD_ATTR_PATH_RECORD;
 			break;
 		case 'V':
@@ -1127,7 +1151,7 @@ main(int argc, char **argv)
 		case 'D':
 			node_print_desc = ALL_DESC;
 			break;
-		case 'C':
+		case 'c':
 			query_type = IB_MAD_ATTR_CLASS_PORT_INFO;
 			break;
 		case 'S':
@@ -1167,6 +1191,12 @@ main(int argc, char **argv)
 		case 'd':
 			osm_debug = 1;
 			break;
+		case 'C':
+			sa_hca_name = optarg;
+			break;
+		case 'P':
+			sa_port_num = strtoul(optarg, NULL, 0);
+			break;
 		case 't':
 			sa_timeout_ms = strtoul(optarg, NULL, 0);
 			break;



More information about the general mailing list