From patchwork Tue Nov 29 09:51:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 13058384 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B75EC46467 for ; Tue, 29 Nov 2022 09:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbiK2JxV (ORCPT ); Tue, 29 Nov 2022 04:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbiK2Jwv (ORCPT ); Tue, 29 Nov 2022 04:52:51 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359BCDEBA; Tue, 29 Nov 2022 01:52:45 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so8544725pjm.2; Tue, 29 Nov 2022 01:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=q+HcPAfOXUEhgB8t67wP/cjouMyhjRZQn2uzLIUxtrM=; b=J6WKtTXnQV8Zq71pPB0zFZTPxvL6UGEHTzjmMv3xN5MdjdEeV+BVL0xkN+cTUImBbc xEuh14jXCXMW/vxptpV8xn5uTAN24mkhL3e00X7OZOHFHOklnIlTi7FSH4CDbQKN562L L/HY799r3W7BrlGIF5dysbYYYQddrtfWUkjgt8hWScl7T9NbiiFMLeHNP/bSEcVYmMGv a2RxTPOr1PC859By7i+Xyb7gShL7lGKM5b4Ks7h6se7EK+MyqaazlL0Exy1klJkW7Nr5 d7/qxZQ2XlvtIPaVH35oJfZmayG1gyKAAUV2ArzX8yLz8S4NbxX8ZUWhCivaDF0MpmSp +HjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=q+HcPAfOXUEhgB8t67wP/cjouMyhjRZQn2uzLIUxtrM=; b=BuCLnsUT56Sku/8BB64FP32bSm0qM3r/6w1eqvJPhMc2jsrItW7yyIY6kPaCCes+zp gI6gB4bLnpvke6hp427Bi72Z94MbXi3KXbN9Kfg0YSGHR8WR73kIaGfBNQD0xkwudUDw 1lVJROSMvJgSC9sPtdRqzuXccD23UWAAWsj2TOBu/W4+XktgyoIUpR5nDeQmO6WDq/1C 28nolLlpvE4tva9eH72+gyI3IwfRjgVhleuNbEXmYmYJvP/7lPF/LOUtyGBRRosClR2W RaA6p9xnUX7GQ86tcL8NVnj88Wo1+JzIluzqtec46Lc6ZQ7z7RxjKJTmgWb4JQfISAIP dVLw== X-Gm-Message-State: ANoB5pn0QYBO2OnE8O55v0x14L/kQyVQASh73lwWbt8irnYJy3sIr2bC 0y8uVjjz+phNu8Wa+fmAXbw= X-Google-Smtp-Source: AA0mqf4Lw/qQGGFmSQRFNytTLBUGv/AQ65WV04fGbUW4eia7yU4P2vgjBbDaOFgMNltEoNBsP5lZEg== X-Received: by 2002:a17:903:2683:b0:186:6f1e:5087 with SMTP id jf3-20020a170903268300b001866f1e5087mr37426289plb.119.1669715564331; Tue, 29 Nov 2022 01:52:44 -0800 (PST) Received: from XH22050090-L.ad.ts.tri-ad.global ([103.175.111.222]) by smtp.gmail.com with ESMTPSA id mv15-20020a17090b198f00b0021937b2118bsm941346pjb.54.2022.11.29.01.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 01:52:44 -0800 (PST) Sender: Vincent Mailhol From: Vincent Mailhol To: Jiri Pirko , netdev@vger.kernel.org, Jakub Kicinski Cc: "David S . Miller" , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, Boris Brezillon , Arnaud Ebalard , Srujana Challa , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Michael Chan , Ioana Ciornei , Dimitris Michailidis , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , Taras Chornyi , Saeed Mahameed , Leon Romanovsky , Ido Schimmel , Petr Machata , Simon Horman , Shannon Nelson , drivers@pensando.io, Ariel Elior , Manish Chopra , Jonathan Lemon , Vadim Fedorenko , Richard Cochran , Vadim Pasternak , Shalom Toledo , linux-crypto@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, Jiri Pirko , Herbert Xu , Hao Chen , Guangbin Huang , Minghao Chi , Shijith Thotton , Vincent Mailhol , Jacob Keller Subject: [PATCH net-next v6 2/3] net: devlink: make the devlink_ops::info_get() callback optional Date: Tue, 29 Nov 2022 18:51:39 +0900 Message-Id: <20221129095140.3913303-3-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129095140.3913303-1-mailhol.vincent@wanadoo.fr> References: <20221129095140.3913303-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Jacob Keller Reviewed-by: Jiri Pirko --- net/core/devlink.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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);