From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Marcin Wojtas <mw@semihalf.com>,
netdev@vger.kernel.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH net-next 2/7] net: phylink: add pcs_validate() method
Date: Thu, 16 Dec 2021 17:10:19 +0000 [thread overview]
Message-ID: <Ybty+2r+adk574Dc@shell.armlinux.org.uk> (raw)
In-Reply-To: <99059dd8-808d-ddaf-3e65-85b1f7652b7d@seco.com>
On Thu, Dec 16, 2021 at 10:42:08AM -0500, Sean Anderson wrote:
>
>
> On 12/14/21 7:32 PM, Russell King (Oracle) wrote:
> > On Tue, Dec 14, 2021 at 06:54:16PM -0500, Sean Anderson wrote:
> > > On 12/14/21 6:27 PM, Russell King (Oracle) wrote:
> > > > On Tue, Dec 14, 2021 at 02:49:13PM -0500, Sean Anderson wrote:
> > > > > Hi Russell,
> > > > >
> > > > > On 12/14/21 9:48 AM, Russell King (Oracle) wrote:
> > > > > > Add a hook for PCS to validate the link parameters. This avoids MAC
> > > > > > drivers having to have knowledge of their PCS in their validate()
> > > > > > method, thereby allowing several MAC drivers to be simplfied.
> > > > > >
> > > > > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > > > > > ---
> > > > > > drivers/net/phy/phylink.c | 31 +++++++++++++++++++++++++++++++
> > > > > > include/linux/phylink.h | 20 ++++++++++++++++++++
> > > > > > 2 files changed, 51 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> > > > > > index c7035d65e159..420201858564 100644
> > > > > > --- a/drivers/net/phy/phylink.c
> > > > > > +++ b/drivers/net/phy/phylink.c
> > > > > > @@ -424,13 +424,44 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
> > > > > > struct phylink_link_state *state)
> > > > > > {
> > > > > > struct phylink_pcs *pcs;
> > > > > > + int ret;
> > > > > >
> > > > > > + /* Get the PCS for this interface mode */
> > > > > > if (pl->mac_ops->mac_select_pcs) {
> > > > > > pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
> > > > > > if (IS_ERR(pcs))
> > > > > > return PTR_ERR(pcs);
> > > > > > + } else {
> > > > > > + pcs = pl->pcs;
> > > > > > + }
> > > > > > +
> > > > > > + if (pcs) {
> > > > > > + /* The PCS, if present, must be setup before phylink_create()
> > > > > > + * has been called. If the ops is not initialised, print an
> > > > > > + * error and backtrace rather than oopsing the kernel.
> > > > > > + */
> > > > > > + if (!pcs->ops) {
> > > > > > + phylink_err(pl, "interface %s: uninitialised PCS\n",
> > > > > > + phy_modes(state->interface));
> > > > > > + dump_stack();
> > > > > > + return -EINVAL;
> > > > > > + }
> > > > > > +
> > > > > > + /* Validate the link parameters with the PCS */
> > > > > > + if (pcs->ops->pcs_validate) {
> > > > > > + ret = pcs->ops->pcs_validate(pcs, supported, state);
> > > > >
> > > > > I wonder if we can add a pcs->supported_interfaces. That would let me
> > > > > write something like
> > > >
> > > > I have two arguments against that:
> > > >
> > > > 1) Given that .mac_select_pcs should not return a PCS that is not
> > > > appropriate for the provided state->interface, I don't see what
> > > > use having a supported_interfaces member in the PCS would give.
> > > > All that phylink would end up doing is validating that the MAC
> > > > was giving us a sane PCS.
> > >
> > > The MAC may not know what the PCS can support. For example, the xilinx
> > > PCS/PMA can be configured to support 1000BASE-X, SGMII, both, or
> > > neither. How else should the mac find out what is supported?
> >
> > I'll reply by asking a more relevant question at this point.
> >
> > If we've asked for a PCS for 1000BASE-X via .mac_select_pcs() and a
> > PCS is returned that does not support 1000BASE-X, what happens then?
> > The system level says 1000BASE-X was supported when it isn't...
> > That to me sounds like bug.
>
> Well, there are two ways to approach this, IMO, and both involve some
> kind of supported_interfaces bitmap. The underlying constraint here is
> that the MAC doesn't really know/care at compile-time what the PCS
> supports.
>
> - The MAC always returns the external PCS, since that is what the user
> configured. In this case, the PCS is responsible for ensuring that the
> interface is supported. If phylink does not do this check, then it
> must be done in pcs_validate().
> - The MAC inspects the PCS's supported_interfaces bitmap, and only
> returns it from mac_select_pcs if it matches.
Yes - we can do these sorts of things later if it turns out there is
a requirement to do so. At the moment, having been through all the
drivers recently, I don't see the need for it yet.
The only driver that may come close is xpcs, and the patches I've
proposed there don't need it - I just populate the PCS support
by calling into xpcs.
--
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-12-16 17:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 14:47 [PATCH net-next 0/7] net: phylink: add PCS validation Russell King (Oracle)
2021-12-14 14:48 ` [PATCH net-next 1/7] net: phylink: add mac_select_pcs() method to phylink_mac_ops Russell King (Oracle)
2021-12-15 2:35 ` Jakub Kicinski
2021-12-14 14:48 ` [PATCH net-next 2/7] net: phylink: add pcs_validate() method Russell King (Oracle)
2021-12-14 19:49 ` Sean Anderson
2021-12-14 23:27 ` Russell King (Oracle)
2021-12-14 23:29 ` Russell King (Oracle)
2021-12-14 23:54 ` Sean Anderson
2021-12-15 0:32 ` Russell King (Oracle)
2021-12-16 15:42 ` Sean Anderson
2021-12-16 17:10 ` Russell King (Oracle) [this message]
2021-12-14 14:48 ` [PATCH net-next 3/7] net: mvpp2: use .mac_select_pcs() interface Russell King (Oracle)
2021-12-14 14:48 ` [PATCH net-next 4/7] net: mvpp2: convert to pcs_validate() and phylink_generic_validate() Russell King (Oracle)
2021-12-14 14:48 ` [PATCH net-next 5/7] net: mvneta: convert to use mac_prepare()/mac_finish() Russell King
2021-12-14 14:48 ` [PATCH net-next 6/7] net: mvneta: convert to phylink pcs operations Russell King
2021-12-14 14:48 ` [PATCH net-next 7/7] net: mvneta: convert to pcs_validate() and phylink_generic_validate() Russell King (Oracle)
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=Ybty+2r+adk574Dc@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=mw@semihalf.com \
--cc=netdev@vger.kernel.org \
--cc=sean.anderson@seco.com \
--cc=thomas.petazzoni@bootlin.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).