Skip to content

Commit 114002b

Browse files
ffainellidavem330
authored andcommitted
net: phy: report link partner features through ethtool
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>
1 parent 7371335 commit 114002b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

drivers/net/phy/phy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
289289
cmd->supported = phydev->supported;
290290

291291
cmd->advertising = phydev->advertising;
292+
cmd->lp_advertising = phydev->lp_advertising;
292293

293294
ethtool_cmd_speed_set(cmd, phydev->speed);
294295
cmd->duplex = phydev->duplex;

drivers/net/phy/phy_device.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ int genphy_read_status(struct phy_device *phydev)
839839
if (err)
840840
return err;
841841

842+
phydev->lp_advertising = 0;
843+
842844
if (AUTONEG_ENABLE == phydev->autoneg) {
843845
if (phydev->supported & (SUPPORTED_1000baseT_Half
844846
| SUPPORTED_1000baseT_Full)) {
@@ -852,6 +854,8 @@ int genphy_read_status(struct phy_device *phydev)
852854
if (adv < 0)
853855
return adv;
854856

857+
phydev->lp_advertising =
858+
mii_stat1000_to_ethtool_lpa_t(lpagb);
855859
lpagb &= adv << 2;
856860
}
857861

@@ -860,6 +864,8 @@ int genphy_read_status(struct phy_device *phydev)
860864
if (lpa < 0)
861865
return lpa;
862866

867+
phydev->lp_advertising |= mii_lpa_to_ethtool_lpa_t(lpa);
868+
863869
adv = phy_read(phydev, MII_ADVERTISE);
864870

865871
if (adv < 0)

include/linux/phy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ struct phy_c45_device_ids {
287287
* adjust_state: Callback for the enet driver to respond to
288288
* changes in the state machine.
289289
*
290-
* speed, duplex, pause, supported, advertising, and
291-
* autoneg are used like in mii_if_info
290+
* speed, duplex, pause, supported, advertising, lp_advertising,
291+
* and autoneg are used like in mii_if_info
292292
*
293293
* interrupts currently only supports enabled or disabled,
294294
* but could be changed in the future to support enabling
@@ -340,6 +340,7 @@ struct phy_device {
340340
/* See mii.h for more info */
341341
u32 supported;
342342
u32 advertising;
343+
u32 lp_advertising;
343344

344345
int autoneg;
345346

0 commit comments

Comments
 (0)