r8169: respect EEE user setting when restarting network
authorHeiner Kallweit <hkallweit1@gmail.com>
Sun, 10 Nov 2019 13:44:54 +0000 (14:44 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Nov 2019 00:07:03 +0000 (16:07 -0800)
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>
drivers/net/ethernet/realtek/r8169_main.c

index d4345493fdba82881034a6058c7fcc4d8a78152c..249b68d00d799616d3573f2e480c59c9666fecb1 100644 (file)
@@ -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;
@@ -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;
@@ -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)
@@ -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);