From patchwork Thu Jun 22 14:37:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 9804547 X-Patchwork-Delegate: ira.weiny@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9162B60386 for ; Thu, 22 Jun 2017 14:37:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80535286A4 for ; Thu, 22 Jun 2017 14:37:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 753B1286B0; Thu, 22 Jun 2017 14:37:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB95D286A4 for ; Thu, 22 Jun 2017 14:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752660AbdFVOhU (ORCPT ); Thu, 22 Jun 2017 10:37:20 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:32781 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752579AbdFVOhT (ORCPT ); Thu, 22 Jun 2017 10:37:19 -0400 Received: by mail-wr0-f196.google.com with SMTP id x23so5164157wrb.0 for ; Thu, 22 Jun 2017 07:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=ttOY6jv0fnLQ7XAOKXR4AiZeKaTy3ZGTxR+Wk8iOIS4=; b=B7LZIBqnDWiq6UNp4MUoS+Fv1nXuHm/0wPm2PC8yRb96sjqZI+q7WhDG1S6ZYmsUK5 kk1Yejj4hnJ9TNE8OcYfWckPIT6FE7KY40Xu9I9vRKtaPG3BoLstdY5W+CSxf4wFPw0O xLlGdsI7oKea7l1Jse5q5HjuJTyuSgNbfMv5VXJJDN5K6k55C6YtPqdozR1Q49Q51oyb b+/1wTl/qaJTidm1fg2N7Tfmd+n8PeQf1A0Cp8OkxxlkcysYCkeyWc+vkryrhE8ayyKS jdKJnoEWQ2x9u5J6ZYNfyGkrYIu8oDn3ktv5k+f4arNPK/EY/lgYnfZVMgOK5Dcn3L7H kbGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=ttOY6jv0fnLQ7XAOKXR4AiZeKaTy3ZGTxR+Wk8iOIS4=; b=A9K6ewbUaNjskAnD5BK5jB+05JtkuHXBFJiglkCwJhnxsVLt8tBGTL6J6hVbw8StiH 7TieOgdlWFToOUy3lAfsTHC64BuBesHTzEZKiB/LHuufBW/BB/WD/K4Hb91oQDqVUNOT CNyUeYShv0FU0vCNPJbGJZ6uE8M2V2uYzMaaJlw7t+8uKoeZuUmIFmEiy7HioNDUnJg4 4xfAtxaRL1Yp5yBYbN+sTz150oKPIameSMEvwB5FhMK2KpRIwb7KgXyQZJP/OJ3x0c2a jQz3K1SBHSMYlDDuyJ3FQgssdiInobzhH4BwhX0G044YWJH1W0EfIzcIRoyDco8jVvON CClA== X-Gm-Message-State: AKS2vOy+kihZ6kgt3SrD52/IxKWgySn6grmVaL2Qz+w9/oVGKd3C7zj/ 1nxT2FEzvl4p9qwAgTA= X-Received: by 10.28.8.72 with SMTP id 69mr2052925wmi.102.1498142237190; Thu, 22 Jun 2017 07:37:17 -0700 (PDT) Received: from [192.168.1.183] (c-73-182-207-166.hsd1.ma.comcast.net. [73.182.207.166]) by smtp.googlemail.com with ESMTPSA id l190sm1528747wmb.18.2017.06.22.07.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 07:37:16 -0700 (PDT) To: "Weiny, Ira" Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH infiniband-diags 3/3] Add support for QP1Dropped counter in PortCounters attribute Message-ID: Date: Thu, 22 Jun 2017 10:37:15 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for missing QP1Dropped counter in PortCounters attribute in libibmad and perfquery.c. Support for this counter is indicated by IsQP1DroppedSupported bit 15 in PerfMgt ClassPortInfo:CapabilityMask. Signed-off-by: Hal Rosenstock --- libibmad/include/infiniband/mad.h | 5 +++++ libibmad/src/dump.c | 15 ++++++++++++++- libibmad/src/fields.c | 5 +++++ src/perfquery.c | 16 +++++++++++----- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h index 50c5bc5..7f6b886 100644 --- a/libibmad/include/infiniband/mad.h +++ b/libibmad/include/infiniband/mad.h @@ -1310,6 +1310,11 @@ enum MAD_FIELDS { IB_PC_EXT_QP1_DROP_F, IB_PC_EXT_ERR_LAST_F, + /* + * Another PortCounters field + */ + IB_PC_QP1_DROP_F, + IB_FIELD_LAST_ /* must be last */ }; diff --git a/libibmad/src/dump.c b/libibmad/src/dump.c index 24878a6..2244f38 100644 --- a/libibmad/src/dump.c +++ b/libibmad/src/dump.c @@ -818,7 +818,20 @@ void mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz) void mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz) { - _dump_fields(buf, bufsz, val, IB_PC_FIRST_F, IB_PC_LAST_F); + int cnt, cnt2; + + cnt = _dump_fields(buf, bufsz, val, + IB_PC_FIRST_F, IB_PC_VL15_DROPPED_F); + if (cnt < 0) + return; + + cnt2 = _dump_fields(buf + cnt, bufsz - cnt, val, + IB_PC_QP1_DROP_F, IB_PC_QP1_DROP_F + 1); + if (cnt2 < 0) + return; + + _dump_fields(buf + cnt + cnt2, bufsz - cnt - cnt2, val, + IB_PC_VL15_DROPPED_F, IB_PC_LAST_F); } void mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz) diff --git a/libibmad/src/fields.c b/libibmad/src/fields.c index b8a5302..e0333f8 100644 --- a/libibmad/src/fields.c +++ b/libibmad/src/fields.c @@ -1004,6 +1004,11 @@ static const ib_field_t ib_mad_f[] = { {1408, 64, "QP1Dropped", mad_dump_uint}, {0, 0}, /* IB_PC_EXT_ERR_LAST_F */ + /* + * Another PortCounters field + */ + {160, 16, "QP1Dropped", mad_dump_uint}, + {0, 0} /* IB_FIELD_LAST_ */ }; diff --git a/src/perfquery.c b/src/perfquery.c index f5d23f2..6bc4d9c 100644 --- a/src/perfquery.c +++ b/src/perfquery.c @@ -66,6 +66,7 @@ struct perf_count { uint32_t rcvconstrainterrors; uint32_t linkintegrityerrors; uint32_t excbufoverrunerrors; + uint32_t qp1dropped; uint32_t vl15dropped; uint32_t xmtdata; uint32_t rcvdata; @@ -190,6 +191,8 @@ static void aggregate_perfcounters(void) aggregate_4bit(&perf_count.linkintegrityerrors, val); mad_decode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &val); aggregate_4bit(&perf_count.excbufoverrunerrors, val); + mad_decode_field(pc, IB_PC_QP1_DROP_F, &val); + aggregate_16bit(&perf_count.qp1dropped, val); mad_decode_field(pc, IB_PC_VL15_DROPPED_F, &val); aggregate_16bit(&perf_count.vl15dropped, val); mad_decode_field(pc, IB_PC_XMT_BYTES_F, &val); @@ -230,6 +233,7 @@ static void output_aggregate_perfcounters(ib_portid_t * portid, &perf_count.linkintegrityerrors); mad_encode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &perf_count.excbufoverrunerrors); + mad_encode_field(pc, IB_PC_QP1_DROP_F, &perf_count.qp1dropped); mad_encode_field(pc, IB_PC_VL15_DROPPED_F, &perf_count.vl15dropped); mad_encode_field(pc, IB_PC_XMT_BYTES_F, &perf_count.xmtdata); mad_encode_field(pc, IB_PC_RCV_BYTES_F, &perf_count.rcvdata); @@ -398,9 +402,7 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, if (aggregate) aggregate_perfcounters(); else - mad_dump_fields(buf, sizeof buf, pc, sizeof pc, - IB_PC_FIRST_F, - (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)?IB_PC_LAST_F:(IB_PC_RCV_PKTS_F+1)); + mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc); } else { /* 1.2 errata: bit 9 is extended counter support @@ -1062,8 +1064,12 @@ int main(int argc, char **argv) goto done; do_reset: - if (argc <= 2 && !extended && (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)) - mask |= (1 << 16); /* reset portxmitwait */ + if (argc <= 2 && !extended) { + if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP) + mask |= (1 << 16); /* reset portxmitwait */ + if (cap_mask & IB_PM_IS_QP1_DROP_SUP) + mask |= (1 << 17); /* reset qp1dropped */ + } if (extended) { mask |= 0xfff0000;