Skip to content

Commit

Permalink
r8169: respect EEE user setting when restarting network
Browse files Browse the repository at this point in the history
Currently, if network is re-started, we advertise all supported EEE
modes, thus potentially overriding a manual adjustment the user made
e.g. via ethtool. Be friendly to the user and preserve a manual
setting on network re-start.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Heiner Kallweit authored and David S. Miller committed Nov 12, 2019
1 parent 0c06d16 commit 7ec3f87
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ struct rtl8169_private {
struct rtl8169_counters *counters;
struct rtl8169_tc_offsets tc_offset;
u32 saved_wolopts;
int eee_adv;

const char *fw_name;
struct rtl_fw *rtl_fw;
Expand Down Expand Up @@ -2101,6 +2102,10 @@ static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data)
}

ret = phy_ethtool_set_eee(tp->phydev, data);

if (!ret)
tp->eee_adv = phy_read_mmd(dev->phydev, MDIO_MMD_AN,
MDIO_AN_EEE_ADV);
out:
pm_runtime_put_noidle(d);
return ret;
Expand Down Expand Up @@ -2131,10 +2136,16 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
static void rtl_enable_eee(struct rtl8169_private *tp)
{
struct phy_device *phydev = tp->phydev;
int supported = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
int adv;

/* respect EEE advertisement the user may have set */
if (tp->eee_adv >= 0)
adv = tp->eee_adv;
else
adv = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);

if (supported > 0)
phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, supported);
if (adv >= 0)
phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
}

static void rtl8169_get_mac_version(struct rtl8169_private *tp)
Expand Down Expand Up @@ -6719,6 +6730,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->pci_dev = pdev;
tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1;
tp->eee_adv = -1;

/* Get the *optional* external "ether_clk" used on some boards */
rc = rtl_get_ether_clk(tp);
Expand Down

0 comments on commit 7ec3f87

Please sign in to comment.