From patchwork Thu Dec 17 19:52:58 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: 7876801 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 0D559BEEE5 for ; Thu, 17 Dec 2015 19:53:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E38B20426 for ; Thu, 17 Dec 2015 19:53:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 308BB2042C for ; Thu, 17 Dec 2015 19:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932083AbbLQTxR (ORCPT ); Thu, 17 Dec 2015 14:53:17 -0500 Received: from resqmta-ch2-01v.sys.comcast.net ([69.252.207.33]:53141 "EHLO resqmta-ch2-01v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754934AbbLQTxP (ORCPT ); Thu, 17 Dec 2015 14:53:15 -0500 Received: from resomta-ch2-05v.sys.comcast.net ([69.252.207.101]) by resqmta-ch2-01v.sys.comcast.net with comcast id ujsb1r0012Bo0NV01jtEGY; Thu, 17 Dec 2015 19:53:14 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-05v.sys.comcast.net with comcast id ujtE1r0051PgSZ601jtExG; Thu, 17 Dec 2015 19:53:14 +0000 Received: by gentwo.org (Postfix, from userid 1001) id 682FC4868; Thu, 17 Dec 2015 13:53:12 -0600 (CST) Message-Id: <20151217195312.334770847@linux.com> Date: Thu, 17 Dec 2015 13:52:58 -0600 From: Christoph Lameter To: Hal Rosenstock Cc: "ira.weiny" Cc: dledford@redhat.com Cc: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH 3/3] bject: IB Core: Display extended counter set if available References: <20151217195255.334854705@linux.com> Content-Disposition: inline; filename=ib_64bit_add_counters DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1450381994; bh=qgmMfAbQ076GAkoq9ECdVbhsZyjO19bXVQxVs7Q5014=; h=Received:Received:Received:Message-Id:Date:From:To:Subject: Content-Type; b=vx1Dd/18wmb5NgI88tr8fCjb4EXfzHWpfPWROR/In4FmMNy9qSWTD7ukXmH4w2s38 8+cyHK3BYFA97Ljwr9IwRcpAtkSvriuoJRhbSp60BY26U3zVonpQWVTbipOHpK5kts X66dREfvM4RXdbiZkwgYEmoBKrHuTfPCrAEYidrwam96+lCOMu+JhBe/SAg/PjEWQ2 m+6YX9ghcdUMt1L5pWXD8wjLoburwwqRc5XVp0brYsQUIzn7GJ8lm97TpC1+CwWPpT e3NA1J0nwZDZjDSQJq1T3Juw8rRsCw5vu4ed2i7b9+qXtvN74aGho3MpjtkR0Lw9Nx iebfvUbgbkgQQ== 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 Check if the extended counters are available and if so create the proper extended and additional 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 @@ -320,6 +320,13 @@ struct port_table_attribute port_pma_att .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 , \ +} + /* * Get a Perfmgmt MAD block of data. * Returns error code or the number of bytes retrieved. @@ -349,7 +356,8 @@ static int get_perf_mad(struct ib_device in_mad->mad_hdr.method = IB_MGMT_METHOD_GET; in_mad->mad_hdr.attr_id = attr; - in_mad->data[41] = port_num; /* PortSelect field */ + if (port_num) + in_mad->data[41] = port_num; /* PortSelect field */ if ((dev->process_mad(dev, IB_MAD_IGNORE_MKEY, port_num, NULL, NULL, @@ -400,6 +408,11 @@ static ssize_t show_pma_counter(struct i ret = sprintf(buf, "%u\n", be32_to_cpup((__be32 *)data)); break; + case 64: + ret = sprintf(buf, "%llu\n", + be64_to_cpup((__be64 *)data)); + break; + default: ret = 0; } @@ -424,6 +437,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, @@ -444,11 +469,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); @@ -521,6 +575,26 @@ err: return NULL; } +/* + * Check if the port supports the Extended Counters. + * Return error code of 0 for success + */ +static int port_check_extended_counters(struct ib_device *dev) +{ + int ret = 0; + struct ib_class_port_info cpi; + + ret = get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO, &cpi, 40, sizeof(cpi)); + + if (ret >= 0) { + if (!(cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH) && + !(cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)) + ret = -ENOSYS; + } + + return ret; +} + static int add_port(struct ib_device *device, int port_num, int (*port_callback)(struct ib_device *, u8, struct kobject *)) @@ -549,7 +623,11 @@ static int add_port(struct ib_device *de return ret; } - ret = sysfs_create_group(&p->kobj, &pma_group); + ret = sysfs_create_group(&p->kobj, + port_check_extended_counters(device) ? + &pma_group_ext : + &pma_group); + if (ret) goto err_put; Index: linux/include/rdma/ib_pma.h =================================================================== --- linux.orig/include/rdma/ib_pma.h +++ linux/include/rdma/ib_pma.h @@ -42,6 +42,7 @@ */ #define IB_PMA_CLASS_CAP_ALLPORTSELECT cpu_to_be16(1 << 8) #define IB_PMA_CLASS_CAP_EXT_WIDTH cpu_to_be16(1 << 9) +#define IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF cpu_to_be16(1 << 10) #define IB_PMA_CLASS_CAP_XMIT_WAIT cpu_to_be16(1 << 12) #define IB_PMA_CLASS_PORT_INFO cpu_to_be16(0x0001)