Subject: Re: [PATCH net-next 3/5] net: phy: allow Clause 45 access via mii ioctl

From: Andrew Lunn <[email-masked]>
Date: Tue, 28 May 2019 17:31:24 +0200

> > Hi Russell,
> > 
> > I find the SIOCGMIIREG/SIOCGMIIPHY ioctls useful for C45 just as much
> > as they are for C22, but I think the way they work is a big hack and
> > for that reason they're less than useful when you need them most.
> > These ioctls work by hijacking the MDIO bus driver of a PHY that is
> > attached to a net_device. Hence they can be used to access at most a
> > PHY that lies on the same MDIO bus as one you already have a
> > phy-handle to.
> > If you have a PHY issue that makes of_phy_connect fail and the
> > net_device to fail to probe, basically you're SOL because you lose
> > that one handle that userspace had to the MDIO bus.
> > Similarly if you're doing a bring-up and all PHY interfaces are fixed-link.
> > Maybe it would be better to rethink this and expose some sysfs nodes
> > for raw MDIO access in the bus drivers.
> 
> I don't see how putting some attributes in sysfs helps

> What would be better would be for the MDIO layer to have /dev nodes
> that userspace could use to access the bus independent of the PHY,
> much the same as we have /dev/i2c-* - but I'm not sure if we really
> want to invent a whole new interface to MDIO buses.

There is work on re-implementing ethtool using a netlink socket.  The
proposed code supports the current MII interface. However, it should
be possible to extend it to pass some other identifier for the PHY,
rather than going via the network interface it is attached to.

Once ethtool netlink gets merged, i will take a look at this.

     Andrew