STRUCT MII_BUS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct mii_bus(9) ✨

okay so bestie, we're in the struct mii_bus(9) page β€” the Kernel API Manual entry β€” and it's literally the blueprint for an MDIO bus. no cap, this is the glow-up doc for the thing that talks to your PHYs. let's get into it πŸ’…


🌸 NAME 🌸

struct mii_bus β€” Represents an MDIO bus πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

like, here's the whole struct, every single field, in order, don't touch:

struct mii_bus {
    struct module *owner;
    const char *name;
    char id[MII_BUS_ID_SIZE];
    void *priv;
    int (*read)(struct mii_bus *bus, int addr, int regnum);
    int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
    int (*read_c45)(struct mii_bus *bus, int addr, int devnum, int regnum);
    int (*write_c45)(struct mii_bus *bus, int addr, int devnum, int regnum, u16 val);
    int (*reset)(struct mii_bus *bus);
    struct mdio_bus_stats stats[PHY_MAX_ADDR];
    struct mutex mdio_lock;
    struct device *parent;
    enum {
      MDIOBUS_ALLOCATED = 1,
      MDIOBUS_REGISTERED,
      MDIOBUS_UNREGISTERED,
      MDIOBUS_RELEASED,
    } state;
    struct device dev;
    struct mdio_device *mdio_map[PHY_MAX_ADDR];
    u32 phy_mask;
    u32 phy_ignore_ta_mask;
    int irq[PHY_MAX_ADDR];
    int reset_delay_us;
    int reset_post_delay_us;
    struct gpio_desc *reset_gpiod;
    struct mutex shared_lock;
  #if IS_ENABLED(CONFIG_PHY_PACKAGE);
    struct phy_package_shared *shared[PHY_MAX_ADDR];
  #endif;
 };

🫢 Members 🫢

every field gets its moment, bestie, no skipping:

  • owner β€” who owns this device πŸ‘‘
  • name β€” user friendly name for this MDIO device, or the driver name
  • id β€” unique identifier for this bus, typically from bus hierarchy
  • priv β€” driver private data πŸ™ˆ
  • read β€” perform a read transfer on the bus
  • write β€” perform a write transfer on the bus
  • read_c45 β€” perform a C45 read transfer on the bus
  • write_c45 β€” perform a C45 write transfer on the bus
  • reset β€” perform a reset of the bus πŸ”₯
  • stats β€” statistic counters per device on the bus
  • mdio_lock β€” a lock to ensure that only one thing can read/write the MDIO bus at a time
  • parent β€” parent device of this bus
  • state β€” state of bus structure
  • dev β€” kernel device representation
  • mdio_map β€” list of all MDIO devices on bus
  • phy_mask β€” PHY addresses to be ignored when probing
  • phy_ignore_ta_mask β€” PHY addresses to ignore the TA/read failure
  • irq β€” an array of interrupts, each PHY's interrupt at the index matching its address
  • reset_delay_us β€” GPIO reset pulse width in microseconds
  • reset_post_delay_us β€” GPIO reset deassert delay in microseconds
  • reset_gpiod β€” Reset GPIO descriptor pointer
  • shared_lock β€” protect access to the shared element
  • shared β€” shared state across different PHYs

πŸ’– Description πŸ’–

the Bus class for PHYs, periodt. devices which provide access to PHYs should register using this structure ✨


🌈 SEE ALSO 🌈

kernel file ./include/linux/phy.h β€” and yes, the whole friend group is here πŸ’€

and that's the whole thing, bestie πŸŽ€ this page lives in ./include/linux and it's dated October 2026 β€” so like, future vibes, iconic. go read your PHY headers, mwah πŸ’–πŸ‘‘

πŸ“¦ where this page comes from