From patchwork Wed Oct 25 12:10:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10026583 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 12EED601E8 for ; Wed, 25 Oct 2017 12:10:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7E7028B74 for ; Wed, 25 Oct 2017 12:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC91528B77; Wed, 25 Oct 2017 12:10:35 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 1EC6028B74 for ; Wed, 25 Oct 2017 12:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdJYMKc (ORCPT ); Wed, 25 Oct 2017 08:10:32 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:47228 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750921AbdJYMKb (ORCPT ); Wed, 25 Oct 2017 08:10:31 -0400 Received: by mail-wm0-f68.google.com with SMTP id r196so1459583wmf.2 for ; Wed, 25 Oct 2017 05:10:30 -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=XZBX5BGxxPh4mLzlEaDPhM3xnS1mTnLvUEveHkPitGM=; b=VBMENkK7O+qQO/KcoK3yt78M/ChkcXQVAnbre2ol9KqWWklEhxy1o9ZMQbLkIiapuX BXV8KsYxODaxT7ayBQUJhHJdyyxssBSD5eVYviYa1RD2xtWPv+5NH32zN/Bo70zB+E61 FvkUf32ZRMd/FH3Z2jXIVItZOHzLC846TqQw0lWiItWwIxIwcTimkM+lXMLF0kpDTu0t Qudud3i4EDmF5pSc7P4WjII9UIk41UzyaO64rUOJZgKeKQLrZtMMlvsEEiAnX4NQNIWY 72X0QAp2PnDcFDqxSwDY5y/mnt2+mrTKuTKzL1LGhtwxb5nykhqchPlKTYHVX2Bj88k0 rzBw== 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=XZBX5BGxxPh4mLzlEaDPhM3xnS1mTnLvUEveHkPitGM=; b=WWW36i4H8wELgAH4qcw/VuvuPtRC/SSLWcYqQ8+cyoCW8NrcTWe3j+TkD80j7gPhUW 6gf+gzL28n5KCZrdwZEQHIKyPxtN1LxYWnU1myaMEmXmvLmmo/361K0Rr+7bSBm+pc+d n0yqiwII+tq4EzUdE7ZXXhmsXRHDuhcwkSCQejixuCvFEyzcFxPSznAO9WuhFHPymrAN E57KTN4b3j0XhSfpdZ2X9lmhf4r2omVAXmv30dstB9zzzC8g7tBI/iRQJ34gFaXCb6qj NOwqkI7oOJWiZICNVdy2ZFCqwHamom4uytbdSt/kYoFv2M8YzMBKgMsg6I2FW/8ZomNJ poyw== X-Gm-Message-State: AMCzsaUMVU2ZhMe+RPAX/JEmaYkbNQoa6BvbchJI9LPpyZ5zF4rYoovH FSNea76Au1B6ino/cWbl4YyNgQV0 X-Google-Smtp-Source: ABhQp+Q9PI5PEJ9ePxnYq17GS3cduMezwadIcWu5zMn93pwduQ+qeM0teEFv1i3oRGwS+92Z4unGYQ== X-Received: by 10.80.191.15 with SMTP id f15mr24052968edk.82.1508933429742; Wed, 25 Oct 2017 05:10:29 -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 n20sm1673110edb.93.2017.10.25.05.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 05:10:29 -0700 (PDT) To: "Weiny, Ira" Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCHv2 infiniband-diags] Add support for QP1Dropped counter in PortCounters attribute Message-ID: <0324cefc-efc8-3e83-c7d0-d206cb3407fe@dev.mellanox.co.il> Date: Wed, 25 Oct 2017 08:10:26 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.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 --- Change since v1: Restored PortXmitWait handling for PortCounters based on PortCountersXmitWaitSupported in ClassPortInfo:CapabilityMask libibmad/include/infiniband/mad.h | 5 +++++ libibmad/src/dump.c | 15 ++++++++++++++- libibmad/src/fields.c | 5 +++++ src/perfquery.c | 30 +++++++++++++++++++++++++----- 4 files changed, 49 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 520287d..bf48689 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..39d628e 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); @@ -380,6 +384,7 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, uint32_t cap_mask2, ib_portid_t * portid, int port, int aggregate) { + int cnt; char buf[1536]; if (extended != 1) { @@ -397,10 +402,21 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, } if (aggregate) aggregate_perfcounters(); - else + 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)); + IB_PC_FIRST_F, IB_PC_VL15_DROPPED_F); + if (cap_mask & IB_PM_IS_QP1_DROP_SUP) { + cnt = strlen(buf); + mad_dump_fields(buf + cnt, sizeof buf - cnt, pc, sizeof pc, + IB_PC_QP1_DROP_F, + IB_PC_QP1_DROP_F + 1); + } + cnt = strlen(buf); + mad_dump_fields(buf + cnt, sizeof buf - cnt, pc, sizeof +pc, + IB_PC_VL15_DROPPED_F, + (cap_mask & IB_PM_PC_XMIT_WAIT_SUP) ? IB_PC_LAST_F: (IB_PC_RCV_PKTS_F + 1)); + } } else { /* 1.2 errata: bit 9 is extended counter support @@ -1062,8 +1078,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;