From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>,
"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>
Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl()
Date: Mon, 1 Nov 2021 19:54:04 +0000 [thread overview]
Message-ID: <YYBF3IZoSN6/O6AL@shell.armlinux.org.uk> (raw)
In-Reply-To: <YYBBHsFEwGdPJw3b@lunn.ch>
On Mon, Nov 01, 2021 at 08:33:50PM +0100, Andrew Lunn wrote:
> On Mon, Nov 01, 2021 at 08:28:59PM +0200, Grygorii Strashko wrote:
> > This patch enables access to C22 PHY MMD address space through
>
> I'm not sure the terminology is correct here. I think it actually
> enables access to C45 address space, making use of C45 over C22.
I agree.
> > phy_mii_ioctl() SIOCGMIIREG/SIOCSMIIREG IOCTLs. It checks if R/W request is
> > received with C45 flag enabled while MDIO bus doesn't support C45 and, in
> > this case, tries to treat prtad as PHY MMD selector and use MMD API.
> >
> > With this change it's possible to r/w PHY MMD registers with phytool, for
> > example, before:
> >
> > phytool read eth0/0x1f:0/0x32
> > 0xffea
> >
> > after:
> > phytool read eth0/0x1f:0/0x32
> > 0x00d1
> > @@ -300,8 +300,19 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
> > prtad = mii_data->phy_id;
> > devad = mii_data->reg_num;
> > }
> > - mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad,
> > - devad);
> > + if (mdio_phy_id_is_c45(mii_data->phy_id) &&
> > + phydev->mdio.bus->probe_capabilities <= MDIOBUS_C22) {
> > + phy_lock_mdio_bus(phydev);
> > +
> > + mii_data->val_out = __mmd_phy_read(phydev->mdio.bus,
> > + mdio_phy_id_devad(mii_data->phy_id),
> > + prtad,
> > + mii_data->reg_num);
> > +
> > + phy_unlock_mdio_bus(phydev);
> > + } else {
> > + mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad, devad);
> > + }
>
> The layering look wrong here. You are trying to perform MDIO bus
> operation here, so it seems odd to perform __mmd_phy_read(). I wonder
> if it would be cleaner to move C45 over C22 down into the mdiobus_
> level API?
The use of the indirect registers is specific to PHYs, and we already
know that various PHYs don't support indirect access, and some emulate
access to the EEE registers - both of which are handled at the PHY
driver level. Pushing indirect MMD access down into the MDIO bus layer
means we need to have some way to deal with that.
Alternatively, if we're just thinking about moving, e.g.:
if (phydev->is_c45) {
val = __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
devad, regnum);
} else {
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
mmd_phy_indirect(bus, phy_addr, devad, regnum);
/* Read the content of the MMD's selected register */
val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
}
We would need to have some way to deal with that "is_c45" flag at
mdio device level (maybe moving it to the mdio_device structure).
Still doesn't help the "phy driver emulates the accesses" problem
though.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2021-11-01 19:54 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) [this message]
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
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=YYBF3IZoSN6/O6AL@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--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=netdev@vger.kernel.org \
--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).