Skip to content

Commit 50e6c7a

Browse files
committed
net: cadence: macb: add ethtool EEE support
Implement ethtool get_eee and set_eee operations for the Cadence GEM MAC, delegating to phylink for PHY-level EEE negotiation state. The MAC-level LPI control (TXLPIEN) is not manipulated directly in the ethtool ops. Instead, phylink_ethtool_set_eee() updates the PHY's EEE advertisement, which triggers link renegotiation. The mac_link_up callback then checks the negotiated EEE state and enables LPI accordingly. Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
1 parent e2b60f3 commit 50e6c7a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,6 +3610,42 @@ static int macb_set_ringparam(struct net_device *netdev,
36103610
return 0;
36113611
}
36123612

3613+
static int macb_get_eee(struct net_device *ndev, struct ethtool_keee *edata)
3614+
{
3615+
struct macb *bp = netdev_priv(ndev);
3616+
int ret;
3617+
3618+
if (!(bp->caps & MACB_CAPS_EEE))
3619+
return -EOPNOTSUPP;
3620+
3621+
ret = phylink_ethtool_get_eee(bp->phylink, edata);
3622+
if (ret)
3623+
return ret;
3624+
3625+
edata->tx_lpi_timer = bp->tx_lpi_timer_ms * 1000;
3626+
3627+
return 0;
3628+
}
3629+
3630+
static int macb_set_eee(struct net_device *ndev, struct ethtool_keee *edata)
3631+
{
3632+
struct macb *bp = netdev_priv(ndev);
3633+
3634+
if (!(bp->caps & MACB_CAPS_EEE))
3635+
return -EOPNOTSUPP;
3636+
3637+
if (edata->tx_lpi_timer)
3638+
bp->tx_lpi_timer_ms = edata->tx_lpi_timer / 1000;
3639+
3640+
/*
3641+
* Don't directly control TXLPIEN here. phylink_ethtool_set_eee()
3642+
* updates the PHY, which will bounce the link if tx_lpi_enabled
3643+
* changes. That triggers mac_link_down/mac_link_up where we
3644+
* enable/disable TXLPIEN based on the negotiated state.
3645+
*/
3646+
return phylink_ethtool_set_eee(bp->phylink, edata);
3647+
}
3648+
36133649
#ifdef CONFIG_MACB_USE_HWSTAMP
36143650
static unsigned int gem_get_tsu_rate(struct macb *bp)
36153651
{
@@ -4025,6 +4061,8 @@ static const struct ethtool_ops gem_ethtool_ops = {
40254061
.set_ringparam = macb_set_ringparam,
40264062
.get_rxnfc = gem_get_rxnfc,
40274063
.set_rxnfc = gem_set_rxnfc,
4064+
.get_eee = macb_get_eee,
4065+
.set_eee = macb_set_eee,
40284066
.nway_reset = phy_ethtool_nway_reset,
40294067
};
40304068

0 commit comments

Comments
 (0)