net: phy: Expose phydev::dev_flags through sysfs
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 10 Mar 2021 22:12:43 +0000 (14:12 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Mar 2021 20:47:27 +0000 (12:47 -0800)
phydev::dev_flags contains a bitmask of configuration bits requested by
the consumer of a PHY device (Ethernet MAC or switch) towards the PHY
driver. Since these flags are often used for requesting LED or other
type of configuration being able to quickly audit them without
instrumenting the kernel is useful.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/ABI/testing/sysfs-class-net-phydev
drivers/net/phy/phy_device.c

index 40ced0ea431663fee1d71801ad87fb9939610940..ac722dd5e69431d0df3c1e567fad2ace11fe44c9 100644 (file)
@@ -51,3 +51,15 @@ Description:
                Boolean value indicating whether the PHY device is used in
                standalone mode, without a net_device associated, by PHYLINK.
                Attribute created only when this is the case.
+
+What:          /sys/class/mdio_bus/<bus>/<device>/phy_dev_flags
+Date:          March 2021
+KernelVersion: 5.13
+Contact:       netdev@vger.kernel.org
+Description:
+               32-bit hexadecimal number representing a bit mask of the
+               configuration bits passed from the consumer of the PHY
+               (Ethernet MAC, switch, etc.) to the PHY driver. The flags are
+               only used internally by the kernel and their placement are
+               not meant to be stable across kernel versions. This is intended
+               for facilitating the debugging of PHY drivers.
index cc38e326405a6585a7b602628ba61c51daa7912a..a009d1769b0816ee8b28698d83129119cc072ee4 100644 (file)
@@ -512,10 +512,21 @@ phy_has_fixups_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(phy_has_fixups);
 
+static ssize_t phy_dev_flags_show(struct device *dev,
+                                 struct device_attribute *attr,
+                                 char *buf)
+{
+       struct phy_device *phydev = to_phy_device(dev);
+
+       return sprintf(buf, "0x%08x\n", phydev->dev_flags);
+}
+static DEVICE_ATTR_RO(phy_dev_flags);
+
 static struct attribute *phy_dev_attrs[] = {
        &dev_attr_phy_id.attr,
        &dev_attr_phy_interface.attr,
        &dev_attr_phy_has_fixups.attr,
+       &dev_attr_phy_dev_flags.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(phy_dev);