Re: [PATCH net-next v8 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes

From: Andrew Lunn
Date: Fri Mar 01 2024 - 17:38:58 EST


On Fri, Mar 01, 2024 at 11:01:50AM +0100, Oleksij Rempel wrote:
> From: Andrew Lunn <andrew@xxxxxxx>
>
> The MAC driver changes its EEE hardware configuration in its
> adjust_link callback. This is called when auto-neg
> completes. Disabling EEE via eee_enabled false will trigger an
> autoneg, and as a result the adjust_link callback will be called with
> phydev->enable_tx_lpi set to false. Similarly, eee_enabled set to true
> and with a change of advertised link modes will result in a new
> autoneg, and a call the adjust_link call.
>
> If set_eee is called with only a change to tx_lpi_enabled which does
> not trigger an auto-neg, it is necessary to call the adjust_link
> callback so that the MAC is reconfigured to take this change into
> account.
>
> When setting phydev->enable_tx_lpi, take both eee_enabled and
> tx_lpi_enabled into account, so the MAC drivers just needs to act on
> phydev->enable_tx_lpi and not the whole EEE configuration.
> The same check should be done for tx_lpi_timer too.
>
> Signed-off-by: Andrew Lunn <andrew@xxxxxxx>
> Reviewed-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

> +static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
> + struct ethtool_keee *data)
> +{
> + if (phydev->eee_cfg.tx_lpi_enabled != data->tx_lpi_enabled ||
> + phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) {
> + eee_to_eeecfg(data, &phydev->eee_cfg);
> + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
> + if (phydev->link) {
> + phydev->link = false;
> + phy_link_down(phydev);
> + phydev->link = true;
> + phy_link_up(phydev);
> + }
> + }
> +}
> +

Thanks

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew