Skip to content

Commit

Permalink
net: intel: e1000e: Use linkmode helpers for EEE
Browse files Browse the repository at this point in the history
Make use of the existing linkmode helpers for converting PHY EEE
register values into links modes, now that ethtool_keee uses link
modes, rather than u32 values.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Feb 28, 2024
1 parent 01cf893 commit 02de174
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drivers/net/ethernet/intel/e1000e/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2223,16 +2223,16 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_keee *edata)
ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data);
if (ret_val)
goto release;
edata->supported_u32 = mmd_eee_cap_to_ethtool_sup_t(phy_data);
mii_eee_cap1_mod_linkmode_t(edata->supported, phy_data);

/* EEE Advertised */
edata->advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert);
mii_eee_cap1_mod_linkmode_t(edata->advertised, adapter->eee_advert);

/* EEE Link Partner Advertised */
ret_val = e1000_read_emi_reg_locked(hw, lpa_addr, &phy_data);
if (ret_val)
goto release;
edata->lp_advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(phy_data);
mii_eee_cap1_mod_linkmode_t(edata->lp_advertised, phy_data);

/* EEE PCS Status */
ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data);
Expand Down Expand Up @@ -2265,6 +2265,8 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_keee *edata)
static int e1000e_set_eee(struct net_device *netdev, struct ethtool_keee *edata)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = {};
__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp) = {};
struct e1000_hw *hw = &adapter->hw;
struct ethtool_keee eee_curr;
s32 ret_val;
Expand All @@ -2283,12 +2285,17 @@ static int e1000e_set_eee(struct net_device *netdev, struct ethtool_keee *edata)
return -EINVAL;
}

if (edata->advertised_u32 & ~(ADVERTISE_100_FULL | ADVERTISE_1000_FULL)) {
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
supported);

if (linkmode_andnot(tmp, edata->advertised, supported)) {
e_err("EEE advertisement supports only 100TX and/or 1000T full-duplex\n");
return -EINVAL;
}

adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised_u32);
adapter->eee_advert = linkmode_to_mii_eee_cap1_t(edata->advertised);

hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled;

Expand Down

0 comments on commit 02de174

Please sign in to comment.