Re: [PATCH net-next v4 5/8] net: ethtool: netlink: Introduce per-phy DUMP helpers
From: Kory Maincent <kory.maincent@bootlin.com>
Date: 2025-03-25 13:34:15
Also in:
lkml, netdev
On Mon, 24 Mar 2025 11:40:07 +0100 Maxime Chevallier [off-list ref] wrote:
quoted hunk ↗ jump to hunk
As there are multiple ethnl commands that report messages based on phy_device information, let's introduce a set of ethnl generic dump helpers to allow DUMP support for each PHY on a given netdev. This logic iterates over the phy_link_topology of each netdev (or a single netdev for filtered DUMP), and call ethnl_default_dump_one() with the req_info populated with ifindex + phyindex. This allows re-using all the existing infra for phy-targetting commands that already use ethnl generic helpers. Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> --- V4 : No changes net/ethtool/netlink.c | 78 +++++++++++++++++++++++++++++++++++++++++++ net/ethtool/netlink.h | 6 ++++ 2 files changed, 84 insertions(+)diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 0345bffa0678..171290eaf406 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c@@ -560,6 +560,84 @@ static int ethnl_default_dump_one(struct sk_buff *skb, return ret; } +/* Specific context for phy-targeting command DUMP operatins. We keep incontext + * the latest phy_index we dumped, in case of an interrupted DUMP. + */ +struct ethnl_dump_ctx_perphy { + unsigned long phy_index; +}; + +/** + * ethnl_dump_start_perphy() - Initialise a dump for PHY cmds + * @ctx: Generic ethnl dump context whose cmd_ctx will be initialized + * + * Initializes a dump context for ethnl commands that may return + * one message per PHY on a single netdev. + * + * Returns: 0 for success, a negative value for errors.
Minimal nitpick. In the kernel doc Return does not take a s.
+/** + * ethnl_dump_one_dev_perphy() - Dump all PHY-related messages for one netdev + * @skb: skb containing the DUMP result + * @ctx: Dump context. Will be kept across the DUMP operation. + * @info: Genl receive info + * + * Some commands are related to PHY devices attached to netdevs. As there may be + * multiple PHYs, this DUMP handler will populate the reply with one message per + * PHY on a single netdev. + * + * Returns: 0 for success or when nothing to do, a negative value otherwise.
Same. Reviewed-by: Kory Maincent <kory.maincent@bootlin.com> Thank you! -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com