Re: [PATCH net-next v13 09/10] net: ethtool: Introduce ethtool command to list ports
From: Paolo Abeni <pabeni@redhat.com>
Date: 2026-07-07 10:12:59
Also in:
lkml
On 7/1/26 1:04 PM, Maxime Chevallier wrote:
quoted hunk ↗ jump to hunk
Expose the phy_port information to userspace, so that we can know how many ports are available on a given interface, as well as their capabilities. For MDI ports, we report the list of supported linkmodes based on what the PHY that drives this port says. For MII ports, i.e. empty SFP cages, we report the MII linkmodes that we can output on this port. Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> --- MAINTAINERS | 1 + net/ethtool/Makefile | 2 +- net/ethtool/netlink.c | 25 +++ net/ethtool/netlink.h | 9 + net/ethtool/port.c | 373 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 net/ethtool/port.cdiff --git a/MAINTAINERS b/MAINTAINERS index 15011f5752a9..d62eaafa8d53 100644 --- a/MAINTAINERS +++ b/MAINTAINERS@@ -18794,6 +18794,7 @@ F: Documentation/devicetree/bindings/net/ethernet-connector.yaml F: Documentation/networking/phy-port.rst F: drivers/net/phy/phy_port.c F: include/linux/phy_port.h +F: net/ethtool/port.c K: struct\s+phy_port|phy_port_ NETWORKING [GENERAL]diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile index 629c10916670..9b5b09670008 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile@@ -9,4 +9,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ module.o cmis_fw_update.o cmis_cdb.o pse-pd.o plca.o \ - phy.o tsconfig.o mse.o + phy.o tsconfig.o mse.o port.odiff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 1af395b54330..c076c07d0a08 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c@@ -26,6 +26,8 @@ static u32 ethnl_bcast_seq; ETHTOOL_FLAG_OMIT_REPLY) #define ETHTOOL_FLAGS_STATS (ETHTOOL_FLAGS_BASIC | ETHTOOL_FLAG_STATS) +char phy_interface_names[PHY_INTERFACE_MODE_MAX][ETH_GSTRING_LEN] __ro_after_init; + const struct nla_policy ethnl_header_policy[] = { [ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 }, [ETHTOOL_A_HEADER_DEV_NAME] = { .type = NLA_NUL_STRING,@@ -431,6 +433,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_TSCONFIG_SET] = ðnl_tsconfig_request_ops, [ETHTOOL_MSG_PHY_GET] = ðnl_phy_request_ops, [ETHTOOL_MSG_MSE_GET] = ðnl_mse_request_ops, + [ETHTOOL_MSG_PORT_GET] = ðnl_port_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)@@ -1572,6 +1575,15 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_mse_get_policy, .maxattr = ARRAY_SIZE(ethnl_mse_get_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_PORT_GET, + .doit = ethnl_default_doit, + .start = ethnl_port_dump_start, + .dumpit = ethnl_port_dumpit, + .done = ethnl_port_dump_done, + .policy = ethnl_port_get_policy, + .maxattr = ARRAY_SIZE(ethnl_port_get_policy) - 1, + },
Both sashikos instances points to multiple races with dumps. I suspect some explicit locking is required. https://sashiko.dev/#/patchset/20260701110427.143945-1-maxime.chevallier%40bootlin.com https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260701110427.143945-1-maxime.chevallier%40bootlin.com I *think* this is hopefully the last pending issue. /P