diff options
author | David S. Miller <[email protected]> | 2017-05-26 14:37:42 -0400 |
---|---|---|
committer | David S. Miller <[email protected]> | 2017-05-26 14:37:42 -0400 |
commit | ae782dec2c60457ec66a5c2589f4bd135ffa5893 (patch) | |
tree | 8376f7f0dad70e6242daaf079b766547ef586e4f | |
parent | 9226976f9bad60e3eeb36a9d69341a584c87a0c3 (diff) | |
parent | 86f22d04dfb5412ffb872f08c1660e3917886925 (diff) |
Merge branch 'phy-sysfs-reciprocal-links'
Florian Fainelli says:
====================
net: phy: Create sysfs reciprocal links for attached_dev/phydev
This patch series addresses a device topology shortcoming where a program
scanning /sys would not be able to establish a mapping between the network
device and the PHY device.
In the process it turned out that no PHY device documentation existed for
sysfs attributes.
Changes in v2:
- document possible phy_interface values in sysfs-class-net-phydev
====================
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-net | 8 | ||||
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-net-phydev | 36 | ||||
-rw-r--r-- | drivers/net/phy/phy_device.c | 11 |
3 files changed, 55 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-net b/Documentation/ABI/testing/sysfs-class-net index 668604fc8e06..6856da99b6f7 100644 --- a/Documentation/ABI/testing/sysfs-class-net +++ b/Documentation/ABI/testing/sysfs-class-net @@ -251,3 +251,11 @@ Contact: [email protected] Description: Indicates the unique physical switch identifier of a switch this port belongs to, as a string. + +What: /sys/class/net/<iface>/phydev +Date: May 2017 +KernelVersion: 4.13 +Contact: [email protected] +Description: + Symbolic link to the PHY device this network device is attached + to. diff --git a/Documentation/ABI/testing/sysfs-class-net-phydev b/Documentation/ABI/testing/sysfs-class-net-phydev new file mode 100644 index 000000000000..c768d5fd8496 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-net-phydev @@ -0,0 +1,36 @@ +What: /sys/class/mdio_bus/<bus>/<device>/attached_dev +Date: May 2017 +KernelVersion: 4.13 +Contact: [email protected] +Description: + Symbolic link to the network device this PHY device is + attached to. + +What: /sys/class/mdio_bus/<bus>/<device>/phy_has_fixups +Date: February 2014 +KernelVersion: 3.15 +Contact: [email protected] +Description: + Boolean value indicating whether the PHY device has + any fixups registered against it (phy_register_fixup) + +What: /sys/class/mdio_bus/<bus>/<device>/phy_id +Date: November 2012 +KernelVersion: 3.8 +Contact: [email protected] +Description: + 32-bit hexadecimal value corresponding to the PHY device's OUI, + model and revision number. + +What: /sys/class/mdio_bus/<bus>/<device>/phy_interface +Date: February 2014 +KernelVersion: 3.15 +Contact: [email protected] +Description: + String value indicating the PHY interface, possible + values are:. + <empty> (not available), mii, gmii, sgmii, tbi, rev-mii, + rmii, rgmii, rgmii-id, rgmii-rxid, rgmii-txid, rtbi, smii + xgmii, moca, qsgmii, trgmii, 1000base-x, 2500base-x, rxaui, + unknown + diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0780e9f9e167..f84414b8f2ee 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -960,6 +960,15 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, phydev->attached_dev = dev; dev->phydev = phydev; + err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, + "attached_dev"); + if (err) + goto error; + + err = sysfs_create_link(&dev->dev.kobj, &phydev->mdio.dev.kobj, + "phydev"); + if (err) + goto error; phydev->dev_flags = flags; @@ -1050,6 +1059,8 @@ void phy_detach(struct phy_device *phydev) struct mii_bus *bus; int i; + sysfs_remove_link(&dev->dev.kobj, "phydev"); + sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); phydev->attached_dev->phydev = NULL; phydev->attached_dev = NULL; phy_suspend(phydev); |