From patchwork Mon Mar 27 15:37:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 9647061 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 93960602D6 for ; Mon, 27 Mar 2017 15:39:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 830AC27D4A for ; Mon, 27 Mar 2017 15:39:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77F9228429; Mon, 27 Mar 2017 15:39:07 +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 DE5E227D4A for ; Mon, 27 Mar 2017 15:39:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbdC0Pis (ORCPT ); Mon, 27 Mar 2017 11:38:48 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34508 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbdC0Pio (ORCPT ); Mon, 27 Mar 2017 11:38:44 -0400 Received: by mail-wr0-f193.google.com with SMTP id w43so11496981wrb.1 for ; Mon, 27 Mar 2017 08:37:57 -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=r3aK4WVNYTWJUNF7UHUoO8LA7BHmT79rYhgWPqJIrUQ=; b=XOWa1oDp90ZhLjgF6vKrqMEZBLXSEouaBktdMVa816aMsrhuvrl7+dfqsKnooKT+lL Gx3M4JPJEovGTNhVbU1LHdxQAhoqUZ+9a9W6MPbdyUw2wxI7B4TWZmhgy3NTvrJeSgTh 2HRneKi3rD6dYEGI27eJCv0mTGewULgUiRqCOjFWcdTv+X2pD6wsjhPm2AWITpGyR/NX 6W4+QbLWPDZzIanv+03C8Nf/ykSz1rJtKS1SQSwGh8VclH12JLVpyb1nLIHkAv880r+Q ouryiKlsDNHYMvX9IHG02rktO2b9ctc0YNo9vxRa/HkhcdlWDziNzh8/7lMEtN97bePV X7yQ== 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=r3aK4WVNYTWJUNF7UHUoO8LA7BHmT79rYhgWPqJIrUQ=; b=sqfm+F4n5Wp5K9LilCJceYGuAJhGCe/SJ2n+9FPbP/4iY1oJZNgdfBmKR3UmQ/tnml Y1Ghx746C/zqFP+Ce2sAVecBnBeIsVVdOIFHFdmmR4elAZoeMnOpoc1S70di9efhZTJS aaOPxTuiLmZ9/ryO9LGfJ0n2y/wZHXPoYCrsARnZYbCPuZ8hi9Azx96urbn1mGDZR98t FDuihu0lGrBVbH/yuP7X8xFlzMk82HU2KqKp3KC3Gqpnrh61ystb9kIiBy4KaE1Xp1Ic clZYvf/SfKHf1XE3FQ/TVfwKF5Go1uOJOFQU9OgTeMRRLZfVFu3DJTbVsytN9Q8BBdyd 6Lhw== X-Gm-Message-State: AFeK/H0l9+GAEroO50gzYRvU3wMRvxdVeNEhko628rfndpflgiTEwyUPbaksdMl0dN4vJQ== X-Received: by 10.223.161.78 with SMTP id r14mr21583707wrr.101.1490629075942; Mon, 27 Mar 2017 08:37:55 -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 v20sm1169659wrb.39.2017.03.27.08.37.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 08:37:55 -0700 (PDT) To: "Weiny, Ira" Cc: Oded Nissan , "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH infiniband-diags 3/3] ibqueryerrors.c: Add support for additional counters in PortCountersExtended Message-ID: <21830b83-d1ed-82f2-8046-c25cf8c68933@dev.mellanox.co.il> Date: Mon, 27 Mar 2017 11:37:53 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 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 Signed-off-by: Oded Nissan Signed-off-by: Hal Rosenstock --- -- 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/src/ibqueryerrors.c b/src/ibqueryerrors.c index 2329f91..938753f 100644 --- a/src/ibqueryerrors.c +++ b/src/ibqueryerrors.c @@ -395,25 +395,41 @@ static int print_results(ib_portid_t * portid, char *node_name, ibnd_node_t * node, uint8_t * pc, int portnum, - int *header_printed, uint8_t *pce, uint16_t cap_mask) + int *header_printed, uint8_t *pce, uint16_t cap_mask, uint32_t cap_mask2) { char buf[1024]; char *str = buf; uint32_t val = 0; - int i, n; + int i, ext_i, n; - for (n = 0, i = IB_PC_ERR_SYM_F; i <= IB_PC_VL15_DROPPED_F; i++) { + for (n = 0, i = IB_PC_ERR_SYM_F, ext_i = IB_PC_EXT_ERR_SYM_F; + i <= IB_PC_VL15_DROPPED_F; i++, ext_i++ ) { if (suppress(i)) continue; /* this is not a counter, skip it */ - if (i == IB_PC_COUNTER_SELECT2_F) + if (i == IB_PC_COUNTER_SELECT2_F) { + ext_i--; continue; + } mad_decode_field(pc, i, (void *)&val); if (exceeds_threshold(i, val)) { - n += snprintf(str + n, 1024 - n, " [%s == %u]", - mad_field_name(i), val); + if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) { + uint64_t val64 = 0; + float val = 0; + char *unit = ""; + mad_decode_field(pce, ext_i, (void *)&val64); + if (val64) { + unit = conv_cnt_human_readable(val64, &val, 0); + n += snprintf(str + n, 1024 - n, + " [%s == %" PRIu64 " (%5.3f%s)]", + mad_field_name(ext_i), val64, val, unit); + } + } + else + n += snprintf(str + n, 1024 - n, " [%s == %u]", + mad_field_name(i), val); /* If there are PortXmitDiscards, get details (if supported) */ if (i == IB_PC_XMT_DISCARDS_F && details) { @@ -437,9 +453,24 @@ if (!suppress(IB_PC_XMT_WAIT_F)) { mad_decode_field(pc, IB_PC_XMT_WAIT_F, (void *)&val); - if (exceeds_threshold(IB_PC_XMT_WAIT_F, val)) - n += snprintf(str + n, 1024 - n, " [%s == %u]", - mad_field_name(IB_PC_XMT_WAIT_F), val); + if (exceeds_threshold(IB_PC_XMT_WAIT_F, val)) { + if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) { + uint64_t val64 = 0; + float val = 0; + char *unit = ""; + mad_decode_field(pce, IB_PC_EXT_XMT_WAIT_F, (void *)&val64); + if (val64) { + unit = conv_cnt_human_readable(val64, &val, 0); + n += snprintf(str + n, 1024 - n, + " [%s == %" PRIu64 " (%5.3f%s)]", + mad_field_name(IB_PC_EXT_XMT_WAIT_F), + val64, val, unit); + } + } + else + n += snprintf(str + n, 1024 - n, " [%s == %u]", + mad_field_name(IB_PC_XMT_WAIT_F), val); + } } /* if we found errors. */ @@ -507,10 +538,11 @@ } static int query_cap_mask(ib_portid_t * portid, char *node_name, int portnum, - uint16_t * cap_mask) + uint16_t * cap_mask, uint32_t * cap_mask2) { uint8_t pc[1024] = { 0 }; uint16_t rc_cap_mask; + uint32_t rc_cap_mask2; portid->sl = lid2sl_table[portid->lid]; @@ -525,8 +557,11 @@ /* ClassPortInfo should be supported as part of libibmad */ memcpy(&rc_cap_mask, pc + 2, sizeof(rc_cap_mask)); /* CapabilityMask */ + memcpy(&rc_cap_mask2, pc + 4, sizeof(rc_cap_mask2)); /* CapabilityMask2 */ + rc_cap_mask2 = ntohl(rc_cap_mask2) >> 5; *cap_mask = rc_cap_mask; + *cap_mask2 = rc_cap_mask2; return 0; } @@ -601,7 +636,7 @@ return (0); } -static int print_errors(ib_portid_t * portid, uint16_t cap_mask, +static int print_errors(ib_portid_t * portid, uint16_t cap_mask, uint32_t cap_mask2, char *node_name, ibnd_node_t * node, int portnum, int *header_printed) { @@ -639,7 +674,7 @@ mad_encode_field(pc, IB_PC_XMT_WAIT_F, &foo); } return (print_results(portid, node_name, node, pc, portnum, - header_printed, pc_ext, cap_mask)); + header_printed, pc_ext, cap_mask, cap_mask2)); } uint8_t *reset_pc_ext(void *rcvbuf, ib_portid_t * dest, @@ -668,6 +703,8 @@ /* Same for attribute IDs */ mad_set_field(rcvbuf, 0, IB_PC_EXT_PORT_SELECT_F, port); mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT_F, mask); + mask = mask >> 16; + mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT2_F, mask); rpc.attr.mod = 0; rpc.timeout = timeout; rpc.datasz = IB_PC_DATA_SZ; @@ -680,7 +717,7 @@ return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf); } -static void clear_port(ib_portid_t * portid, uint16_t cap_mask, +static void clear_port(ib_portid_t * portid, uint16_t cap_mask, uint32_t cap_mask2, char *node_name, int port) { uint8_t pc[1024] = { 0 }; @@ -714,15 +751,21 @@ ibmad_port); } - if (clear_counts && - (cap_mask & - (IB_PM_EXT_WIDTH_SUPPORTED | IB_PM_EXT_WIDTH_NOIETF_SUP))) { - if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) - mask = 0xFF; - else - mask = 0x0F; + if (cap_mask & (IB_PM_EXT_WIDTH_SUPPORTED | IB_PM_EXT_WIDTH_NOIETF_SUP)) { + mask = 0; + if (clear_counts) + if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) + mask = 0xFF; + else + mask = 0x0F; - if (!reset_pc_ext(pc, portid, port, mask, ibd_timeout, + if (clear_errors && (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP)) { + mask |= 0xfff0000; + if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP) + mask |= (1 << 28); + } + + if (mask && !reset_pc_ext(pc, portid, port, mask, ibd_timeout, ibmad_port)) fprintf(stderr, "Failed to reset extended data counters %s, " "%s port %d\n", node_name, portid2str(portid), @@ -739,6 +782,7 @@ int all_port_sup = 0; ib_portid_t portid = { 0 }; uint16_t cap_mask = 0; + uint32_t cap_mask2 = 0; char *node_name = NULL; switch (node->type) { @@ -775,7 +819,7 @@ } } - if ((query_cap_mask(&portid, node_name, p, &cap_mask) == 0) && + if ((query_cap_mask(&portid, node_name, p, &cap_mask, &cap_mask2) == 0) && (cap_mask & IB_PM_ALL_PORT_SELECT)) all_port_sup = 1; @@ -792,12 +836,12 @@ &header_printed); summary.ports_checked++; if (!all_port_sup) - clear_port(&portid, cap_mask, node_name, p); + clear_port(&portid, cap_mask, cap_mask2, node_name, p); } } } else { if (all_port_sup) - if (!print_errors(&portid, cap_mask, node_name, node, + if (!print_errors(&portid, cap_mask, cap_mask2, node_name, node, 0xFF, &header_printed)) { summary.ports_checked += node->numports; goto clear; @@ -811,11 +855,11 @@ ib_portid_set(&portid, node->ports[p]->base_lid, 0, 0); - print_errors(&portid, cap_mask, node_name, node, p, + print_errors(&portid, cap_mask, cap_mask2, node_name, node, p, &header_printed); summary.ports_checked++; if (!all_port_sup) - clear_port(&portid, cap_mask, node_name, p); + clear_port(&portid, cap_mask, cap_mask2, node_name, p); } } } @@ -823,7 +867,7 @@ clear: summary.nodes_checked++; if (all_port_sup) - clear_port(&portid, cap_mask, node_name, 0xFF); + clear_port(&portid, cap_mask, cap_mask2, node_name, 0xFF); free(node_name); }