public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: maxime.chevallier@bootlin.com
Cc: Simon Horman <horms@kernel.org>,
	edumazet@google.com, davem@davemloft.net, pabeni@redhat.com,
	vladimir.oltean@nxp.com, daniel@makrotopia.org, kabel@kernel.org,
	nicveronese@gmail.com, mwojtas@chromium.org,
	romain.gantois@bootlin.com, herve.codina@bootlin.com,
	netdev@vger.kernel.org, kuba@kernel.org,
	dimitri.fedrau@liebherr.com, andrew@lunn.ch,
	o.rempel@pengutronix.de, linux@armlinux.org.uk,
	linux-kernel@vger.kernel.org, kory.maincent@bootlin.com,
	hkallweit1@gmail.com, thomas.petazzoni@bootlin.com,
	christophe.leroy@csgroup.eu, f.fainelli@gmail.com
Subject: Re: [net-next,v6,10/10] net: ethtool: Introduce ethtool command to list ports
Date: Fri,  6 Mar 2026 13:58:54 +0000	[thread overview]
Message-ID: <20260306135854.492356-1-horms@kernel.org> (raw)
In-Reply-To: <20260304145444.442334-11-maxime.chevallier@bootlin.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: ethtool: Introduce ethtool command to list ports

This commit introduces a new ethtool netlink command to expose phy_port
information to userspace, allowing enumeration of available ports and
their capabilities on a given interface.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2265e2c9bfbe..668af8739c21 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18421,6 +18421,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/port.c b/net/ethtool/port.c
> new file mode 100644
> index 000000000000..d870ed70769e
> --- /dev/null
> +++ b/net/ethtool/port.c
> @@ -0,0 +1,376 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright 2026 Bootlin
> + *
> + */
> +#include "common.h"
> +#include "bitset.h"
> +#include "netlink.h"
> +
> +#include <linux/phy.h>
> +#include <linux/phy_link_topology.h>
> +#include <linux/phy_port.h>
> +#include <net/netdev_lock.h>

[ ... ]

> +static int port_dump_one(struct sk_buff *skb, struct net_device *dev,
> +			 struct netlink_callback *cb)
> +{
> +	struct port_dump_ctx *ctx = port_dump_ctx_get(cb);
> +	void *ehdr;
> +	int ret;
> +
> +	ehdr = ethnl_dump_put(skb, cb, ETHTOOL_A_PORT_HEADER);
> +	if (!ehdr)
> +		return -EMSGSIZE;

Is ETHTOOL_A_PORT_HEADER the correct constant here?

The third parameter to ethnl_dump_put() should be the genetlink command
ID that gets stored in the message header's cmd field. Looking at other
dump implementations in net/ethtool/:

net/ethtool/tunnels.c:
    ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY);

net/ethtool/tsinfo.c:
    ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_TSINFO_GET_REPLY);

net/ethtool/rss.c:
    ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_RSS_GET_REPLY);

These all pass ETHTOOL_MSG_*_GET_REPLY command constants, not
ETHTOOL_A_* attribute constants.

ETHTOOL_A_PORT_HEADER is a netlink attribute with value 1 (from
include/uapi/linux/ethtool_netlink.h). Meanwhile, this file's
ethnl_port_request_ops structure correctly uses
ETHTOOL_MSG_PORT_GET_REPLY for .reply_cmd, suggesting the same
constant should be used here. Can this cause the wrong command ID
to be sent in every dump response message?

> +
> +	memset(ctx->reply_data, 0, sizeof(struct port_reply_data));
> +	ctx->reply_data->base.dev = dev;
> +
> +	rtnl_lock();
> +	netdev_lock_ops(dev);
> +
> +	ret = port_prepare_data(&ctx->req_info->base, &ctx->reply_data->base,
> +				genl_info_dump(cb));
> +
> +	netdev_unlock_ops(dev);
> +	rtnl_unlock();
> +
> +	if (ret < 0)
> +		goto out;
> +
> +	ret = ethnl_fill_reply_header(skb, dev, ETHTOOL_A_PORT_HEADER);
> +	if (ret < 0)
> +		goto out;
> +
> +	ret = port_fill_reply(skb, &ctx->req_info->base, &ctx->reply_data->base);
> +
> +out:
> +	ctx->reply_data->base.dev = NULL;
> +	if (ret < 0)
> +		genlmsg_cancel(skb, ehdr);
> +	else
> +		genlmsg_end(skb, ehdr);
> +
> +	return ret;
> +}

[ ... ]

> +const struct ethnl_request_ops ethnl_port_request_ops = {
> +	.request_cmd		= ETHTOOL_MSG_PORT_GET,
> +	.reply_cmd		= ETHTOOL_MSG_PORT_GET_REPLY,
> +	.hdr_attr		= ETHTOOL_A_PORT_HEADER,
> +	.req_info_size		= sizeof(struct port_req_info),
> +	.reply_data_size	= sizeof(struct port_reply_data),
> +
> +	.parse_request		= port_parse_request,
> +	.prepare_data		= port_prepare_data,
> +	.reply_size		= port_reply_size,
> +	.fill_reply		= port_fill_reply,
> +};

  reply	other threads:[~2026-03-06 13:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 14:54 [PATCH net-next v6 00/10] net: phy_port: SFP modules representation and phy_port listing Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 01/10] net: phy: phy_link_topology: Add a helper for opportunistic alloc Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 02/10] net: phy: phy_link_topology: Track ports in phy_link_topology Maxime Chevallier
2026-03-06 14:09   ` [net-next,v6,02/10] " Simon Horman
2026-03-06 15:57     ` Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 03/10] net: phylink: Register a phy_port for MAC-driven SFP busses Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 04/10] net: phy: Create SFP phy_port before registering upstream Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 05/10] net: phy: Represent PHY-less SFP modules with phy_port Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 06/10] net: phylink: " Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 07/10] net: phy: phy_port: Store information about a MII port's vacant state Maxime Chevallier
2026-03-06 14:03   ` [net-next,v6,07/10] " Simon Horman
2026-03-06 15:50     ` Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 08/10] net: phy: phy_link_topology: Add a helper to retrieve ports Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 09/10] netlink: specs: Add ethernet port listing with ethtool Maxime Chevallier
2026-03-04 14:54 ` [PATCH net-next v6 10/10] net: ethtool: Introduce ethtool command to list ports Maxime Chevallier
2026-03-06 13:58   ` Simon Horman [this message]
2026-03-06 15:33     ` [net-next,v6,10/10] " Maxime Chevallier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260306135854.492356-1-horms@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=christophe.leroy@csgroup.eu \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=dimitri.fedrau@liebherr.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=kabel@kernel.org \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mwojtas@chromium.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicveronese@gmail.com \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=romain.gantois@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox