* [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev
@ 2017-05-25 16:21 Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 1/3] " Florian Fainelli
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-05-25 16:21 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, Florian Fainelli
Hi David, Andrew,
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.
Thanks!
Changes in v2:
- document possible phy_interface values in sysfs-class-net-phydev
Florian Fainelli (3):
net: phy: Create sysfs reciprocal links for attached_dev/phydev
net: sysfs: Document "phydev" symbolic link
net: sysfs: Document PHY device sysfs attributes
Documentation/ABI/testing/sysfs-class-net | 8 ++++++
Documentation/ABI/testing/sysfs-class-net-phydev | 36 ++++++++++++++++++++++++
drivers/net/phy/phy_device.c | 11 ++++++++
3 files changed, 55 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-class-net-phydev
--
2.9.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev
2017-05-25 16:21 [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Florian Fainelli
@ 2017-05-25 16:21 ` Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 2/3] net: sysfs: Document "phydev" symbolic link Florian Fainelli
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-05-25 16:21 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, Florian Fainelli
There is currently no way for a program scanning /sys to know whether a
network device is attached to a particular PHY device, just like the PHY
device is not pointed back to its attached network device.
Create a symbolic link in the network device's namespace named "phydev"
which points to the PHY device and create a symbolic link in the PHY
device's namespace named "attached_dev" that points back to the network
device. These links are set up during phy_attach_direct() and removed
during phy_detach() for symetry.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phy_device.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1219eeab69d1..8151477c7027 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);
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/3] net: sysfs: Document "phydev" symbolic link
2017-05-25 16:21 [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 1/3] " Florian Fainelli
@ 2017-05-25 16:21 ` Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 3/3] net: sysfs: Document PHY device sysfs attributes Florian Fainelli
2017-05-25 16:42 ` [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Andrew Lunn
3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-05-25 16:21 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, Florian Fainelli
Now that we link the network device to its PHY device, document this
sysfs symbolic link.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Documentation/ABI/testing/sysfs-class-net | 8 ++++++++
1 file changed, 8 insertions(+)
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: netdev@vger.kernel.org
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: netdev@vger.kernel.org
+Description:
+ Symbolic link to the PHY device this network device is attached
+ to.
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 3/3] net: sysfs: Document PHY device sysfs attributes
2017-05-25 16:21 [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 1/3] " Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 2/3] net: sysfs: Document "phydev" symbolic link Florian Fainelli
@ 2017-05-25 16:21 ` Florian Fainelli
2017-05-25 16:42 ` [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Andrew Lunn
3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-05-25 16:21 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, Florian Fainelli
Document the different sysfs attributes that exist for PHY devices:
attached_dev, phy_has_fixups, phy_id and phy_interface.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Documentation/ABI/testing/sysfs-class-net-phydev | 36 ++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-class-net-phydev
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: netdev@vger.kernel.org
+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: netdev@vger.kernel.org
+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: netdev@vger.kernel.org
+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: netdev@vger.kernel.org
+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
+
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev
2017-05-25 16:21 [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Florian Fainelli
` (2 preceding siblings ...)
2017-05-25 16:21 ` [PATCH net-next v2 3/3] net: sysfs: Document PHY device sysfs attributes Florian Fainelli
@ 2017-05-25 16:42 ` Andrew Lunn
2017-05-26 18:38 ` David Miller
3 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2017-05-25 16:42 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, davem
On Thu, May 25, 2017 at 09:21:40AM -0700, Florian Fainelli wrote:
> Hi David, Andrew,
>
> 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.
>
> Thanks!
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev
2017-05-25 16:42 ` [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Andrew Lunn
@ 2017-05-26 18:38 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-05-26 18:38 UTC (permalink / raw)
To: andrew; +Cc: f.fainelli, netdev
From: Andrew Lunn <andrew@lunn.ch>
Date: Thu, 25 May 2017 18:42:27 +0200
> On Thu, May 25, 2017 at 09:21:40AM -0700, Florian Fainelli wrote:
>> Hi David, Andrew,
>>
>> 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.
>>
>> Thanks!
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Series applied, thanks everyone.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-26 18:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-25 16:21 [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 1/3] " Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 2/3] net: sysfs: Document "phydev" symbolic link Florian Fainelli
2017-05-25 16:21 ` [PATCH net-next v2 3/3] net: sysfs: Document PHY device sysfs attributes Florian Fainelli
2017-05-25 16:42 ` [PATCH net-next v2 0/3] net: phy: Create sysfs reciprocal links for attached_dev/phydev Andrew Lunn
2017-05-26 18:38 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).