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

Vladimir Oltean olteanv at gmail.com
Tue Nov 23 04:08:25 PST 2021


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?



More information about the Linux-mediatek mailing list