From patchwork Thu Apr 6 12:34:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 9667077 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 6E9A6601EB for ; Thu, 6 Apr 2017 12:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 571C028574 for ; Thu, 6 Apr 2017 12:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AA1228584; Thu, 6 Apr 2017 12:35:09 +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 4FCE228574 for ; Thu, 6 Apr 2017 12:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756869AbdDFMfD (ORCPT ); Thu, 6 Apr 2017 08:35:03 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35378 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757289AbdDFMeo (ORCPT ); Thu, 6 Apr 2017 08:34:44 -0400 Received: by mail-wr0-f195.google.com with SMTP id t20so11025936wra.2 for ; Thu, 06 Apr 2017 05:34:43 -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-transfer-encoding; bh=jofDrzK4o4MrOIwFYFWdr42OX0kMkuIvIAAw1XpuePo=; b=j4mcg/LWBqklVqFVwATS/cMdokDPXqX1WtDlPpfin+Fzu0B1AaKGmUvms5y+7t0w25 TX5ZHRfxjNezzTEO7hgoyXDS/+R2NHiHnLja4fYeDX9cRCyWyqmHt6S2xPcwfnejO/Pp ki8eS2F3hMfR5z1tTEvRGOf9td/Dnc9hJOLhbPGF0W3ytn66dKKwPnsBeAntpVOGDxo0 3Jz07K1vZfT0E+fp01Yt+qtptU8MYYbbFJnUUsAeKVqx9N+Q+GnYtyYpBQvUlD/OjNxz A84AK5JuqRHD8yyyVLTqwvEy8CbXQ3aQeL6biRs+EkQNYq249HCKtD5BjgE0tdZet/oK addA== 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-transfer-encoding; bh=jofDrzK4o4MrOIwFYFWdr42OX0kMkuIvIAAw1XpuePo=; b=ZWTKLmTLbjbpebNl0mcluM+IJ8qajBF+L5bqCi7FR2W/dPFxVtHyyCXYT4HRAnlPKp kUuc5XCvvU7G+r9U2oVbqetZR8gRoiXlzvrBeA2du46F2GBGOA4zcZGp6VEnruOpjpWw aZyeUzR/pPLVg0C9HRquE4Mb2XBqZyw29Ih1qMIQZVoPG8mJFxZou2xmfrepoEKBHZxD qaEcqfHFVLlz7ckj4sON8NnbgrQe94fbUsWuRh0iZ0EuJiF1r1YdixeQ5NiMfCPFNZXM QIARMNgeehwdXnReH8GPRaA3nazl4WwgbhAh2ZKD3uCpVr3WNekNjMNXYf/b9HQXVQo4 vGQQ== X-Gm-Message-State: AFeK/H0PdyJwyZfQKQ+j2hdjlvb2HwnspPazTxVkB9WUju8YbEPL5byn IrOHIZeqEl1Fng== X-Received: by 10.28.145.130 with SMTP id t124mr24103426wmd.39.1491482082346; Thu, 06 Apr 2017 05:34:42 -0700 (PDT) Received: from [192.168.1.183] (c-67-189-170-197.hsd1.ma.comcast.net. [67.189.170.197]) by smtp.googlemail.com with ESMTPSA id b82sm26235980wmh.4.2017.04.06.05.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2017 05:34:41 -0700 (PDT) To: "Weiny, Ira" Cc: Oded Nissan , "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCHv2 infiniband-diags 2/3] perfquery.c: Add support for additional counters in PortCountersExtended Message-ID: <7d53f135-fb47-db26-1855-8a953ae32658@dev.mellanox.co.il> Date: Thu, 6 Apr 2017 08:34:39 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 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 From: Oded Nissan Support aggregation when AllPortSelect is not supported and reset of those counters. Signed-off-by: Oded Nissan Signed-off-by: Hal Rosenstock --- Change since v1: Increase buffer size -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h index 587dcfe..08bbf6b 100644 --- a/include/ibdiag_common.h +++ b/include/ibdiag_common.h @@ -81,6 +81,15 @@ extern char *ibd_nd_format; #define IS_PM_RSFEC_COUNTERS_SUP (CL_HTON16(((uint16_t)1)<<14)) #endif +#ifndef IB_PM_IS_QP1_DROP_SUP +#define IB_PM_IS_QP1_DROP_SUP (CL_HTON16(((uint16_t)1)<<15)) +#endif + +/* PM ClassPortInfo CapabilityMask2 Bits */ +#ifndef IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP +#define IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP (CL_HTON32(((uint32_t)1)<<1)) +#endif + /* SM PortInfo CapabilityMask2 Bits */ #ifndef IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED #define IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED (CL_HTON16(0x0002)) diff --git a/src/perfquery.c b/src/perfquery.c index 948ce52..384c116 100644 --- a/src/perfquery.c +++ b/src/perfquery.c @@ -85,13 +85,30 @@ struct perf_count_ext { uint64_t portunicastrcvpkts; uint64_t portmulticastxmitpkits; uint64_t portmulticastrcvpkts; + + uint32_t counterSelect2; + uint64_t symbolErrorCounter; + uint64_t linkErrorRecoveryCounter; + uint64_t linkDownedCounter; + uint64_t portRcvErrors; + uint64_t portRcvRemotePhysicalErrors; + uint64_t portRcvSwitchRelayErrors; + uint64_t portXmitDiscards; + uint64_t portXmitConstraintErrors; + uint64_t portRcvConstraintErrors; + uint64_t localLinkIntegrityErrors; + uint64_t excessiveBufferOverrunErrors; + uint64_t VL15Dropped; + uint64_t portXmitWait; + uint64_t QP1Dropped; }; static uint8_t pc[1024]; struct perf_count perf_count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -struct perf_count_ext perf_count_ext = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +struct perf_count_ext perf_count_ext = + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define ALL_PORTS 0xFF #define MAX_PORTS 255 @@ -228,7 +245,7 @@ static void output_aggregate_perfcounters(ib_portid_t * portid, portid2str(portid), ALL_PORTS, ntohs(cap_mask), buf); } -static void aggregate_perfcounters_ext(uint16_t cap_mask) +static void aggregate_perfcounters_ext(uint16_t cap_mask, uint32_t cap_mask2) { uint32_t val; uint64_t val64; @@ -256,15 +273,48 @@ static void aggregate_perfcounters_ext(uint16_t cap_mask) mad_decode_field(pc, IB_PC_EXT_RCV_MPKTS_F, &val64); aggregate_64bit(&perf_count_ext.portmulticastrcvpkts, val64); } + + if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) { + mad_decode_field(pc, IB_PC_EXT_COUNTER_SELECT2_F, &val); + perf_count_ext.counterSelect2 = val; + mad_decode_field(pc, IB_PC_EXT_ERR_SYM_F, &val64); + aggregate_64bit(&perf_count_ext.symbolErrorCounter, val64); + mad_decode_field(pc, IB_PC_EXT_LINK_RECOVERS_F, &val64); + aggregate_64bit(&perf_count_ext.linkErrorRecoveryCounter, val64); + mad_decode_field(pc, IB_PC_EXT_LINK_DOWNED_F, &val64); + aggregate_64bit(&perf_count_ext.linkDownedCounter, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_RCV_F, &val64); + aggregate_64bit(&perf_count_ext.portRcvErrors, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_PHYSRCV_F, &val64); + aggregate_64bit(&perf_count_ext.portRcvRemotePhysicalErrors, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_SWITCH_REL_F, &val64); + aggregate_64bit(&perf_count_ext.portRcvSwitchRelayErrors, val64); + mad_decode_field(pc, IB_PC_EXT_XMT_DISCARDS_F, &val64); + aggregate_64bit(&perf_count_ext.portXmitDiscards, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_XMTCONSTR_F, &val64); + aggregate_64bit(&perf_count_ext.portXmitConstraintErrors, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_RCVCONSTR_F, &val64); + aggregate_64bit(&perf_count_ext.portRcvConstraintErrors, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_LOCALINTEG_F, &val64); + aggregate_64bit(&perf_count_ext.localLinkIntegrityErrors, val64); + mad_decode_field(pc, IB_PC_EXT_ERR_EXCESS_OVR_F, &val64); + aggregate_64bit(&perf_count_ext.excessiveBufferOverrunErrors, val64); + mad_decode_field(pc, IB_PC_EXT_VL15_DROPPED_F, &val64); + aggregate_64bit(&perf_count_ext.VL15Dropped, val64); + mad_decode_field(pc, IB_PC_EXT_XMT_WAIT_F, &val64); + aggregate_64bit(&perf_count_ext.portXmitWait, val64); + mad_decode_field(pc, IB_PC_EXT_QP1_DROP_F, &val64); + aggregate_64bit(&perf_count_ext.QP1Dropped, val64); + } } static void output_aggregate_perfcounters_ext(ib_portid_t * portid, - uint16_t cap_mask) + uint16_t cap_mask, uint32_t cap_mask2) { - char buf[1024]; + char buf[1536]; uint32_t val = ALL_PORTS; - memset(buf, 0, 1024); + memset(buf, 0, sizeof(buf)); /* set port_select to 255 to emulate AllPortSelect */ mad_encode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val); @@ -289,17 +339,50 @@ static void output_aggregate_perfcounters_ext(ib_portid_t * portid, &perf_count_ext.portmulticastrcvpkts); } + if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) { + mad_encode_field(pc, IB_PC_EXT_COUNTER_SELECT2_F, + &perf_count_ext.counterSelect2); + mad_encode_field(pc, IB_PC_EXT_ERR_SYM_F, + &perf_count_ext.symbolErrorCounter); + mad_encode_field(pc, IB_PC_EXT_LINK_RECOVERS_F, + &perf_count_ext.linkErrorRecoveryCounter); + mad_encode_field(pc, IB_PC_EXT_LINK_DOWNED_F, + &perf_count_ext.linkDownedCounter); + mad_encode_field(pc, IB_PC_EXT_ERR_RCV_F, + &perf_count_ext.portRcvErrors); + mad_encode_field(pc, IB_PC_EXT_ERR_PHYSRCV_F, + &perf_count_ext.portRcvRemotePhysicalErrors); + mad_encode_field(pc, IB_PC_EXT_ERR_SWITCH_REL_F, + &perf_count_ext.portRcvSwitchRelayErrors); + mad_encode_field(pc, IB_PC_EXT_XMT_DISCARDS_F, + &perf_count_ext.portXmitDiscards); + mad_encode_field(pc, IB_PC_EXT_ERR_XMTCONSTR_F, + &perf_count_ext.portXmitConstraintErrors); + mad_encode_field(pc, IB_PC_EXT_ERR_RCVCONSTR_F, + &perf_count_ext.portRcvConstraintErrors); + mad_encode_field(pc, IB_PC_EXT_ERR_LOCALINTEG_F, + &perf_count_ext.localLinkIntegrityErrors); + mad_encode_field(pc, IB_PC_EXT_ERR_EXCESS_OVR_F, + &perf_count_ext.excessiveBufferOverrunErrors); + mad_encode_field(pc, IB_PC_EXT_VL15_DROPPED_F, + &perf_count_ext.VL15Dropped); + mad_encode_field(pc, IB_PC_EXT_XMT_WAIT_F, + &perf_count_ext.portXmitWait); + mad_encode_field(pc, IB_PC_EXT_QP1_DROP_F, + &perf_count_ext.QP1Dropped); + } + mad_dump_perfcounters_ext(buf, sizeof buf, pc, sizeof pc); - printf("# Port extended counters: %s port %d (CapMask: 0x%02X)\n%s", - portid2str(portid), ALL_PORTS, ntohs(cap_mask), buf); + printf("# Port extended counters: %s port %d (CapMask: 0x%02X CapMask2: 0x%07X)\n%s", + portid2str(portid), ALL_PORTS, ntohs(cap_mask), cap_mask2, buf); } static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, uint32_t cap_mask2, ib_portid_t * portid, int port, int aggregate) { - char buf[1024]; + char buf[1536]; if (extended != 1) { memset(pc, 0, sizeof(pc)); @@ -335,7 +419,7 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, IB_GSI_PORT_COUNTERS_EXT, srcport)) IBEXIT("perfextquery"); if (aggregate) - aggregate_perfcounters_ext(cap_mask); + aggregate_perfcounters_ext(cap_mask, cap_mask2); else mad_dump_perfcounters_ext(buf, sizeof buf, pc, sizeof pc); @@ -951,7 +1041,7 @@ int main(int argc, char **argv) cap_mask); else output_aggregate_perfcounters_ext(&portid, - cap_mask); + cap_mask, cap_mask2); } } else if (ports_count > 1) { for (i = 0; i < ports_count; i++) @@ -964,7 +1054,7 @@ int main(int argc, char **argv) cap_mask); else output_aggregate_perfcounters_ext(&portid, - cap_mask); + cap_mask, cap_mask2); } } else dump_perfcounters(extended, ibd_timeout, cap_mask, cap_mask2, @@ -977,6 +1067,14 @@ do_reset: if (argc <= 2 && !extended && (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)) mask |= (1 << 16); /* reset portxmitwait */ + if (extended) { + mask |= 0xfff0000; + if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP) + mask |= (1 << 28); + if (cap_mask & IB_PM_IS_QP1_DROP_SUP) + mask |= (1 << 29); + } + if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) { for (i = start_port; i <= num_ports; i++) reset_counters(extended, ibd_timeout, mask, &portid, i);