netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Waldekranz <tobias@waldekranz.com>
To: Andrew Lunn <andrew@lunn.ch>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	linux-kernel@vger.kernel.org,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Sean Anderson <sean.anderson@seco.com>
Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl()
Date: Thu, 04 Nov 2021 12:17:47 +0100	[thread overview]
Message-ID: <87pmrgjhk4.fsf@waldekranz.com> (raw)
In-Reply-To: <YYLk0dEKX2Jlq0Se@lunn.ch>

On Wed, Nov 03, 2021 at 20:36, Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Nov 03, 2021 at 08:42:07PM +0200, Grygorii Strashko wrote:
>> 
>> 
>> On 03/11/2021 02:27, Andrew Lunn wrote:
>> > > > What i find interesting is that you and the other resent requester are
>> > > > using the same user space tool. If you implement C45 over C22 in that
>> > > > tool, you get your solution, and it will work for older kernels as
>> > > > well. Also, given the diverse implementations of this IOTCL, it
>> > > > probably works for more drivers than just those using phy_mii_ioctl().
>> > > 
>> > > Do you mean change uapi, like
>> > >   add mdio_phy_id_is_c45_over_c22() and
>> > >   flag #define MDIO_PHY_ID_C45_OVER_C22 0x4000?
>> > 
>> > No, i mean user space implements C45 over C22. Make phytool write
>> > MII_MMD_CTRL and MII_MMD_DATA to perform a C45 over C22.
>> 
>> Now I give up - as mentioned there is now way to sync User space vs Kernel
>> MMD transactions and so no way to get trusted results.

Except that there is a way: https://github.com/wkz/mdio-tools

I can see that Sean has already mentioned it in the other branch of the
thread (thanks for the plug :)). I have posted it to netdev before:

https://lore.kernel.org/netdev/C42DZQLTPHM5.2THDSRK84BI3T@wkz-x280/

It allows you to send an entire "MDIO program" to the kernel, where
mdio-netlink will (1) lock the bus, (2) run your program in a small VM,
and (3) unlock the bus.

There are currently two programs in the project:

- `mdio`: A basic register peek/poke program that uses the mdio-netlink
  module in the kernel to do its thing. The source is structured in such
  a way that custom access modes can be easily added. Today there are
  accessors for C22 PHYs, C45 MMDs, Marvell Alaska paged PHYs, Marvell
  LinkStreet switches, and XRS700x switches.

- `mvls`: Specialized read-only debug tool for Marvell LinkStreet
  switches. This does _not_ rely on the mdio-netlink kernel module,
  instead it uses the standard devlink API. Let's you dump the VTU/ATU
  etc.

You could easily add a new addressing mode to `mdio` to do C45-over-C22
accesses. Would that work for you Grygorii?

> Except that it will probably work 99% of the time, which is enough for
> a debug tool.

Why though, why would we not build something that is rock solid? Ever
since ce69e2162f15, the flood gates are open. Any vendor can implement
mdio-netlink on their own, or just download mine. We are only punishing
ourselves at this point.

> phylib is pretty idle most of the time, it just polls
> the PHY once a second to see if the link status has changed. And does
> not poll at all if interrupts are wired up. And you can always do a
> read three times and see if you get the same answer, or do a write
> followed by a read to see if the write actually happened correctly, or
> corrupted some other register.

As a staunch opponent of Vendor SDKs myself, I get where you are coming
from - really.

I guess I just don't have the brain power to operate this kind of Rube
Goldberg machinery and debug my problems at the same time. We have a
mutex right there already, let's use it!

I'll shut up now - I just had to make one final appeal :)

  reply	other threads:[~2021-11-04 11:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 18:28 [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl() Grygorii Strashko
2021-11-01 19:33 ` Andrew Lunn
2021-11-01 19:54   ` Russell King (Oracle)
2021-11-02  0:49     ` Andrew Lunn
2021-11-02 12:39       ` Russell King (Oracle)
2021-11-02 17:13         ` Andrew Lunn
2021-11-02 19:46           ` Sean Anderson
2021-11-02 23:38             ` Russell King (Oracle)
2021-11-04 15:05               ` Sean Anderson
2021-11-02 17:19         ` Grygorii Strashko
2021-11-02 17:41           ` Russell King (Oracle)
2021-11-02 18:37             ` Grygorii Strashko
2021-11-02 19:12               ` Grygorii Strashko
2021-11-02 21:46                 ` Andrew Lunn
2021-11-02 22:22                   ` Grygorii Strashko
2021-11-03  0:27                     ` Andrew Lunn
2021-11-03 18:42                       ` Grygorii Strashko
2021-11-03 19:36                         ` Andrew Lunn
2021-11-04 11:17                           ` Tobias Waldekranz [this message]
2021-11-04 12:35                             ` Russell King (Oracle)
2021-11-04 12:40                               ` Russell King (Oracle)
2021-11-04 13:13                                 ` Tobias Waldekranz
2021-11-04 13:06                               ` Tobias Waldekranz

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=87pmrgjhk4.fsf@waldekranz.com \
    --to=tobias@waldekranz.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=sean.anderson@seco.com \
    --cc=vigneshr@ti.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).