diff mbox series

[net-next,v5,3/4] net: devlink: make the devlink_ops::info_get() callback optional

Message ID 20221129000550.3833570-4-mailhol.vincent@wanadoo.fr (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: devlink: return the driver name in devlink_nl_info_fill | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vincent Mailhol Nov. 29, 2022, 12:05 a.m. UTC
Some drivers only reported the driver name in their
devlink_ops::info_get() callback. Now that the core provides this
information, the callback became empty. For such drivers, just
removing the callback would prevent the core from executing
devlink_nl_info_fill() meaning that "devlink dev info" would not
return anything.

Make the callback function optional by executing
devlink_nl_info_fill() even if devlink_ops::info_get() is NULL.

N.B.: the drivers with devlink support which previously did not
implement devlink_ops::info_get() will now also be able to report
the driver name.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
 net/core/devlink.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Jacob Keller Nov. 29, 2022, 12:24 a.m. UTC | #1
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Vincent Mailhol
> Sent: Monday, November 28, 2022 4:06 PM
> To: Jiri Pirko <jiri@nvidia.com>; netdev@vger.kernel.org; Jakub Kicinski
> <kuba@kernel.org>
> Cc: Andrew Lunn <andrew@lunn.ch>; Shijith Thotton <sthotton@marvell.com>;
> Simon Horman <simon.horman@corigine.com>; Kurt Kanzenbach
> <kurt@linutronix.de>; Eric Dumazet <edumazet@google.com>; Jerin Jacob
> <jerinj@marvell.com>; Subbaraya Sundeep <sbhatta@marvell.com>; Ioana
> Ciornei <ioana.ciornei@nxp.com>; drivers@pensando.io; Linu Cherian
> <lcherian@marvell.com>; Florian Fainelli <f.fainelli@gmail.com>; Herbert Xu
> <herbert@gondor.apana.org.au>; Leon Romanovsky <leon@kernel.org>; linux-
> rdma@vger.kernel.org; Shalom Toledo <shalomt@mellanox.com>; Srujana
> Challa <schalla@marvell.com>; Minghao Chi <chi.minghao@zte.com.cn>; Hao
> Chen <chenhao288@hisilicon.com>; Guangbin Huang
> <huangguangbin2@huawei.com>; Shannon Nelson <snelson@pensando.io>;
> intel-wired-lan@lists.osuosl.org; Vadim Fedorenko <vadfed@fb.com>; Paolo
> Abeni <pabeni@redhat.com>; Yisen Zhuang <yisen.zhuang@huawei.com>; Sunil
> Goutham <sgoutham@marvell.com>; Ariel Elior <aelior@marvell.com>; Ido
> Schimmel <idosch@nvidia.com>; Richard Cochran <richardcochran@gmail.com>;
> Arnaud Ebalard <arno@natisbad.org>; Jiri Pirko <jiri@mellanox.com>; Michael
> Chan <michael.chan@broadcom.com>; Vincent Mailhol
> <mailhol.vincent@wanadoo.fr>; Petr Machata <petrm@nvidia.com>; Salil Mehta
> <salil.mehta@huawei.com>; Dimitris Michailidis <dmichail@fungible.com>;
> Manish Chopra <manishc@marvell.com>; Boris Brezillon
> <bbrezillon@kernel.org>; oss-drivers@corigine.com; Vadim Pasternak
> <vadimp@mellanox.com>; linux-kernel@vger.kernel.org; David S . Miller
> <davem@davemloft.net>; Taras Chornyi <tchornyi@marvell.com>; hariprasad
> <hkelam@marvell.com>; linux-crypto@vger.kernel.org; Jonathan Lemon
> <jonathan.lemon@gmail.com>; Vladimir Oltean <olteanv@gmail.com>; Saeed
> Mahameed <saeedm@nvidia.com>; Geetha sowjanya <gakula@marvell.com>
> Subject: [Intel-wired-lan] [PATCH net-next v5 3/4] net: devlink: make the
> devlink_ops::info_get() callback optional
> 
> Some drivers only reported the driver name in their
> devlink_ops::info_get() callback. Now that the core provides this
> information, the callback became empty. For such drivers, just
> removing the callback would prevent the core from executing
> devlink_nl_info_fill() meaning that "devlink dev info" would not
> return anything.
> 
> Make the callback function optional by executing
> devlink_nl_info_fill() even if devlink_ops::info_get() is NULL.
> 
> N.B.: the drivers with devlink support which previously did not
> implement devlink_ops::info_get() will now also be able to report
> the driver name.
> 

Makes sense to me.

Thanks,
Jake
Jiri Pirko Nov. 29, 2022, 8:26 a.m. UTC | #2
Tue, Nov 29, 2022 at 01:05:49AM CET, mailhol.vincent@wanadoo.fr wrote:
>Some drivers only reported the driver name in their
>devlink_ops::info_get() callback. Now that the core provides this
>information, the callback became empty. For such drivers, just
>removing the callback would prevent the core from executing
>devlink_nl_info_fill() meaning that "devlink dev info" would not
>return anything.
>
>Make the callback function optional by executing
>devlink_nl_info_fill() even if devlink_ops::info_get() is NULL.
>
>N.B.: the drivers with devlink support which previously did not
>implement devlink_ops::info_get() will now also be able to report
>the driver name.
>
>Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
diff mbox series

Patch

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 3babc16eeb6b..817d978bb729 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6773,9 +6773,11 @@  devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink,
 		goto err_cancel_msg;
 
 	req.msg = msg;
-	err = devlink->ops->info_get(devlink, &req, extack);
-	if (err)
-		goto err_cancel_msg;
+	if (devlink->ops->info_get) {
+		err = devlink->ops->info_get(devlink, &req, extack);
+		if (err)
+			goto err_cancel_msg;
+	}
 
 	err = devlink_nl_driver_info_get(dev->driver, &req);
 	if (err)
@@ -6796,9 +6798,6 @@  static int devlink_nl_cmd_info_get_doit(struct sk_buff *skb,
 	struct sk_buff *msg;
 	int err;
 
-	if (!devlink->ops->info_get)
-		return -EOPNOTSUPP;
-
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg)
 		return -ENOMEM;
@@ -6824,7 +6823,7 @@  static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
 	int err = 0;
 
 	devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
-		if (idx < start || !devlink->ops->info_get)
+		if (idx < start)
 			goto inc;
 
 		devl_lock(devlink);