From: "Émeric Vigier" <emeric.vigier@savoirfairelinux.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Steve Glendinning <steve@shawell.net>,
steve glendinning <steve.glendinning@smsc.com>,
netdev@vger.kernel.org, Nancy Lin <nancy.lin@smsc.com>
Subject: Re: [PATCH] smsc95xx: support ethtool get_regs
Date: Sat, 7 Jul 2012 09:58:04 -0400 (EDT) [thread overview]
Message-ID: <203906907.2074.1341669484945.JavaMail.root@mail.savoirfairelinux.com> (raw)
In-Reply-To: <1341620651.2923.49.camel@bwh-desktop.uk.solarflarecom.com>
----- Mail original -----
> On Fri, 2012-07-06 at 14:15 -0400, Émeric Vigier wrote:
> > From: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
> >
> > Inspired by implementation in smsc911x.c and smsc9420.c
> > Tested on ARM/pandaboard rev A3
> >
> > Signed-off-by: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
> > ---
> > drivers/net/usb/smsc95xx.c | 37
> > +++++++++++++++++++++++++++++++++++++
> > 1 files changed, 37 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/net/usb/smsc95xx.c
> > b/drivers/net/usb/smsc95xx.c
> > index b1112e7..bce14f6 100644
> > --- a/drivers/net/usb/smsc95xx.c
> > +++ b/drivers/net/usb/smsc95xx.c
> > @@ -578,6 +578,41 @@ static int smsc95xx_ethtool_set_eeprom(struct
> > net_device *netdev,
> > return smsc95xx_write_eeprom(dev, ee->offset, ee->len, data);
> > }
> >
> > +
> > +static int smsc95xx_ethtool_getregslen(struct net_device *dev)
> > +{
> > + /* all smsc95xx registers plus all phy registers */
> > + return COE_CR - ID_REV + 1 + 32 * sizeof(u32);
> > +}
> > +
> > +static void
> > +smsc95xx_ethtool_getregs(struct net_device *netdev, struct
> > ethtool_regs *regs,
> > + void *buf)
> > +{
> > + struct usbnet *dev = netdev_priv(netdev);
> > + unsigned int i, j = 0, retval;
> > + u32 *data = buf;
> > +
> > + netif_dbg(dev, hw, dev->net, "ethtool_getregs\n");
> > +
> > + retval = smsc95xx_read_reg(dev, ID_REV, ®s->version);
> > + if (retval < 0) {
> > + netdev_warn(dev->net, "REGS: cannot read ID_REV\n");
> > + return;
> > + }
> > +
> > + for (i = 0; i <= COE_CR; i += (sizeof(u32))) {
> > + retval = smsc95xx_read_reg(dev, i, &data[j++]);
> > + if (retval < 0) {
> > + netdev_warn(dev->net, "REGS: cannot read reg[%x]\n", i);
> > + return;
> > + }
> > + }
>
> Why does this start with i = 0 whereas the calculation of the length
> uses ID_REV as the starting point? Maybe ID_REV == 0, but you should
> be
> consistent in whether you use the name or literal number.
You are right. I will broadcast ID_REV usage.
>
> > + for (i = 0; i <= PHY_SPECIAL; i++)
> > + data[j++] = smsc95xx_mdio_read(netdev, dev->mii.phy_id, i);
> > +}
>
> Again, why use PHY_SPECIAL (+ 1) here as opposed to 32 in the
> calculation of the length?
32 was ok, but I hesitated between defining a SMSC95XX_PHY_END or using the last defined register.
Are 32 register-PHY generic to most devices? I mean could 32 be use widely?
>
> Ben.
>
> > static const struct ethtool_ops smsc95xx_ethtool_ops = {
> > .get_link = usbnet_get_link,
> > .nway_reset = usbnet_nway_reset,
> > @@ -589,6 +624,8 @@ static const struct ethtool_ops
> > smsc95xx_ethtool_ops = {
> > .get_eeprom_len = smsc95xx_ethtool_get_eeprom_len,
> > .get_eeprom = smsc95xx_ethtool_get_eeprom,
> > .set_eeprom = smsc95xx_ethtool_set_eeprom,
> > + .get_regs_len = smsc95xx_ethtool_getregslen,
> > + .get_regs = smsc95xx_ethtool_getregs,
> > };
> >
> > static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq
> > *rq, int cmd)
>
> --
> 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.
>
>
--
Emeric
next prev parent reply other threads:[~2012-07-07 13:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1291035348.223127.1341596173191.JavaMail.root@mail.savoirfairelinux.com>
2012-07-06 18:15 ` [PATCH] smsc95xx: support ethtool get_regs Émeric Vigier
2012-07-06 20:01 ` Francois Romieu
2012-07-06 21:26 ` Émeric Vigier
2012-07-06 22:11 ` Francois Romieu
2012-07-07 14:13 ` Émeric Vigier
2012-07-07 0:24 ` Ben Hutchings
2012-07-07 13:58 ` Émeric Vigier [this message]
2012-07-07 19:55 ` Ben Hutchings
2012-07-09 13:44 ` Émeric Vigier
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=203906907.2074.1341669484945.JavaMail.root@mail.savoirfairelinux.com \
--to=emeric.vigier@savoirfairelinux.com \
--cc=bhutchings@solarflare.com \
--cc=nancy.lin@smsc.com \
--cc=netdev@vger.kernel.org \
--cc=steve.glendinning@smsc.com \
--cc=steve@shawell.net \
/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).