All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
Cc: "ira.weiny" <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Subject: Re: [PATCH 3/3] bject: IB Core: Display extended counter set if available
Date: Thu, 17 Dec 2015 18:19:17 -0500	[thread overview]
Message-ID: <567342F5.5090000@dev.mellanox.co.il> (raw)
In-Reply-To: <alpine.DEB.2.20.1512171649070.22782-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>

On 12/17/2015 5:50 PM, Christoph Lameter wrote:
> On Thu, 17 Dec 2015, Hal Rosenstock wrote:
> 
>> On 12/17/2015 4:28 PM, Christoph Lameter wrote:
>>> So port_check_extended_counters need to return another value for this.
>>> The IETF ones are the uni/mcast xxx counters?
>>
>> Yes
> 
> Ok. Then this patch on top of the last one should give us all of what you
> want:
> 
> 
> 
> Subject: IB core counters: Support noietf extended counters
> 
> Detect if we have extended counters but not IETF counters.
> For that we need a special table and create a function that
> returns the table address.
> 
> 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
> @@ -493,6 +493,26 @@ static struct attribute *pma_attrs_ext[]
>  	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
> @@ -503,6 +523,11 @@ static struct attribute_group pma_group_
>  	.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);
> @@ -576,23 +601,32 @@ err:
>  }
> 
>  /*
> - * Check if the port supports the Extended Counters.
> - * Return error code of 0 for success
> + * Figure out which counter table to use depending on
> + * the device capabilities.
>   */
> -static int port_check_extended_counters(struct ib_device *dev)
> +static struct attribute_group *get_counter_table(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;
> +	if (ret < 0)
> +		/* Fall back to normal counters */
> +		return &pma_group;
> +
> +
> +	if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH) {
> +		/* We have extended counters */
> +
> +		if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
> +			/* But not the IETF ones */
> +			return &pma_group_noietf;

These 2 capability bits are mutually exclusive so I think it should be:

	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;
	}

	return &pma_group;

> +
> +		return &pma_group_ext;
>  	}
> 
> -	return ret;
> +	return &pma_group;
>  }
> 
>  static int add_port(struct ib_device *device, int port_num,
> @@ -623,11 +657,7 @@ static int add_port(struct ib_device *de
>  		return ret;
>  	}
> 
> -	ret = sysfs_create_group(&p->kobj,
> -		port_check_extended_counters(device) ?
> -			&pma_group_ext :
> -			&pma_group);
> -
> +	ret = sysfs_create_group(&p->kobj, get_counter_table(device));
>  	if (ret)
>  		goto err_put;
> 
> 
--
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

  parent reply	other threads:[~2015-12-17 23:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 19:52 [PATCH 0/3] IB 64 bit counter support V2 Christoph Lameter
2015-12-17 19:52 ` [PATCH 1/3] IB Core: Create get_perf_mad function in sysfs.c Christoph Lameter
     [not found]   ` <20151217195312.126391272-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-17 20:12     ` Hal Rosenstock
     [not found]   ` <5684E027.4040006@sandisk.com>
     [not found]     ` <5684E027.4040006-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-01-04  3:47       ` ira.weiny
2015-12-17 19:52 ` [PATCH 2/3] IB core counters: Specify attribute_id in port_table_attribute Christoph Lameter
     [not found]   ` <20151217195312.228660904-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-17 20:12     ` Hal Rosenstock
2015-12-17 19:52 ` [PATCH 3/3] bject: IB Core: Display extended counter set if available Christoph Lameter
     [not found]   ` <20151217195312.334770847-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2015-12-17 20:11     ` Hal Rosenstock
     [not found]       ` <567316F7.9030707-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-17 21:28         ` Christoph Lameter
     [not found]           ` <alpine.DEB.2.20.1512171527060.22782-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-12-17 21:48             ` Hal Rosenstock
     [not found]               ` <56732D97.2080303-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-17 22:50                 ` Christoph Lameter
     [not found]                   ` <alpine.DEB.2.20.1512171649070.22782-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-12-17 23:19                     ` Hal Rosenstock [this message]
     [not found]                       ` <567342F5.5090000-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-18 13:39                         ` Christoph Lameter
     [not found]                           ` <alpine.DEB.2.20.1512180737150.32514-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-12-18 13:52                             ` Hal Rosenstock
     [not found]                               ` <56740F8C.4060703-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-18 15:46                                 ` Christoph Lameter
     [not found]                                   ` <alpine.DEB.2.20.1512180944540.1506-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-12-18 16:26                                     ` Hal Rosenstock
2015-12-17 20:40     ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=567342F5.5090000@dev.mellanox.co.il \
    --to=hal-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.