linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: Add c45_phy_ids sysfs entry
@ 2025-05-23 13:26 Yajun Deng
  2025-05-23 13:55 ` Andrew Lunn
  0 siblings, 1 reply; 8+ messages in thread
From: Yajun Deng @ 2025-05-23 13:26 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Yajun Deng

The phy_id only shows the PHY ID of the c22 device, and the c45 device
didn't store the PHY ID in the phy_id.

Export c45_phy_ids for the c45 device.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 .../ABI/testing/sysfs-class-net-phydev         | 10 ++++++++++
 drivers/net/phy/phy_device.c                   | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-net-phydev b/Documentation/ABI/testing/sysfs-class-net-phydev
index ac722dd5e694..f6194fd6927c 100644
--- a/Documentation/ABI/testing/sysfs-class-net-phydev
+++ b/Documentation/ABI/testing/sysfs-class-net-phydev
@@ -26,6 +26,16 @@ Description:
 		This ID is used to match the device with the appropriate
 		driver.
 
+What:		/sys/class/mdio_bus/<bus>/<device>/c45_phy_ids
+Date:		May 2025
+KernelVersion:	6.16
+Contact:	netdev@vger.kernel.org
+Description:
+		This attribute contains the 32-bit PHY Identifier as reported
+		by the device during bus enumeration, encoded in hexadecimal.
+		These C45 IDs are used to match the device with the appropriate
+		driver.
+
 What:		/sys/class/mdio_bus/<bus>/<device>/phy_interface
 Date:		February 2014
 KernelVersion:	3.15
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 781dfa6680eb..eecd8273111c 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -581,6 +581,23 @@ phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(phy_id);
 
+static ssize_t
+c45_phy_ids_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+	const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
+	unsigned int i;
+	size_t len = 0;
+
+	for (i = 1; i < num_ids; i++)
+		len += sysfs_emit_at(buf, len, "0x%.8lx ",
+				(unsigned long)phydev->c45_ids.device_ids[i]);
+	buf[len - 1] = '\n';
+
+	return len;
+}
+static DEVICE_ATTR_RO(c45_phy_ids);
+
 static ssize_t
 phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -618,6 +635,7 @@ static DEVICE_ATTR_RO(phy_dev_flags);
 
 static struct attribute *phy_dev_attrs[] = {
 	&dev_attr_phy_id.attr,
+	&dev_attr_c45_phy_ids.attr,
 	&dev_attr_phy_interface.attr,
 	&dev_attr_phy_has_fixups.attr,
 	&dev_attr_phy_dev_flags.attr,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-05-29  1:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 13:26 [PATCH net-next] net: phy: Add c45_phy_ids sysfs entry Yajun Deng
2025-05-23 13:55 ` Andrew Lunn
2025-05-26  8:11   ` Yajun Deng
2025-05-26  8:19     ` Russell King (Oracle)
2025-05-26  8:52       ` Yajun Deng
2025-05-26 14:02         ` Andrew Lunn
2025-05-28 13:08         ` Russell King (Oracle)
2025-05-29  1:51           ` Yajun Deng

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).