diff --git a/doc/man/perfquery.8.in b/doc/man/perfquery.8.in index 8c4a62a..3f935fa 100644 --- a/doc/man/perfquery.8.in +++ b/doc/man/perfquery.8.in @@ -143,12 +143,6 @@ the counters of the specified ports. If the destination lid does not support the AllPortSelect flag, all ports will be iterated through to emulate AllPortSelect behavior. .TP -.B \fB\-l, \-\-loop_ports\fP -.sp -If all ports are selected by the user (either through the \fB\-a\fP option -or port 255) or multiple ports are specified iterate through each port rather -than doing than aggregate operation. -.TP .B \fB\-r, \-\-reset_after_read\fP .sp reset counters after read @@ -295,10 +289,10 @@ perfquery \-x \-R 0x20 1 # reset extended performance counters of port 1 only perfquery \-R \-a 32 # reset performance counters of all ports perfquery \-R 32 2 0x0fff # reset only error counters of port 2 perfquery \-R 32 2 0xf000 # reset only non\-error counters of port 2 +perfquery 32 1\-10 # read performance counters from lid 32, port 1\-10, output each port perfquery \-a 32 1\-10 # read performance counters from lid 32, port 1\-10, aggregate output -perfquery \-l 32 1\-10 # read performance counters from lid 32, port 1\-10, output each port +perfquery 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, output each port perfquery \-a 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, aggregate output -perfquery \-l 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, output each port .ft P .fi .SS AUTHOR diff --git a/doc/rst/perfquery.8.in.rst b/doc/rst/perfquery.8.in.rst index 5e3d709..b7c5fec 100644 --- a/doc/rst/perfquery.8.in.rst +++ b/doc/rst/perfquery.8.in.rst @@ -107,11 +107,6 @@ OPTIONS the AllPortSelect flag, all ports will be iterated through to emulate AllPortSelect behavior. -**-l, --loop_ports** - If all ports are selected by the user (either through the **-a** option - or port 255) or multiple ports are specified iterate through each port rather - than doing than aggregate operation. - **-r, --reset_after_read** reset counters after read @@ -174,10 +169,10 @@ EXAMPLES perfquery -R -a 32 # reset performance counters of all ports perfquery -R 32 2 0x0fff # reset only error counters of port 2 perfquery -R 32 2 0xf000 # reset only non-error counters of port 2 + perfquery 32 1-10 # read performance counters from lid 32, port 1-10, output each port perfquery -a 32 1-10 # read performance counters from lid 32, port 1-10, aggregate output - perfquery -l 32 1-10 # read performance counters from lid 32, port 1-10, output each port + perfquery 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, output each port perfquery -a 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, aggregate output - perfquery -l 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, output each port AUTHOR ====== diff --git a/src/perfquery.c b/src/perfquery.c index df8556b..7ac96a7 100644 --- a/src/perfquery.c +++ b/src/perfquery.c @@ -368,7 +368,7 @@ static void reset_counters(int extended, int timeout, int mask, } } -static int reset, reset_only, all_ports, loop_ports, port, extended, xmt_sl, +static int reset, reset_only, all_ports, port, extended, xmt_sl, rcv_sl, xmt_disc, rcv_err, extended_speeds, smpl_ctl, oprcvcounters, flowctlcounters, vloppackets, vlopdata, vlxmitflowctlerrors, vlxmitcounters, swportvlcong, rcvcc, slrcvfecn, slrcvbecn, xmitcc, vlxmittimecc; @@ -642,9 +642,6 @@ static int process_opt(void *context, int ch, char *optarg) all_ports++; port = ALL_PORTS; break; - case 'l': - loop_ports++; - break; case 'r': reset++; break; @@ -693,7 +690,6 @@ int main(int argc, char **argv) {"vlxmittimecc", 12, 0, NULL, "show VL Xmit Time congestion control counters"}, {"smplctl", 'c', 0, NULL, "show samples control"}, {"all_ports", 'a', 0, NULL, "show aggregated counters"}, - {"loop_ports", 'l', 0, NULL, "iterate through each port"}, {"reset_after_read", 'r', 0, NULL, "reset counters after read"}, {"Reset_only", 'R', 0, NULL, "only reset counters"}, {0} @@ -711,10 +707,11 @@ int main(int argc, char **argv) "-R -a 32\t# reset performance counters of all ports", "-R 32 2 0x0fff\t# reset only error counters of port 2", "-R 32 2 0xf000\t# reset only non-error counters of port 2", + "32 1-10\t# read performance counters from lid 32, port 1-10, output each port", "-a 32 1-10\t# read performance counters from lid 32, port 1-10, aggregate output", - "-l 32 1-10\t# read performance counters from lid 32, port 1-10, output each port", + "32 1,4,8\t# read performance counters from lid 32, port 1, 4, and 8, output each port", "-a 32 1,4,8\t# read performance counters from lid 32, port 1, 4, and 8, aggregate output", - "-l 32 1,4,8\t# read performance counters from lid 32, port 1, 4, and 8, output each port", + NULL, }; @@ -877,52 +874,71 @@ int main(int argc, char **argv) goto done; } + if (smp_query_via(data, &portid, IB_ATTR_NODE_INFO, 0, 0, srcport) < 0) + IBERROR("smp query nodeinfo failed"); + node_type = mad_get_field(data, 0, IB_NODE_TYPE_F); + mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports); + if (!num_ports) + IBERROR("smp query nodeinfo: num ports invalid"); - if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) { - if (smp_query_via(data, &portid, IB_ATTR_NODE_INFO, 0, 0, - srcport) < 0) + if (node_type == IB_NODE_SWITCH) { + if (smp_query_via(data, &portid, IB_ATTR_SWITCH_INFO, + 0, 0, srcport) < 0) IBERROR("smp query nodeinfo failed"); - node_type = mad_get_field(data, 0, IB_NODE_TYPE_F); - mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports); - if (!num_ports) - IBERROR("smp query nodeinfo: num ports invalid"); - - if (node_type == IB_NODE_SWITCH) { - if (smp_query_via(data, &portid, IB_ATTR_SWITCH_INFO, - 0, 0, srcport) < 0) - IBERROR("smp query nodeinfo failed"); - enhancedport0 = - mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F); - if (enhancedport0) - start_port = 0; + enhancedport0 = + mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F); + } + + if (all_ports_loop) { + if (node_type == IB_NODE_SWITCH && enhancedport0) + start_port = 0; + IBWARN("Emulating AllPortSelect by iterating through all ports"); + } else if (ports_count > 1) { + if (node_type == IB_NODE_CA) + IBERROR("Cannot specify > 1 port for CA"); + + for (i = 0; i < ports_count; i++) { + if (ports[i] > num_ports) + IBERROR("port %u out of range", ports[i]); + + if (!ports[i]) { + if (node_type == IB_NODE_SWITCH + && !enhancedport0) + IBERROR("enhanced port 0 not supported"); + if (node_type == IB_NODE_CA) + IBERROR("port 0 invalid for CA"); + } + } + } else { + if (port > num_ports) + IBERROR("port %u out of range", port); + if (!port) { + if (node_type == IB_NODE_SWITCH + && !enhancedport0) + IBERROR("enhanced port 0 not supported"); + if (node_type == IB_NODE_CA) + IBERROR("port 0 invalid for CA"); } - if (all_ports_loop && !loop_ports) - IBWARN - ("Emulating AllPortSelect by iterating through all ports"); } if (reset_only) goto do_reset; - if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) { + if (all_ports_loop) { for (i = start_port; i <= num_ports; i++) dump_perfcounters(extended, ibd_timeout, cap_mask, - &portid, i, (all_ports_loop - && !loop_ports)); - if (all_ports_loop && !loop_ports) { - if (extended != 1) - output_aggregate_perfcounters(&portid, - cap_mask); - else - output_aggregate_perfcounters_ext(&portid, - cap_mask); - } + &portid, i, 1); + if (extended != 1) + output_aggregate_perfcounters(&portid, + cap_mask); + else + output_aggregate_perfcounters_ext(&portid, + cap_mask); } else if (ports_count > 1) { for (i = 0; i < ports_count; i++) dump_perfcounters(extended, ibd_timeout, cap_mask, - &portid, ports[i], - (all_ports && !loop_ports)); - if (all_ports && !loop_ports) { + &portid, ports[i], all_ports); + if (all_ports) { if (extended != 1) output_aggregate_perfcounters(&portid, cap_mask); @@ -941,7 +957,7 @@ int main(int argc, char **argv) if (argc <= 2 && !extended && (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)) mask |= (1 << 16); /* reset portxmitwait */ - if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) { + if (all_ports_loop) { for (i = start_port; i <= num_ports; i++) reset_counters(extended, ibd_timeout, mask, &portid, i); } else if (ports_count > 1) {