Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: Expose phydev::dev_flags through sysfs

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>

authored by

Florian Fainelli and committed by
David S. Miller
b0bade51 ee47ed08

+23
+12
Documentation/ABI/testing/sysfs-class-net-phydev
··· 51 51 Boolean value indicating whether the PHY device is used in 52 52 standalone mode, without a net_device associated, by PHYLINK. 53 53 Attribute created only when this is the case. 54 + 55 + What: /sys/class/mdio_bus/<bus>/<device>/phy_dev_flags 56 + Date: March 2021 57 + KernelVersion: 5.13 58 + Contact: netdev@vger.kernel.org 59 + Description: 60 + 32-bit hexadecimal number representing a bit mask of the 61 + configuration bits passed from the consumer of the PHY 62 + (Ethernet MAC, switch, etc.) to the PHY driver. The flags are 63 + only used internally by the kernel and their placement are 64 + not meant to be stable across kernel versions. This is intended 65 + for facilitating the debugging of PHY drivers.
+11
drivers/net/phy/phy_device.c
··· 512 512 } 513 513 static DEVICE_ATTR_RO(phy_has_fixups); 514 514 515 + static ssize_t phy_dev_flags_show(struct device *dev, 516 + struct device_attribute *attr, 517 + char *buf) 518 + { 519 + struct phy_device *phydev = to_phy_device(dev); 520 + 521 + return sprintf(buf, "0x%08x\n", phydev->dev_flags); 522 + } 523 + static DEVICE_ATTR_RO(phy_dev_flags); 524 + 515 525 static struct attribute *phy_dev_attrs[] = { 516 526 &dev_attr_phy_id.attr, 517 527 &dev_attr_phy_interface.attr, 518 528 &dev_attr_phy_has_fixups.attr, 529 + &dev_attr_phy_dev_flags.attr, 519 530 NULL, 520 531 }; 521 532 ATTRIBUTE_GROUPS(phy_dev);