From patchwork Tue Jan 12 19:14:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 72423 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0CJBB33022707 for ; Tue, 12 Jan 2010 19:11:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751029Ab0ALTLK (ORCPT ); Tue, 12 Jan 2010 14:11:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753496Ab0ALTLK (ORCPT ); Tue, 12 Jan 2010 14:11:10 -0500 Received: from mail-bw0-f227.google.com ([209.85.218.227]:61210 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029Ab0ALTLJ (ORCPT ); Tue, 12 Jan 2010 14:11:09 -0500 Received: by bwz27 with SMTP id 27so1408197bwz.21 for ; Tue, 12 Jan 2010 11:11:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=nT7fMvD2GrIxrKjwwiC+VKN0nAH3PYcxS2n/T7/QkxQ=; b=az9YeMlA+fIttkuZK/6gvASxx7N/fjGNifTn1tEcWGI/IRuZOADuxw9SVMHjEjPBP0 vcGg7JBq10+RGvp7mmK3wqVXia9SMJimwXRm14s1MYHdXXrUtC75pV9HQ3EZ5JOAT0ra 8BPpg7gIY/pVUZyNQK5dLSErecDQUhqzHubxg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=qZXrBgyy0B5gF1rf+12SMORyu5tea6ozBNrrmPMeSsn73s7sWdsY3ixfCCgJt7rqfM V/+6oWR1DgJ02ubdSasq8iTbuC1BnAIKvePRu7W7/pI/65id87sEdy2hXig98CCFYIIx NzzLb+f5ePHndmPII5dbo7Y77rQQ+JiYA3X3c= Received: by 10.204.4.67 with SMTP id 3mr1782119bkq.189.1263323466622; Tue, 12 Jan 2010 11:11:06 -0800 (PST) Received: from me.localdomain ([72.14.240.164]) by mx.google.com with ESMTPS id 13sm9535789bwz.2.2010.01.12.11.11.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 12 Jan 2010 11:11:05 -0800 (PST) Received: by me.localdomain (Postfix, from userid 1000) id 2A6D011DF8; Tue, 12 Jan 2010 21:14:20 +0200 (IST) Date: Tue, 12 Jan 2010 21:14:20 +0200 From: Sasha Khapyorsky To: Hal Rosenstock Cc: linux-rdma@vger.kernel.org Subject: Re: [PATCH] infiniband-diags/ibqueryerrors: Add support for optional PortRcvErrorDetails counter Message-ID: <20100112191420.GJ574@me> References: <20091231191054.GA27874@comcast.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091231191054.GA27874@comcast.net> User-Agent: Mutt/1.5.20 (2009-06-14) 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 47bd2af..0ebe4bf 100644 --- a/infiniband-diags/src/ibqueryerrors.c +++ b/infiniband-diags/src/ibqueryerrors.c @@ -205,30 +205,31 @@ static void report_suppressed(void) printf("\n"); } -static int print_xmitdisc_details(char *buf, size_t size, ib_portid_t * portid, - ibnd_node_t * node, char *node_name, - int portnum) +static int query_and_dump(char *buf, size_t size, ib_portid_t * portid, + ibnd_node_t * node, char *node_name, int portnum, + const char *attr_name, uint16_t attr_id, + int start_field, int end_field) { uint8_t pc[1024]; uint32_t val = 0; int i, n; - memset(pc, 0, 1024); + memset(pc, 0, sizeof(pc)); - 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); + if (!pma_query_via(pc, portid, portnum, ibd_timeout, attr_id, + ibmad_port)) { + IBWARN("%s query failed on %s, %s port %d", attr_name, + 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++) { + for (n = 0, i = start_field; i < end_field; i++) { mad_decode_field(pc, i, (void *)&val); if (val) n += snprintf(buf + n, size - n, " [%s == %u]", mad_field_name(i), val); } + return n; } @@ -256,8 +257,20 @@ static void print_results(ib_portid_t * portid, char *node_name, /* 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); + n += query_and_dump(str + n, sizeof(buf) - n, portid, + node, node_name, portnum, + "PortXmitDiscardDetails", + IB_GSI_PORT_XMIT_DISCARD_DETAILS, + IB_PC_RCV_LOCAL_PHY_ERR_F, + IB_PC_RCV_ERR_LAST_F); + /* If there are PortRcvErrors, get details (if supported) */ + } else if (i == IB_PC_ERR_RCV_F && details && val) { + n += query_and_dump(str + n, sizeof(buf) - n, portid, + node, node_name, portnum, + "PortRecvErrorsDetails", + IB_GSI_PORT_RCV_ERROR_DETAILS, + IB_PC_XMT_INACT_DISC_F, + IB_PC_XMT_DISC_LAST_F); } }