From patchwork Tue Nov 10 22:04:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 59179 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 nAAM7tlf026154 for ; Tue, 10 Nov 2009 22:07:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756660AbZKJWHg (ORCPT ); Tue, 10 Nov 2009 17:07:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756713AbZKJWHg (ORCPT ); Tue, 10 Nov 2009 17:07:36 -0500 Received: from nspiron-2.llnl.gov ([128.115.41.82]:28701 "EHLO nspiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756660AbZKJWHf (ORCPT ); Tue, 10 Nov 2009 17:07:35 -0500 X-Attachments: None Received: from mail-2.llnl.gov ([128.115.41.181]) by nspiron-2.llnl.gov with ESMTP; 10 Nov 2009 14:07:41 -0800 Received: from jeepcj7.llnl.gov (jeepcj7.llnl.gov [134.9.93.67]) by mail-2.llnl.gov (8.13.1/8.12.3/LLNL evision: 1.7 $) with SMTP id nAAM7ZAe032661; Tue, 10 Nov 2009 14:07:35 -0800 Date: Tue, 10 Nov 2009 14:04:40 -0800 From: Ira Weiny To: Sasha Khapyorsky Cc: "linux-rdma@vger.kernel.org" Subject: [PATCH] infiniband-diags/ibqueryerrors: Reformat the output of the xmtdiscard details. Message-Id: <20091110140440.c6b30018.weiny2@llnl.gov> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.10.4; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c index 61a34e4..c8122e7 100644 --- a/infiniband-diags/src/ibqueryerrors.c +++ b/infiniband-diags/src/ibqueryerrors.c @@ -199,8 +199,35 @@ static void report_suppressed(void) } } -static void print_results(char *node_name, ibnd_node_t * node, uint8_t * pc, - int portnum, int *header_printed) +static int print_xmitdisc_details(char *buf, size_t size, ib_portid_t * portid, + ibnd_node_t * node, char * node_name, int portnum) +{ + uint8_t pc[1024]; + uint32_t val = 0; + int n = 0; + int i = 0; + + memset(pc, 0, 1024); + + 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 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(buf + n, size - n, " [%s == %d]", + mad_field_name(i), val); + } + return n; +} + +static void print_results(ib_portid_t * portid, char *node_name, ibnd_node_t * node, + uint8_t * pc, int portnum, int *header_printed) { char buf[1024]; char *str = buf; @@ -219,6 +246,12 @@ static void print_results(char *node_name, ibnd_node_t * node, uint8_t * pc, if (val) n += snprintf(str + n, 1024 - n, " [%s == %d]", mad_field_name(i), val); + + /* If there are PortXmitDiscards, get details (if supported) */ + if (i == IB_PC_XMT_DISCARDS_F && details && val) { + n += print_xmitdisc_details(str + n, 1024-n, portid, + node, node_name, portnum); + } } if (!suppress(IB_PC_XMT_WAIT_F)) { @@ -274,35 +307,10 @@ 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); @@ -317,20 +325,7 @@ static void print_port(ib_portid_t * portid, uint16_t cap_mask, char *node_name, uint32_t foo = 0; 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); - } + print_results(portid, node_name, node, pc, portnum, header_printed); } static void clear_port(ib_portid_t * portid, uint16_t cap_mask,