Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl()

From: Andrew Lunn
Date: Wed Nov 03 2021 - 15:37:02 EST


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 it will probably work 99% of the time, which is enough for
a debug tool. 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.

Andrew