From patchwork Wed Dec 16 16:22:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christoph Lameter (Ampere)" X-Patchwork-Id: 7863631 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 40D1CBEEE1 for ; Wed, 16 Dec 2015 16:22:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3177620396 for ; Wed, 16 Dec 2015 16:22:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06CAB202AE for ; Wed, 16 Dec 2015 16:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753498AbbLPQWN (ORCPT ); Wed, 16 Dec 2015 11:22:13 -0500 Received: from resqmta-ch2-03v.sys.comcast.net ([69.252.207.35]:45691 "EHLO resqmta-ch2-03v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753192AbbLPQWM (ORCPT ); Wed, 16 Dec 2015 11:22:12 -0500 Received: from resomta-ch2-03v.sys.comcast.net ([69.252.207.99]) by resqmta-ch2-03v.sys.comcast.net with comcast id uGKf1r00829Cfhx01GNCKh; Wed, 16 Dec 2015 16:22:12 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-03v.sys.comcast.net with comcast id uGNB1r0011PgSZ601GNBzz; Wed, 16 Dec 2015 16:22:11 +0000 Received: by gentwo.org (Postfix, from userid 1001) id D80FB1874; Wed, 16 Dec 2015 10:22:10 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id D630BE62; Wed, 16 Dec 2015 10:22:10 -0600 (CST) Date: Wed, 16 Dec 2015 10:22:10 -0600 (CST) From: Christoph Lameter X-X-Sender: cl@east.gentwo.org To: Jason Gunthorpe cc: Hal Rosenstock , "ira.weiny" , dledford@redhat.com, linux-rdma@vger.kernel.org Subject: Re: [PATCH 3/3] IB core: Display 64 bit counters from the extended set In-Reply-To: <20151215212035.GD28167@obsidianresearch.com> Message-ID: References: <20151211182532.332343651@linux.com> <20151211182543.329283794@linux.com> <20151211235630.GG7855@phlsvsds.ph.intel.com> <20151212000047.GA9961@obsidianresearch.com> <566EEE69.5080906@dev.mellanox.co.il> <20151215195554.GA28167@obsidianresearch.com> <5670717F.9090701@dev.mellanox.co.il> <20151215212035.GD28167@obsidianresearch.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1450282932; bh=W/sghtWricjCtaQSPsrqa96UZF9+ZSFgWN+ej5ICAjQ=; h=Received:Received:Received:Received:Date:From:To:Subject: Message-ID:Content-Type; b=WASoZ+3JjeL8rOjCurkH6Til+PAQKQ1YXYnFkDpoX+RGOE1ybCH8f2l5b9u6HQ3QI CuEOVaAw4VOvw+K4c3F/R0Gq0J2MPe8xsARgdfEPuO6la4sz+TXuZXb8kS92ku1YbE 1eDAvb6BlGHivvJHYH6IxvkljFb+CmltkMnpn8xOdeBJt8HAcQgiQYAdvU+fATiIaa o5s41ho76/yZ9x0jOrTkYNjAIwguVR9EnVaWvSv5GmEfXnLPVCLhw9CNEmceYU2GFM j5XEHMTRGXUNd/8bucmLwme/0gFv6TERhDDEh2ArBWJXQtHluDweYarLzo3U8rOVvl wac9MI0gVhxgg== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 15 Dec 2015, Jason Gunthorpe wrote: > > The unicast/multicast extended counters are not always supported - > > depends on setting of PerfMgt ClassPortInfo > > CapabilityMask.IsExtendedWidthSupportedNoIETF (bit 10). > > Yes.. certainly this proposed patch needs to account for that and > continue to use the 32 bit ones in that case. So this is in struct ib_class_port_info the capability_mask? This does not seem to be used anywhere in the IB core. Here is a draft patch to change the counters depending on a bit (which I do not know how to determine). So this would hopefully work if someone would insert the proper check. Note that this patch no longer needs the earlier 2 patches. From Christoph Lameter Subject: IB Core: Display extended counter set if available Check if the extended counters are available and if so create the proper extended and additional counters. DRAFT: This is missing the check if this device supports extended counters. Signed-off-by: Christoph Lameter --- 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 Index: linux/drivers/infiniband/core/sysfs.c =================================================================== --- linux.orig/drivers/infiniband/core/sysfs.c +++ linux/drivers/infiniband/core/sysfs.c @@ -39,6 +39,7 @@ #include #include +#include struct ib_port { struct kobject kobj; @@ -65,6 +66,7 @@ struct port_table_attribute { struct port_attribute attr; char name[8]; int index; + int attr_id; }; static ssize_t port_attr_show(struct kobject *kobj, @@ -314,7 +316,15 @@ static ssize_t show_port_pkey(struct ib_ #define PORT_PMA_ATTR(_name, _counter, _width, _offset) \ struct port_table_attribute port_pma_attr_##_name = { \ .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \ - .index = (_offset) | ((_width) << 16) | ((_counter) << 24) \ + .index = (_offset) | ((_width) << 16) | ((_counter) << 24), \ + .attr_id = IB_PMA_PORT_COUNTERS , \ +} + +#define PORT_PMA_ATTR_EXT(_name, _width, _offset) \ +struct port_table_attribute port_pma_attr_ext_##_name = { \ + .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \ + .index = (_offset) | ((_width) << 16), \ + .attr_id = IB_PMA_PORT_COUNTERS_EXT , \ } static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr, @@ -344,7 +354,7 @@ static ssize_t show_pma_counter(struct i in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_PERF_MGMT; in_mad->mad_hdr.class_version = 1; in_mad->mad_hdr.method = IB_MGMT_METHOD_GET; - in_mad->mad_hdr.attr_id = cpu_to_be16(0x12); /* PortCounters */ + in_mad->mad_hdr.attr_id = tab_attr->attr_id; in_mad->data[41] = p->port_num; /* PortSelect field */ @@ -375,6 +385,11 @@ static ssize_t show_pma_counter(struct i ret = sprintf(buf, "%u\n", be32_to_cpup((__be32 *)(out_mad->data + 40 + offset / 8))); break; + case 64: + ret = sprintf(buf, "%llu\n", + be64_to_cpup((__be64 *)(out_mad->data + 40 + offset / 8))); + break; + default: ret = 0; } @@ -403,6 +418,18 @@ static PORT_PMA_ATTR(port_rcv_data static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256); static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288); +/* + * Counters added by extended set + */ +static PORT_PMA_ATTR_EXT(port_xmit_data , 64, 64); +static PORT_PMA_ATTR_EXT(port_rcv_data , 64, 128); +static PORT_PMA_ATTR_EXT(port_xmit_packets , 64, 192); +static PORT_PMA_ATTR_EXT(port_rcv_packets , 64, 256); +static PORT_PMA_ATTR_EXT(unicast_xmit_packets , 64, 320); +static PORT_PMA_ATTR_EXT(unicast_rcv_packets , 64, 384); +static PORT_PMA_ATTR_EXT(multicast_xmit_packets , 64, 448); +static PORT_PMA_ATTR_EXT(multicast_rcv_packets , 64, 512); + static struct attribute *pma_attrs[] = { &port_pma_attr_symbol_error.attr.attr, &port_pma_attr_link_error_recovery.attr.attr, @@ -423,11 +450,40 @@ static struct attribute *pma_attrs[] = { NULL }; +static struct attribute *pma_attrs_ext[] = { + &port_pma_attr_symbol_error.attr.attr, + &port_pma_attr_link_error_recovery.attr.attr, + &port_pma_attr_link_downed.attr.attr, + &port_pma_attr_port_rcv_errors.attr.attr, + &port_pma_attr_port_rcv_remote_physical_errors.attr.attr, + &port_pma_attr_port_rcv_switch_relay_errors.attr.attr, + &port_pma_attr_port_xmit_discards.attr.attr, + &port_pma_attr_port_xmit_constraint_errors.attr.attr, + &port_pma_attr_port_rcv_constraint_errors.attr.attr, + &port_pma_attr_local_link_integrity_errors.attr.attr, + &port_pma_attr_excessive_buffer_overrun_errors.attr.attr, + &port_pma_attr_VL15_dropped.attr.attr, + &port_pma_attr_ext_port_xmit_data.attr.attr, + &port_pma_attr_ext_port_rcv_data.attr.attr, + &port_pma_attr_ext_port_xmit_packets.attr.attr, + &port_pma_attr_ext_port_rcv_packets.attr.attr, + &port_pma_attr_ext_unicast_rcv_packets.attr.attr, + &port_pma_attr_ext_unicast_xmit_packets.attr.attr, + &port_pma_attr_ext_multicast_rcv_packets.attr.attr, + &port_pma_attr_ext_multicast_xmit_packets.attr.attr, + NULL +}; + static struct attribute_group pma_group = { .name = "counters", .attrs = pma_attrs }; +static struct attribute_group pma_group_ext = { + .name = "counters", + .attrs = pma_attrs_ext +}; + static void ib_port_release(struct kobject *kobj) { struct ib_port *p = container_of(kobj, struct ib_port, kobj); @@ -528,7 +584,9 @@ static int add_port(struct ib_device *de return ret; } - ret = sysfs_create_group(&p->kobj, &pma_group); + ret = sysfs_create_group(&p->kobj, + *** Extended counters *** ? &pma_group_ext : &pma_group); + if (ret) goto err_put;