STRUCT PHY_DEVICE(9)
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 instancedevlinkβ creates a link between phy dev and mac dev, if the external phy used by current mac interface is managed by another mac interfacephyindexβ unique id across the phy's parent tree of phys to address the PHY from userspace, similar toifindex. A zero index means the PHY wasn't assigned an id yet.phy_idβ UID for this device found during discoveryc45_idsβ 802.3-c45 Device Identifiers ifis_c45is_c45β set to true if this PHY uses clause 45 addressingis_internalβ set to true if this PHY is internal to a MACis_pseudo_fixed_linkβ set to true if this PHY is an Ethernet switch, etc.is_gigabit_capableβ set to true if PHY supports 1000Mbpshas_fixupsβ set to true if this PHY has fixups/quirkssuspendedβ set to true if this PHY has been suspended successfullysuspended_by_mdio_busβ set to true if this PHY was suspended by MDIO bussysfs_linksβ internal boolean tracking sysfs symbolic links setup/removalloopback_enabledβ set true if this PHY has been loopbacked successfullydownshifted_rateβ set true if link speed has been downshiftedis_on_sfp_moduleβ set true if PHY is located on an SFP modulemac_managed_pmβ set true if MAC driver takes of suspending/resuming PHYwol_enabledβ set to true if the PHY or the attached MAC have Wake-on-LAN enabledis_genphy_drivenβ PHY is driven by one of the generic PHY driversautonegβ flag autoneg being usedlinkβ current link stateautoneg_completeβ flag auto negotiation of the link has completedpauseβ current pauseasym_pauseβ current asymmetric pauseinterruptsβ flag interrupts have been enabledirq_suspendedβ flag indicating PHY is suspended and therefore interrupt handling shall be postponed until PHY has resumedirq_rerunβ flag indicating interrupts occurred while PHY was suspended, requiring a rerun of the interrupt handler after resumedefault_timestampβ flag indicating whether we are using the phy timestamp as the default onerate_matchingβ current rate matching modestateβ state of the PHY for management purposesdev_flagsβ device-specific flags used by the PHY driverinterfaceβenum phy_interface_tvaluepossible_interfacesβ bitmap of interface modes that the attached PHY will switch between depending on media speedspeedβ current link speedduplexβ current duplexportβ current portmaster_slave_getβ current master/slave advertisementmaster_slave_setβ user requested master/slave configurationmaster_slave_stateβ current master/slave configurationsupportedβ combined MAC/PHY supported linkmodesadvertisingβ currently advertised linkmodeslp_advertisingβ current link partner advertised linkmodesadv_oldβ saved advertised while power saving for WoLsupported_eeeβ supported PHY EEE linkmodesadvertising_eeeβ currently advertised EEE linkmodeseee_disabled_modesβ energy efficient ethernet modes not to be advertisedenable_tx_lpiβ when True, MAC should transmit LPI to PHYeee_activeβ phylib private state, indicating that EEE has been negotiatedautonomous_eee_disabledβ set when autonomous EEE has been disabled, used to re-apply after PHY soft reseteee_cfgβ user configuration of EEEhost_interfacesβ PHY interface modes supported by hostphy_led_triggersβ array of LED triggersphy_num_led_triggersβ number of triggers inphy_led_triggerslast_triggeredβ last LED trigger for link speedled_link_triggerβ LED trigger for link up/downledsβ list of PHY LED structuresirqβ IRQ number of the PHY's interrupt (-1if none)privβ pointer to driver private datasharedβ pointer to private data shared by phys in one packageskbβ netlink message for cable diagnosticsehdrβ nNtlink header for cable diagnostics (yes, βnNtlinkβ, that's what it says π)nestβ netlink nest used for cable diagnosticsstate_queueβ work queue for state machinelockβ mutex for serialization access to PHYsfp_bus_attachedβ flag indicating whether the SFP bus has been attachedsfp_busβ SFP bus attached to this PHY's fiber portphylinkβ pointer to phylink instance for this PHYattached_devβ the attached enet driver's device instance ptrmii_tsβ pointer to time stamper callbackspsecβ pointer to Power Sourcing Equipment control structportsβ list of PHY ports structuresn_portsβ number of ports currently attached to the PHYmax_n_portsβ max number of ports this PHY can exposemdixβ current crossovermdix_ctrlβ user setting of crossoverpma_extableβ cached value of PMA/PMD Extended Abilities Registerlink_down_eventsβ number of times link was lostphy_link_changeβ callback for phylink for notification of link changeadjust_linkβ callback for the enet controller to respond to changes: in the link statemacsec_opsβ MACsec offloading opsoatc14_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 notesstruct mdio_bus_stats(9)β the stats bestie πstruct mii_bus(9)β bus bestie, of coursemdiobus_alloc(9)β she's on the list too π¦enum phy_state(9)β the state girlie, obviouslystruct 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 forenum link_inband_signalling(9)β in-band, in the list πstruct phy_plca_cfg(9)β config bestiestruct 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 queenstruct 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 π
phy_id_compare(9)β the originalphy_id_compare_vendor(9)β vendor-flavouredphy_id_compare_model(9)β model-flavouredphydev_id_compare(9)β and thephydevone, because consistency is a myth but we love her anyway π
π state, wakeup & eee stuff
phy_is_started(9)β started or not, that's the question βphy_driver_is_genphy(9)β genphy check, cutephy_disable_eee_mode(9)β eee mode, handledphy_can_wakeup(9)β can she wake up? πphy_may_wakeup(9)β may she wake up? also on the list π«Ά
π the read/write girlies (there are SO many)
like, a whole section's worth, and every one of them made the cut, fr fr πβ¨
phy_read(9)β read bestie__phy_read(9)β and her double-underscore sister πphy_write(9)β write bestie__phy_write(9)β double-underscore write, also here__phy_modify_changed(9)β modify-changed representation πphy_read_mmd_poll_timeout(9)β the long-name queen, respect her π__phy_set_bits(9)β set bits, dunder edition__phy_clear_bits(9)β clear bits, dunder editionphy_set_bits(9)β set bits, public editionphy_clear_bits(9)β clear bits, public edition__phy_set_bits_mmd(9)β set bits mmd, dunder__phy_clear_bits_mmd(9)β clear bits mmd, dunderphy_set_bits_mmd(9)β set bits mmd, publicphy_clear_bits_mmd(9)β clear bits mmd, public
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 πΈ
phy_interrupt_is_valid(9)β interrupt validity check, she's herephy_polling_mode(9)β polling mode representation β¨phy_has_hwtstamp(9)β hwtstamp checkphy_has_rxtstamp(9)β rx flavourphy_has_tsinfo(9)β tsinfo flavourphy_has_txtstamp(9)β tx flavourphy_is_default_hwtstamp(9)β default hwtstamp check πphy_on_sfp(9)β sfp girlie, of coursephy_interface_mode_is_rgmii(9)β rgmii interface checkphy_interface_mode_is_8023z(9)β 8023z interface check, love the numbers βphy_interface_is_rgmii(9)β the other rgmii interface check, and yes both are listed πphy_is_pseudo_fixed_link(9)β pseudo fixed link check π¦phy_module_driver(9)β and the final boss: the module driver macro helper, closing us out π
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms