STRUCT PHY_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct phy_ops(9) β€” the kernel API manual, bestie edition

okay so picture this: it's struct phy_ops(9) from the Kernel API Manual, and it's literally just a big ol' bundle of function pointers for doing phy operations. that's it. that's the whole vibe. think of it as the group chat of callbacks a phy driver signs up for β€” every member is a little "hey bestie can you handle this for me" 🫢


✨ NAME ✨

struct phy_ops β€” the set of function pointers for performing phy operations. no cap, that's the entire job description πŸ’…


🌸 SYNOPSIS 🌸

struct phy_ops {
    int (*init)(struct phy *phy);
    int (*exit)(struct phy *phy);
    int (*power_on)(struct phy *phy);
    int (*power_off)(struct phy *phy);
    int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
    int (*set_media)(struct phy *phy, enum phy_media media);
    int (*set_speed)(struct phy *phy, int speed);
    int (*configure)(struct phy *phy, union phy_configure_opts *opts);
    int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
union phy_configure_opts *opts);
    int (*reset)(struct phy *phy);
    int (*calibrate)(struct phy *phy);
    int (*connect)(struct phy *phy, int port);
    int (*disconnect)(struct phy *phy, int port);
    int (*notify_phystate)(struct phy *phy, union phy_notify state);
    void (*release)(struct phy *phy);
    struct module *owner;
 };

look at all those little pointer besties lined up. iconic lineup honestly πŸŽ€


πŸ¦‹ Members πŸ¦‹

okay let's go down the list one by one, i gotchu:

  • init β€” the operation to be performed for initializing the phy. the "hi nice to meet you" moment ✨
  • exit β€” the operation to be performed while exiting. the goodbye, the "ok bye love you" πŸ‘‹
  • power_on β€” powering on the phy. waking it up, giving it a little stretch πŸ”₯
  • power_off β€” powering off the phy. nap time fr fr 😴
  • set_mode β€” set the mode of the phy. main character energy, choose your era πŸ’«
  • set_media β€” set the media type of the phy (optional). lowkey optional, highkey useful 🌈
  • set_speed β€” set the speed of the phy (optional). also optional! zoom zoom ⭐
  • configure β€” Optional.

Used to change the PHY parameters. phy_init must have been called on the phy first β€” like, no skipping steps bestie, that's the whole prerequisite 🫢

Returns: 0 if successful, an negative error code otherwise. (yes it says "an negative", i'm just the messenger πŸ’€)

  • validate β€” Optional.

Used to check that the current set of parameters can be handled by the phy. implementations are free to tune the parameters passed as arguments if needed by some implementation detail or constraints. important part: it must not change any actual configuration of the PHY β€” so calling it as many times as deemed fit by the consumer must have no side effect. it's giving "look but don't touch" πŸ™ˆ

Returns: 0 if the configuration can be applied, an negative error code otherwise.

  • reset β€” resetting the phy. factory reset but make it cute πŸŽ€
  • calibrate β€” calibrate the phy. tuning it up until it's serving exactly right πŸ’…
  • notify_phystate β€” notify and configure the phy for a particular state. it does both!! overachiever behavior πŸ‘‘
  • release β€” ops to be performed while the consumer relinquishes the PHY. the hand-it-back moment 🫴
  • owner β€” the module owner containing the ops. every struct needs a parent, periodt.
ngl the synopsis also shows connect (takes struct phy *phy and int port) and disconnect (same signature) β€” and the members list here does not spell out what they do. so i'm not gonna make anything up. they're in the struct, that's what we know, iykyk 🧚

πŸ’œ SEE ALSO πŸ’œ

  • Kernel file ./include/linux/phy/phy.h
  • union phy_configure_opts(9)
  • struct phy_attrs(9)
  • struct phy(9)
  • struct phy_provider(9)
  • struct phy_lookup(9)

go read those too, they're all friends of this struct and they all slay 🌸


that's the whole page bestie, you ate it up πŸ’– and before you go β€” this cutie lives at ./include/linux/phy, dated October 2026, and yeah it's struct phy_ops(9), we been knew πŸ¦‹ mwah, go write some slay callbacks ✨

πŸ“¦ where this page comes from