From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Michael Walle <mwalle@kernel.org>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Yisen Zhuang" <yisen.zhuang@huawei.com>,
"Salil Mehta" <salil.mehta@huawei.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
"Marek Behún" <kabel@kernel.org>, "Xu Liang" <lxu@maxlinear.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Simon Horman" <simon.horman@corigine.com>
Subject: Re: [PATCH net-next v3 02/11] net: phy: introduce phy_has_c45_registers()
Date: Tue, 1 Aug 2023 16:57:28 +0100 [thread overview]
Message-ID: <ZMkraPZvWWKhY8lT@shell.armlinux.org.uk> (raw)
In-Reply-To: <bce942b71db8c4b9bf741db517e7ca5f@kernel.org>
On Tue, Aug 01, 2023 at 05:20:22PM +0200, Michael Walle wrote:
> > In the case of the above (the code in __phy_read_mmd()), I wouldn't
> > at least initially change the test there.
> >
> > phydev->is_c45 will only be true if we probed the PHY using clause
> > 45 accesses. Thus, it will be set if "the bus supports clause 45
> > accesses" _and_ "the PHY responds to those accesses".
> >
> > Changing that to only "the bus supports clause 45 accesses" means
> > that a PHY supporting only clause 22 access with indirect clause
> > 45 access then fails if it's used with a bus that supports both
> > clause 22 and clause 45 accesses.
>
> Yeah of course. It was more about the naming, but I just realized
> that with mdiobus_supports_c45() you can't access the original
> "is_c45" property of the PHY. So maybe this patch needs to be split
> into two to get rid of .is_c45:
>
> First a mechanical one:
> phy_has_c45_registers() {
> return phydev->is_c45;
> }
Andrew's objection was that "phy_has_c45_registers" is a misnomer, and
suggested "_transfers" instead - because a PHY can have C45 registers
that are accessible via the indirect registers in C22 space.
I'd go one further:
static bool phy_supports_c45_transfers(struct phy_device *phydev)
{
return phydev->is_c45;
}
Since that covers that (a) the bus needs to support C45 transfers and
(b) the PHY also needs to respond to C45 transfers.
If we want to truly know whether a clause 22 PHY has clause 45
registers, that's difficult to answer, because then you're into the
realms of "does this PHY implement the indirect access method" and
we haven't been keeping track of that for the PHYs we have drivers
for - many will do, but it's optional in clause 22. The problem is
that when it's not implemented, the registers could be serving some
other function.
> phy_has_c22_registers() {
> return !phydev->is_c45;
> }
The reverse is not true, as clause 45 PHYs can also support clause 22
registers - from 802.3:
"For cases where a single entity combines Clause 45 MMDs with Clause 22
registers, then the Clause 22 registers may be accessed using the Clause
45 electrical interface and the Clause 22 management frame structure."
"Bit 5.0 is used to indicate that Clause 22 functionality has been
implemented within a Clause 45 electrical interface device."
Therefore, this would more accurately describe when Clause 22 registers
are present for a PHY:
static bool phy_has_c22_registers(struct phy_device *phydev)
{
/* If we probed the PHY without clause 45 accesses, then by
* definition, clause 22 registers must be present.
*/
if (!phydev->is_c45)
return true;
/* If we probed the PHY with clause 45 accesses, clause 22
* registers may be present if bit 0 in the Devices-in-pacakge
* register pair is set.
*/
return phydev->c45_ids.devices_in_package & BIT(0);
}
Note that this doesn't take account of whether the bus supports clause
22 register access - there are a number of MDIO buses that do not
support such accesses, and they may be coupled with a PHY that does
support clause 22 registers.
I'm aware of a SFP with a Realtek PHY on that falls into this exact
case, and getting that working is progressing at the moment.
> For all the places Andrew said it's correct. Leave all the
> other uses of .is_c45 as is for now and rework them in a
> later patch to use mdiobus_supports_{c22,c45}().
For the two cases in marvell10g and bcm84881, the test there for
is_c45 is purely to determine "was this ID found on a PHY supporting
clause 45 access" - however, in both cases, a check is made for MMDs
present in devices_in_package which will fail if the PHY wasn't
discovered in clause 45 mode.
Note that 88x3310 does not support clause 22 access. I forget whether
bcm84881 does or not.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2023-08-01 15:58 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 15:07 [PATCH net-next v3 00/11] net: phy: C45-over-C22 access Michael Walle
2023-07-12 15:07 ` [PATCH net-next v3 01/11] net: phy: get rid of redundant is_c45 information Michael Walle
2023-07-18 17:25 ` Andrew Lunn
2023-07-12 15:07 ` [PATCH net-next v3 02/11] net: phy: introduce phy_has_c45_registers() Michael Walle
2023-07-18 17:26 ` Andrew Lunn
2023-07-18 20:07 ` Andrew Lunn
2023-07-19 7:11 ` Michael Walle
2023-08-01 14:47 ` Michael Walle
2023-08-01 14:57 ` Russell King (Oracle)
2023-08-01 15:20 ` Michael Walle
2023-08-01 15:57 ` Russell King (Oracle) [this message]
2023-08-02 15:33 ` Michael Walle
2023-08-02 16:06 ` Russell King (Oracle)
2023-08-02 17:11 ` Michael Walle
2023-08-02 23:00 ` Russell King (Oracle)
2023-08-02 16:15 ` Andrew Lunn
2023-08-02 17:10 ` Russell King (Oracle)
2023-08-02 22:21 ` Andrew Lunn
2023-08-02 22:28 ` Russell King (Oracle)
2023-09-05 8:22 ` Michael Walle
2023-07-12 15:07 ` [PATCH net-next v3 03/11] net: phy: replace is_c45 with phy_accces_mode Michael Walle
2023-07-18 17:40 ` Andrew Lunn
2023-07-18 17:52 ` Russell King (Oracle)
2023-07-18 19:18 ` Andrew Lunn
2023-07-18 21:46 ` Russell King (Oracle)
2023-07-18 23:30 ` Andrew Lunn
2023-07-18 19:53 ` Michael Walle
2023-07-18 20:16 ` Andrew Lunn
2023-07-12 15:07 ` [PATCH net-next v3 04/11] net: phy: make the "prevent_c45_scan" a property of the MII bus Michael Walle
2023-07-18 23:31 ` Andrew Lunn
2023-07-12 15:07 ` [PATCH net-next v3 05/11] net: phy: print an info if a broken C45 bus is found Michael Walle
2023-07-18 23:32 ` Andrew Lunn
2023-07-12 15:07 ` [PATCH net-next v3 06/11] net: phy: add error checks in mmd_phy_indirect() Michael Walle
2023-07-18 23:34 ` Andrew Lunn
2023-07-12 15:07 ` [PATCH net-next v3 07/11] net: phy: introduce phy_mdiobus_read_mmd() Michael Walle
2023-07-18 23:54 ` Andrew Lunn
2023-07-19 7:21 ` Michael Walle
2023-07-12 15:07 ` [PATCH net-next v3 08/11] net: phy: add support for C45-over-C22 transfers Michael Walle
2023-07-13 8:56 ` Simon Horman
2023-07-13 9:00 ` Michael Walle
2023-07-13 9:19 ` Simon Horman
2023-07-12 15:07 ` [PATCH net-next v3 09/11] net: phy: introduce phy_promote_to_c45() Michael Walle
2023-07-13 8:56 ` Simon Horman
2023-07-12 15:07 ` [PATCH net-next v3 10/11] net: mdio: add C45-over-C22 fallback to fwnode_mdiobus_register_phy() Michael Walle
2023-07-19 0:03 ` Andrew Lunn
2023-07-19 7:32 ` Michael Walle
2023-07-12 15:07 ` [PATCH net-next v3 11/11] net: mdio: support C45-over-C22 when probed via OF Michael Walle
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=ZMkraPZvWWKhY8lT@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lxu@maxlinear.com \
--cc=mwalle@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=simon.horman@corigine.com \
--cc=yisen.zhuang@huawei.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).