Re: [PATCH net-next v2 1/7] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management

From: Maxime Chevallier
Date: Sat Mar 08 2025 - 08:52:15 EST


Hi Oleksij,

On Fri, 7 Mar 2025 19:24:26 +0100
Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> wrote:

> Convert the LAN78xx driver to use the PHYlink framework for managing
> PHY and MAC interactions.
>
> Key changes include:
> - Replace direct PHY operations with phylink equivalents (e.g.,
> phylink_start, phylink_stop).
> - Introduce lan78xx_phylink_setup for phylink initialization and
> configuration.
> - Add phylink MAC operations (lan78xx_mac_config,
> lan78xx_mac_link_down, lan78xx_mac_link_up) for managing link
> settings and flow control.
> - Remove redundant and now phylink-managed functions like
> `lan78xx_link_status_change`.
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

I only have a small comment, the rest looks OK (at least to me) :

> +static int lan78xx_phylink_setup(struct lan78xx_net *dev)
> +{
> + phy_interface_t link_interface;
> + struct phylink *phylink;
> +
> + dev->phylink_config.dev = &dev->net->dev;
> + dev->phylink_config.type = PHYLINK_NETDEV;
> + dev->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE |
> + MAC_10 | MAC_100 | MAC_1000FD;
> + dev->phylink_config.mac_managed_pm = true;
> +
> + if (dev->chipid == ID_REV_CHIP_ID_7801_) {
> + __set_bit(PHY_INTERFACE_MODE_RGMII,
> + dev->phylink_config.supported_interfaces);
> + __set_bit(PHY_INTERFACE_MODE_RGMII_ID,
> + dev->phylink_config.supported_interfaces);
> + __set_bit(PHY_INTERFACE_MODE_RGMII_RXID,
> + dev->phylink_config.supported_interfaces);
> + __set_bit(PHY_INTERFACE_MODE_RGMII_TXID,
> + dev->phylink_config.supported_interfaces);

You can use :

phy_interface_set_rgmii(dev->phylink_config.supported_interfaces);

instead of setting all indivdual RGMII modes :)

> + link_interface = PHY_INTERFACE_MODE_RGMII_ID;
> + } else {
> + __set_bit(PHY_INTERFACE_MODE_INTERNAL,
> + dev->phylink_config.supported_interfaces);
> + link_interface = PHY_INTERFACE_MODE_INTERNAL;
> + }
> +
> + phylink = phylink_create(&dev->phylink_config, dev->net->dev.fwnode,
> + link_interface, &lan78xx_phylink_mac_ops);
> + if (IS_ERR(phylink))
> + return PTR_ERR(phylink);
> +
> + dev->phylink = phylink;
> +
> + return 0;
> +}
> +

Maxime