[PATCH RFC net-next 8/8] net: phylink: allow PCS to be removed

Russell King (Oracle) linux at armlinux.org.uk
Tue Nov 23 08:08:09 PST 2021


On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
> On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
> > Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
> > the PCS from phylink. This is only supported on non-legacy drivers
> > where doing so will have no effect on the mac_config() calling
> > behaviour.
> > 
> > Signed-off-by: Russell King (Oracle) <rmk+kernel at armlinux.org.uk>
> > ---
> >  drivers/net/phy/phylink.c | 20 +++++++++++++++-----
> >  1 file changed, 15 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> > index a935655c39c0..9f0f0e0aad55 100644
> > --- a/drivers/net/phy/phylink.c
> > +++ b/drivers/net/phy/phylink.c
> > @@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);
> >   * in mac_prepare() or mac_config() methods if it is desired to dynamically
> >   * change the PCS.
> >   *
> > - * Please note that there are behavioural changes with the mac_config()
> > - * callback if a PCS is present (denoting a newer setup) so removing a PCS
> > - * is not supported, and if a PCS is going to be used, it must be registered
> > - * by calling phylink_set_pcs() at the latest in the first mac_config() call.
> > + * Please note that for legacy phylink users, there are behavioural changes
> > + * with the mac_config() callback if a PCS is present (denoting a newer setup)
> > + * so removing a PCS is not supported. If a PCS is going to be used, it must
> > + * be registered by calling phylink_set_pcs() at the latest in the first
> > + * mac_config() call.
> > + *
> > + * For modern drivers, this may be called with a NULL pcs argument to
> > + * disconnect the PCS from phylink.
> >   */
> >  void phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs)
> >  {
> > +	if (pl->config->legacy_pre_march2020 && pl->pcs && !pcs) {
> > +		phylink_warn(pl,
> > +			     "Removing PCS is not supported in a legacy driver");
> > +		return;
> > +	}
> > +
> >  	pl->pcs = pcs;
> > -	pl->pcs_ops = pcs->ops;
> > +	pl->pcs_ops = pcs ? pcs->ops : NULL;
> >  }
> >  EXPORT_SYMBOL_GPL(phylink_set_pcs);
> >  
> > -- 
> > 2.30.2
> > 
> 
> I've read the discussion at
> https://lore.kernel.org/netdev/cfcb368f-a785-9ea5-c446-1906eacd8c03@seco.com/
> and I still am not sure that I understand what is the use case behind
> removing a PCS?

Passing that to Sean to answer in detail...

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



More information about the Linux-mediatek mailing list