[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250523132606.2814-1-yajun.deng@linux.dev>
Date: Fri, 23 May 2025 21:26:06 +0800
From: Yajun Deng <yajun.deng@...ux.dev>
To: andrew@...n.ch,
hkallweit1@...il.com,
linux@...linux.org.uk,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yajun Deng <yajun.deng@...ux.dev>
Subject: [PATCH net-next] net: phy: Add c45_phy_ids sysfs entry
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@...ux.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@...r.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
Powered by blists - more mailing lists