Skip to content

Commit e3b6876

Browse files
lunnkuba-moo
authored andcommitted
net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks
MAC drivers which support EEE need to know the results of the EEE auto-neg in order to program the hardware to perform EEE or not. The oddly named phy_init_eee() can be used to determine this, it returns 0 if EEE should be used, or a negative error code, e.g. -EOPPROTONOTSUPPORT if the PHY does not support EEE or negotiate resulted in it not being used. However, many MAC drivers get this wrong. Add phydev->enable_tx_lpi which indicates the result of the autoneg for EEE, including if EEE is administratively disabled with ethtool. The MAC driver can then access this in the same way as link speed and duplex in the adjust link callback. If enable_tx_lpi is true, the MAC should send low power indications and does not need to consider anything else with respect to EEE. Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: Oleksij Rempel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6f2fc85 commit e3b6876

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/net/phy/phy.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,16 @@ static int phy_check_link_status(struct phy_device *phydev)
983983
if (phydev->link && phydev->state != PHY_RUNNING) {
984984
phy_check_downshift(phydev);
985985
phydev->state = PHY_RUNNING;
986+
err = genphy_c45_eee_is_active(phydev,
987+
NULL, NULL, NULL);
988+
if (err < 0)
989+
phydev->enable_tx_lpi = false;
990+
else
991+
phydev->enable_tx_lpi = !!err;
986992
phy_link_up(phydev);
987993
} else if (!phydev->link && phydev->state != PHY_NOLINK) {
988994
phydev->state = PHY_NOLINK;
995+
phydev->enable_tx_lpi = false;
989996
phy_link_down(phydev);
990997
}
991998

include/linux/phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ struct macsec_ops;
594594
* @supported_eee: supported PHY EEE linkmodes
595595
* @advertising_eee: Currently advertised EEE linkmodes
596596
* @eee_enabled: Flag indicating whether the EEE feature is enabled
597+
* @enable_tx_lpi: When True, MAC should transmit LPI to PHY
597598
* @lp_advertising: Current link partner advertised linkmodes
598599
* @host_interfaces: PHY interface modes supported by host
599600
* @eee_broken_modes: Energy efficient ethernet modes which should be prohibited
@@ -713,6 +714,7 @@ struct phy_device {
713714

714715
/* Energy efficient ethernet modes which should be prohibited */
715716
u32 eee_broken_modes;
717+
bool enable_tx_lpi;
716718

717719
#ifdef CONFIG_LED_TRIGGER_PHY
718720
struct phy_led_trigger *phy_led_triggers;

0 commit comments

Comments
 (0)