From patchwork Fri Dec 11 18:25:33 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: 7831881 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 A93F5BEEE1 for ; Fri, 11 Dec 2015 18:25:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF19020430 for ; Fri, 11 Dec 2015 18:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4C8920562 for ; Fri, 11 Dec 2015 18:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713AbbLKSZq (ORCPT ); Fri, 11 Dec 2015 13:25:46 -0500 Received: from resqmta-ch2-06v.sys.comcast.net ([69.252.207.38]:50517 "EHLO resqmta-ch2-06v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbbLKSZp (ORCPT ); Fri, 11 Dec 2015 13:25:45 -0500 Received: from resomta-ch2-18v.sys.comcast.net ([69.252.207.114]) by resqmta-ch2-06v.sys.comcast.net with comcast id sJNh1r0092Udklx01JRkZx; Fri, 11 Dec 2015 18:25:44 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-18v.sys.comcast.net with comcast id sJRk1r0091PgSZ601JRkLD; Fri, 11 Dec 2015 18:25:44 +0000 Received: by gentwo.org (Postfix, from userid 1001) id 35C9E172B; Fri, 11 Dec 2015 12:25:43 -0600 (CST) Message-Id: <20151211182543.135984387@linux.com> Date: Fri, 11 Dec 2015 12:25:33 -0600 From: Christoph Lameter To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH 1/3] IB core: Allow specification of attr_id in PORT_PMA_ATTR macro References: <20151211182532.332343651@linux.com> Content-Disposition: inline; filename=0001-IB-core-Allow-specification-of-attr_id-in-PORT_PMA_A.patch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1449858344; bh=HP4SfG+dBdFGpd6G4RZZPYo/sABhJmX72eLc3pHFMrw=; h=Received:Received:Received:Message-Id:Date:From:To:Subject: Content-Type; b=DRUPnNVFVO6SNMBCFqBRorvkdlYYk3obEuFCMDRwu4Izon8XROrzDr2W4LV5hnpc2 x8HF8B7p9PnsUg9vQUNpC1OQ2Yus3UFDpwgTVI00MGeHw8MVk0swJEwdRaV4UzN9IK I8kTUDT0W85uk7FkGn3kw4fGgSb9GdiSW+bjjayTX8bt7RdLbLBSLRYq4E1XQTOOtz dZAiSl00CHLakW3S+0xDxyhoFNgqAbEpe4SnV+rAW4PRAIOQeUNBwQ2QMjJTYDUh9B v4GLx5DFPFRN4X+0LKwKmyGbP5ymMK4VdGIKBkaArHfWheUr8k2HD5EgA7b6CFXeMr quAkruOESoQmA== 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 This is necessary to support the extended attributes which involves a different attribute id. Signed-off-by: Christoph Lameter Reviewed-by: Ira Weiny --- drivers/infiniband/core/sysfs.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index b1f37d4..1c8716f 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/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, @@ -311,10 +313,11 @@ static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr, return sprintf(buf, "0x%04x\n", pkey); } -#define PORT_PMA_ATTR(_name, _counter, _width, _offset) \ +#define PORT_PMA_ATTR(_name, _counter, _width, _offset, _attr_id) \ 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 = _attr_id , \ } static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr, @@ -344,7 +347,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr, 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 */ @@ -386,22 +389,22 @@ out: return ret; } -static PORT_PMA_ATTR(symbol_error , 0, 16, 32); -static PORT_PMA_ATTR(link_error_recovery , 1, 8, 48); -static PORT_PMA_ATTR(link_downed , 2, 8, 56); -static PORT_PMA_ATTR(port_rcv_errors , 3, 16, 64); -static PORT_PMA_ATTR(port_rcv_remote_physical_errors, 4, 16, 80); -static PORT_PMA_ATTR(port_rcv_switch_relay_errors , 5, 16, 96); -static PORT_PMA_ATTR(port_xmit_discards , 6, 16, 112); -static PORT_PMA_ATTR(port_xmit_constraint_errors , 7, 8, 128); -static PORT_PMA_ATTR(port_rcv_constraint_errors , 8, 8, 136); -static PORT_PMA_ATTR(local_link_integrity_errors , 9, 4, 152); -static PORT_PMA_ATTR(excessive_buffer_overrun_errors, 10, 4, 156); -static PORT_PMA_ATTR(VL15_dropped , 11, 16, 176); -static PORT_PMA_ATTR(port_xmit_data , 12, 32, 192); -static PORT_PMA_ATTR(port_rcv_data , 13, 32, 224); -static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256); -static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288); +static PORT_PMA_ATTR(symbol_error , 0, 16, 32, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(link_error_recovery , 1, 8, 48, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(link_downed , 2, 8, 56, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_errors , 3, 16, 64, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_remote_physical_errors, 4, 16, 80, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_switch_relay_errors , 5, 16, 96, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_xmit_discards , 6, 16, 112, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_xmit_constraint_errors , 7, 8, 128, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_constraint_errors , 8, 8, 136, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(local_link_integrity_errors , 9, 4, 152, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(excessive_buffer_overrun_errors, 10, 4, 156, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(VL15_dropped , 11, 16, 176, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_xmit_data , 12, 32, 192, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_data , 13, 32, 224, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256, IB_PMA_PORT_COUNTERS); +static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288, IB_PMA_PORT_COUNTERS); static struct attribute *pma_attrs[] = { &port_pma_attr_symbol_error.attr.attr,