STRUCT PHY_DEVICE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Okay bestie, welcome to struct phy_device(9) from the Kernel API Manual ✨ β€” this is the whole struct, and we are keeping every single bit of it. No cap.

πŸŽ€ NAME πŸŽ€

struct phy_device β€” an instance of a PHY πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

struct phy_device {
    struct mdio_device mdio;
    const struct phy_driver *drv;
    struct device_link *devlink;
    u32 phyindex;
    u32 phy_id;
    struct phy_c45_device_ids c45_ids;
    unsigned is_c45:1;
    unsigned is_internal:1;
    unsigned is_pseudo_fixed_link:1;
    unsigned is_gigabit_capable:1;
    unsigned has_fixups:1;
    unsigned suspended:1;
    unsigned suspended_by_mdio_bus:1;
    unsigned sysfs_links:1;
    unsigned loopback_enabled:1;
    unsigned downshifted_rate:1;
    unsigned is_on_sfp_module:1;
    unsigned mac_managed_pm:1;
    unsigned wol_enabled:1;
    unsigned is_genphy_driven:1;
    unsigned autoneg:1;
    unsigned link:1;
    unsigned autoneg_complete:1;
    bool pause:1;
    bool asym_pause:1;
    unsigned interrupts:1;
    unsigned irq_suspended:1;
    unsigned irq_rerun:1;
    unsigned default_timestamp:1;
    int rate_matching;
    enum phy_state state;
    u32 dev_flags;
    phy_interface_t interface;
    unsigned long possible_interfaces[BITS_TO_LONGS(
PHY_INTERFACE_MODE_MAX)];
    int speed;
    int duplex;
    int port;
    u8 master_slave_get;
    u8 master_slave_set;
    u8 master_slave_state;
    unsigned long supported[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long advertising[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long lp_advertising[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long adv_old[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long supported_eee[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long advertising_eee[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    unsigned long eee_disabled_modes[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
    bool enable_tx_lpi;
    bool eee_active;
    bool autonomous_eee_disabled;
    struct eee_config eee_cfg;
    unsigned long host_interfaces[BITS_TO_LONGS(
PHY_INTERFACE_MODE_MAX)];
  #ifdef CONFIG_LED_TRIGGER_PHY;
    struct phy_led_trigger *phy_led_triggers;
    unsigned int phy_num_led_triggers;
    struct phy_led_trigger *last_triggered;
    struct phy_led_trigger *led_link_trigger;
  #endif;
    struct list_head leds;
    int irq;
    void *priv;
  #if IS_ENABLED(CONFIG_PHY_PACKAGE);
    struct phy_package_shared *shared;
  #endif;
    struct sk_buff *skb;
    void *ehdr;
    struct nlattr *nest;
    struct delayed_work state_queue;
    struct mutex lock;
    bool sfp_bus_attached;
    struct sfp_bus *sfp_bus;
    struct phylink *phylink;
    struct net_device *attached_dev;
    struct mii_timestamper *mii_ts;
    struct pse_control *psec;
    struct list_head ports;
    int n_ports;
    int max_n_ports;
    u8 mdix;
    u8 mdix_ctrl;
    int pma_extable;
    unsigned int link_down_events;
    void (*phy_link_change)(struct phy_device *phydev, bool up);
    void (*adjust_link)(struct net_device *dev);
  #if IS_ENABLED(CONFIG_MACSEC);
    const struct macsec_ops *macsec_ops;
  #endif;
    struct phy_oatc14_sqi_capability oatc14_sqi_capability;
};

πŸ’… Members πŸ’…

  • mdio β€” the MDIO bus this PHY is on πŸŽ€
  • drv β€” pointer to the driver for this PHY instance
  • devlink β€” creates a link between phy dev and mac dev, if the external phy used by current mac interface is managed by another mac interface
  • phyindex β€” unique id across the phy's parent tree of phys to address the PHY from userspace, similar to ifindex. A zero index means the PHY wasn't assigned an id yet.
  • phy_id β€” UID for this device found during discovery
  • c45_ids β€” 802.3-c45 Device Identifiers if is_c45
  • is_c45 β€” set to true if this PHY uses clause 45 addressing
  • is_internal β€” set to true if this PHY is internal to a MAC
  • is_pseudo_fixed_link β€” set to true if this PHY is an Ethernet switch, etc.
  • is_gigabit_capable β€” set to true if PHY supports 1000Mbps
  • has_fixups β€” set to true if this PHY has fixups/quirks
  • suspended β€” set to true if this PHY has been suspended successfully
  • suspended_by_mdio_bus β€” set to true if this PHY was suspended by MDIO bus
  • sysfs_links β€” internal boolean tracking sysfs symbolic links setup/removal
  • loopback_enabled β€” set true if this PHY has been loopbacked successfully
  • downshifted_rate β€” set true if link speed has been downshifted
  • is_on_sfp_module β€” set true if PHY is located on an SFP module
  • mac_managed_pm β€” set true if MAC driver takes of suspending/resuming PHY
  • wol_enabled β€” set to true if the PHY or the attached MAC have Wake-on-LAN enabled
  • is_genphy_driven β€” PHY is driven by one of the generic PHY drivers
  • autoneg β€” flag autoneg being used
  • link β€” current link state
  • autoneg_complete β€” flag auto negotiation of the link has completed
  • pause β€” current pause
  • asym_pause β€” current asymmetric pause
  • interrupts β€” flag interrupts have been enabled
  • irq_suspended β€” flag indicating PHY is suspended and therefore interrupt handling shall be postponed until PHY has resumed
  • irq_rerun β€” flag indicating interrupts occurred while PHY was suspended, requiring a rerun of the interrupt handler after resume
  • default_timestamp β€” flag indicating whether we are using the phy timestamp as the default one
  • rate_matching β€” current rate matching mode
  • state β€” state of the PHY for management purposes
  • dev_flags β€” device-specific flags used by the PHY driver
  • interface β€” enum phy_interface_t value
  • possible_interfaces β€” bitmap of interface modes that the attached PHY will switch between depending on media speed
  • speed β€” current link speed
  • duplex β€” current duplex
  • port β€” current port
  • master_slave_get β€” current master/slave advertisement
  • master_slave_set β€” user requested master/slave configuration
  • master_slave_state β€” current master/slave configuration
  • supported β€” combined MAC/PHY supported linkmodes
  • advertising β€” currently advertised linkmodes
  • lp_advertising β€” current link partner advertised linkmodes
  • adv_old β€” saved advertised while power saving for WoL
  • supported_eee β€” supported PHY EEE linkmodes
  • advertising_eee β€” currently advertised EEE linkmodes
  • eee_disabled_modes β€” energy efficient ethernet modes not to be advertised
  • enable_tx_lpi β€” when True, MAC should transmit LPI to PHY
  • eee_active β€” phylib private state, indicating that EEE has been negotiated
  • autonomous_eee_disabled β€” set when autonomous EEE has been disabled, used to re-apply after PHY soft reset
  • eee_cfg β€” user configuration of EEE
  • host_interfaces β€” PHY interface modes supported by host
  • phy_led_triggers β€” array of LED triggers
  • phy_num_led_triggers β€” number of triggers in phy_led_triggers
  • last_triggered β€” last LED trigger for link speed
  • led_link_trigger β€” LED trigger for link up/down
  • leds β€” list of PHY LED structures
  • irq β€” IRQ number of the PHY's interrupt (-1 if none)
  • priv β€” pointer to driver private data
  • shared β€” pointer to private data shared by phys in one package
  • skb β€” netlink message for cable diagnostics
  • ehdr β€” nNtlink header for cable diagnostics (yes, β€œnNtlink”, that's what it says 😭)
  • nest β€” netlink nest used for cable diagnostics
  • state_queue β€” work queue for state machine
  • lock β€” mutex for serialization access to PHY
  • sfp_bus_attached β€” flag indicating whether the SFP bus has been attached
  • sfp_bus β€” SFP bus attached to this PHY's fiber port
  • phylink β€” pointer to phylink instance for this PHY
  • attached_dev β€” the attached enet driver's device instance ptr
  • mii_ts β€” pointer to time stamper callbacks
  • psec β€” pointer to Power Sourcing Equipment control struct
  • ports β€” list of PHY ports structures
  • n_ports β€” number of ports currently attached to the PHY
  • max_n_ports β€” max number of ports this PHY can expose
  • mdix β€” current crossover
  • mdix_ctrl β€” user setting of crossover
  • pma_extable β€” cached value of PMA/PMD Extended Abilities Register
  • link_down_events β€” number of times link was lost
  • phy_link_change β€” callback for phylink for notification of link change
  • adjust_link β€” callback for the enet controller to respond to changes: in the link state
  • macsec_ops β€” MACsec offloading ops
  • oatc14_sqi_capability β€” SQI capability information for OATC14 10Base-T1S PHY

🌈 Description 🌈

Bit-map tea, bestie:

  • Bits [15:0] are free to use by the PHY driver to communicate driver specific behavior.
  • Bits [23:16] are currently reserved for future use.
  • Bits [31:24] are reserved for defining generic PHY driver behavior.
interrupts currently only supports enabled or disabled, but could be changed in the future to support enabling and disabling specific interrupts.

Contains some infrastructure for polling and interrupt handling, as well as handling shifts in PHY hardware state. 🫢

πŸ‘€ SEE ALSO ✨

okay bestie, this is the part where the whole friend group shows up πŸ˜­πŸ’– the phy_device page does not exist in a vacuum β€” she's got a whole ensemble cast, and they all live over in the kernel file ./include/linux/phy.h. Every single one of them is on the list, no cap, so let's do the roll call πŸŽ€


🌸 the types-and-structs girlies

these are the ones doing the actual definitions, the main character energy of the header file πŸ’…

  • enum phy_interface_t(9) β€” yes her, she's here πŸ‘‘
  • phy_modes(9) β€” periodt ✨
  • rgmii_clock(9) β€” iconic, no notes
  • struct mdio_bus_stats(9) β€” the stats bestie πŸ“
  • struct mii_bus(9) β€” bus bestie, of course
  • mdiobus_alloc(9) β€” she's on the list too πŸ¦‹
  • enum phy_state(9) β€” the state girlie, obviously
  • struct phy_c45_device_ids(9) β€” c45 representation πŸ™ˆ
  • struct phy_oatc14_sqi_capability(9) β€” yes, that's the exact spelling, don't come for me πŸ’€
  • struct phy_tdr_config(9) β€” present and accounted for
  • enum link_inband_signalling(9) β€” in-band, in the list πŸ’œ
  • struct phy_plca_cfg(9) β€” config bestie
  • struct phy_plca_status(9) β€” and her status bestie, they come as a pair 🫢
  • struct phy_led(9) β€” led girlie ✨
  • struct phy_mse_capability(9) β€” capability queen
  • struct phy_mse_snapshot(9) β€” snapshot queen, equally important πŸ’…
  • struct phy_driver(9) β€” the driver struct, the actual blueprint, obsessed πŸ”₯

πŸ¦‹ the id-compare crew

four of them, all matching the same vibe, all matching the same energy πŸ’–


πŸŽ€ state, wakeup & eee stuff


🌈 the read/write girlies (there are SO many)

like, a whole section's worth, and every one of them made the cut, fr fr πŸ’€βœ¨

the way that there are four separate mmd bit functions and two separate dunder pairs… she really said "completeness" πŸ’…


🧚 the timestamps, interrupts & misc besties

the last lil cluster, and honestly? they ate 🌸


bestie note 🫢 β€” that's all 53 cross-references plus the header file itself. nothing got cut, nothing got merged, and nothing got "cleaned up". if you need it, it's in ./include/linux/phy.h. iykyk πŸ’…

and that's the page, babes πŸŽ€ sourced from ./include/linux, stamped October 2026, and titled struct phy_device(9) β€” go forth and read your struct, you absolute icon πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from