All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] IB core: 64 bit counter support V3
@ 2015-12-21 14:20 Christoph Lameter
  2015-12-21 14:20 ` [PATCH 1/3] Create get_perf_mad function in sysfs.c Christoph Lameter
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Christoph Lameter @ 2015-12-21 14:20 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: ira.weiny, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

V2->V3
  - Also add support for NOIETF counter mode where we have 64 bit
  	counters but not the multicast/unicast counters.
  - Add Reviewed-by's from Hal.

V1->V2
  - Add detection of the capability for 64 bit counter support
  - Lots of improvements as a result of suggestions by Hal Rosenstock.

Currently we only use 32 bits for the packet and byte counters. There have
been extended countes available for some time but we have no support for
those yet upstream. We keep having issues with 32 bit counters wrapping.
Especially the byte counter can wrap frequently (as in multiple times per
minute)

This patch adds 4 new counters (for full extended mode) and updates 4 32
bit counters to use the 64 bit sizes (for NOIETF and full extended mode)
so that they no longer wrap.

Should the device not support 64 bit counters then only the original 32
bit counters will be visible.

This patchset can be pulled from my git repo on kernel.org

git pull git://git.kernel.org/pub/scm/linux/kernle/git/christoph/rdma.git counter_64bit

Thanks to Hal Rosenstock and Ira Weiny for reviewing this patchset.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/3] Create get_perf_mad function in sysfs.c
  2015-12-21 14:20 [PATCH 0/3] IB core: 64 bit counter support V3 Christoph Lameter
@ 2015-12-21 14:20 ` Christoph Lameter
       [not found]   ` <20151221142039.168096557-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
  2015-12-21 14:20 ` [PATCH 2/3] Specify attribute_id in port_table_attribute Christoph Lameter
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2015-12-21 14:20 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: ira.weiny, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

[-- Attachment #1: 0001-IB-Core-Create-get_perf_mad-function-in-sysfs.c.patch --]
[-- Type: text/plain, Size: 4104 bytes --]

Create a new function to retrieve performance management
data from the existing code in get_pma_counter().

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/sysfs.c | 62 ++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 22 deletions(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index b1f37d4..acefe85 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -317,21 +317,21 @@ struct port_table_attribute port_pma_attr_##_name = {			\
 	.index = (_offset) | ((_width) << 16) | ((_counter) << 24)	\
 }
 
-static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
-				char *buf)
+/*
+ * Get a Perfmgmt MAD block of data.
+ * Returns error code or the number of bytes retrieved.
+ */
+static int get_perf_mad(struct ib_device *dev, int port_num, int attr,
+		void *data, int offset, size_t size)
 {
-	struct port_table_attribute *tab_attr =
-		container_of(attr, struct port_table_attribute, attr);
-	int offset = tab_attr->index & 0xffff;
-	int width  = (tab_attr->index >> 16) & 0xff;
-	struct ib_mad *in_mad  = NULL;
-	struct ib_mad *out_mad = NULL;
+	struct ib_mad *in_mad;
+	struct ib_mad *out_mad;
 	size_t mad_size = sizeof(*out_mad);
 	u16 out_mad_pkey_index = 0;
 	ssize_t ret;
 
-	if (!p->ibdev->process_mad)
-		return sprintf(buf, "N/A (no PMA)\n");
+	if (!dev->process_mad)
+		return -ENOSYS;
 
 	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
@@ -344,12 +344,12 @@ 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       = attr;
 
-	in_mad->data[41] = p->port_num;	/* PortSelect field */
+	in_mad->data[41] = port_num;	/* PortSelect field */
 
-	if ((p->ibdev->process_mad(p->ibdev, IB_MAD_IGNORE_MKEY,
-		 p->port_num, NULL, NULL,
+	if ((dev->process_mad(dev, IB_MAD_IGNORE_MKEY,
+		 port_num, NULL, NULL,
 		 (const struct ib_mad_hdr *)in_mad, mad_size,
 		 (struct ib_mad_hdr *)out_mad, &mad_size,
 		 &out_mad_pkey_index) &
@@ -358,31 +358,49 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
 		ret = -EINVAL;
 		goto out;
 	}
+	memcpy(data, out_mad->data + offset, size);
+	ret = size;
+out:
+	kfree(in_mad);
+	kfree(out_mad);
+	return ret;
+}
+
+static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
+				char *buf)
+{
+	struct port_table_attribute *tab_attr =
+		container_of(attr, struct port_table_attribute, attr);
+	int offset = tab_attr->index & 0xffff;
+	int width  = (tab_attr->index >> 16) & 0xff;
+	ssize_t ret;
+	u8 data[8];
+
+	ret = get_perf_mad(p->ibdev, p->port_num, cpu_to_be16(0x12), &data,
+			40 + offset / 8, sizeof(data));
+	if (ret < 0)
+		return sprintf(buf, "N/A (no PMA)\n");
 
 	switch (width) {
 	case 4:
-		ret = sprintf(buf, "%u\n", (out_mad->data[40 + offset / 8] >>
+		ret = sprintf(buf, "%u\n", (*data >>
 					    (4 - (offset % 8))) & 0xf);
 		break;
 	case 8:
-		ret = sprintf(buf, "%u\n", out_mad->data[40 + offset / 8]);
+		ret = sprintf(buf, "%u\n", *data);
 		break;
 	case 16:
 		ret = sprintf(buf, "%u\n",
-			      be16_to_cpup((__be16 *)(out_mad->data + 40 + offset / 8)));
+			      be16_to_cpup((__be16 *)data));
 		break;
 	case 32:
 		ret = sprintf(buf, "%u\n",
-			      be32_to_cpup((__be32 *)(out_mad->data + 40 + offset / 8)));
+			      be32_to_cpup((__be32 *)data));
 		break;
 	default:
 		ret = 0;
 	}
 
-out:
-	kfree(in_mad);
-	kfree(out_mad);
-
 	return ret;
 }
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/3] Specify attribute_id in port_table_attribute
  2015-12-21 14:20 [PATCH 0/3] IB core: 64 bit counter support V3 Christoph Lameter
  2015-12-21 14:20 ` [PATCH 1/3] Create get_perf_mad function in sysfs.c Christoph Lameter
@ 2015-12-21 14:20 ` Christoph Lameter
       [not found]   ` <20151221142039.281989535-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
  2015-12-21 14:20 ` [PATCH 3/3] Display extended counter set if available Christoph Lameter
       [not found] ` <20151221142026.238104419-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2015-12-21 14:20 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: ira.weiny, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

[-- Attachment #1: 0002-IB-core-counters-Specify-attribute_id-in-port_table_.patch --]
[-- Type: text/plain, Size: 1956 bytes --]

Add the attr_id on port_table_attribute since we will have to add
a different port_table_attribute for the extended attribute soon.

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/sysfs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index acefe85..34dcc23 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -39,6 +39,7 @@
 #include <linux/string.h>
 
 #include <rdma/ib_mad.h>
+#include <rdma/ib_pma.h>
 
 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,8 @@ static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
 #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 ,				\
 }
 
 /*
@@ -376,7 +379,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
 	ssize_t ret;
 	u8 data[8];
 
-	ret = get_perf_mad(p->ibdev, p->port_num, cpu_to_be16(0x12), &data,
+	ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data,
 			40 + offset / 8, sizeof(data));
 	if (ret < 0)
 		return sprintf(buf, "N/A (no PMA)\n");
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/3] Display extended counter set if available
  2015-12-21 14:20 [PATCH 0/3] IB core: 64 bit counter support V3 Christoph Lameter
  2015-12-21 14:20 ` [PATCH 1/3] Create get_perf_mad function in sysfs.c Christoph Lameter
  2015-12-21 14:20 ` [PATCH 2/3] Specify attribute_id in port_table_attribute Christoph Lameter
@ 2015-12-21 14:20 ` Christoph Lameter
       [not found]   ` <20151221142039.386488696-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
       [not found] ` <20151221142026.238104419-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2015-12-21 14:20 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: ira.weiny, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

[-- Attachment #1: 0003-IB-Core-Display-extended-counter-set-if-available.patch --]
[-- Type: text/plain, Size: 6547 bytes --]

V2->V3: Add check for NOIETF mode and create special table
  for that case.

Check if the extended counters are available and if so
create the proper extended and additional counters.

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/sysfs.c | 104 +++++++++++++++++++++++++++++++++++++++-
 include/rdma/ib_pma.h           |   1 +
 2 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 34dcc23..b179fca 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -320,6 +320,13 @@ struct port_table_attribute port_pma_attr_##_name = {			\
 	.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.
@@ -400,6 +407,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
 		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 +436,18 @@ 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);
 
+/*
+ * 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 +468,65 @@ 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 *pma_attrs_noietf[] = {
+	&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,
+	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 struct attribute_group pma_group_noietf = {
+	.name  = "counters",
+	.attrs  = pma_attrs_noietf
+};
+
 static void ib_port_release(struct kobject *kobj)
 {
 	struct ib_port *p = container_of(kobj, struct ib_port, kobj);
@@ -521,6 +599,30 @@ err:
 	return NULL;
 }
 
+/*
+ * Figure out which counter table to use depending on
+ * the device capabilities.
+ */
+static struct attribute_group *get_counter_table(struct ib_device *dev)
+{
+	struct ib_class_port_info cpi;
+
+	if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,
+				&cpi, 40, sizeof(cpi)) >= 0) {
+
+		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
+			/* We have extended counters */
+			return &pma_group_ext;
+
+		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
+			/* But not the IETF ones */
+			return &pma_group_noietf;
+	}
+
+	/* Fall back to normal counters */
+	return &pma_group;
+}
+
 static int add_port(struct ib_device *device, int port_num,
 		    int (*port_callback)(struct ib_device *,
 					 u8, struct kobject *))
@@ -549,7 +651,7 @@ static int add_port(struct ib_device *device, int port_num,
 		return ret;
 	}
 
-	ret = sysfs_create_group(&p->kobj, &pma_group);
+	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
 	if (ret)
 		goto err_put;
 
diff --git a/include/rdma/ib_pma.h b/include/rdma/ib_pma.h
index a5889f1..2f8a65c 100644
--- a/include/rdma/ib_pma.h
+++ b/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)
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] Create get_perf_mad function in sysfs.c
       [not found]   ` <20151221142039.168096557-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
@ 2015-12-21 17:42     ` ira.weiny
  0 siblings, 0 replies; 15+ messages in thread
From: ira.weiny @ 2015-12-21 17:42 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Hal Rosenstock, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, Dec 21, 2015 at 08:20:27AM -0600, Christoph Lameter wrote:
> Create a new function to retrieve performance management
> data from the existing code in get_pma_counter().
> 
> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/infiniband/core/sysfs.c | 62 ++++++++++++++++++++++++++---------------
>  1 file changed, 40 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index b1f37d4..acefe85 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -317,21 +317,21 @@ struct port_table_attribute port_pma_attr_##_name = {			\
>  	.index = (_offset) | ((_width) << 16) | ((_counter) << 24)	\
>  }
>  
> -static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
> -				char *buf)
> +/*
> + * Get a Perfmgmt MAD block of data.
> + * Returns error code or the number of bytes retrieved.
> + */
> +static int get_perf_mad(struct ib_device *dev, int port_num, int attr,
> +		void *data, int offset, size_t size)
>  {
> -	struct port_table_attribute *tab_attr =
> -		container_of(attr, struct port_table_attribute, attr);
> -	int offset = tab_attr->index & 0xffff;
> -	int width  = (tab_attr->index >> 16) & 0xff;
> -	struct ib_mad *in_mad  = NULL;
> -	struct ib_mad *out_mad = NULL;
> +	struct ib_mad *in_mad;
> +	struct ib_mad *out_mad;
>  	size_t mad_size = sizeof(*out_mad);
>  	u16 out_mad_pkey_index = 0;
>  	ssize_t ret;
>  
> -	if (!p->ibdev->process_mad)
> -		return sprintf(buf, "N/A (no PMA)\n");
> +	if (!dev->process_mad)
> +		return -ENOSYS;
>  
>  	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
>  	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> @@ -344,12 +344,12 @@ 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       = attr;
>  
> -	in_mad->data[41] = p->port_num;	/* PortSelect field */
> +	in_mad->data[41] = port_num;	/* PortSelect field */
>  
> -	if ((p->ibdev->process_mad(p->ibdev, IB_MAD_IGNORE_MKEY,
> -		 p->port_num, NULL, NULL,
> +	if ((dev->process_mad(dev, IB_MAD_IGNORE_MKEY,
> +		 port_num, NULL, NULL,
>  		 (const struct ib_mad_hdr *)in_mad, mad_size,
>  		 (struct ib_mad_hdr *)out_mad, &mad_size,
>  		 &out_mad_pkey_index) &
> @@ -358,31 +358,49 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>  		ret = -EINVAL;
>  		goto out;
>  	}
> +	memcpy(data, out_mad->data + offset, size);
> +	ret = size;
> +out:
> +	kfree(in_mad);
> +	kfree(out_mad);
> +	return ret;
> +}
> +
> +static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
> +				char *buf)
> +{
> +	struct port_table_attribute *tab_attr =
> +		container_of(attr, struct port_table_attribute, attr);
> +	int offset = tab_attr->index & 0xffff;
> +	int width  = (tab_attr->index >> 16) & 0xff;
> +	ssize_t ret;
> +	u8 data[8];
> +
> +	ret = get_perf_mad(p->ibdev, p->port_num, cpu_to_be16(0x12), &data,
> +			40 + offset / 8, sizeof(data));
> +	if (ret < 0)
> +		return sprintf(buf, "N/A (no PMA)\n");
>  
>  	switch (width) {
>  	case 4:
> -		ret = sprintf(buf, "%u\n", (out_mad->data[40 + offset / 8] >>
> +		ret = sprintf(buf, "%u\n", (*data >>
>  					    (4 - (offset % 8))) & 0xf);
>  		break;
>  	case 8:
> -		ret = sprintf(buf, "%u\n", out_mad->data[40 + offset / 8]);
> +		ret = sprintf(buf, "%u\n", *data);
>  		break;
>  	case 16:
>  		ret = sprintf(buf, "%u\n",
> -			      be16_to_cpup((__be16 *)(out_mad->data + 40 + offset / 8)));
> +			      be16_to_cpup((__be16 *)data));
>  		break;
>  	case 32:
>  		ret = sprintf(buf, "%u\n",
> -			      be32_to_cpup((__be32 *)(out_mad->data + 40 + offset / 8)));
> +			      be32_to_cpup((__be32 *)data));
>  		break;
>  	default:
>  		ret = 0;
>  	}
>  
> -out:
> -	kfree(in_mad);
> -	kfree(out_mad);
> -
>  	return ret;
>  }
>  
> -- 
> 2.5.0
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] Specify attribute_id in port_table_attribute
       [not found]   ` <20151221142039.281989535-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
@ 2015-12-21 17:43     ` ira.weiny
  0 siblings, 0 replies; 15+ messages in thread
From: ira.weiny @ 2015-12-21 17:43 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Hal Rosenstock, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, Dec 21, 2015 at 08:20:28AM -0600, Christoph Lameter wrote:
> Add the attr_id on port_table_attribute since we will have to add
> a different port_table_attribute for the extended attribute soon.
> 
> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/infiniband/core/sysfs.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index acefe85..34dcc23 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -39,6 +39,7 @@
>  #include <linux/string.h>
>  
>  #include <rdma/ib_mad.h>
> +#include <rdma/ib_pma.h>
>  
>  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,8 @@ static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
>  #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 ,				\
>  }
>  
>  /*
> @@ -376,7 +379,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>  	ssize_t ret;
>  	u8 data[8];
>  
> -	ret = get_perf_mad(p->ibdev, p->port_num, cpu_to_be16(0x12), &data,
> +	ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data,
>  			40 + offset / 8, sizeof(data));
>  	if (ret < 0)
>  		return sprintf(buf, "N/A (no PMA)\n");
> -- 
> 2.5.0
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]   ` <20151221142039.386488696-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
@ 2015-12-21 17:53     ` ira.weiny
       [not found]       ` <20151221175311.GI3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
  2015-12-24 16:22     ` eran ben elisha
  1 sibling, 1 reply; 15+ messages in thread
From: ira.weiny @ 2015-12-21 17:53 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Hal Rosenstock, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, Dec 21, 2015 at 08:20:29AM -0600, Christoph Lameter wrote:
> V2->V3: Add check for NOIETF mode and create special table
>   for that case.
> 
> Check if the extended counters are available and if so
> create the proper extended and additional counters.
> 
> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/infiniband/core/sysfs.c | 104 +++++++++++++++++++++++++++++++++++++++-
>  include/rdma/ib_pma.h           |   1 +
>  2 files changed, 104 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index 34dcc23..b179fca 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -320,6 +320,13 @@ struct port_table_attribute port_pma_attr_##_name = {			\
>  	.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.
> @@ -400,6 +407,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>  		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 +436,18 @@ 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);
>  
> +/*
> + * 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 +468,65 @@ 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 *pma_attrs_noietf[] = {
> +	&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,
> +	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 struct attribute_group pma_group_noietf = {
> +	.name  = "counters",
> +	.attrs  = pma_attrs_noietf
> +};
> +
>  static void ib_port_release(struct kobject *kobj)
>  {
>  	struct ib_port *p = container_of(kobj, struct ib_port, kobj);
> @@ -521,6 +599,30 @@ err:
>  	return NULL;
>  }
>  
> +/*
> + * Figure out which counter table to use depending on
> + * the device capabilities.
> + */
> +static struct attribute_group *get_counter_table(struct ib_device *dev)
> +{
> +	struct ib_class_port_info cpi;
> +
> +	if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,
> +				&cpi, 40, sizeof(cpi)) >= 0) {
> +
> +		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
> +			/* We have extended counters */
> +			return &pma_group_ext;
> +
> +		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
> +			/* But not the IETF ones */
> +			return &pma_group_noietf;
> +	}
> +
> +	/* Fall back to normal counters */
> +	return &pma_group;
> +}
> +
>  static int add_port(struct ib_device *device, int port_num,
>  		    int (*port_callback)(struct ib_device *,
>  					 u8, struct kobject *))
> @@ -549,7 +651,7 @@ static int add_port(struct ib_device *device, int port_num,
>  		return ret;
>  	}
>  
> -	ret = sysfs_create_group(&p->kobj, &pma_group);
> +	ret = sysfs_create_group(&p->kobj, get_counter_table(device));

Don't we need to change all the sysfs_remove_groups to use get_counter_table as
well?

Ira

>  	if (ret)
>  		goto err_put;
>  
> diff --git a/include/rdma/ib_pma.h b/include/rdma/ib_pma.h
> index a5889f1..2f8a65c 100644
> --- a/include/rdma/ib_pma.h
> +++ b/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)
> -- 
> 2.5.0
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]       ` <20151221175311.GI3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
@ 2015-12-21 17:57         ` Hal Rosenstock
       [not found]           ` <56783D89.4060704-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Hal Rosenstock @ 2015-12-21 17:57 UTC (permalink / raw)
  To: ira.weiny, Christoph Lameter
  Cc: Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On 12/21/2015 12:53 PM, ira.weiny wrote:
> On Mon, Dec 21, 2015 at 08:20:29AM -0600, Christoph Lameter wrote:
>> V2->V3: Add check for NOIETF mode and create special table
>>   for that case.
>>
>> Check if the extended counters are available and if so
>> create the proper extended and additional counters.
>>
>> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
>> ---
>>  drivers/infiniband/core/sysfs.c | 104 +++++++++++++++++++++++++++++++++++++++-
>>  include/rdma/ib_pma.h           |   1 +
>>  2 files changed, 104 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
>> index 34dcc23..b179fca 100644
>> --- a/drivers/infiniband/core/sysfs.c
>> +++ b/drivers/infiniband/core/sysfs.c
>> @@ -320,6 +320,13 @@ struct port_table_attribute port_pma_attr_##_name = {			\
>>  	.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.
>> @@ -400,6 +407,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>>  		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 +436,18 @@ 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);
>>  
>> +/*
>> + * 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 +468,65 @@ 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 *pma_attrs_noietf[] = {
>> +	&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,
>> +	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 struct attribute_group pma_group_noietf = {
>> +	.name  = "counters",
>> +	.attrs  = pma_attrs_noietf
>> +};
>> +
>>  static void ib_port_release(struct kobject *kobj)
>>  {
>>  	struct ib_port *p = container_of(kobj, struct ib_port, kobj);
>> @@ -521,6 +599,30 @@ err:
>>  	return NULL;
>>  }
>>  
>> +/*
>> + * Figure out which counter table to use depending on
>> + * the device capabilities.
>> + */
>> +static struct attribute_group *get_counter_table(struct ib_device *dev)
>> +{
>> +	struct ib_class_port_info cpi;
>> +
>> +	if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,
>> +				&cpi, 40, sizeof(cpi)) >= 0) {
>> +
>> +		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
>> +			/* We have extended counters */
>> +			return &pma_group_ext;
>> +
>> +		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
>> +			/* But not the IETF ones */
>> +			return &pma_group_noietf;
>> +	}
>> +
>> +	/* Fall back to normal counters */
>> +	return &pma_group;
>> +}
>> +
>>  static int add_port(struct ib_device *device, int port_num,
>>  		    int (*port_callback)(struct ib_device *,
>>  					 u8, struct kobject *))
>> @@ -549,7 +651,7 @@ static int add_port(struct ib_device *device, int port_num,
>>  		return ret;
>>  	}
>>  
>> -	ret = sysfs_create_group(&p->kobj, &pma_group);
>> +	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
> 
> Don't we need to change all the sysfs_remove_groups to use get_counter_table as
> well?

Looks like it to me too. Good catch.

-- Hal

> 
> Ira
> 
>>  	if (ret)
>>  		goto err_put;
>>  
>> diff --git a/include/rdma/ib_pma.h b/include/rdma/ib_pma.h
>> index a5889f1..2f8a65c 100644
>> --- a/include/rdma/ib_pma.h
>> +++ b/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)
>> -- 
>> 2.5.0
>>
>>
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]           ` <56783D89.4060704-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2015-12-21 19:31             ` Christoph Lameter
       [not found]               ` <alpine.DEB.2.20.1512211330290.19955-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2015-12-21 19:31 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: ira.weiny, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, 21 Dec 2015, Hal Rosenstock wrote:

> > Don't we need to change all the sysfs_remove_groups to use get_counter_table as
> > well?
>
> Looks like it to me too. Good catch.

Fix follows:

From: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
Subject: Fix sysfs entry removal by storing the table format in  pma_table

Store the table being used in the ib_port structure and use it when sysfs
entries have to be removed.

Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>

Index: linux/drivers/infiniband/core/sysfs.c
===================================================================
--- linux.orig/drivers/infiniband/core/sysfs.c
+++ linux/drivers/infiniband/core/sysfs.c
@@ -47,6 +47,7 @@ struct ib_port {
 	struct attribute_group gid_group;
 	struct attribute_group pkey_group;
 	u8                     port_num;
+	struct attribute_group *pma_table;
 };

 struct port_attribute {
@@ -651,7 +652,8 @@ static int add_port(struct ib_device *de
 		return ret;
 	}

-	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
+	p->pma_table = get_counter_table(device);
+	ret = sysfs_create_group(&p->kobj, p->pma_table);
 	if (ret)
 		goto err_put;

@@ -710,7 +712,7 @@ err_free_gid:
 	p->gid_group.attrs = NULL;

 err_remove_pma:
-	sysfs_remove_group(&p->kobj, &pma_group);
+	sysfs_remove_group(&p->kobj, p->pma_table);

 err_put:
 	kobject_put(&p->kobj);
@@ -923,7 +925,7 @@ static void free_port_list_attributes(st
 	list_for_each_entry_safe(p, t, &device->port_list, entry) {
 		struct ib_port *port = container_of(p, struct ib_port, kobj);
 		list_del(&p->entry);
-		sysfs_remove_group(p, &pma_group);
+		sysfs_remove_group(p, port->pma_table);
 		sysfs_remove_group(p, &port->pkey_group);
 		sysfs_remove_group(p, &port->gid_group);
 		kobject_put(p);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]               ` <alpine.DEB.2.20.1512211330290.19955-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
@ 2015-12-21 19:47                 ` ira.weiny
       [not found]                   ` <20151221194729.GK3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: ira.weiny @ 2015-12-21 19:47 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Hal Rosenstock, Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, Dec 21, 2015 at 01:31:31PM -0600, Christoph Lameter wrote:
> On Mon, 21 Dec 2015, Hal Rosenstock wrote:
> 
> > > Don't we need to change all the sysfs_remove_groups to use get_counter_table as
> > > well?
> >
> > Looks like it to me too. Good catch.
> 
> Fix follows:
> 
> From: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> Subject: Fix sysfs entry removal by storing the table format in  pma_table
> 
> Store the table being used in the ib_port structure and use it when sysfs
> entries have to be removed.
> 
> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>

Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

> 
> Index: linux/drivers/infiniband/core/sysfs.c
> ===================================================================
> --- linux.orig/drivers/infiniband/core/sysfs.c
> +++ linux/drivers/infiniband/core/sysfs.c
> @@ -47,6 +47,7 @@ struct ib_port {
>  	struct attribute_group gid_group;
>  	struct attribute_group pkey_group;
>  	u8                     port_num;
> +	struct attribute_group *pma_table;
>  };
> 
>  struct port_attribute {
> @@ -651,7 +652,8 @@ static int add_port(struct ib_device *de
>  		return ret;
>  	}
> 
> -	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
> +	p->pma_table = get_counter_table(device);
> +	ret = sysfs_create_group(&p->kobj, p->pma_table);
>  	if (ret)
>  		goto err_put;
> 
> @@ -710,7 +712,7 @@ err_free_gid:
>  	p->gid_group.attrs = NULL;
> 
>  err_remove_pma:
> -	sysfs_remove_group(&p->kobj, &pma_group);
> +	sysfs_remove_group(&p->kobj, p->pma_table);
> 
>  err_put:
>  	kobject_put(&p->kobj);
> @@ -923,7 +925,7 @@ static void free_port_list_attributes(st
>  	list_for_each_entry_safe(p, t, &device->port_list, entry) {
>  		struct ib_port *port = container_of(p, struct ib_port, kobj);
>  		list_del(&p->entry);
> -		sysfs_remove_group(p, &pma_group);
> +		sysfs_remove_group(p, port->pma_table);
>  		sysfs_remove_group(p, &port->pkey_group);
>  		sysfs_remove_group(p, &port->gid_group);
>  		kobject_put(p);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]                   ` <20151221194729.GK3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
@ 2015-12-21 19:52                     ` Hal Rosenstock
  0 siblings, 0 replies; 15+ messages in thread
From: Hal Rosenstock @ 2015-12-21 19:52 UTC (permalink / raw)
  To: ira.weiny, Christoph Lameter
  Cc: Hal Rosenstock, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On 12/21/2015 2:47 PM, ira.weiny wrote:
> On Mon, Dec 21, 2015 at 01:31:31PM -0600, Christoph Lameter wrote:
>> On Mon, 21 Dec 2015, Hal Rosenstock wrote:
>>
>>>> Don't we need to change all the sysfs_remove_groups to use get_counter_table as
>>>> well?
>>>
>>> Looks like it to me too. Good catch.
>>
>> Fix follows:
>>
>> From: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
>> Subject: Fix sysfs entry removal by storing the table format in  pma_table
>>
>> Store the table being used in the ib_port structure and use it when sysfs
>> entries have to be removed.
>>
>> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> 
> Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

> 
>>
>> Index: linux/drivers/infiniband/core/sysfs.c
>> ===================================================================
>> --- linux.orig/drivers/infiniband/core/sysfs.c
>> +++ linux/drivers/infiniband/core/sysfs.c
>> @@ -47,6 +47,7 @@ struct ib_port {
>>  	struct attribute_group gid_group;
>>  	struct attribute_group pkey_group;
>>  	u8                     port_num;
>> +	struct attribute_group *pma_table;
>>  };
>>
>>  struct port_attribute {
>> @@ -651,7 +652,8 @@ static int add_port(struct ib_device *de
>>  		return ret;
>>  	}
>>
>> -	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
>> +	p->pma_table = get_counter_table(device);
>> +	ret = sysfs_create_group(&p->kobj, p->pma_table);
>>  	if (ret)
>>  		goto err_put;
>>
>> @@ -710,7 +712,7 @@ err_free_gid:
>>  	p->gid_group.attrs = NULL;
>>
>>  err_remove_pma:
>> -	sysfs_remove_group(&p->kobj, &pma_group);
>> +	sysfs_remove_group(&p->kobj, p->pma_table);
>>
>>  err_put:
>>  	kobject_put(&p->kobj);
>> @@ -923,7 +925,7 @@ static void free_port_list_attributes(st
>>  	list_for_each_entry_safe(p, t, &device->port_list, entry) {
>>  		struct ib_port *port = container_of(p, struct ib_port, kobj);
>>  		list_del(&p->entry);
>> -		sysfs_remove_group(p, &pma_group);
>> +		sysfs_remove_group(p, port->pma_table);
>>  		sysfs_remove_group(p, &port->pkey_group);
>>  		sysfs_remove_group(p, &port->gid_group);
>>  		kobject_put(p);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/3] IB core: 64 bit counter support V3
       [not found] ` <20151221142026.238104419-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
@ 2015-12-23 19:33   ` Doug Ledford
  0 siblings, 0 replies; 15+ messages in thread
From: Doug Ledford @ 2015-12-23 19:33 UTC (permalink / raw)
  To: Christoph Lameter, Hal Rosenstock
  Cc: ira.weiny, linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

On 12/21/2015 09:20 AM, Christoph Lameter wrote:
> V2->V3
>   - Also add support for NOIETF counter mode where we have 64 bit
>   	counters but not the multicast/unicast counters.
>   - Add Reviewed-by's from Hal.
> 
> V1->V2
>   - Add detection of the capability for 64 bit counter support
>   - Lots of improvements as a result of suggestions by Hal Rosenstock.
> 
> Currently we only use 32 bits for the packet and byte counters. There have
> been extended countes available for some time but we have no support for
> those yet upstream. We keep having issues with 32 bit counters wrapping.
> Especially the byte counter can wrap frequently (as in multiple times per
> minute)
> 
> This patch adds 4 new counters (for full extended mode) and updates 4 32
> bit counters to use the 64 bit sizes (for NOIETF and full extended mode)
> so that they no longer wrap.
> 
> Should the device not support 64 bit counters then only the original 32
> bit counters will be visible.
> 
> This patchset can be pulled from my git repo on kernel.org
> 
> git pull git://git.kernel.org/pub/scm/linux/kernle/git/christoph/rdma.git counter_64bit
> 
> Thanks to Hal Rosenstock and Ira Weiny for reviewing this patchset.
> 

Hi Christoph,

I've pulled this set in.  However, two things would be helpful in the
future:

1) Prepend the area you are patching to your patch subjects.  Aka, you
put IB core: on the cover letter, but the individual patches did not
have that.  They should (and generally I would use IB/core:).

2) When assigning a V1/V2/V3, pass that as part of the --subject-prefix
you give to git.  When you use it on the cover letter, patchworks drops
it entirely (patchworks does not keep cover letters, and does not
transfer v1 tags from cover letters to the subsequent patches).  This
makes it *much* easier for me to pick out which of your patches in
patchworks are the most recent.

Thanks ;-)

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]   ` <20151221142039.386488696-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
  2015-12-21 17:53     ` ira.weiny
@ 2015-12-24 16:22     ` eran ben elisha
       [not found]       ` <CAKHjkjkwneRd9kTfHbQHLYMexhtP4ibE0sdHrUeYWmV=3fvYLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 15+ messages in thread
From: eran ben elisha @ 2015-12-24 16:22 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Hal Rosenstock, ira.weiny, Hal Rosenstock, Doug Ledford,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Mon, Dec 21, 2015 at 4:20 PM, Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org> wrote:
> V2->V3: Add check for NOIETF mode and create special table
>   for that case.
>
> Check if the extended counters are available and if so
> create the proper extended and additional counters.
>
> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/infiniband/core/sysfs.c | 104 +++++++++++++++++++++++++++++++++++++++-
>  include/rdma/ib_pma.h           |   1 +
>  2 files changed, 104 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index 34dcc23..b179fca 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -320,6 +320,13 @@ struct port_table_attribute port_pma_attr_##_name = {                      \
>         .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.
> @@ -400,6 +407,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>                 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 +436,18 @@ 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);
>
> +/*
> + * 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 +468,65 @@ 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 *pma_attrs_noietf[] = {
> +       &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,
> +       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 struct attribute_group pma_group_noietf = {
> +       .name  = "counters",
> +       .attrs  = pma_attrs_noietf
> +};
> +
>  static void ib_port_release(struct kobject *kobj)
>  {
>         struct ib_port *p = container_of(kobj, struct ib_port, kobj);
> @@ -521,6 +599,30 @@ err:
>         return NULL;
>  }
>
> +/*
> + * Figure out which counter table to use depending on
> + * the device capabilities.
> + */
> +static struct attribute_group *get_counter_table(struct ib_device *dev)
> +{
> +       struct ib_class_port_info cpi;
> +
> +       if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,

Why 0, need to pass port num.
See proposal Matan and myself sent.

Eran
> +                               &cpi, 40, sizeof(cpi)) >= 0) {
> +
> +               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
> +                       /* We have extended counters */
> +                       return &pma_group_ext;
> +
> +               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
> +                       /* But not the IETF ones */
> +                       return &pma_group_noietf;
> +       }
> +
> +       /* Fall back to normal counters */
> +       return &pma_group;
> +}
> +
>  static int add_port(struct ib_device *device, int port_num,
>                     int (*port_callback)(struct ib_device *,
>                                          u8, struct kobject *))
> @@ -549,7 +651,7 @@ static int add_port(struct ib_device *device, int port_num,
>                 return ret;
>         }
>
> -       ret = sysfs_create_group(&p->kobj, &pma_group);
> +       ret = sysfs_create_group(&p->kobj, get_counter_table(device));
>         if (ret)
>                 goto err_put;
>
> diff --git a/include/rdma/ib_pma.h b/include/rdma/ib_pma.h
> index a5889f1..2f8a65c 100644
> --- a/include/rdma/ib_pma.h
> +++ b/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)
> --
> 2.5.0
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]       ` <CAKHjkjkwneRd9kTfHbQHLYMexhtP4ibE0sdHrUeYWmV=3fvYLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-12-24 17:06         ` Hal Rosenstock
  2015-12-24 18:45         ` ira.weiny
  1 sibling, 0 replies; 15+ messages in thread
From: Hal Rosenstock @ 2015-12-24 17:06 UTC (permalink / raw)
  To: eran ben elisha, Christoph Lameter
  Cc: ira.weiny, Hal Rosenstock, Doug Ledford,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On 12/24/2015 11:22 AM, eran ben elisha wrote:
> On Mon, Dec 21, 2015 at 4:20 PM, Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org> wrote:
>> V2->V3: Add check for NOIETF mode and create special table
>>   for that case.
>>
>> Check if the extended counters are available and if so
>> create the proper extended and additional counters.
>>
>> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>> Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
>> ---
>>  drivers/infiniband/core/sysfs.c | 104 +++++++++++++++++++++++++++++++++++++++-
>>  include/rdma/ib_pma.h           |   1 +
>>  2 files changed, 104 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
>> index 34dcc23..b179fca 100644
>> --- a/drivers/infiniband/core/sysfs.c
>> +++ b/drivers/infiniband/core/sysfs.c
>> @@ -320,6 +320,13 @@ struct port_table_attribute port_pma_attr_##_name = {                      \
>>         .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.
>> @@ -400,6 +407,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
>>                 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 +436,18 @@ 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);
>>
>> +/*
>> + * 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 +468,65 @@ 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 *pma_attrs_noietf[] = {
>> +       &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,
>> +       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 struct attribute_group pma_group_noietf = {
>> +       .name  = "counters",
>> +       .attrs  = pma_attrs_noietf
>> +};
>> +
>>  static void ib_port_release(struct kobject *kobj)
>>  {
>>         struct ib_port *p = container_of(kobj, struct ib_port, kobj);
>> @@ -521,6 +599,30 @@ err:
>>         return NULL;
>>  }
>>
>> +/*
>> + * Figure out which counter table to use depending on
>> + * the device capabilities.
>> + */
>> +static struct attribute_group *get_counter_table(struct ib_device *dev)
>> +{
>> +       struct ib_class_port_info cpi;
>> +
>> +       if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,
> 
> Why 0, need to pass port num.

ClassPortInfo attribute does not have PortSelect field like other
PerfMgt attributes which is where this port num is placed.

-- Hal

> See proposal Matan and myself sent.
> 
> Eran
>> +                               &cpi, 40, sizeof(cpi)) >= 0) {
>> +
>> +               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
>> +                       /* We have extended counters */
>> +                       return &pma_group_ext;
>> +
>> +               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
>> +                       /* But not the IETF ones */
>> +                       return &pma_group_noietf;
>> +       }
>> +
>> +       /* Fall back to normal counters */
>> +       return &pma_group;
>> +}
>> +
>>  static int add_port(struct ib_device *device, int port_num,
>>                     int (*port_callback)(struct ib_device *,
>>                                          u8, struct kobject *))
>> @@ -549,7 +651,7 @@ static int add_port(struct ib_device *device, int port_num,
>>                 return ret;
>>         }
>>
>> -       ret = sysfs_create_group(&p->kobj, &pma_group);
>> +       ret = sysfs_create_group(&p->kobj, get_counter_table(device));
>>         if (ret)
>>                 goto err_put;
>>
>> diff --git a/include/rdma/ib_pma.h b/include/rdma/ib_pma.h
>> index a5889f1..2f8a65c 100644
>> --- a/include/rdma/ib_pma.h
>> +++ b/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)
>> --
>> 2.5.0
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] Display extended counter set if available
       [not found]       ` <CAKHjkjkwneRd9kTfHbQHLYMexhtP4ibE0sdHrUeYWmV=3fvYLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2015-12-24 17:06         ` Hal Rosenstock
@ 2015-12-24 18:45         ` ira.weiny
  1 sibling, 0 replies; 15+ messages in thread
From: ira.weiny @ 2015-12-24 18:45 UTC (permalink / raw)
  To: eran ben elisha
  Cc: Christoph Lameter, Hal Rosenstock, Hal Rosenstock, Doug Ledford,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Jason Gunthorpe

On Thu, Dec 24, 2015 at 06:22:14PM +0200, eran ben elisha wrote:
> On Mon, Dec 21, 2015 at 4:20 PM, Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org> wrote:

[snip]

> >
> > +/*
> > + * Figure out which counter table to use depending on
> > + * the device capabilities.
> > + */
> > +static struct attribute_group *get_counter_table(struct ib_device *dev)
> > +{
> > +       struct ib_class_port_info cpi;
> > +
> > +       if (get_perf_mad(dev, 0, IB_PMA_CLASS_PORT_INFO,
> 
> Why 0, need to pass port num.
> See proposal Matan and myself sent.
> 

Passing a port num to a ClassPortInfo query makes no sense?

Your proposal sets a field which is wrong (I think it sets part of TrapGID if
my math is correct) in the ClassPortInfo query as per the spec.

I think the fix needs to be somewhere else.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-12-24 18:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 14:20 [PATCH 0/3] IB core: 64 bit counter support V3 Christoph Lameter
2015-12-21 14:20 ` [PATCH 1/3] Create get_perf_mad function in sysfs.c Christoph Lameter
     [not found]   ` <20151221142039.168096557-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-21 17:42     ` ira.weiny
2015-12-21 14:20 ` [PATCH 2/3] Specify attribute_id in port_table_attribute Christoph Lameter
     [not found]   ` <20151221142039.281989535-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-21 17:43     ` ira.weiny
2015-12-21 14:20 ` [PATCH 3/3] Display extended counter set if available Christoph Lameter
     [not found]   ` <20151221142039.386488696-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-21 17:53     ` ira.weiny
     [not found]       ` <20151221175311.GI3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2015-12-21 17:57         ` Hal Rosenstock
     [not found]           ` <56783D89.4060704-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-21 19:31             ` Christoph Lameter
     [not found]               ` <alpine.DEB.2.20.1512211330290.19955-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-12-21 19:47                 ` ira.weiny
     [not found]                   ` <20151221194729.GK3860-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2015-12-21 19:52                     ` Hal Rosenstock
2015-12-24 16:22     ` eran ben elisha
     [not found]       ` <CAKHjkjkwneRd9kTfHbQHLYMexhtP4ibE0sdHrUeYWmV=3fvYLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-24 17:06         ` Hal Rosenstock
2015-12-24 18:45         ` ira.weiny
     [not found] ` <20151221142026.238104419-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-23 19:33   ` [PATCH 0/3] IB core: 64 bit counter support V3 Doug Ledford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.