From patchwork Wed Mar 5 14:19:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65BB4C19F32 for ; Wed, 5 Mar 2025 15:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E4Vt/+sE9uq1aYjpbMx/58Ei8i4J79Zx7ZN6MMUPbsc=; b=mi0zpMw/qkLmXNTe2klN4m2wir 892USE/xOX4GY09RhIlemNsbINOsOSyFn14DarT0GWDRhwjCI83oNVOAzqJKiXVqRxn6dJ+jJSJ7u HYZ0Cyr82hmFKhHFp7swLxGb92U23n1Ngz/wCAqKUtbasJFuM5BUucj5tAUMMCPlpVM0MgPPwyUIL wBZnH9EU26XEAfFB/tpKZoGHKZtBb9oqYa3BybYc6I1PpSeC4Itg9V6QLITdmJ8d16pp5fUYAZopZ TJ67UHhpKfze0xlev9MDiiqyNE2PlUhpVX/eXGmWvu21p1qX4JSN8HbBdVhS46PXeulkW6C2QD+Eq 18It6gxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpqkh-00000008WvR-1qiw; Wed, 05 Mar 2025 15:33:43 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppb9-00000008KGm-0Y7s for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:49 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B724D44110; Wed, 5 Mar 2025 14:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4Vt/+sE9uq1aYjpbMx/58Ei8i4J79Zx7ZN6MMUPbsc=; b=G4k4yM9ttZ1iCsFOil5MiRmHa+ABS8VQg8xqJL5FlX9vz94dEpz99jUqSUYRMfIrNKAxVz 7mlAh06hqjgSEiIrXbXQK6WKS/LpC4K67pFFXTkpcUmSLt7qamYHn9CdoswfUX+Uny1RLm H9RhMj3OooeLwlTelbQCGHnb/Zk/z6wkhs09xyEskdHF6BSZ6VRbefvh9liJ41B/92VqFI 1H8OPP49pPX6iKbyBiegf76eA6y6nNN7hvuKrZCvfp7j6Nj3s/OMTcrBjuT1UxDLjRkDge 7A2N6aW9bvZlF2mULovljGK1Xl8rKp79x3Fx1Y0kU+1fMQKImZitqJHfBjxQ4g== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 1/7] net: ethtool: netlink: Allow per-netdevice DUMP operations Date: Wed, 5 Mar 2025 15:19:31 +0100 Message-ID: <20250305141938.319282-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061947_310510_3FB2C0AC X-CRM114-Status: GOOD ( 16.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have a number of netlink commands in the ethnl family that may have multiple objects to dump even for a single net_device, including : - PLCA, PSE-PD, phy: one message per PHY device - tsinfo: one message per timestamp source (netdev + phys) - rss: One per RSS context To get this behaviour, these netlink commands need to roll a custom ->dumpit(). To prepare making per-netdev DUMP more generic in ethnl, introduce a member in the ethnl ops to indicate if a given command may allow pernetdev DUMPs (also referred to as filtered DUMPs). Signed-off-by: Maxime Chevallier --- net/ethtool/netlink.c | 45 ++++++++++++++++++++++++++++--------------- net/ethtool/netlink.h | 1 + 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 734849a57369..0815b28ba32f 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -578,21 +578,34 @@ static int ethnl_default_dumpit(struct sk_buff *skb, int ret = 0; rcu_read_lock(); - for_each_netdev_dump(net, dev, ctx->pos_ifindex) { - dev_hold(dev); + if (ctx->req_info->dev) { + dev = ctx->req_info->dev; rcu_read_unlock(); - - ret = ethnl_default_dump_one(skb, dev, ctx, genl_info_dump(cb)); - + /* Filtered DUMP request targeted to a single netdev. We already + * hold a ref to the netdev from ->start() + */ + ret = ethnl_default_dump_one_dev(skb, dev, ctx, + genl_info_dump(cb)); rcu_read_lock(); - dev_put(dev); - - if (ret < 0 && ret != -EOPNOTSUPP) { - if (likely(skb->len)) - ret = skb->len; - break; + netdev_put(ctx->req_info->dev, &ctx->req_info->dev_tracker); + } else { + for_each_netdev_dump(net, dev, ctx->pos_ifindex) { + dev_hold(dev); + rcu_read_unlock(); + + ret = ethnl_default_dump_one(skb, dev, ctx, + genl_info_dump(cb)); + + rcu_read_lock(); + dev_put(dev); + + if (ret < 0 && ret != -EOPNOTSUPP) { + if (likely(skb->len)) + ret = skb->len; + break; + } + ret = 0; } - ret = 0; } rcu_read_unlock(); @@ -626,10 +639,10 @@ static int ethnl_default_start(struct netlink_callback *cb) } ret = ethnl_default_parse(req_info, &info->info, ops, false); - if (req_info->dev) { - /* We ignore device specification in dump requests but as the - * same parser as for non-dump (doit) requests is used, it - * would take reference to the device if it finds one + if (req_info->dev && !ops->allow_pernetdev_dump) { + /* We ignore device specification in unfiltered dump requests + * but as the same parser as for non-dump (doit) requests is + * used, it would take reference to the device if it finds one */ netdev_put(req_info->dev, &req_info->dev_tracker); req_info->dev = NULL; diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index ec6ab5443a6f..4db27182741f 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -388,6 +388,7 @@ struct ethnl_request_ops { unsigned int req_info_size; unsigned int reply_data_size; bool allow_nodev_do; + bool allow_pernetdev_dump; u8 set_ntf_cmd; int (*parse_request)(struct ethnl_req_info *req_info, From patchwork Wed Mar 5 14:19:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB7B5C282EC for ; Wed, 5 Mar 2025 14:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VSOYBw/5jkwuslYtI7ZM9ppsbctGLWTWVfGhnv8zcfI=; b=Do8E6x6wGmh/XDQzFOiL6kdUkK CNyzqH3H9hg4odRUjvpSHXt3xvCZyVhWiOSj4uw4k6rwUwA7YqM09cAIMRdQGBIhUmEkIbwPBsblt IX9hbceyde3hGY0JwAHzORfwH2vfk9QzmSMUKKF7n/6z3/SJMGt8TTXtheXsLCpthWEGILMC/n7DN xo/Gd6VS2G3+4C0+4Itrj3PcObOlJEAomcf256N7sLUUG5mnCkOJzYsuXt2U4SdWmZ1YF/UgcDXE7 doezlh8tMjStf7xBmrG42VdS4L1+iUUHXTBplCCcy24AtmZS92TfxuT71UvJlnsayI5Nn/dG7eTnD Z+f8t2tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tppj2-00000008Lcv-23zL; Wed, 05 Mar 2025 14:27:56 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppbA-00000008KGv-037U for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:49 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D61434411E; Wed, 5 Mar 2025 14:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VSOYBw/5jkwuslYtI7ZM9ppsbctGLWTWVfGhnv8zcfI=; b=CNpRq1d/cuzV9UnWGhB+RaDXUSGmm9HAq663efZaVsTdaNmMDT1+YAzBf22ETP/VsRZ5J7 5nXR+yn9v8wDezHRD9xmPiw9drZAJwb+A9IAcW90X6NKm34MpP0uq/FTcFw1zYmLTjiwEx G79sGNOi+vOLTl99j5HS1jKDtKxaXvI2ARMZUbIX6e9iTolYExJJQMcwhAqfMLtmOF9Rw7 UXdKuxF/oOaJMnYXwhzq/eLezyG1oID53j3fA+ujwOcaC+Nqj2xS4AThoWz3xAnSLr8rOZ MF/e5rBg6HiL4yjfGZzgg9k2O7TEN9TQ5cAFY1ro3TjDrAZAurajff1UhGBavA== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 2/7] net: ethtool: netlink: Rename ethnl_default_dump_one Date: Wed, 5 Mar 2025 15:19:32 +0100 Message-ID: <20250305141938.319282-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061948_196555_240AEF03 X-CRM114-Status: GOOD ( 11.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As we work on getting more objects out of a per-netdev DUMP, rename ethnl_default_dump_one() into ethnl_default_dump_one_dev(), making it explicit that this dumps everything for one netdev. Signed-off-by: Maxime Chevallier --- net/ethtool/netlink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 0815b28ba32f..6dddaea2babb 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -533,9 +533,9 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info) return ret; } -static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev, - const struct ethnl_dump_ctx *ctx, - const struct genl_info *info) +static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *dev, + const struct ethnl_dump_ctx *ctx, + const struct genl_info *info) { void *ehdr; int ret; @@ -593,8 +593,8 @@ static int ethnl_default_dumpit(struct sk_buff *skb, dev_hold(dev); rcu_read_unlock(); - ret = ethnl_default_dump_one(skb, dev, ctx, - genl_info_dump(cb)); + ret = ethnl_default_dump_one_dev(skb, dev, ctx, + genl_info_dump(cb)); rcu_read_lock(); dev_put(dev); From patchwork Wed Mar 5 14:19:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DD93C19F32 for ; Wed, 5 Mar 2025 14:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IGHa73UrWTjwmuPsRwwRvgvwr91/An8UhMtuQjsToI0=; b=D1CQnD/lf+zJVhVTfn0zmeWxFs uB+OEVdrdZygzU16m9/AMrDQrkd3w3bv9t+NZGta9CfEc85/IaXUe7mCKh/gGy7jasZNhc0zMkvgK shgPu6M7wa4ntrqLrSXnCmiBTWTTtHZU10d/045cKa9RIH0eaajfJUTOGY1FliVG87BXdMTp7LoBm 7cPhAw/4By3ZPMTlUteVReeGoAaCuuOOmqeR2oCZVS94WzxCbws92+bj4cl8AqeClpGMksrH8dcCP 3fqS4laQQfD/frvvqsobFBrTIzIIlcvvrA9U49NJk+aEDFOjQ+I+Ac3TB68oMfBKcmBYTQCHN9Uo4 wufAaw8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tppeK-00000008Kw0-3Mvj; Wed, 05 Mar 2025 14:23:04 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppb9-00000008KHZ-1Qh1 for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:48 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D5ADE4410F; Wed, 5 Mar 2025 14:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IGHa73UrWTjwmuPsRwwRvgvwr91/An8UhMtuQjsToI0=; b=IOIhiSWOLlEWKpQS/KwLdJQVwH/QlI9ooRoMKQwKm0ynVeEAQev3tigTHRAaE+CKVOlUKV 3a0hAhjMmkWCn7mXXyrTRHxH5maOnZBUzkufJUWx5SVs5HZmxr+IZeHc70oDlpyOTEY8ld /cSTuVykab7Iw1tiGXAOy3MsCHNYWBPW8E2X9yOOAUc7cP/fmpvvfurAp9zAMTizTAsZNt 3mHB5iJ79dr5aOQrVrQHV/xjEYZBzfzs1wNz5CzPURx6eh9EYpHibB3J6GxbLNJse9g0h6 Awdae6hnFWDBGg1vxTTXpQUiF3xEERNg0j2Y3pF7Sel1TROfoMdn4FATINoJig== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 3/7] net: ethtool: netlink: Introduce command-specific dump_one_dev Date: Wed, 5 Mar 2025 15:19:33 +0100 Message-ID: <20250305141938.319282-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061947_539364_747FF14D X-CRM114-Status: GOOD ( 20.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prepare more generic ethnl DUMP hanldling, by allowing netlink commands to register their own dump_one_dev() callback. This avoids having to roll with a fully custom genl ->dumpit callback, allowing the re-use of some ethnl plumbing. Fallback to the default dump_one_dev behaviour when no custom callback is found. The command dump context is maintained within the ethnl_dump_ctx, that we move in netlink.h so that command handlers can access it. This context can be allocated/freed in new ->dump_start() and ->dump_done() callbacks. Signed-off-by: Maxime Chevallier --- net/ethtool/netlink.c | 58 +++++++++++++++++++++++++------------------ net/ethtool/netlink.h | 35 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 6dddaea2babb..c0215f4acc05 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -336,24 +336,6 @@ int ethnl_multicast(struct sk_buff *skb, struct net_device *dev) /* GET request helpers */ -/** - * struct ethnl_dump_ctx - context structure for generic dumpit() callback - * @ops: request ops of currently processed message type - * @req_info: parsed request header of processed request - * @reply_data: data needed to compose the reply - * @pos_ifindex: saved iteration position - ifindex - * - * These parameters are kept in struct netlink_callback as context preserved - * between iterations. They are initialized by ethnl_default_start() and used - * in ethnl_default_dumpit() and ethnl_default_done(). - */ -struct ethnl_dump_ctx { - const struct ethnl_request_ops *ops; - struct ethnl_req_info *req_info; - struct ethnl_reply_data *reply_data; - unsigned long pos_ifindex; -}; - static const struct ethnl_request_ops * ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_STRSET_GET] = ðnl_strset_request_ops, @@ -533,9 +515,9 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info) return ret; } -static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *dev, - const struct ethnl_dump_ctx *ctx, - const struct genl_info *info) +static int ethnl_default_dump_one(struct sk_buff *skb, + const struct ethnl_dump_ctx *ctx, + const struct genl_info *info) { void *ehdr; int ret; @@ -546,13 +528,13 @@ static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *de if (!ehdr) return -EMSGSIZE; - ethnl_init_reply_data(ctx->reply_data, ctx->ops, dev); rtnl_lock(); ret = ctx->ops->prepare_data(ctx->req_info, ctx->reply_data, info); rtnl_unlock(); if (ret < 0) goto out; - ret = ethnl_fill_reply_header(skb, dev, ctx->ops->hdr_attr); + ret = ethnl_fill_reply_header(skb, ctx->reply_data->dev, + ctx->ops->hdr_attr); if (ret < 0) goto out; ret = ctx->ops->fill_reply(skb, ctx->req_info, ctx->reply_data); @@ -560,11 +542,29 @@ static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *de out: if (ctx->ops->cleanup_data) ctx->ops->cleanup_data(ctx->reply_data); - ctx->reply_data->dev = NULL; + if (ret < 0) genlmsg_cancel(skb, ehdr); else genlmsg_end(skb, ehdr); + + return ret; +} + +static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *dev, + struct ethnl_dump_ctx *ctx, + const struct genl_info *info) +{ + int ret; + + ethnl_init_reply_data(ctx->reply_data, ctx->ops, dev); + + if (ctx->ops->dump_one_dev) + ret = ctx->ops->dump_one_dev(skb, ctx, info); + else + ret = ethnl_default_dump_one(skb, ctx, info); + + ctx->reply_data->dev = NULL; return ret; } @@ -593,6 +593,7 @@ static int ethnl_default_dumpit(struct sk_buff *skb, dev_hold(dev); rcu_read_unlock(); + ctx->req_info->dev = dev; ret = ethnl_default_dump_one_dev(skb, dev, ctx, genl_info_dump(cb)); @@ -655,6 +656,12 @@ static int ethnl_default_start(struct netlink_callback *cb) ctx->reply_data = reply_data; ctx->pos_ifindex = 0; + if (ctx->ops->dump_start) { + ret = ctx->ops->dump_start(ctx); + if (ret) + goto free_reply_data; + } + return 0; free_reply_data: @@ -670,6 +677,9 @@ static int ethnl_default_done(struct netlink_callback *cb) { struct ethnl_dump_ctx *ctx = ethnl_dump_context(cb); + if (ctx->ops->dump_done) + ctx->ops->dump_done(ctx); + kfree(ctx->reply_data); kfree(ctx->req_info); diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 4db27182741f..d7506b08e5d6 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -307,6 +307,26 @@ struct ethnl_reply_data { struct net_device *dev; }; +/** + * struct ethnl_dump_ctx - context structure for generic dumpit() callback + * @ops: request ops of currently processed message type + * @req_info: parsed request header of processed request + * @reply_data: data needed to compose the reply + * @pos_ifindex: saved iteration position - ifindex + * @cmd_ctx: command-specific context to maintain across the dump. + * + * These parameters are kept in struct netlink_callback as context preserved + * between iterations. They are initialized by ethnl_default_start() and used + * in ethnl_default_dumpit() and ethnl_default_done(). + */ +struct ethnl_dump_ctx { + const struct ethnl_request_ops *ops; + struct ethnl_req_info *req_info; + struct ethnl_reply_data *reply_data; + unsigned long pos_ifindex; + void *cmd_ctx; +}; + int ethnl_ops_begin(struct net_device *dev); void ethnl_ops_complete(struct net_device *dev); @@ -372,6 +392,15 @@ int ethnl_sock_priv_set(struct sk_buff *skb, struct net_device *dev, u32 portid, * - 0 if no configuration has changed * - 1 if configuration changed and notification should be generated * - negative errno on errors + * @dump_start: + * Optional callback to prepare a dump operation, should there be a need + * to maintain some context across the dump. + * @dump_one_dev; + * Optional callback to generate all messages for a given netdev. This + * is relevant only when a request can produce different results for the + * same netdev depending on command-specific attributes. + * @dump_done: + * Optional callback to cleanup any context allocated in ->dump_start() * * Description of variable parts of GET request handling when using the * unified infrastructure. When used, a pointer to an instance of this @@ -408,6 +437,12 @@ struct ethnl_request_ops { struct genl_info *info); int (*set)(struct ethnl_req_info *req_info, struct genl_info *info); + + int (*dump_start)(struct ethnl_dump_ctx *ctx); + int (*dump_one_dev)(struct sk_buff *skb, + struct ethnl_dump_ctx *ctx, + const struct genl_info *info); + void (*dump_done)(struct ethnl_dump_ctx *ctx); }; /* request handlers */ From patchwork Wed Mar 5 14:19:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E56ADC19F32 for ; Wed, 5 Mar 2025 14:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zJgNEItKL9gd+qK8TatNT2syXyozU40dfnTO0unlKEY=; b=r3CUM+qR1EtWf/3NuOfWWs1wml CVxhxr6hgGSPlrv2F+LSxRfIYmTEkfR/qtgG1wDy/fkMM6xR+DbgyT+dACUo+wkgrVwfNIaI8QWl7 r+tOx7zYYSDg6ntN/m4XfB13c6pqckXG3Yf3yY21iYPXu0xfolLJvBwsrDPoLBCrgMkobq573BUkw vmwzH601H0S83tdlNj9SPkIP/seGuFZasQgafqF70lXBQOhD7CNwloMD10wSOjmsozpRDYj2FXkte MJnrs4UwUts5RRz3iZhqyaBbzEfIXX0dDFFnaekLF39oFg/eR7APhZlIlVaccg5+O5Kvo3qlgZJGy nfTXhdYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpphS-00000008LLo-2mQE; Wed, 05 Mar 2025 14:26:18 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppbA-00000008KIB-0sLs for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:49 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id DE8C0430B7; Wed, 5 Mar 2025 14:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zJgNEItKL9gd+qK8TatNT2syXyozU40dfnTO0unlKEY=; b=PUl5UzEO8dOz/sIqp5xFVmMCLIrOAcnXM6lu94YWybX96zzbqH5Km0mbjwLEmixA13ENjc y28QojU/ClX+E9qbDkOBim0bHGJSHiWQboAfhwqZ3LHuG+vMy1A6ec9wILqxN/2a7HYxVc 7iSQBaFPFUDuy584j6swxPc2vOMgToKsN3SFjDc3os6eWio/xFPD/GEN7eJ16+OFIqKY7z TfqpmK1gaxyS93o1OsPEZ61+4gi9yYcWgJMr4NwDtdtVIc/lisyeCUavzz1Op2Wo46FMjR DA08uSLgzmveGRwVRvaA+WPMe2d6uQuuXBlJ/EISP/mmfvdXucQsKW+l1VgqZA== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 4/7] net: ethtool: netlink: Introduce per-phy DUMP helpers Date: Wed, 5 Mar 2025 15:19:34 +0100 Message-ID: <20250305141938.319282-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061948_377357_14A72852 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- net/ethtool/netlink.c | 53 +++++++++++++++++++++++++++++++++++++++++++ net/ethtool/netlink.h | 6 +++++ 2 files changed, 59 insertions(+) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index c0215f4acc05..474362af1aea 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -551,6 +551,59 @@ static int ethnl_default_dump_one(struct sk_buff *skb, return ret; } +/* Specific context for phy-targeting command DUMP operatins. We keep in context + * the latest phy_index we dumped, in case of an interrupted DUMP. + */ +struct ethnl_dump_ctx_perphy { + unsigned long phy_index; +}; + +int ethnl_dump_start_perphy(struct ethnl_dump_ctx *ctx) +{ + struct ethnl_dump_ctx_perphy *dump_ctx; + + dump_ctx = kzalloc(sizeof(*dump_ctx), GFP_KERNEL); + if (!dump_ctx) + return -ENOMEM; + + ctx->cmd_ctx = dump_ctx; + + return 0; +} + +void ethnl_dump_done_perphy(struct ethnl_dump_ctx *ctx) +{ + kfree(ctx->cmd_ctx); +} + +int ethnl_dump_one_dev_perphy(struct sk_buff *skb, + struct ethnl_dump_ctx *ctx, + const struct genl_info *info) +{ + struct ethnl_dump_ctx_perphy *dump_ctx = ctx->cmd_ctx; + struct net_device *dev = ctx->reply_data->dev; + struct phy_device_node *pdn; + int ret = 0; + + if (!dev->link_topo) + return 0; + + xa_for_each_start(&dev->link_topo->phys, dump_ctx->phy_index, + pdn, dump_ctx->phy_index) { + ctx->req_info->phy_index = dump_ctx->phy_index; + + /* We can re-use the original dump_one as ->prepare_data in + * commands use ethnl_req_get_phydev(), which gets the PHY from + * what's in req_info + */ + ret = ethnl_default_dump_one(skb, ctx, info); + if (ret) + break; + } + + return ret; +} + static int ethnl_default_dump_one_dev(struct sk_buff *skb, struct net_device *dev, struct ethnl_dump_ctx *ctx, const struct genl_info *info) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index d7506b08e5d6..835376a9c84c 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -327,6 +327,12 @@ struct ethnl_dump_ctx { void *cmd_ctx; }; +/* Generic callbacks to be used by PHY targeting commands */ +int ethnl_dump_start_perphy(struct ethnl_dump_ctx *ctx); +int ethnl_dump_one_dev_perphy(struct sk_buff *skb, struct ethnl_dump_ctx *ctx, + const struct genl_info *info); +void ethnl_dump_done_perphy(struct ethnl_dump_ctx *ctx); + int ethnl_ops_begin(struct net_device *dev); void ethnl_ops_complete(struct net_device *dev); From patchwork Wed Mar 5 14:19:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B970C19F32 for ; Wed, 5 Mar 2025 14:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2qPyL9N7Q/3DJbs1Iir3Lv/lMTjkAgZxpY0tmk2eGXY=; b=0YJH0bQfqvCwXZECIsRbUwQYis dkUgnWJ91AgLDNUbCZEz2yQM6uiqyZ5DaTh/QMHD/6SaOdh84ud9dZmz64iCouuopliDnX3Hvgoga tvLxtFW2wYfasS16NKtVoe+JgEvpwmVSoiphBk4LQbWl2qZMAIpHFIX/S9xTSewLaBoAubdHvjLmQ n5M7IWlG80rbrjr3i6A17gEz8zyzIxwAVB6rU27XiN6nTodFDho/B8uuPLywzTvFA4pdOaRXkpZAw VYXlWDY1FOx72XYJWFqwsH/ULW5YG5j8ezqCVid/NZafemAGiLBUNFsqnFzHX9ljSf1aT8obVV0gc dBmt9Jdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tppkc-00000008Lvt-18yP; Wed, 05 Mar 2025 14:29:34 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppbB-00000008KJh-25as for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:51 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E87994411B; Wed, 5 Mar 2025 14:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2qPyL9N7Q/3DJbs1Iir3Lv/lMTjkAgZxpY0tmk2eGXY=; b=HFcH5bBdbdpwpx3ffyLB5bUDIdRpFIX+wXVHEaZo+QLLnYKm6qiSoZg0SJwjtjo2tLt7D1 p3ncnhQT5GPHcR2ivlmHuqEU/QHXOUF32EeX31lmwXxxQKNL/t9B1csr8Zy2GXhh5CzxzG LNU90oTfFR87D0Uv5SvhnItTfkV7QeJW0gmr8fhs7+v5jcdHfP14l/UBIT0DRnyo0ep7CQ ht7VYUimYnHzVstaZon41P1VLXEnHH8a9rdKln3u8Ns8K2NnMmvVyyNgSPEiYKjqWD5s9H 70XZXRWs6Q9c1lpi5cdHofIvxECux4dMFnoDQ0/IJRCju8l/wq01Nz7gK6PRIg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 5/7] net: ethtool: phy: Convert the PHY_GET command to generic phy dump Date: Wed, 5 Mar 2025 15:19:35 +0100 Message-ID: <20250305141938.319282-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepvddtueefvdfhiefgieelfeeggeefiedvueevkedttddvffekleeujedtjeeuteehnecuffhomhgrihhnpegsrghsvgdruggvvhenucfkphepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvpdhhvghlohepfhgvughorhgrrdhhohhmvgdpmhgrihhlfhhrohhmpehmrgigihhmvgdrtghhvghvrghllhhivghrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvuddprhgtphhtthhopegurghvvghmsegurghvvghmlhhofhhtrdhnvghtpdhrtghpthhtoheprghnughrvgifsehluhhnnhdrtghhpdhrtghpthhtohepkhhusggrsehkvghrnhgvl hdrohhrghdprhgtphhtthhopegvughumhgriigvthesghhoohhglhgvrdgtohhmpdhrtghpthhtohepphgrsggvnhhisehrvgguhhgrthdrtghomhdprhgtphhtthhopehhkhgrlhhlfigvihhtudesghhmrghilhdrtghomhdprhgtphhtthhopehmrgigihhmvgdrtghhvghvrghllhhivghrsegsohhothhlihhnrdgtohhmpdhrtghpthhtohepnhgvthguvghvsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061949_844667_1764E304 X-CRM114-Status: GOOD ( 19.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that we have an infrastructure in ethnl for perphy DUMPs, we can get rid of the custom ->doit and ->dumpit to deal with PHY listing commands. As most of the code was custom, this basically means re-writing how we deal with PHY listing. Signed-off-by: Maxime Chevallier --- net/ethtool/netlink.c | 9 +- net/ethtool/netlink.h | 4 - net/ethtool/phy.c | 335 ++++++++++++------------------------------ 3 files changed, 103 insertions(+), 245 deletions(-) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 474362af1aea..b4d774786849 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -379,6 +379,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, [ETHTOOL_MSG_TSCONFIG_GET] = ðnl_tsconfig_request_ops, [ETHTOOL_MSG_TSCONFIG_SET] = ðnl_tsconfig_request_ops, + [ETHTOOL_MSG_PHY_GET] = ðnl_phy_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -1332,10 +1333,10 @@ static const struct genl_ops ethtool_genl_ops[] = { }, { .cmd = ETHTOOL_MSG_PHY_GET, - .doit = ethnl_phy_doit, - .start = ethnl_phy_start, - .dumpit = ethnl_phy_dumpit, - .done = ethnl_phy_done, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, .policy = ethnl_phy_get_policy, .maxattr = ARRAY_SIZE(ethnl_phy_get_policy) - 1, }, diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 835376a9c84c..bc6dde699a32 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -541,10 +541,6 @@ int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int ethnl_act_module_fw_flash(struct sk_buff *skb, struct genl_info *info); int ethnl_rss_dump_start(struct netlink_callback *cb); int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb); -int ethnl_phy_start(struct netlink_callback *cb); -int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info); -int ethnl_phy_dumpit(struct sk_buff *skb, struct netlink_callback *cb); -int ethnl_phy_done(struct netlink_callback *cb); int ethnl_tsinfo_start(struct netlink_callback *cb); int ethnl_tsinfo_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int ethnl_tsinfo_done(struct netlink_callback *cb); diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c index ed8f690f6bac..90c27dd1a5c6 100644 --- a/net/ethtool/phy.c +++ b/net/ethtool/phy.c @@ -11,296 +11,157 @@ #include struct phy_req_info { - struct ethnl_req_info base; - struct phy_device_node *pdn; + struct ethnl_req_info base; }; -#define PHY_REQINFO(__req_base) \ - container_of(__req_base, struct phy_req_info, base) +struct phy_reply_data { + struct ethnl_reply_data base; + u32 phyindex; + char *drvname; + char *name; + unsigned int upstream_type; + char *upstream_sfp_name; + unsigned int upstream_index; + char *downstream_sfp_name; +}; + +#define PHY_REPDATA(__reply_base) \ + container_of(__reply_base, struct phy_reply_data, base) const struct nla_policy ethnl_phy_get_policy[ETHTOOL_A_PHY_HEADER + 1] = { [ETHTOOL_A_PHY_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), }; -/* Caller holds rtnl */ -static ssize_t -ethnl_phy_reply_size(const struct ethnl_req_info *req_base, - struct netlink_ext_ack *extack) +static int phy_reply_size(const struct ethnl_req_info *req_info, + const struct ethnl_reply_data *reply_data) { - struct phy_req_info *req_info = PHY_REQINFO(req_base); - struct phy_device_node *pdn = req_info->pdn; - struct phy_device *phydev = pdn->phy; + struct phy_reply_data *rep_data = PHY_REPDATA(reply_data); size_t size = 0; - ASSERT_RTNL(); - /* ETHTOOL_A_PHY_INDEX */ size += nla_total_size(sizeof(u32)); /* ETHTOOL_A_DRVNAME */ - if (phydev->drv) - size += nla_total_size(strlen(phydev->drv->name) + 1); + if (rep_data->drvname) + size += nla_total_size(strlen(rep_data->drvname) + 1); /* ETHTOOL_A_NAME */ - size += nla_total_size(strlen(dev_name(&phydev->mdio.dev)) + 1); + size += nla_total_size(strlen(rep_data->name) + 1); /* ETHTOOL_A_PHY_UPSTREAM_TYPE */ size += nla_total_size(sizeof(u32)); - if (phy_on_sfp(phydev)) { - const char *upstream_sfp_name = sfp_get_name(pdn->parent_sfp_bus); - - /* ETHTOOL_A_PHY_UPSTREAM_SFP_NAME */ - if (upstream_sfp_name) - size += nla_total_size(strlen(upstream_sfp_name) + 1); + if (rep_data->upstream_sfp_name) + size += nla_total_size(strlen(rep_data->upstream_sfp_name) + 1); - /* ETHTOOL_A_PHY_UPSTREAM_INDEX */ + if (rep_data->upstream_index) size += nla_total_size(sizeof(u32)); - } - - /* ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME */ - if (phydev->sfp_bus) { - const char *sfp_name = sfp_get_name(phydev->sfp_bus); - if (sfp_name) - size += nla_total_size(strlen(sfp_name) + 1); - } + if (rep_data->downstream_sfp_name) + size += nla_total_size(strlen(rep_data->downstream_sfp_name) + 1); return size; } -static int -ethnl_phy_fill_reply(const struct ethnl_req_info *req_base, struct sk_buff *skb) +static int phy_prepare_data(const struct ethnl_req_info *req_info, + struct ethnl_reply_data *reply_data, + const struct genl_info *info) { - struct phy_req_info *req_info = PHY_REQINFO(req_base); - struct phy_device_node *pdn = req_info->pdn; - struct phy_device *phydev = pdn->phy; - enum phy_upstream ptype; + struct phy_reply_data *rep_data = PHY_REPDATA(reply_data); + struct phy_link_topology *topo = reply_data->dev->link_topo; + struct nlattr **tb = info->attrs; + struct phy_device_node *pdn; + struct phy_device *phydev; - ptype = pdn->upstream_type; + /* RTNL is held by th caller */ + phydev = ethnl_req_get_phydev(req_info, tb, ETHTOOL_A_PHY_HEADER, + info->extack); + if (IS_ERR_OR_NULL(phydev)) + return -EOPNOTSUPP; - if (nla_put_u32(skb, ETHTOOL_A_PHY_INDEX, phydev->phyindex) || - nla_put_string(skb, ETHTOOL_A_PHY_NAME, dev_name(&phydev->mdio.dev)) || - nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_TYPE, ptype)) - return -EMSGSIZE; + pdn = xa_load(&topo->phys, phydev->phyindex); + if (!pdn) + return -EOPNOTSUPP; - if (phydev->drv && - nla_put_string(skb, ETHTOOL_A_PHY_DRVNAME, phydev->drv->name)) - return -EMSGSIZE; + rep_data->phyindex = phydev->phyindex; + rep_data->name = kstrdup(dev_name(&phydev->mdio.dev), GFP_KERNEL); + rep_data->drvname = kstrdup(phydev->drv->name, GFP_KERNEL); + rep_data->upstream_type = pdn->upstream_type; - if (ptype == PHY_UPSTREAM_PHY) { + if (pdn->upstream_type == PHY_UPSTREAM_PHY) { struct phy_device *upstream = pdn->upstream.phydev; - const char *sfp_upstream_name; - - /* Parent index */ - if (nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_INDEX, upstream->phyindex)) - return -EMSGSIZE; - - if (pdn->parent_sfp_bus) { - sfp_upstream_name = sfp_get_name(pdn->parent_sfp_bus); - if (sfp_upstream_name && - nla_put_string(skb, ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, - sfp_upstream_name)) - return -EMSGSIZE; - } + rep_data->upstream_index = upstream->phyindex; } - if (phydev->sfp_bus) { - const char *sfp_name = sfp_get_name(phydev->sfp_bus); + if (pdn->parent_sfp_bus) + rep_data->upstream_sfp_name = kstrdup(sfp_get_name(pdn->parent_sfp_bus), + GFP_KERNEL); - if (sfp_name && - nla_put_string(skb, ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, - sfp_name)) - return -EMSGSIZE; - } + if (phydev->sfp_bus) + rep_data->downstream_sfp_name = kstrdup(sfp_get_name(phydev->sfp_bus), + GFP_KERNEL); return 0; } -static int ethnl_phy_parse_request(struct ethnl_req_info *req_base, - struct nlattr **tb, - struct netlink_ext_ack *extack) +static int phy_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_info, + const struct ethnl_reply_data *reply_data) { - struct phy_link_topology *topo = req_base->dev->link_topo; - struct phy_req_info *req_info = PHY_REQINFO(req_base); - struct phy_device *phydev; - - phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_PHY_HEADER], - extack); - if (!phydev) - return 0; - - if (IS_ERR(phydev)) - return PTR_ERR(phydev); - - if (!topo) - return 0; - - req_info->pdn = xa_load(&topo->phys, phydev->phyindex); - - return 0; -} - -int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info) -{ - struct phy_req_info req_info = {}; - struct nlattr **tb = info->attrs; - struct sk_buff *rskb; - void *reply_payload; - int reply_len; - int ret; - - ret = ethnl_parse_header_dev_get(&req_info.base, - tb[ETHTOOL_A_PHY_HEADER], - genl_info_net(info), info->extack, - true); - if (ret < 0) - return ret; - - rtnl_lock(); - - ret = ethnl_phy_parse_request(&req_info.base, tb, info->extack); - if (ret < 0) - goto err_unlock_rtnl; - - /* No PHY, return early */ - if (!req_info.pdn) - goto err_unlock_rtnl; - - ret = ethnl_phy_reply_size(&req_info.base, info->extack); - if (ret < 0) - goto err_unlock_rtnl; - reply_len = ret + ethnl_reply_header_size(); - - rskb = ethnl_reply_init(reply_len, req_info.base.dev, - ETHTOOL_MSG_PHY_GET_REPLY, - ETHTOOL_A_PHY_HEADER, - info, &reply_payload); - if (!rskb) { - ret = -ENOMEM; - goto err_unlock_rtnl; - } + struct phy_reply_data *rep_data = PHY_REPDATA(reply_data); - ret = ethnl_phy_fill_reply(&req_info.base, rskb); - if (ret) - goto err_free_msg; - - rtnl_unlock(); - ethnl_parse_header_dev_put(&req_info.base); - genlmsg_end(rskb, reply_payload); - - return genlmsg_reply(rskb, info); - -err_free_msg: - nlmsg_free(rskb); -err_unlock_rtnl: - rtnl_unlock(); - ethnl_parse_header_dev_put(&req_info.base); - return ret; -} - -struct ethnl_phy_dump_ctx { - struct phy_req_info *phy_req_info; - unsigned long ifindex; - unsigned long phy_index; -}; - -int ethnl_phy_start(struct netlink_callback *cb) -{ - const struct genl_info *info = genl_info_dump(cb); - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; - int ret; + if (nla_put_u32(skb, ETHTOOL_A_PHY_INDEX, rep_data->phyindex) || + nla_put_string(skb, ETHTOOL_A_PHY_NAME, rep_data->name) || + nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_TYPE, rep_data->upstream_type)) + return -EMSGSIZE; - BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx)); + if (rep_data->drvname && + nla_put_string(skb, ETHTOOL_A_PHY_DRVNAME, rep_data->drvname)) + return -EMSGSIZE; - ctx->phy_req_info = kzalloc(sizeof(*ctx->phy_req_info), GFP_KERNEL); - if (!ctx->phy_req_info) - return -ENOMEM; + if (rep_data->upstream_index && + nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_INDEX, + rep_data->upstream_index)) + return -EMSGSIZE; - ret = ethnl_parse_header_dev_get(&ctx->phy_req_info->base, - info->attrs[ETHTOOL_A_PHY_HEADER], - sock_net(cb->skb->sk), cb->extack, - false); - ctx->ifindex = 0; - ctx->phy_index = 0; + if (rep_data->upstream_sfp_name && + nla_put_string(skb, ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, + rep_data->upstream_sfp_name)) + return -EMSGSIZE; - if (ret) - kfree(ctx->phy_req_info); + if (rep_data->downstream_sfp_name && + nla_put_string(skb, ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, + rep_data->downstream_sfp_name)) + return -EMSGSIZE; - return ret; + return 0; } -int ethnl_phy_done(struct netlink_callback *cb) +static void phy_cleanup_data(struct ethnl_reply_data *reply_data) { - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; - - if (ctx->phy_req_info->base.dev) - ethnl_parse_header_dev_put(&ctx->phy_req_info->base); - - kfree(ctx->phy_req_info); + struct phy_reply_data *rep_data = PHY_REPDATA(reply_data); - return 0; + kfree(rep_data->drvname); + kfree(rep_data->name); + kfree(rep_data->upstream_sfp_name); + kfree(rep_data->downstream_sfp_name); } -static int ethnl_phy_dump_one_dev(struct sk_buff *skb, struct net_device *dev, - struct netlink_callback *cb) -{ - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; - struct phy_req_info *pri = ctx->phy_req_info; - struct phy_device_node *pdn; - int ret = 0; - void *ehdr; - - if (!dev->link_topo) - return 0; - - xa_for_each_start(&dev->link_topo->phys, ctx->phy_index, pdn, ctx->phy_index) { - ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_PHY_GET_REPLY); - if (!ehdr) { - ret = -EMSGSIZE; - break; - } - - ret = ethnl_fill_reply_header(skb, dev, ETHTOOL_A_PHY_HEADER); - if (ret < 0) { - genlmsg_cancel(skb, ehdr); - break; - } - - pri->pdn = pdn; - ret = ethnl_phy_fill_reply(&pri->base, skb); - if (ret < 0) { - genlmsg_cancel(skb, ehdr); - break; - } - - genlmsg_end(skb, ehdr); - } +const struct ethnl_request_ops ethnl_phy_request_ops = { + .request_cmd = ETHTOOL_MSG_PHY_GET, + .reply_cmd = ETHTOOL_MSG_PHY_GET_REPLY, + .hdr_attr = ETHTOOL_A_PHY_HEADER, + .req_info_size = sizeof(struct phy_req_info), + .reply_data_size = sizeof(struct phy_reply_data), - return ret; -} + .prepare_data = phy_prepare_data, + .reply_size = phy_reply_size, + .fill_reply = phy_fill_reply, + .cleanup_data = phy_cleanup_data, -int ethnl_phy_dumpit(struct sk_buff *skb, struct netlink_callback *cb) -{ - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; - struct net *net = sock_net(skb->sk); - struct net_device *dev; - int ret = 0; - - rtnl_lock(); - - if (ctx->phy_req_info->base.dev) { - ret = ethnl_phy_dump_one_dev(skb, ctx->phy_req_info->base.dev, cb); - } else { - for_each_netdev_dump(net, dev, ctx->ifindex) { - ret = ethnl_phy_dump_one_dev(skb, dev, cb); - if (ret) - break; - - ctx->phy_index = 0; - } - } - rtnl_unlock(); + .dump_start = ethnl_dump_start_perphy, + .dump_one_dev = ethnl_dump_one_dev_perphy, + .dump_done = ethnl_dump_done_perphy, - return ret; -} + .allow_pernetdev_dump = true, +}; From patchwork Wed Mar 5 14:19:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46F78C19F32 for ; Wed, 5 Mar 2025 14:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+x958E8fd59wo0+S7PShlBqxAJBPIungIQ5oX/0I4ho=; b=LIvoQnVloGM0ATh0LF4O3eKO+e jPcCkMGMESLQPgPFPZME0j6AecvFf3TmBOgnVRt1VRc5DLSMUoMzlnmjdiMvAzHldFyyYRnW3nWtK KeF7jtjTBHarbWctBXLB0nC6FwYY5T2HoXNGCN0xME0iB8jAx5r/TxQE99yLdAMkj9znkqZyqeVJk uYuzuxpADfJtrMejMf+bR7pv0oY77KFVBYaEjJqY91MpTUf+qt0TEP1OxQaMWVNB2TugRAZxRox2x BwGQ0AfMnIOY+uZz4pnHR26+2zhym6mn3ARK8xqVL10mmeUVwMQUGj/kMX0iPJk9yqcaOonOC62oT T75KRO5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tppmB-00000008MD1-3tGI; Wed, 05 Mar 2025 14:31:11 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppbC-00000008KKY-2OYb for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:52 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1B7FC44120; Wed, 5 Mar 2025 14:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+x958E8fd59wo0+S7PShlBqxAJBPIungIQ5oX/0I4ho=; b=f939CQ8ODCi0F1EgpvuCG5vlwN9oysZaONqaeSoRBnPbwZQGnWdCvB0wUjjNzQUkmAauMu OZ6ZpOpDQfMcl3sgdrT4M0YJrbP3IIK8o4WUVefYrd5uXESoxQZtOc0sSFHCT6FnD1/QeA n7hjVqLyoki1LvC3iHDeoyxMsyQCFkydryywx9ljuIQqi9E43Fy3XFsG4tiKe4i4hF1t+B lByFw/HCTvLPH7YS6miQBLm84BJ0XwfmJkDIpxGHkS+W1GcK1466Aby0/qZH1WK2edAq9u WC9DWydSGN7kLst1CVNkO6Djme1flLbqc972QhiWiq3l0B46CzpT7+NzkpUr9g== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 6/7] net: ethtool: plca: Use per-PHY DUMP operations Date: Wed, 5 Mar 2025 15:19:36 +0100 Message-ID: <20250305141938.319282-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061950_757087_033E05D8 X-CRM114-Status: UNSURE ( 8.52 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Leverage the per-phy ethnl DUMP helpers in case we have more that one PLCA-able PHY on the link. This is done for both PLCA status and PLCA config. Signed-off-by: Maxime Chevallier --- net/ethtool/plca.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c index e1f7820a6158..2148ff607561 100644 --- a/net/ethtool/plca.c +++ b/net/ethtool/plca.c @@ -191,6 +191,12 @@ const struct ethnl_request_ops ethnl_plca_cfg_request_ops = { .set = ethnl_set_plca, .set_ntf_cmd = ETHTOOL_MSG_PLCA_NTF, + + .dump_start = ethnl_dump_start_perphy, + .dump_one_dev = ethnl_dump_one_dev_perphy, + .dump_done = ethnl_dump_done_perphy, + + .allow_pernetdev_dump = true, }; // PLCA get status message -------------------------------------------------- // @@ -268,4 +274,10 @@ const struct ethnl_request_ops ethnl_plca_status_request_ops = { .prepare_data = plca_get_status_prepare_data, .reply_size = plca_get_status_reply_size, .fill_reply = plca_get_status_fill_reply, + + .dump_start = ethnl_dump_start_perphy, + .dump_one_dev = ethnl_dump_one_dev_perphy, + .dump_done = ethnl_dump_done_perphy, + + .allow_pernetdev_dump = true, }; From patchwork Wed Mar 5 14:19:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 14002844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9597CC19F32 for ; Wed, 5 Mar 2025 14:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lqhVF62lXxp4ehI9VcV/C1HiZcbumD+HxLx7oV5CC5s=; b=xp4RXUtpcbBaHFdwpAgL3jKcsN RGTgmmfQM1ZR8UPvhnGIcUOs2yQ2vJZsfkl9lO3z/ZJxFbau1WVE3bQmpeKiA5a1qie/bg9BLxZXr 1FlcEKK46AWNUjmXbYUKiqS4XZ8tj1dde5RcRjRtZKZTj2WtiywMTW83nunai9E5bbOvkZLVyDoCD WztjKfCkueP+y7o+T6kSxuvUYQfdk6hseK5HJzzR7z8gYo+aeKr9xIOczbRP9p5n3Lcn7JF4/egiC wFCwRdfmyHAWK5upW/opfAorhHoEIBfyxMI0Vr1nY4wXLY6rKm892NAY7y69zfV8UL5aPLruvQIlx Vh0QKoPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tppnl-00000008MNA-2Vs5; Wed, 05 Mar 2025 14:32:49 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tppbD-00000008KLA-2ZOI for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2025 14:19:53 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 2094744140; Wed, 5 Mar 2025 14:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741184390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lqhVF62lXxp4ehI9VcV/C1HiZcbumD+HxLx7oV5CC5s=; b=ceW9uAAo4G9bXVuI4ZERHZyb/kah8I5x/RmDD3jQstKr4v1Uea10lH0vRJ5MnV/mRG1IAC 0axyedojTiTmRYXsyZ0w4Q2vj/ayCy1hUYkisREnON9sioxjuF1Fg+MXQ+atkL0HJLYl4N 2ru30DHgRuSo5xcNNt7ve938uNjidbytT8b+LIg9gbjOXWEGQ+Iife9M93b+RDHsOHMQvA VQ9iO4gCbJmw6MewUMZzlsoezgJBT4KE+mt2i72DWJFtYuj2ULb0FCxAUTLendA9H7/94R aZ4ekHPX02VtIpZXem78gVpdKMznuHsUK8T0uk7KrtNrtGp6CkKy40rHAUy0CQ== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Russell King , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Oleksij Rempel , Simon Horman , Romain Gantois , Piergiorgio Beruto Subject: [PATCH net-next 7/7] net: ethtool: pse-pd: Use per-PHY DUMP operations Date: Wed, 5 Mar 2025 15:19:37 +0100 Message-ID: <20250305141938.319282-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305141938.319282-1-maxime.chevallier@bootlin.com> References: <20250305141938.319282-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepveegtdffleffleevueellefgjeefvedvjefhheegfefgffdvfeetgeevudetffdtnecukfhppedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgdphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvddupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmr giivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohephhhkrghllhifvghithdusehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_061951_795169_149A4CBF X-CRM114-Status: UNSURE ( 8.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Leverage the per-phy ethnl DUMP helpers in case we have more that one PSE PHY on the link. Signed-off-by: Maxime Chevallier --- net/ethtool/pse-pd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ethtool/pse-pd.c b/net/ethtool/pse-pd.c index 4f6b99eab2a6..f3d14be8bdd9 100644 --- a/net/ethtool/pse-pd.c +++ b/net/ethtool/pse-pd.c @@ -314,4 +314,10 @@ const struct ethnl_request_ops ethnl_pse_request_ops = { .set = ethnl_set_pse, /* PSE has no notification */ + + .dump_start = ethnl_dump_start_perphy, + .dump_one_dev = ethnl_dump_one_dev_perphy, + .dump_done = ethnl_dump_done_perphy, + + .allow_pernetdev_dump = true, };