Skip to content

Commit 49168d1

Browse files
lunnkuba-moo
authored andcommitted
net: phy: Add phy_support_eee() indicating MAC support EEE
In order for EEE to operate, both the MAC and the PHY need to support it, similar to how pause works. With some exception - a number of PHYs have SmartEEE or AutoGrEEEn support in order to provide some EEE-like power savings with non-EEE capable MACs. Copy the pause concept and add the call phy_support_eee() which the MAC makes after connecting the PHY to indicate it supports EEE. phylib will then advertise EEE when auto-neg is performed. 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 3e43b90 commit 49168d1

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

drivers/net/phy/phy_device.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,34 @@ void phy_advertise_eee_all(struct phy_device *phydev)
29102910
}
29112911
EXPORT_SYMBOL_GPL(phy_advertise_eee_all);
29122912

2913+
/**
2914+
* phy_support_eee - Set initial EEE policy configuration
2915+
* @phydev: Target phy_device struct
2916+
*
2917+
* This function configures the initial policy for Energy Efficient Ethernet
2918+
* (EEE) on the specified PHY device, influencing that EEE capabilities are
2919+
* advertised before the link is established. It should be called during PHY
2920+
* registration by the MAC driver and/or the PHY driver (for SmartEEE PHYs)
2921+
* if MAC supports LPI or PHY is capable to compensate missing LPI functionality
2922+
* of the MAC.
2923+
*
2924+
* The function sets default EEE policy parameters, including preparing the PHY
2925+
* to advertise EEE capabilities based on hardware support.
2926+
*
2927+
* It also sets the expected configuration for Low Power Idle (LPI) in the MAC
2928+
* driver. If the PHY framework determines that both local and remote
2929+
* advertisements support EEE, and the negotiated link mode is compatible with
2930+
* EEE, it will set enable_tx_lpi = true. The MAC driver is expected to act on
2931+
* this setting by enabling the LPI timer if enable_tx_lpi is set.
2932+
*/
2933+
void phy_support_eee(struct phy_device *phydev)
2934+
{
2935+
linkmode_copy(phydev->advertising_eee, phydev->supported_eee);
2936+
phydev->eee_cfg.tx_lpi_enabled = true;
2937+
phydev->eee_cfg.eee_enabled = true;
2938+
}
2939+
EXPORT_SYMBOL(phy_support_eee);
2940+
29132941
/**
29142942
* phy_support_sym_pause - Enable support of symmetrical pause
29152943
* @phydev: target phy_device struct

include/linux/phy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ struct phy_device {
706706
__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
707707
/* used with phy_speed_down */
708708
__ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old);
709-
/* used for eee validation */
709+
/* used for eee validation and configuration*/
710710
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported_eee);
711711
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising_eee);
712712
bool eee_enabled;
@@ -1973,6 +1973,7 @@ void phy_advertise_supported(struct phy_device *phydev);
19731973
void phy_advertise_eee_all(struct phy_device *phydev);
19741974
void phy_support_sym_pause(struct phy_device *phydev);
19751975
void phy_support_asym_pause(struct phy_device *phydev);
1976+
void phy_support_eee(struct phy_device *phydev);
19761977
void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
19771978
bool autoneg);
19781979
void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);

0 commit comments

Comments
 (0)