[PATCH net-next v5 00/13] net: phy: Rework linkmodes handling in a dedicated file

From: Maxime Chevallier
Date: Fri Mar 07 2025 - 12:36:33 EST


Hello everyone,

This is V5 of the phy_caps series. In a nutshell, this series reworks the way
we maintain the list of speed/duplex capablities for each linkmode so that we
no longer have multiple definition of these associations.

That will help making sure that when people add new linkmodes in
include/uapi/linux/ethtool.h, they don't have to update phylib and phylink as
well, making the process more straightforward and less error-prone.

It also generalises the phy_caps interface to be able to lookup linkmodes
from phy_interface_t, which is needed for the multi-port work I've been working
on for a while.

This V5 addresse Russell's and Paolo's reviews, namely :

- Error out when encountering an unknown SPEED_XXX setting

It prints an error and fails to initialize phylib. I've tested by
introducing a dummy 1.6T speed, I guess it's only a matter of time
before that actually happens :)

- Deal more gracefully with the fixed-link settings, keeping some level of
compatibility with what we had before by making sure we report a
single BaseT mode like before.

V1 : https://lore.kernel.org/netdev/20250222142727.894124-1-maxime.chevallier@xxxxxxxxxxx/
V2 : https://lore.kernel.org/netdev/20250226100929.1646454-1-maxime.chevallier@xxxxxxxxxxx/
V3 : https://lore.kernel.org/netdev/20250228145540.2209551-1-maxime.chevallier@xxxxxxxxxxx/
V4 : https://lore.kernel.org/netdev/20250303090321.805785-1-maxime.chevallier@xxxxxxxxxxx/

Maxime Chevallier (13):
net: ethtool: Export the link_mode_params definitions
net: phy: Use an internal, searchable storage for the linkmodes
net: phy: phy_caps: Move phy_speeds to phy_caps
net: phy: phy_caps: Move __set_linkmode_max_speed to phy_caps
net: phy: phy_caps: Introduce phy_caps_valid
net: phy: phy_caps: Implement link_capabilities lookup by linkmode
net: phy: phy_caps: Allow looking-up link caps based on speed and
duplex
net: phy: phy_device: Use link_capabilities lookup for PHY aneg config
net: phylink: Use phy_caps_lookup for fixed-link configuration
net: phy: drop phy_settings and the associated lookup helpers
net: phylink: Add a mapping between MAC_CAPS and LINK_CAPS
net: phylink: Convert capabilities to linkmodes using phy_caps
net: phylink: Use phy_caps to get an interface's capabilities and
modes

drivers/net/phy/Makefile | 2 +-
drivers/net/phy/phy-caps.h | 63 ++++++
drivers/net/phy/phy-core.c | 253 ++----------------------
drivers/net/phy/phy.c | 37 +---
drivers/net/phy/phy_caps.c | 359 +++++++++++++++++++++++++++++++++++
drivers/net/phy/phy_device.c | 16 +-
drivers/net/phy/phylink.c | 355 ++++++++++------------------------
include/linux/ethtool.h | 8 +
include/linux/phy.h | 15 --
net/ethtool/common.c | 1 +
net/ethtool/common.h | 7 -
11 files changed, 571 insertions(+), 545 deletions(-)
create mode 100644 drivers/net/phy/phy-caps.h
create mode 100644 drivers/net/phy/phy_caps.c

--
2.48.1