From patchwork Fri Sep 21 22:02:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1493601 X-Patchwork-Delegate: ira.weiny@intel.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 59727DF28C for ; Fri, 21 Sep 2012 22:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752407Ab2IUWDE (ORCPT ); Fri, 21 Sep 2012 18:03:04 -0400 Received: from prdiron-3.llnl.gov ([128.15.143.173]:6344 "EHLO prdiron-3.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907Ab2IUWDD (ORCPT ); Fri, 21 Sep 2012 18:03:03 -0400 X-Attachments: Received: from eris.llnl.gov (HELO trebuchet.chaos) ([128.115.7.7]) by prdiron-3.llnl.gov with SMTP; 21 Sep 2012 15:03:02 -0700 Date: Fri, 21 Sep 2012 15:02:59 -0700 From: Ira Weiny To: "linux-rdma@vger.kernel.org" Subject: [PATCH] infiniband-diags: Fix SA error reporting for common MAD errors Message-Id: <20120921150259.5fb75a794fae33ac60e5f0d9@llnl.gov> X-Mailer: Sylpheed 3.2.0 (GTK+ 2.18.9; 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 Signed-off-by: Ira Weiny --- src/ibdiag_sa.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/ibdiag_sa.c b/src/ibdiag_sa.c index 2b84bfa..2a9f008 100644 --- a/src/ibdiag_sa.c +++ b/src/ibdiag_sa.c @@ -192,19 +192,43 @@ static inline const char *ib_sa_err_str(IN uint8_t status) return (ib_sa_error_str[status]); } +static const char *ib_mad_inv_field_str[] = { + "MAD No invalid fields", + "MAD Bad version", + "MAD Method specified is not supported", + "MAD Method/Attribute combination is not supported", + "MAD Reserved", + "MAD Reserved", + "MAD Reserved", + "MAD fields or attribute modifier; invalid value" + "MAD UNKNOWN ERROR" +}; +#define MAD_ERR_UNKNOWN (ARR_SIZE(ib_mad_inv_field_str) - 1) + +static inline const char *ib_mad_inv_field_err_str(IN uint8_t f) +{ + if (f > MAD_ERR_UNKNOWN) + f = MAD_ERR_UNKNOWN; + return (ib_mad_inv_field_str[f]); +} + void sa_report_err(int status) { int st = status & 0xff; - char sm_err_str[64] = { 0 }; + char mad_err_str[64] = { 0 }; char sa_err_str[64] = { 0 }; if (st) - sprintf(sm_err_str, " SM(%s)", ib_get_err_str(st)); + sprintf(mad_err_str, " (%s; %s; %s)", + (st & 0x1) ? "BUSY" : "", + (st & 0x2) ? "Redirection Required" : "", + ib_mad_inv_field_err_str(st>>2)); + st = status >> 8; if (st) sprintf(sa_err_str, " SA(%s)", ib_sa_err_str((uint8_t) st)); fprintf(stderr, "ERROR: Query result returned 0x%04x, %s%s\n", - status, sm_err_str, sa_err_str); + status, mad_err_str, sa_err_str); }