net: phy: report link partner features through ethtool
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 6 Dec 2013 21:01:30 +0000 (13:01 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Dec 2013 01:38:58 +0000 (20:38 -0500)
The PHY library already reads the MII_STAT1000 and MII_LPA registers in
genphy_read_status(), so extend it to also populate the PHY device link
partner advertised features such that we can feed this back into ethtool
when asked for it in phy_ethtool_gset().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
include/linux/phy.h

index 36c6994436b7ce7edb9ff9a0d9725c1aa09a4407..05cb8fe742f914529127b8b0b5d9858ef2da49ac 100644 (file)
@@ -289,6 +289,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
        cmd->supported = phydev->supported;
 
        cmd->advertising = phydev->advertising;
+       cmd->lp_advertising = phydev->lp_advertising;
 
        ethtool_cmd_speed_set(cmd, phydev->speed);
        cmd->duplex = phydev->duplex;
index d6447b3f7409d2b19a5c5186f017780bb29080b8..6db36595eac9b52732b5acdc244e36af0877ae53 100644 (file)
@@ -839,6 +839,8 @@ int genphy_read_status(struct phy_device *phydev)
        if (err)
                return err;
 
+       phydev->lp_advertising = 0;
+
        if (AUTONEG_ENABLE == phydev->autoneg) {
                if (phydev->supported & (SUPPORTED_1000baseT_Half
                                        | SUPPORTED_1000baseT_Full)) {
@@ -852,6 +854,8 @@ int genphy_read_status(struct phy_device *phydev)
                        if (adv < 0)
                                return adv;
 
+                       phydev->lp_advertising =
+                               mii_stat1000_to_ethtool_lpa_t(lpagb);
                        lpagb &= adv << 2;
                }
 
@@ -860,6 +864,8 @@ int genphy_read_status(struct phy_device *phydev)
                if (lpa < 0)
                        return lpa;
 
+               phydev->lp_advertising |= mii_lpa_to_ethtool_lpa_t(lpa);
+
                adv = phy_read(phydev, MII_ADVERTISE);
 
                if (adv < 0)
index 7ff751ae6f0ab84a5deee91752a644fae6422222..90a666e0884b9ecdf612da8dff6d7f3e53151933 100644 (file)
@@ -287,8 +287,8 @@ struct phy_c45_device_ids {
  * adjust_state: Callback for the enet driver to respond to
  * changes in the state machine.
  *
- * speed, duplex, pause, supported, advertising, and
- * autoneg are used like in mii_if_info
+ * speed, duplex, pause, supported, advertising, lp_advertising,
+ * and autoneg are used like in mii_if_info
  *
  * interrupts currently only supports enabled or disabled,
  * but could be changed in the future to support enabling
@@ -340,6 +340,7 @@ struct phy_device {
        /* See mii.h for more info */
        u32 supported;
        u32 advertising;
+       u32 lp_advertising;
 
        int autoneg;