Re: [PATCH net-next 2/2] net: dsa: microchip: Add SGMII port support to KSZ9477 switch
From: Vladimir Oltean
Date: Sun Nov 10 2024 - 10:50:52 EST
On Sat, 9 Nov 2024 at 03:56, <Tristram.Ha@xxxxxxxxxxxxx> wrote:
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index f73833e24622..8163342d778a 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -354,10 +354,30 @@ static void ksz9477_phylink_mac_link_up(struct phylink_config *config,
> int speed, int duplex, bool tx_pause,
> bool rx_pause);
>
> +static struct phylink_pcs *
> +ksz_phylink_mac_select_pcs(struct phylink_config *config,
> + phy_interface_t interface)
> +{
> + struct dsa_port *dp = dsa_phylink_to_port(config);
> + struct ksz_device *dev = dp->ds->priv;
> + struct ksz_port *p = &dev->ports[dp->index];
> +
> + if (!p->sgmii)
> + return ERR_PTR(-EOPNOTSUPP);
Since commit 7530ea26c810 ("net: phylink: remove "using_mac_select_pcs""),
returning ERR_PTR(-EOPNOTSUPP) here would actually be fatal. This error
code no longer carries any special meaning.
It would be a good idea to Cc Russell King for phylink changes.
> + switch (interface) {
> + case PHY_INTERFACE_MODE_SGMII:
> + case PHY_INTERFACE_MODE_1000BASEX:
> + return &p->pcs_priv->pcs;
> + default:
> + return NULL;
> + }
> +}
> +
> static const struct phylink_mac_ops ksz9477_phylink_mac_ops = {
> .mac_config = ksz_phylink_mac_config,
> .mac_link_down = ksz_phylink_mac_link_down,
> .mac_link_up = ksz9477_phylink_mac_link_up,
> + .mac_select_pcs = ksz_phylink_mac_select_pcs,
> };