ksz_phy_addr_to_port(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ ksz_phy_addr_to_port β€” the PHY-address-to-port glow-up ✨

okay bestie, so this is a Kernel API Manual page for ksz_phy_addr_to_port(9) and honestly it's giving "small function, big main character energy" πŸ’… let's get into it.


🌸 NAME 🌸

ksz_phy_addr_to_port β€” literally maps a PHY address to the corresponding switch port. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int ksz_phy_addr_to_port (struct ksz_device *dev , int addr );

no cap, that's the whole signature ✨


πŸ’– ARGUMENTS πŸ’–

  • dev β€” pointer to the device structure. you know, the device. the one doing the device-ing 🫢
  • addr β€” the PHY address you want to map to a port.

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea β˜• β€” this function finds the corresponding switch port for a given PHY address by iterating over all user ports on the device. yes, all of them. it's doing the rounds, it's being thorough πŸ’…

for each port it checks two things:

  • does that port's PHY address in phy_addr_map match the specified address? πŸ‘€
  • does the port contain an internal PHY?

and if a match is found, the index of the port gets returned. slay ✨


πŸ”₯ RETURN πŸ”₯

  • Port index on success πŸŽ‰
  • -EINVAL if no matching port is found 😭 (iykyk, it happens)

🌈 SEE ALSO 🌈

the kernel file lives right here: ./drivers/net/dsa/microchip/ksz_common.c πŸ“

and here's the whole friend group, all iconic, all in the same directory-era:


πŸ’€ tiny reminder bestie: if nothing matches, you're getting -EINVAL back, not a port index. don't @ me, that's just what the return value says.

and that's the whole page πŸ§šπŸ’œ this one's from ./drivers/net/dsa/microchip, dated October 2026, and it's called ksz_phy_addr_to_port(9) β€” periodt. πŸ“βœ¨

πŸ“¦ where this page comes from