Re: [PATCH net-next v2 3/6] r8169: add support for phylink

From: Jakub Kicinski

Date: Sat Jun 13 2026 - 18:06:14 EST


This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
r8169: add support for phylink

Transfer old framework to phylink. Phylink can support fiber mode card
which can not get link status or link speed from standard phy registers.

> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 560f987437b63..615bd4107359a 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
[ ... ]
> @@ -2661,13 +2672,10 @@ static void rtl_jumbo_config(struct rtl8169_private *tp)
> pcie_set_readrq(tp->pci_dev, readrq);
>
> /* Chip doesn't support pause in jumbo mode */
> - if (jumbo) {
> - linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> - tp->phydev->advertising);
> - linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> - tp->phydev->advertising);
> - phy_start_aneg(tp->phydev);
> - }
> + if (jumbo)
> + tp->phylink_config.mac_capabilities &= ~(MAC_SYM_PAUSE | MAC_ASYM_PAUSE);
> + else
> + tp->phylink_config.mac_capabilities |= (MAC_SYM_PAUSE | MAC_ASYM_PAUSE);
> }

[Severity: High]
Does phylink re-read mac_capabilities on start?

It looks like dynamic bitwise modifications to tp->phylink_config.mac_capabilities
made here are ignored by phylink. Since phylink does not update the pl->supported
link mode mask during phylink_start(), won't the PHY continue to incorrectly
advertise pause capabilities to the link partner when jumbo frames are enabled?

[ ... ]
> @@ -4142,11 +4150,17 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
> {
> struct rtl8169_private *tp = netdev_priv(dev);
>
> + if (netif_running(dev))
> + phylink_stop(tp->phylink);
> +
> WRITE_ONCE(dev->mtu, new_mtu);
> netdev_update_features(dev);
> rtl_jumbo_config(tp);
> rtl_set_eee_txidle_timer(tp);
>
> + if (netif_running(dev))
> + phylink_start(tp->phylink);
> +
> return 0;
> }

[ ... ]
> +static int rtl_init_phylink(struct rtl8169_private *tp)
> +{
> + struct phylink *pl;
> + phy_interface_t phy_mode;
> +
> + tp->phylink_config.dev = &tp->dev->dev;
> + tp->phylink_config.type = PHYLINK_NETDEV;
> + tp->phylink_config.mac_managed_pm = true;
> + tp->phylink_config.lpi_capabilities = rtl8169_get_lpi_caps(tp);
> + tp->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
> +
> + if (tp->sfp_mode) {
> + phy_mode = PHY_INTERFACE_MODE_INTERNAL;
> + tp->phylink_config.mac_capabilities |= MAC_10000FD;
> + } else {
> + tp->phylink_config.mac_capabilities |= MAC_10 | MAC_100;
> + phy_mode = PHY_INTERFACE_MODE_INTERNAL;

[Severity: High]
Does hardcoding phy_mode to PHY_INTERFACE_MODE_INTERNAL here break older
adapters that use discrete PHYs over GMII or MII?

Prior to this patch, the driver dynamically checked tp->supports_gmii to set
either PHY_INTERFACE_MODE_GMII or PHY_INTERFACE_MODE_MII. Forcing INTERNAL
might tell the PHY driver that the PHY is integrated into the MAC, which could
cause discrete PHY drivers to skip necessary initializations, fail validation
checks, or misconfigure interface delays.

> +
> + if (tp->mac_version == RTL_GIGA_MAC_VER_80)
> + tp->phylink_config.mac_capabilities |= MAC_1000FD | MAC_2500FD |
> + MAC_5000FD | MAC_10000FD;