archive mirror
 help / color / mirror / Atom feed
From: Bogdan Costescu <>
To: Jeff Garzik <>
Cc: Bogdan Costescu <>,
	Linux Kernel Mailing List <>,
	<>, "David S. Miller" <>,
	Linus Torvalds <>
Subject: Re: PATCH: ethtool MII helpers
Date: Wed, 13 Jun 2001 17:29:55 +0200 (CEST)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, 12 Jun 2001, Jeff Garzik wrote:

> What are you doing that you need to access all registers from userspace?

The main purpose is debugging. Some registers give you more detailed info
about what's going on; you don't need this for normal functioning, but
when you're looking for "what's wrong" it might give you additional
details (next page, transceiver manufacturer/model for hardware bugs,
etc.). That's why I proposed restricted access, a normal user shouldn't
need this info, but the sysadmin might.
Probably the same info can be taken from the card inside the kernel,
convert it to some user parsable form and give it to user through /proc or
something similar. But I think that the implementation would be much more
complicated than allowing direct access to MII registers.

One other argument: mii-diag currently allows this. ethtool would mean a
step backwards 8-)

> Right now we have quite a bit of
> deployed code using MII ioctls, and there is a gigabit MII standard; so,
> Becker's argument is that each driver should provide a set of MII
> ioctls, emulating behavior when hardware isn't exactly per spec.

I'm more-or-less supporting this oppinion. But I use Don's mii-diag
heavily in debugging media-related problems for 3c59x, so I might be
biased 8-)

> We have control over the ethtool API, and we can
> correct its deficiencies, whereas any MII spec deficiencies must be
> worked out inside the driver.

I agree that this is a problem. Even more, if you start emulating MII for
non-MII NICs, you might get into trouble when presenting the available
info in a MII-compatible way (f.e. how would you emulate "link partner
ability" ?). But the NIC specific deficiencies should be worked out inside
the driver, isn't this always the case with a common API ?

> Further, there is the question of "how much MII to implement" --
> currently the MII-ioctl-based net drivers all implement -basic- MII, but
> I guarantee that you will find per-driver(per-chip) differences in the
> MII implementation... which is a flaw in the MII ioctl implementation in
> the driver, regardless of how the chip is designed.

I take that you mean by implementing basic MII that the drivers don't take
advantage of the additional info when dealing with media settings. The
drivers do allow user access to all MII registers when available.
Per-driver or per-chip differences mean that the driver author didn't do a
good job at emulating MII 8-)

> There are completeness flaws in more than one MII ioctl implementation.

IMHO, this is only because there is no agreed-upon standard. But this can
be corrected. What prevents ethtool implementations from being flawed ?

> The ethtool API doesn't have that problem.

Well, IMHO you can't directly compare the two. MII has hardware support,
so for a MII-capable NIC, you usually just handle access to the registers.
ethtool is software only and you emulate everything; if you would
also partly emulate MII (where you need to), you are in the same

> For drivers without support for either, just add ethtool support.

Well, that's my point. You need to write code in both cases. So why do you
choose ethtool ?

> For 2.5?  I don't know.  I am not a visionary.  I defer that to Linus
> and David and Donald and Jamal and Alexey and...  I am mainly a
> maintainer and merge monkey, only implementing new APIs when the needs
> are blindingly obvious.

I don't want to push anything. But when oppinions start to diverge, there
will always be (from all sides!) something like: "my version can do this,
but yours can't". So I'm all for _one_ way of doing things.

> You misunderstood the code.  The "caching" here is whatever is -already-
> being done by the driver.  Many Becker-style drivers cache the
> advertising value.  If such a driver uses the ethtool MII code, that is
> one less MII read that needs to occur.

No, I was talking mainly about 'bmcr' and 'bmsr'. I'm not aware of any
driver that caches these values currently.

> > +       if (mii->autoneg < 0)
> > +               autoneg = mii->autoneg = (bmcr & BMCR_ANENABLE) ? 1 : 0;
> > +       else    autoneg = mii->autoneg;
> >
> > You don't read anything from the hardware at this point. Why do you want
> > caching ?
> I don't understand your question.  Of course we have read BMCR from the
> hardware at that point, read the code...

My question was directly related to caching of 'autoneg'. You need to read
'bmcr' before, sure, but why not directly "computing" autoneg instead of
the "if" ? What do you achieve by setting autoneg to potentially something
else than the actual BMCR setting ?

> It is really up to interpretation of the individual driver author (or in
> this case mii.c author), because the net core doesn't know nor care
> about XCVR_xxx.

Yes, but it might make a difference for debugging too. For the example
that I gave, it really helps knowing which of the 2 MII transceivers on
the card is used. So, this info might need to be propagated as exactly
as possible even to user space. And probably needs to be driver-specific,
not in mii.c, anyway.


Bogdan Costescu

IWR - Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen
Universitaet Heidelberg, INF 368, D-69120 Heidelberg, GERMANY
Telephone: +49 6221 54 8869, Telefax: +49 6221 54 8868
E-mail: Bogdan.Costescu@IWR.Uni-Heidelberg.De

  parent reply	other threads:[~2001-06-13 15:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-10 17:34 Jeff Garzik
2001-06-11  5:59 ` Pekka Savola
2001-06-11  6:10   ` Keith Owens
2001-06-12 17:09 ` Bogdan Costescu
2001-06-12 17:40   ` Jeff Garzik
2001-06-12 18:40     ` PATCH: ethtool MII helpers (vers 2) Jeff Garzik
2001-06-13 15:29     ` Bogdan Costescu [this message]
2001-06-13 16:56     ` PATCH: ethtool MII helpers Donald Becker
2001-06-13 20:24       ` Jeff Garzik
2001-06-15 17:22         ` Bogdan Costescu
2001-06-22  5:10 ` Chris Wedgwood
2001-06-22  5:24   ` Jeff Garzik
2001-06-22  5:34     ` Chris Wedgwood
2001-06-22  5:58       ` Jeff Garzik

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:

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

  git send-email \ \ \ \ \ \ \ \
    --subject='Re: PATCH: ethtool MII helpers' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).