mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
Merge branch 'net-phy-improve-and-simplify-eee-handling-in-phylib'
Heiner Kallweit says: ==================== net: phy: improve and simplify EEE handling in phylib This series improves and simplifies phylib's EEE handling. ==================== Link: https://patch.msgid.link/3caa3151-13ac-44a8-9bb6-20f82563f698@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
59ed446bc4
|
|
@ -683,13 +683,10 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_mdix);
|
|||
static int genphy_c45_write_eee_adv(struct phy_device *phydev,
|
||||
unsigned long *adv)
|
||||
{
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp);
|
||||
int val, changed = 0;
|
||||
|
||||
linkmode_andnot(tmp, adv, phydev->eee_disabled_modes);
|
||||
|
||||
if (linkmode_intersects(phydev->supported_eee, PHY_EEE_CAP1_FEATURES)) {
|
||||
val = linkmode_to_mii_eee_cap1_t(tmp);
|
||||
val = linkmode_to_mii_eee_cap1_t(adv);
|
||||
|
||||
/* IEEE 802.3-2018 45.2.7.13 EEE advertisement 1
|
||||
* (Register 7.60)
|
||||
|
|
@ -707,7 +704,7 @@ static int genphy_c45_write_eee_adv(struct phy_device *phydev,
|
|||
}
|
||||
|
||||
if (linkmode_intersects(phydev->supported_eee, PHY_EEE_CAP2_FEATURES)) {
|
||||
val = linkmode_to_mii_eee_cap2_t(tmp);
|
||||
val = linkmode_to_mii_eee_cap2_t(adv);
|
||||
|
||||
/* IEEE 802.3-2022 45.2.7.16 EEE advertisement 2
|
||||
* (Register 7.62)
|
||||
|
|
@ -1467,42 +1464,29 @@ EXPORT_SYMBOL_GPL(genphy_c45_plca_get_status);
|
|||
/**
|
||||
* genphy_c45_eee_is_active - get EEE status
|
||||
* @phydev: target phy_device struct
|
||||
* @adv: variable to store advertised linkmodes
|
||||
* @lp: variable to store LP advertised linkmodes
|
||||
*
|
||||
* Description: this function will read local and link partner PHY
|
||||
* advertisements. Compare them return current EEE state.
|
||||
* Description: this function will read link partner PHY advertisement
|
||||
* and compare it to local advertisement to return current EEE state.
|
||||
*/
|
||||
int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *adv,
|
||||
unsigned long *lp)
|
||||
int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *lp)
|
||||
{
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp_adv) = {};
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp_lp) = {};
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
|
||||
bool eee_active;
|
||||
int ret;
|
||||
|
||||
ret = genphy_c45_read_eee_adv(phydev, tmp_adv);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = genphy_c45_read_eee_lpa(phydev, tmp_lp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
linkmode_and(common, tmp_adv, tmp_lp);
|
||||
if (!linkmode_empty(tmp_adv) && !linkmode_empty(common))
|
||||
eee_active = phy_check_valid(phydev->speed, phydev->duplex,
|
||||
common);
|
||||
else
|
||||
eee_active = false;
|
||||
|
||||
if (adv)
|
||||
linkmode_copy(adv, tmp_adv);
|
||||
if (lp)
|
||||
linkmode_copy(lp, tmp_lp);
|
||||
|
||||
return eee_active;
|
||||
linkmode_and(common, phydev->advertising_eee, tmp_lp);
|
||||
if (linkmode_empty(common))
|
||||
return 0;
|
||||
|
||||
return phy_check_valid(phydev->speed, phydev->duplex, common);
|
||||
}
|
||||
EXPORT_SYMBOL(genphy_c45_eee_is_active);
|
||||
|
||||
|
|
@ -1519,14 +1503,14 @@ int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
|
|||
{
|
||||
int ret;
|
||||
|
||||
ret = genphy_c45_eee_is_active(phydev, data->advertised,
|
||||
data->lp_advertised);
|
||||
ret = genphy_c45_eee_is_active(phydev, data->lp_advertised);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
data->eee_active = phydev->eee_active;
|
||||
linkmode_andnot(data->supported, phydev->supported_eee,
|
||||
phydev->eee_disabled_modes);
|
||||
linkmode_copy(data->advertised, phydev->advertising_eee);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(genphy_c45_ethtool_get_eee);
|
||||
|
|
|
|||
|
|
@ -1031,7 +1031,7 @@ static int phy_check_link_status(struct phy_device *phydev)
|
|||
if (phydev->link && phydev->state != PHY_RUNNING) {
|
||||
phy_check_downshift(phydev);
|
||||
phydev->state = PHY_RUNNING;
|
||||
err = genphy_c45_eee_is_active(phydev, NULL, NULL);
|
||||
err = genphy_c45_eee_is_active(phydev, NULL);
|
||||
phydev->eee_active = err > 0;
|
||||
phydev->enable_tx_lpi = phydev->eee_cfg.tx_lpi_enabled &&
|
||||
phydev->eee_active;
|
||||
|
|
@ -1780,7 +1780,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
|
|||
if (!phydev->drv)
|
||||
return -EIO;
|
||||
|
||||
ret = genphy_c45_eee_is_active(phydev, NULL, NULL);
|
||||
ret = genphy_c45_eee_is_active(phydev, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!ret)
|
||||
|
|
|
|||
|
|
@ -3580,23 +3580,22 @@ static int phy_probe(struct device *dev)
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
/* Get the EEE modes we want to prohibit. */
|
||||
of_set_phy_eee_broken(phydev);
|
||||
|
||||
/* Some PHYs may advertise, by default, not support EEE modes. So,
|
||||
* we need to clean them. In addition remove all disabled EEE modes.
|
||||
*/
|
||||
linkmode_and(phydev->advertising_eee, phydev->supported_eee,
|
||||
phydev->advertising_eee);
|
||||
linkmode_andnot(phydev->advertising_eee, phydev->advertising_eee,
|
||||
phydev->eee_disabled_modes);
|
||||
|
||||
/* There is no "enabled" flag. If PHY is advertising, assume it is
|
||||
* kind of enabled.
|
||||
*/
|
||||
phydev->eee_cfg.eee_enabled = !linkmode_empty(phydev->advertising_eee);
|
||||
|
||||
/* Some PHYs may advertise, by default, not support EEE modes. So,
|
||||
* we need to clean them.
|
||||
*/
|
||||
if (phydev->eee_cfg.eee_enabled)
|
||||
linkmode_and(phydev->advertising_eee, phydev->supported_eee,
|
||||
phydev->advertising_eee);
|
||||
|
||||
/* Get the EEE modes we want to prohibit. We will ask
|
||||
* the PHY stop advertising these mode later on
|
||||
*/
|
||||
of_set_phy_eee_broken(phydev);
|
||||
|
||||
/* Get master/slave strap overrides */
|
||||
of_set_phy_timing_role(phydev);
|
||||
|
||||
|
|
|
|||
|
|
@ -1339,16 +1339,6 @@ void of_set_phy_eee_broken(struct phy_device *phydev);
|
|||
void of_set_phy_timing_role(struct phy_device *phydev);
|
||||
int phy_speed_down_core(struct phy_device *phydev);
|
||||
|
||||
/**
|
||||
* phy_disable_eee_mode - Don't advertise an EEE mode.
|
||||
* @phydev: The phy_device struct
|
||||
* @link_mode: The EEE mode to be disabled
|
||||
*/
|
||||
static inline void phy_disable_eee_mode(struct phy_device *phydev, u32 link_mode)
|
||||
{
|
||||
linkmode_set_bit(link_mode, phydev->eee_disabled_modes);
|
||||
}
|
||||
|
||||
/**
|
||||
* phy_is_started - Convenience function to check whether PHY is started
|
||||
* @phydev: The phy_device struct
|
||||
|
|
@ -1358,6 +1348,19 @@ static inline bool phy_is_started(struct phy_device *phydev)
|
|||
return phydev->state >= PHY_UP;
|
||||
}
|
||||
|
||||
/**
|
||||
* phy_disable_eee_mode - Don't advertise an EEE mode.
|
||||
* @phydev: The phy_device struct
|
||||
* @link_mode: The EEE mode to be disabled
|
||||
*/
|
||||
static inline void phy_disable_eee_mode(struct phy_device *phydev, u32 link_mode)
|
||||
{
|
||||
WARN_ON(phy_is_started(phydev));
|
||||
|
||||
linkmode_set_bit(link_mode, phydev->eee_disabled_modes);
|
||||
linkmode_clear_bit(link_mode, phydev->advertising_eee);
|
||||
}
|
||||
|
||||
void phy_resolve_aneg_pause(struct phy_device *phydev);
|
||||
void phy_resolve_aneg_linkmode(struct phy_device *phydev);
|
||||
void phy_check_downshift(struct phy_device *phydev);
|
||||
|
|
@ -2029,8 +2032,7 @@ int genphy_c45_plca_set_cfg(struct phy_device *phydev,
|
|||
const struct phy_plca_cfg *plca_cfg);
|
||||
int genphy_c45_plca_get_status(struct phy_device *phydev,
|
||||
struct phy_plca_status *plca_st);
|
||||
int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *adv,
|
||||
unsigned long *lp);
|
||||
int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *lp);
|
||||
int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
|
||||
struct ethtool_keee *data);
|
||||
int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user