STRUCT PHY_PORT(9)
β¨ struct phy_port(9) β¨
the kernel API manual, section 9 β bestie edition π«Ά
okay so picture this: it's a whole struct in the kernel that's basically the main character representation of a network device's physical interface. like, the actual pluggy-inny port part, not the whole device. she's serving hardware-truth realness π
and honestly? iconic.
π NAME π
struct phy_port β no cap, this is literally a representation of a network device physical interface. that's it, that's the vibe check β¨
πΈ SYNOPSIS πΈ
here's the whole glow-up, copy-pasted from the source exact-exact, so you know it's real:
struct phy_port {
struct list_head head;
enum phy_port_parent parent_type;
union {
struct phy_device *phy;
};
const struct phy_port_ops *ops;
int pairs;
unsigned long mediums;
unsigned long supported[BITS_TO_LONGS(
__ETHTOOL_LINK_MODE_MASK_NBITS)];
unsigned long interfaces[BITS_TO_LONGS( PHY_INTERFACE_MODE_MAX)];
unsigned int not_described:1;
unsigned int active:1;
unsigned int is_mii:1;
unsigned int is_sfp:1;
};
look at all those bitfields at the bottom though β :1 after :1 after :1, she is packed, she is efficient, she is not wasting a single bit ππ
π¦ Members π¦
okay bestie, let's go through every single one of her fields because we do NOT skip members in this house π
headβ the port's parent uses this to keep her in a list of ports. it's giving group-chat member list energy. she's listed πparent_typeβ tells you the type of device this port is directly connected to. like, who's your parent? what's the family tree situation? π³{unnamed_union}β it's an anonymous union, no name, no label, just vibes. she's mysterious like that πphyβ if the parent happens to bePHY_PORT_PHYDEV, this is the PHY controlling that port. lowkey the only time she shows up to the party β¨opsβ the callback ops, implemented by the port controller. this is where the port controller gets to show off its tricks πͺpairsβ the number of pairs this port has, and it's0if that concept doesn't even apply. not every port is a pairs girly πmediumsβ a bitmask of the physical mediums this port provides access to. bitmask baddie πsupportedβ the link modes this port can expose β but only if this port is MDI (not MII). MDI girlies only, sorry MII πinterfacesβ the MII interfaces this port supports, if this port is MII. the flip side of the coin, we love a matching set π¦not_describedβ signals to the parent driver that this port isn't described, which means it's fully up to the parent to filter its capabilities. no description? no problem, parent's problem now πactiveβ says whether the port is currently part of the active link. is she in the link or is she just lurking? main character check βis_miiβ tells you if this port is MII (Media Independent Interface) or MDI (Media Dependent Interface). pick a lane bestie, the acronyms are fighting πis_sfpβ says if this port drives an SFP cage. cage driver energy, lowkey feral π₯
π SEE ALSO π
- Kernel file
./include/linux/phy_port.h enum phy_port_parent(9)
go read those next, iyktyk, they're the prequel π
fr fr bestie, that's the whole struct β every field, every bitfield, every anonymous union. don't @ me if your parent driver forgets to filter capabilities when not_described is set, that's a you problem ππ
and that's the tea, signed off from the ./include/linux source tree, dated October 2026, struct phy_port(9) forever and always π«Άβ¨
π¦ 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