From patchwork Mon Nov 2 09:40:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eli Dorfman (Voltaire)" X-Patchwork-Id: 56951 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 nA29VTP2008054 for ; Mon, 2 Nov 2009 09:31:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753226AbZKBJbX (ORCPT ); Mon, 2 Nov 2009 04:31:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754238AbZKBJbX (ORCPT ); Mon, 2 Nov 2009 04:31:23 -0500 Received: from fwil.voltaire.com ([193.47.165.2]:11398 "EHLO exil.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753226AbZKBJbW (ORCPT ); Mon, 2 Nov 2009 04:31:22 -0500 Received: from [172.25.1.69] ([172.25.1.69]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 11:31:20 +0200 Message-ID: <4AEEA903.4030406@gmail.com> Date: Mon, 02 Nov 2009 11:40:19 +0200 From: "Eli Dorfman (Voltaire)" User-Agent: Thunderbird 2.0.0.17 (X11/20080914) MIME-Version: 1.0 To: Sasha Khapyorsky CC: linux-rdma Subject: Re: [PATCH v2] infiniband-diags/saquery: Report SA MAD Class specific status. References: <4AED4241.4000808@gmail.com> <20091101165223.GJ29434@me> In-Reply-To: <20091101165223.GJ29434@me> X-OriginalArrivalTime: 02 Nov 2009 09:31:20.0376 (UTC) FILETIME=[3C574380:01CA5B9F] 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/saquery.c b/infiniband-diags/src/saquery.c index 6c44b63..9495cd9 100644 --- a/infiniband-diags/src/saquery.c +++ b/infiniband-diags/src/saquery.c @@ -124,6 +124,45 @@ int requested_lid_flag = 0; uint64_t requested_guid = 0; int requested_guid_flag = 0; +#define SA_ERR_UNKNOWN IB_SA_MAD_STATUS_PRIO_SUGGESTED + +const char *ib_sa_error_str[] = { + "SA_NO_ERROR", + "SA_ERR_NO_RESOURCES", + "SA_ERR_REQ_INVALID", + "SA_ERR_NO_RECORDS", + "SA_ERR_TOO_MANY_RECORDS", + "SA_ERR_REQ_INVALID_GID", + "SA_ERR_REQ_INSUFFICIENT_COMPONENTS", + "SA_ERR_REQ_DENIED", + "SA_ERR_STATUS_PRIO_SUGGESTED", + "SA_ERR_UNKNOWN" +}; + +static inline const char *ib_sa_err_str(IN uint8_t status) +{ + if (status > SA_ERR_UNKNOWN) + status = SA_ERR_UNKNOWN; + return (ib_sa_error_str[status]); +} + +static inline void report_err(int status) +{ + int st = status & 0xff; + char sm_err_str[64] = { 0 }; + char sa_err_str[64] = { 0 }; + + if (st) + sprintf(sm_err_str, " SM(%s)", ib_get_err_str(st)); + + st = status >> 8; + if (st) + sprintf(sa_err_str, " SA(%s)", ib_sa_err_str(st)); + + fprintf(stderr, "ERROR: Query result returned 0x%04x, %s%s\n", + status, sm_err_str, sa_err_str); +} + static int sa_query(struct bind_handle *h, uint8_t method, uint16_t attr, uint32_t mod, uint64_t comp_mask, uint64_t sm_key, void *data) @@ -794,8 +833,7 @@ static int get_any_records(bind_handle_t h, } if (result.status != IB_SUCCESS) { - fprintf(stderr, "Query result returned: %s\n", - ib_get_err_str(result.status)); + report_err(result.status); return result.status; } @@ -1009,8 +1047,7 @@ static int get_print_class_port_info(bind_handle_t h) return ret; } if (result.status != IB_SUCCESS) { - fprintf(stderr, "ERROR: Query result returned: %s\n", - ib_get_err_str(result.status)); + report_err(result.status); return (result.status); } dump_results(&result, dump_class_port_info);