STRUCT ETHTOOL_PHY_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

struct ethtool_phy_ops β€” the optional PHY device options, bestie. That's it, that's the whole vibe. It's a little bundle of function pointers you can fill in for your PHY, and literally none of them are required (more on that in a sec, it's giving "no pressure" πŸ’…).

This is straight out of the Kernel API Manual, and we're gonna go through the whole thing together, no skipping, no cap ✨


✨ SYNOPSIS ✨

Okay so here's the struct in all its glory, copied exactly, don't @ me about the line breaks:

struct ethtool_phy_ops {
    int (*get_sset_count)(struct phy_device *dev);
    int (*get_strings)(struct phy_device *dev, u8 *data);
    int (*get_stats)(struct phy_device *dev, struct ethtool_stats
*stats, u64 *data);
    int (*get_plca_cfg)(struct phy_device *dev, struct phy_plca_cfg
*plca_cfg);
    int (*set_plca_cfg)(struct phy_device *dev, const struct
phy_plca_cfg *plca_cfg, struct netlink_ext_ack *extack);
    int (*get_plca_status)(struct phy_device *dev, struct
phy_plca_status *plca_st);
    int (*start_cable_test)(struct phy_device *phydev, struct
netlink_ext_ack *extack);
    int (*start_cable_test_tdr)(struct phy_device *phydev, struct
netlink_ext_ack *extack, const struct phy_tdr_config *config);
 };

Look at all those function pointers πŸ¦‹ β€” every single one of them is a little optional superpower you can bolt onto your PHY. Slay.


πŸ‘‘ Members πŸ‘‘

Let's do a lil roll call, one by one, so you know exactly who's who in this friend group 🫢

  • get_sset_count β€” tells you how many strings get_strings is gonna write. Basically the "how many are we expecting" headcount before the party πŸŽ‰
  • get_strings β€” hands back a set of strings that describe the objects you asked for. The actual name tags, if you will 🏷️
  • get_stats β€” returns extended statistics about the PHY device. All the numbers, all the receipts πŸ“Š
  • get_plca_cfg β€” returns the PLCA configuration. Reading the settings, lowkey iconic.
  • set_plca_cfg β€” sets the PLCA configuration. Now you're writing the settings, main character energy πŸ”₯
  • get_plca_status β€” gets the PLCA configuration. Yep, the doc says "Get PLCA configuration" for this one too β€” I'm just passing along what it says, fr fr πŸ™ˆ
  • start_cable_test β€” starts a cable test. Go little cable, go 🧚
  • start_cable_test_tdr β€” starts a Time Domain Reflectometry cable test. The fancy one. The deluxe edition ⭐

🌸 Description 🌸

Okay here's the part you actually need to remember, bestie, so let me be loud about it:

All operations are optional (i.e. the function pointer may be set to NULL) and callers must take this into account. So like, don't just assume every pointer's been filled in β€” vibe check your struct first πŸ’€

Also: callers must hold the RTNL lock. That's not a suggestion, that's the rule. Lock first, then call. Periodt πŸ”’


πŸ¦‹ SEE ALSO πŸ¦‹

The kernel file lives at ./include/linux/ethtool.h, and honestly the whole extended fam is worth a look πŸ‘€:


πŸ’– Friendly reminder before you bounce: set your unset pointers to NULL, check for NULL before you call, and hold the RTNL lock. That's the whole assignment, you've got this 🫢

And that's the page, bestie! It came from ./include/linux, it's dated October 2026, and the whole thing is filed under struct ethtool_phy_ops(9). Go be iconic with your PHY ops πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from