From patchwork Tue Nov 3 19:25:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 57362 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA3JPG6D023726 for ; Tue, 3 Nov 2009 19:25:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbZKCTZJ (ORCPT ); Tue, 3 Nov 2009 14:25:09 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753299AbZKCTZI (ORCPT ); Tue, 3 Nov 2009 14:25:08 -0500 Received: from qmta02.westchester.pa.mail.comcast.net ([76.96.62.24]:35027 "EHLO QMTA02.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751614AbZKCTZH (ORCPT ); Tue, 3 Nov 2009 14:25:07 -0500 Received: from OMTA15.westchester.pa.mail.comcast.net ([76.96.62.87]) by QMTA02.westchester.pa.mail.comcast.net with comcast id 0e7R1d00E1swQuc52jRD5U; Tue, 03 Nov 2009 19:25:13 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA15.westchester.pa.mail.comcast.net with comcast id 0jZS1d00T0hNrtn3bjZS5G; Tue, 03 Nov 2009 19:33:27 +0000 Received: from hal.comcast.net (localhost.localdomain [127.0.0.1]) by hal.comcast.net (8.14.3/8.14.3) with ESMTP id nA3JPTKL016612; Tue, 3 Nov 2009 14:25:34 -0500 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id nA3JPDcu016581; Tue, 3 Nov 2009 14:25:13 -0500 Date: Tue, 3 Nov 2009 14:25:13 -0500 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PATCH] infiniband-diags/ibqueryerrors: Add support for PortXmitDiscardDetails Message-ID: <20091103192513.GA16577@comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/man/ibqueryerrors.8 b/infiniband-diags/man/ibqueryerrors.8 index 1352246..d5a499e 100644 --- a/infiniband-diags/man/ibqueryerrors.8 +++ b/infiniband-diags/man/ibqueryerrors.8 @@ -1,4 +1,4 @@ -.TH IBQUERYERRORS 8 "Jan 24, 2008" "OpenIB" "OpenIB Diagnostics" +.TH IBQUERYERRORS 8 "Oct 30, 2009" "OpenIB" "OpenIB Diagnostics" .SH NAME ibqueryerrors.pl \- query and report non-zero IB port counters @@ -58,6 +58,8 @@ printed or not. This is because data counters are only \fBprinted\fR on ports which have errors. This means if a port has 0 errors and the \-K option is specified the data counters will be cleared without any printed output. .TP +\fB\-\-details\fR include transmit discard details +.TP \fB\-R\fR (This option is obsolete and does nothing) .SH COMMON OPTIONS diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c index f83f29e..61a34e4 100644 --- a/infiniband-diags/src/ibqueryerrors.c +++ b/infiniband-diags/src/ibqueryerrors.c @@ -2,6 +2,7 @@ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved. * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved. * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved. + * Copyright (c) 2009 HNR Consulting. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -65,7 +66,7 @@ int sup_total = 0; enum MAD_FIELDS *suppressed_fields = NULL; char *dr_path = NULL; uint8_t node_type_to_print = 0; -unsigned clear_errors = 0, clear_counts = 0; +unsigned clear_errors = 0, clear_counts = 0, details = 0; #define PRINT_SWITCH 0x1 #define PRINT_CA 0x2 @@ -273,10 +274,35 @@ static int query_cap_mask(ib_portid_t *portid, char *node_name, int portnum, return 0; } +static void print_xmitdisc_details(ibnd_node_t * node, char * node_name, + uint8_t * pc, int portnum) +{ + char buf[1024]; + char *str = buf; + uint32_t val = 0; + int n = 0; + int i = 0; + + buf[0] = 0; + for (n = 0, i = IB_PC_XMT_INACT_DISC_F; i <= IB_PC_XMT_SW_HOL_DISC_F; i++) { + mad_decode_field(pc, i, (void *)&val); + if (val) + n += snprintf(str + n, 1024 - n, " [%s == %d]", + mad_field_name(i), val); + } + if (n > 0) { + printf(" GUID 0x%" PRIx64 " port %d:%s\n", node->guid, + portnum, str); + if (port_config) + print_port_config(node_name, node, portnum); + } +} + static void print_port(ib_portid_t * portid, uint16_t cap_mask, char *node_name, ibnd_node_t * node, int portnum, int *header_printed) { uint8_t pc[1024]; + uint32_t xmtdisc; memset(pc, 0, 1024); @@ -292,6 +318,19 @@ static void print_port(ib_portid_t * portid, uint16_t cap_mask, char *node_name, mad_encode_field(pc, IB_PC_XMT_WAIT_F, &foo); } print_results(node_name, node, pc, portnum, header_printed); + + /* If there are PortXmitDiscards, get details (if supported) */ + mad_decode_field(pc, IB_PC_XMT_DISCARDS_F, &xmtdisc); + if (details && xmtdisc) { + if (!pma_query_via(pc, portid, portnum, ibd_timeout, + IB_GSI_PORT_XMIT_DISCARD_DETAILS, + ibmad_port)) { + IBWARN("IB_GSI_PORT_XMIT_DISCARD_DETAILS query failed on %s, %s port %d", + node_name, portid2str(portid), portnum); + return; + } + print_xmitdisc_details(node, node_name, pc, portnum); + } } static void clear_port(ib_portid_t * portid, uint16_t cap_mask, @@ -318,6 +357,13 @@ static void clear_port(ib_portid_t * portid, uint16_t cap_mask, IB_GSI_PORT_COUNTERS, ibmad_port)) IBERROR("Failed to reset errors %s port %d", node_name, port); + + if (details && clear_errors) { + mask = 0xF; + performance_reset_via(pc, portid, port, mask, ibd_timeout, + IB_GSI_PORT_XMIT_DISCARD_DETAILS, + ibmad_port); + } } void print_node(ibnd_node_t * node, void *user_data) @@ -428,6 +474,9 @@ static int process_opt(void *context, int ch, char *optarg) case 5: node_type_to_print |= PRINT_ROUTER; break; + case 6: + details = 1; + break; case 'G': case 'S': node_guid_str = optarg; @@ -484,6 +533,7 @@ int main(int argc, char **argv) {"switch", 3, 0, NULL, "print data for switches only"}, {"ca", 4, 0, NULL, "print data for CA's only"}, {"router", 5, 0, NULL, "print data for routers only"}, + {"details", 6, 0, NULL, "include transmit discard details"}, {"clear-errors", 'k', 0, NULL, "Clear error counters after read"}, {"clear-counts", 'K', 0, NULL,