linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: <netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>,
	<davem@davemloft.net>, <havard@skinnemoen.net>,
	<plagnioj@jcrosoft.com>, <jamie@jamieiles.com>,
	<linux-kernel@vger.kernel.org>, <patrice.vilchez@atmel.com>
Subject: Re: [PATCH 09/10] net/macb: ethtool interface: add register dump feature
Date: Thu, 6 Sep 2012 00:36:14 +0100	[thread overview]
Message-ID: <1346888174.5325.55.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <fcd1c2443a30f23ffcd8de28328c5a382e2a2459.1346775479.git.nicolas.ferre@atmel.com>

On Wed, 2012-09-05 at 11:00 +0200, Nicolas Ferre wrote:
> Add macb_get_regs() ethtool function and its helper function:
> macb_get_regs_len().
> 
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
>  drivers/net/ethernet/cadence/macb.c |   40 +++++++++++++++++++++++++++++++++++
>  drivers/net/ethernet/cadence/macb.h |    3 +++
>  2 files changed, 43 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index c7c39f1..f31c0a7 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1321,10 +1321,50 @@ static void macb_get_drvinfo(struct net_device *dev,
>  	strcpy(info->bus_info, dev_name(&bp->pdev->dev));
>  }
>  
> +static int macb_get_regs_len(struct net_device *netdev)
> +{
> +	return MACB_GREGS_LEN * sizeof(u32);
> +}
> +
> +static void macb_get_regs(struct net_device *dev, struct ethtool_regs *regs,
> +			  void *p)
> +{
> +	struct macb *bp = netdev_priv(dev);
> +	unsigned int tail, head;
> +	u32 *regs_buff = p;
> +
> +        memset(p, 0, MACB_GREGS_LEN * sizeof(u32));

The ethtool core does that for you.  (Drivers can't be trusted to do
it!)

> +	regs->version = MACB_BFEXT(IDNUM, macb_readl(bp, MID));

Note that the version field is supposed to be the version of the
register dump format.  Is this value sufficient for userland to easily
decide whether macb_is_gem()?  Are there spare bits that you can set if
you change the format later?

> +	tail = macb_tx_ring_wrap(bp->tx_tail);
> +	head = macb_tx_ring_wrap(bp->tx_head);
> +
> +	regs_buff[0]  = macb_readl(bp, NCR);
> +	regs_buff[1]  = macb_or_gem_readl(bp, NCFGR);
> +	regs_buff[2]  = macb_readl(bp, NSR);
> +	regs_buff[3]  = macb_readl(bp, TSR);
> +	regs_buff[4]  = macb_readl(bp, RBQP);
> +	regs_buff[5]  = macb_readl(bp, TBQP);
> +	regs_buff[6]  = macb_readl(bp, RSR);
> +	regs_buff[7]  = macb_readl(bp, IMR);
> +
> +	regs_buff[8]  = tail;
> +	regs_buff[9]  = head;
> +	regs_buff[10] = macb_tx_dma(bp, tail);
> +	regs_buff[11] = macb_tx_dma(bp, head);
> +
> +	if (macb_is_gem(bp)) {
> +		regs_buff[12] = gem_readl(bp, USRIO);
> +		regs_buff[13] = gem_readl(bp, DMACFG);
> +	}
> +}
> +
>  static const struct ethtool_ops macb_ethtool_ops = {
>  	.get_settings		= macb_get_settings,
>  	.set_settings		= macb_set_settings,
>  	.get_drvinfo		= macb_get_drvinfo,
> +	.get_regs_len		= macb_get_regs_len,
> +	.get_regs		= macb_get_regs,
>  	.get_link		= ethtool_op_get_link,
>  	.get_ts_info		= ethtool_op_get_ts_info,
>  };
> diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
> index 8a4ee2f..d509e88 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -10,6 +10,9 @@
>  #ifndef _MACB_H
>  #define _MACB_H
>  
> +
> +#define MACB_GREGS_LEN 32

Why is this rather larger than the actual number of registers you
return?  Also, the name is not a great idea as 'regs_len' is normally a
number of bytes.

Ben.

>  /* MACB register offsets */
>  #define MACB_NCR				0x0000
>  #define MACB_NCFGR				0x0004

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  parent reply	other threads:[~2012-09-05 23:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05  8:19 [PATCH 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup Nicolas Ferre
2012-09-05  8:19 ` [PATCH 01/10] net/macb: Add support for Gigabit Ethernet mode Nicolas Ferre
2012-09-05  8:19 ` [PATCH 02/10] net/macb: memory barriers cleanup Nicolas Ferre
2012-09-05  8:19 ` [PATCH 03/10] net/macb: change debugging messages Nicolas Ferre
2012-09-05  8:19 ` [PATCH 04/10] net/macb: Fix a race in macb_start_xmit() Nicolas Ferre
2012-09-05 21:30   ` David Miller
2012-09-06 14:52     ` Nicolas Ferre
2012-09-06 15:49     ` Havard Skinnemoen
2012-09-07 16:34       ` Nicolas Ferre
2012-09-05  9:00 ` [PATCH 05/10] net/macb: clean up ring buffer logic Nicolas Ferre
2012-09-05  9:00 ` [PATCH 06/10] net/macb: better manage tx errors Nicolas Ferre
2012-09-05  9:00 ` [PATCH 07/10] net/macb: tx status is more than 8 bits now Nicolas Ferre
2012-09-05  9:00 ` [PATCH 08/10] net/macb: macb_get_drvinfo: add GEM/MACB suffix to differentiate revision Nicolas Ferre
2012-09-05 21:31   ` David Miller
2012-09-05 23:27   ` Ben Hutchings
2012-09-06 14:01     ` Nicolas Ferre
2012-09-06 17:42       ` David Miller
2012-09-05  9:00 ` [PATCH 09/10] net/macb: ethtool interface: add register dump feature Nicolas Ferre
2012-09-05 21:32   ` David Miller
2012-09-05 23:36   ` Ben Hutchings [this message]
2012-09-06 14:20     ` [PATCH v2 " Nicolas Ferre
2012-09-06 14:34       ` Ben Hutchings
2012-09-05  9:04 ` [PATCH 10/10] net/macb: Offset first RX buffer by two bytes Nicolas Ferre

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=1346888174.5325.55.camel@bwh-desktop.uk.solarflarecom.com \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=havard@skinnemoen.net \
    --cc=jamie@jamieiles.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=patrice.vilchez@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).