Skip to content

Commit ae782de

Browse files
committed
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 <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 9226976 + 86f22d0 commit ae782de

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

Documentation/ABI/testing/sysfs-class-net

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,11 @@ Contact: netdev@vger.kernel.org
251251
Description:
252252
Indicates the unique physical switch identifier of a switch this
253253
port belongs to, as a string.
254+
255+
What: /sys/class/net/<iface>/phydev
256+
Date: May 2017
257+
KernelVersion: 4.13
258+
Contact: netdev@vger.kernel.org
259+
Description:
260+
Symbolic link to the PHY device this network device is attached
261+
to.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
What: /sys/class/mdio_bus/<bus>/<device>/attached_dev
2+
Date: May 2017
3+
KernelVersion: 4.13
4+
Contact: netdev@vger.kernel.org
5+
Description:
6+
Symbolic link to the network device this PHY device is
7+
attached to.
8+
9+
What: /sys/class/mdio_bus/<bus>/<device>/phy_has_fixups
10+
Date: February 2014
11+
KernelVersion: 3.15
12+
Contact: netdev@vger.kernel.org
13+
Description:
14+
Boolean value indicating whether the PHY device has
15+
any fixups registered against it (phy_register_fixup)
16+
17+
What: /sys/class/mdio_bus/<bus>/<device>/phy_id
18+
Date: November 2012
19+
KernelVersion: 3.8
20+
Contact: netdev@vger.kernel.org
21+
Description:
22+
32-bit hexadecimal value corresponding to the PHY device's OUI,
23+
model and revision number.
24+
25+
What: /sys/class/mdio_bus/<bus>/<device>/phy_interface
26+
Date: February 2014
27+
KernelVersion: 3.15
28+
Contact: netdev@vger.kernel.org
29+
Description:
30+
String value indicating the PHY interface, possible
31+
values are:.
32+
<empty> (not available), mii, gmii, sgmii, tbi, rev-mii,
33+
rmii, rgmii, rgmii-id, rgmii-rxid, rgmii-txid, rtbi, smii
34+
xgmii, moca, qsgmii, trgmii, 1000base-x, 2500base-x, rxaui,
35+
unknown
36+

drivers/net/phy/phy_device.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,15 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
960960

961961
phydev->attached_dev = dev;
962962
dev->phydev = phydev;
963+
err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj,
964+
"attached_dev");
965+
if (err)
966+
goto error;
967+
968+
err = sysfs_create_link(&dev->dev.kobj, &phydev->mdio.dev.kobj,
969+
"phydev");
970+
if (err)
971+
goto error;
963972

964973
phydev->dev_flags = flags;
965974

@@ -1050,6 +1059,8 @@ void phy_detach(struct phy_device *phydev)
10501059
struct mii_bus *bus;
10511060
int i;
10521061

1062+
sysfs_remove_link(&dev->dev.kobj, "phydev");
1063+
sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev");
10531064
phydev->attached_dev->phydev = NULL;
10541065
phydev->attached_dev = NULL;
10551066
phy_suspend(phydev);

0 commit comments

Comments
 (0)