From patchwork Sun Nov 27 13:09:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent MAILHOL X-Patchwork-Id: 13056744 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 62DECC352A1 for ; Sun, 27 Nov 2022 13:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbiK0NKJ (ORCPT ); Sun, 27 Nov 2022 08:10:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiK0NKE (ORCPT ); Sun, 27 Nov 2022 08:10:04 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A120DDF6C; Sun, 27 Nov 2022 05:09:58 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id p12so7813352plq.4; Sun, 27 Nov 2022 05:09:58 -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=0ZsXPiwPOVu7JihBSzIX9RMliHJg1zhwJcyiOwYn5LE=; b=KwJMKBZedewWTw2AYgadSrDQJh5K2xX0zFcZDpqAsOMhznSyUoNmuTIG+/DMG+evxd SWjXdQyeXnwoGbQxFBekzMnAuZDeV5dSl6PwXdzNzkb45jJC+8K8j1myIffH6fmXqzE3 VD9cUWqGlAKdzpnDikGQXNMNPVdY1yUGugFJ++7CmRhP3fL1HlIZt/1ZEZ5ckPpLnUX4 6ilBV0dhoGa07b8xjMJF+WXsiYuOyZWIXmI7s1/BOHDSbh7Lg2QWkKv9LFnFFwnFVePN MTRBsE53vqKkTMGHNPRmiWsiVIugI8n+Gy9030V7S3QGpwQiMsjepWBhiYHOz2O8OfYb 65Hg== 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=0ZsXPiwPOVu7JihBSzIX9RMliHJg1zhwJcyiOwYn5LE=; b=CdgrDpMq7SkR/QDCQhTVEbuA8EfSsmla1748vtMyVk+oQLGGmy4YQIHec8pdyLFWCe LbAWy2phYLR2/1k3k5U3nCgEBsfTPArNVHLG7257sG+kM1+KTwqw3+EUXQWOE7AMLViz ijk8SCQ0S2Y1tOtBUPHMa+7JuO3FO4nqKjSP99RNY0xsfGT/Q9n7dIGMjrqOhHj972wm e8xUeDhm7fx+hQvpfmKvmyd32CZqRyp4Bhq+Zr2TWvhkgK5RQEgLtjjL0bSdR25U4VfJ EwiFnzVzfw+COcIeInEr3M8sqY452L1v0BmUuZct6/oOKaMo/iT0HzR9Oy3EYK1W9OAw AAvg== X-Gm-Message-State: ANoB5pnCQoY17Ko9VMYkdZl8AToa9rKPlkUZEE9T5mHOat8A2Pner/0u 5kkL1EOCkilJoP+L1jOQj38= X-Google-Smtp-Source: AA0mqf4V5hYar5riUHM4zUSas46jIem/YoPjekB9ahNyuLrurPdoxj2NAgRwb39fvA5BSY7GOsR6oA== X-Received: by 2002:a17:902:c946:b0:186:99e3:c079 with SMTP id i6-20020a170902c94600b0018699e3c079mr27225014pla.149.1669554597977; Sun, 27 Nov 2022 05:09:57 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q17-20020a170902eb9100b00188a908cbddsm6710225plg.302.2022.11.27.05.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 05:09:57 -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 , Ido Schimmel Subject: [PATCH net-next v3 1/5] mlxsw: minimal: fix mlxsw_m_module_get_drvinfo() to correctly report driver name Date: Sun, 27 Nov 2022 22:09:15 +0900 Message-Id: <20221127130919.638324-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221127130919.638324-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221127130919.638324-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 Currently, mlxsw_m_module_get_drvinfo() reports the device_kind. The device_kind is not necessarily the same as the device_name. For example, the mlxsw_i2c implementation sets up the device_kind as ic2_client::name in [1] which indicates the type of the device (e.g. chip name), not the actual driver name. Fix it so that it correctly reports the driver name. [1] mlxsw_i2c_probe() from drivers/net/ethernet/mellanox/mlxsw/i2c.c Link: https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/i2c.c#L714 Fixes: 9bbd7efbc055 ("mlxsw: i2c: Extend initialization with querying firmware info") CC: Shalom Toledo CC: Ido Schimmel CC: Vadim Pasternak Signed-off-by: Vincent Mailhol --- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c index 6b56eadd736e..9b37ddbe0cba 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c @@ -92,7 +92,7 @@ static void mlxsw_m_module_get_drvinfo(struct net_device *dev, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; - strscpy(drvinfo->driver, mlxsw_m->bus_info->device_kind, + strscpy(drvinfo->driver, dev_driver_string(dev->dev.parent), sizeof(drvinfo->driver)); snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%d", From patchwork Sun Nov 27 13:09:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent MAILHOL X-Patchwork-Id: 13056745 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 E6409C46467 for ; Sun, 27 Nov 2022 13:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiK0NKZ (ORCPT ); Sun, 27 Nov 2022 08:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbiK0NKO (ORCPT ); Sun, 27 Nov 2022 08:10:14 -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 058CBDF6D; Sun, 27 Nov 2022 05:10:08 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso11580595pjt.0; Sun, 27 Nov 2022 05:10:08 -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=IvGCayvT1wrZ4HfMEpEiFtD2YHJkr4R5tohql3dWU+g=; b=okN2Y2Wp7abBRiLot6BlIxc1Ou6BKAOMwsBvM79Xvllqiid1BUG0KMPKC4bevz4q2H tq5wRTNFFIyS2e6tTU3EJV6YKxM9EGMBvptMol6Pmsxhao7cpfMiUTmA9PugCdmNdw7D znImuKAaIX2KbwZ2XzxsYHHq4SpvK5pr1XJBUGvw91oyBM0fmkb6X43l928wk/xYHTjH drGGgiaq5PtjtzWMNHF5VFYiKFLThDobS9OFD+MRAQPlRcNny9blkw1FE303IRT8o9na qnuvBldQ85CXRfGWKnpuhOHD60T5bCcqv4Uy/F1YpvFE8+GUm678yM00qar2D76JCa5Z dFCQ== 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=IvGCayvT1wrZ4HfMEpEiFtD2YHJkr4R5tohql3dWU+g=; b=oFL4xJmVuHhKXHi1ZqPusZ324OJWTsD+jBRNIWOysgQI/i9DKb3VqN6lMYDXBLpcmJ pvPsiAjLX6z0K3tAseWJCAsVeYFlKEoXHdES8KsYbR9Zw2HvfPhVgJD4IZ9RnV49iDNW bwz+pjIqGgDTYx+MHkRt0ItMJtKMI0xsCjvAJ32/+MzzV9OV8Hv2Bv9SdXZ/Kxb024k9 O0BHvNjTA5cZY5DXshYS3NKje3eOQGVYTSDn/e7pHerEd9tjE6F48NosBECbik/DECvV 9IjVR5SYqzyCqVCz8OdfV+S5PuMc4AsnnRYikyMYsLui6yirgNJQfyL+9Nf0Ewonhq6y T5bg== X-Gm-Message-State: ANoB5plFFDBwhfP+rMf7v9qL+eQqAFngQodZhHrb7V4XA5S5AEOWDKUQ 6HNgoc3cqkmFb2FOuh/aQwQ= X-Google-Smtp-Source: AA0mqf4Dk9WPi4BLnpif8989C+H6hbvudTv8XZdKjK1ZGzmT2xqFwp6N/1Exmp8XwVBk2OfSw25ClQ== X-Received: by 2002:a17:902:bd42:b0:186:9c2b:3a39 with SMTP id b2-20020a170902bd4200b001869c2b3a39mr27661689plx.115.1669554607585; Sun, 27 Nov 2022 05:10:07 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q17-20020a170902eb9100b00188a908cbddsm6710225plg.302.2022.11.27.05.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 05:10:07 -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 , Ido Schimmel Subject: [PATCH net-next v3 2/5] mlxsw: core: fix mlxsw_devlink_info_get() to correctly report driver name Date: Sun, 27 Nov 2022 22:09:16 +0900 Message-Id: <20221127130919.638324-3-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221127130919.638324-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221127130919.638324-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 Currently, mlxsw_devlink_info_get() reports the device_kind. The device_kind is not necessarily the same as the device_name. For example, the mlxsw_i2c implementation sets up the device_kind as ic2_client::name in [1] which indicates the type of the device (e.g. chip name). Fix it so that it correctly reports the driver name. [1] mlxsw_i2c_probe() from drivers/net/ethernet/mellanox/mlxsw/i2c.c Link: https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/i2c.c#L714 Fixes: a9c8336f6544 ("mlxsw: core: Add support for devlink info command") CC: Shalom Toledo CC: Ido Schimmel CC: Vadim Pasternak Signed-off-by: Vincent Mailhol --- drivers/net/ethernet/mellanox/mlxsw/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index a83f6bc30072..d8b1bb03cdb0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1453,6 +1453,7 @@ mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) { struct mlxsw_core *mlxsw_core = devlink_priv(devlink); + struct device *dev = mlxsw_core->bus_info->dev; char fw_info_psid[MLXSW_REG_MGIR_FW_INFO_PSID_SIZE]; u32 hw_rev, fw_major, fw_minor, fw_sub_minor; char mgir_pl[MLXSW_REG_MGIR_LEN]; @@ -1460,7 +1461,7 @@ mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, int err; err = devlink_info_driver_name_put(req, - mlxsw_core->bus_info->device_kind); + dev_driver_string(dev->parent)); if (err) return err; From patchwork Sun Nov 27 13:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent MAILHOL X-Patchwork-Id: 13056746 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 ADB65C47088 for ; Sun, 27 Nov 2022 13:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiK0NKp (ORCPT ); Sun, 27 Nov 2022 08:10:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiK0NKZ (ORCPT ); Sun, 27 Nov 2022 08:10:25 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C125F012; Sun, 27 Nov 2022 05:10:17 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id x66so8085945pfx.3; Sun, 27 Nov 2022 05:10:17 -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=oHWxH3dMNEMXdY+UxCG1jC3zuNNiQor6nOaOmzQWVXw=; b=pEcIpili+PZebZcptbL39lNbU9U+b7qYVgXFmF1X1f+iDKjwwk+Wy9S8+Xdxf66eYj K5zSAPCBAmOgJFEwwCottN6zfXoT4Lkcn69uFAIzK0nausJ+41AMCQyV0hEwGZnxJqKe NWGdMfDPdxt7f9hxFGIQIB4j8ukj2QY6ve/jF3lwz7YegeUdBwi+A/l8beWFY0/8LC+k DwHjarvEfx7MLj74VNQpI/Q0jFtNqfiLsc1XhHDimwuMDGOgstDsvX5BAsSkwQNBEbSR djIogLNtxz/n57ZElMM1vIjnaDNirh40tfspHKaSWWBwU9ILrHFd55ni1+E1FL7mlhvI zJPA== 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=oHWxH3dMNEMXdY+UxCG1jC3zuNNiQor6nOaOmzQWVXw=; b=P2pF9q/Oh18w3h2HU5yh6RF1grWr6rB59J/ED7ZcugFuU6cItTMJC2Cl0WEoO9g+Tm gfLPTY6+d+e00z/At2nPp665OqnO3n+ulXpPCdoLVS/jk4joIDh8Dpi/2GEY2Bx3Vc9V vBST1N78oPuRhNEZfeFte6Hdtf8XFfFGBGXjfYNs341dD/6dEcIo2gQPpxMRtcwHxYMr d2qFBbQ5kY6jO5dLnlPOmtwdyhVeCgDwK46BFrWtb3p40QDZC9unzdkBlGlVGK5Gqgvw nLdKPAmsQ3eFo+oOSjGIX9qnHI1VNt+0BXXfJsRif9UhNINYY5LBhYkuS7Nz7KFHTStD M8lQ== X-Gm-Message-State: ANoB5pkH9S6IAXZawxkfYL2m07zKOkJ63QRw/b52YDCPvMCFCwfIpA9U arSmPp8bwxmcRURNLR+/zls= X-Google-Smtp-Source: AA0mqf5c5SOnfVoFwyuyqLJOi842s697syCTdfOaOAzAdGUhjgl2I6Sm6nopN2/HKz6j9v3rlqHRcA== X-Received: by 2002:a05:6a00:d66:b0:56a:fd45:d054 with SMTP id n38-20020a056a000d6600b0056afd45d054mr33670710pfv.3.1669554616792; Sun, 27 Nov 2022 05:10:16 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q17-20020a170902eb9100b00188a908cbddsm6710225plg.302.2022.11.27.05.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 05:10:16 -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 Subject: [PATCH net-next v3 3/5] net: devlink: let the core report the driver name instead of the drivers Date: Sun, 27 Nov 2022 22:09:17 +0900 Message-Id: <20221127130919.638324-4-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221127130919.638324-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221127130919.638324-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 The driver name is available in device_driver::name. Right now, drivers still have to report this piece of information themselves in their devlink_ops::info_get callback function. In order to factorize code, make devlink_nl_info_fill() add the driver name attribute. nla_put() does not check if an attribute already exists and unconditionally reserves new space [1]. To avoid attribute duplication, clean-up all the drivers which are currently reporting the driver name in their callback. [1] https://elixir.bootlin.com/linux/v6.0/source/lib/nlattr.c#L993 Signed-off-by: Vincent Mailhol --- .../crypto/marvell/octeontx2/otx2_cpt_devlink.c | 4 ---- drivers/net/dsa/hirschmann/hellcreek.c | 5 ----- drivers/net/dsa/mv88e6xxx/devlink.c | 5 ----- drivers/net/dsa/sja1105/sja1105_devlink.c | 12 +++--------- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 4 ---- .../freescale/dpaa2/dpaa2-eth-devlink.c | 11 +---------- .../ethernet/fungible/funeth/funeth_devlink.c | 2 +- .../hisilicon/hns3/hns3pf/hclge_devlink.c | 5 ----- .../hisilicon/hns3/hns3vf/hclgevf_devlink.c | 5 ----- drivers/net/ethernet/intel/ice/ice_devlink.c | 6 ------ .../ethernet/marvell/octeontx2/af/rvu_devlink.c | 2 +- .../marvell/octeontx2/nic/otx2_devlink.c | 9 +-------- .../marvell/prestera/prestera_devlink.c | 5 ----- .../net/ethernet/mellanox/mlx5/core/devlink.c | 4 ---- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ------ .../net/ethernet/netronome/nfp/nfp_devlink.c | 4 ---- .../net/ethernet/pensando/ionic/ionic_devlink.c | 4 ---- drivers/net/ethernet/qlogic/qed/qed_devlink.c | 4 ---- drivers/net/netdevsim/dev.c | 3 --- drivers/ptp/ptp_ocp.c | 4 ---- net/core/devlink.c | 17 +++++++++++++++++ 21 files changed, 24 insertions(+), 97 deletions(-) diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c b/drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c index 7503f6b18ac5..a2aba0b0d68a 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c @@ -76,10 +76,6 @@ static int otx2_cpt_devlink_info_get(struct devlink *dl, struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf; int err; - err = devlink_info_driver_name_put(req, "rvu_cptpf"); - if (err) - return err; - err = otx2_cpt_dl_info_firmware_version_put(req, cptpf->eng_grps.grp, "fw.ae", OTX2_CPT_AE_TYPES); if (err) diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index 951f7935c872..595a548bb0a8 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -1176,11 +1176,6 @@ static int hellcreek_devlink_info_get(struct dsa_switch *ds, struct netlink_ext_ack *extack) { struct hellcreek *hellcreek = ds->priv; - int ret; - - ret = devlink_info_driver_name_put(req, "hellcreek"); - if (ret) - return ret; return devlink_info_version_fixed_put(req, DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c index 1266eabee086..a08dab75e0c0 100644 --- a/drivers/net/dsa/mv88e6xxx/devlink.c +++ b/drivers/net/dsa/mv88e6xxx/devlink.c @@ -821,11 +821,6 @@ int mv88e6xxx_devlink_info_get(struct dsa_switch *ds, struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip = ds->priv; - int err; - - err = devlink_info_driver_name_put(req, "mv88e6xxx"); - if (err) - return err; return devlink_info_version_fixed_put(req, DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, diff --git a/drivers/net/dsa/sja1105/sja1105_devlink.c b/drivers/net/dsa/sja1105/sja1105_devlink.c index 10c6fea1227f..da532614f34a 100644 --- a/drivers/net/dsa/sja1105/sja1105_devlink.c +++ b/drivers/net/dsa/sja1105/sja1105_devlink.c @@ -120,16 +120,10 @@ int sja1105_devlink_info_get(struct dsa_switch *ds, struct netlink_ext_ack *extack) { struct sja1105_private *priv = ds->priv; - int rc; - - rc = devlink_info_driver_name_put(req, "sja1105"); - if (rc) - return rc; - rc = devlink_info_version_fixed_put(req, - DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, - priv->info->name); - return rc; + return devlink_info_version_fixed_put(req, + DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, + priv->info->name); } int sja1105_devlink_setup(struct dsa_switch *ds) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 8a6f788f6294..26913dc816d3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -892,10 +892,6 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, u32 ver = 0; int rc; - rc = devlink_info_driver_name_put(req, DRV_MODULE_NAME); - if (rc) - return rc; - if (BNXT_PF(bp) && (bp->flags & BNXT_FLAG_DSN_VALID)) { sprintf(buf, "%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X", bp->dsn[7], bp->dsn[6], bp->dsn[5], bp->dsn[4], diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c index 5c6dd3029e2f..76f808d38066 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c @@ -37,18 +37,9 @@ static int dpaa2_eth_dl_info_get(struct devlink *devlink, struct dpaa2_eth_devlink_priv *dl_priv = devlink_priv(devlink); struct dpaa2_eth_priv *priv = dl_priv->dpaa2_priv; char buf[10]; - int err; - - err = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (err) - return err; scnprintf(buf, 10, "%d.%d", priv->dpni_ver_major, priv->dpni_ver_minor); - err = devlink_info_version_running_put(req, "dpni", buf); - if (err) - return err; - - return 0; + return devlink_info_version_running_put(req, "dpni", buf); } static struct dpaa2_eth_trap_item * diff --git a/drivers/net/ethernet/fungible/funeth/funeth_devlink.c b/drivers/net/ethernet/fungible/funeth/funeth_devlink.c index d50c222948b4..6668375edff6 100644 --- a/drivers/net/ethernet/fungible/funeth/funeth_devlink.c +++ b/drivers/net/ethernet/fungible/funeth/funeth_devlink.c @@ -6,7 +6,7 @@ static int fun_dl_info_get(struct devlink *dl, struct devlink_info_req *req, struct netlink_ext_ack *extack) { - return devlink_info_driver_name_put(req, KBUILD_MODNAME); + return 0; } static const struct devlink_ops fun_dl_ops = { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c index 4c441e6a5082..3d3b69605423 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -13,11 +13,6 @@ static int hclge_devlink_info_get(struct devlink *devlink, struct hclge_devlink_priv *priv = devlink_priv(devlink); char version_str[HCLGE_DEVLINK_FW_STRING_LEN]; struct hclge_dev *hdev = priv->hdev; - int ret; - - ret = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (ret) - return ret; snprintf(version_str, sizeof(version_str), "%lu.%lu.%lu.%lu", hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE3_MASK, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c index fdc19868b818..a6c3c5e8f0ab 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c @@ -13,11 +13,6 @@ static int hclgevf_devlink_info_get(struct devlink *devlink, struct hclgevf_devlink_priv *priv = devlink_priv(devlink); char version_str[HCLGEVF_DEVLINK_FW_STRING_LEN]; struct hclgevf_dev *hdev = priv->hdev; - int ret; - - ret = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (ret) - return ret; snprintf(version_str, sizeof(version_str), "%lu.%lu.%lu.%lu", hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE3_MASK, diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c index 1d638216484d..ba74977e75dc 100644 --- a/drivers/net/ethernet/intel/ice/ice_devlink.c +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c @@ -311,12 +311,6 @@ static int ice_devlink_info_get(struct devlink *devlink, } } - err = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (err) { - NL_SET_ERR_MSG_MOD(extack, "Unable to set driver name"); - goto out_free_ctx; - } - ice_info_get_dsn(pf, ctx); err = devlink_info_serial_number_put(req, ctx->buf); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c index 88dee589cb21..f15439d26d21 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c @@ -1550,7 +1550,7 @@ static int rvu_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, static int rvu_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) { - return devlink_info_driver_name_put(req, DRV_NAME); + return 0; } static const struct devlink_ops rvu_devlink_ops = { diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c index 777a27047c8e..5cc6416cf1a6 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c @@ -77,18 +77,11 @@ static const struct devlink_param otx2_dl_params[] = { otx2_dl_mcam_count_validate), }; -/* Devlink OPs */ static int otx2_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) { - struct otx2_devlink *otx2_dl = devlink_priv(devlink); - struct otx2_nic *pfvf = otx2_dl->pfvf; - - if (is_otx2_vf(pfvf->pcifunc)) - return devlink_info_driver_name_put(req, "rvu_nicvf"); - - return devlink_info_driver_name_put(req, "rvu_nicpf"); + return 0; } static const struct devlink_ops otx2_devlink_ops = { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c index 84ad05c9f12d..2a4c9df4eb79 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c @@ -355,11 +355,6 @@ static int prestera_dl_info_get(struct devlink *dl, { struct prestera_switch *sw = devlink_priv(dl); char buf[16]; - int err; - - err = devlink_info_driver_name_put(req, PRESTERA_DRV_NAME); - if (err) - return err; snprintf(buf, sizeof(buf), "%d.%d.%d", sw->dev->fw_rev.maj, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index cc2ae427dcb0..751bc4a9edcf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -46,10 +46,6 @@ mlx5_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, u32 running_fw, stored_fw; int err; - err = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (err) - return err; - err = devlink_info_version_fixed_put(req, "fw.psid", dev->board_id); if (err) return err; diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index d8b1bb03cdb0..a0a06e2eff82 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1453,18 +1453,12 @@ mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) { struct mlxsw_core *mlxsw_core = devlink_priv(devlink); - struct device *dev = mlxsw_core->bus_info->dev; char fw_info_psid[MLXSW_REG_MGIR_FW_INFO_PSID_SIZE]; u32 hw_rev, fw_major, fw_minor, fw_sub_minor; char mgir_pl[MLXSW_REG_MGIR_LEN]; char buf[32]; int err; - err = devlink_info_driver_name_put(req, - dev_driver_string(dev->parent)); - if (err) - return err; - mlxsw_reg_mgir_pack(mgir_pl); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgir), mgir_pl); if (err) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c index 8bfd48d50ef0..4c601ff09cd3 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c @@ -239,10 +239,6 @@ nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, char *buf = NULL; int err; - err = devlink_info_driver_name_put(req, "nfp"); - if (err) - return err; - vendor = nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor"); part = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"); sn = nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial"); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c index 567f778433e2..e6ff757895ab 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c @@ -26,10 +26,6 @@ static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, char buf[16]; int err = 0; - err = devlink_info_driver_name_put(req, IONIC_DRV_NAME); - if (err) - return err; - err = devlink_info_version_running_put(req, DEVLINK_INFO_VERSION_GENERIC_FW, idev->dev_info.fw_version); diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.c b/drivers/net/ethernet/qlogic/qed/qed_devlink.c index 6bb4e165b592..922c47797af6 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_devlink.c +++ b/drivers/net/ethernet/qlogic/qed/qed_devlink.c @@ -162,10 +162,6 @@ static int qed_devlink_info_get(struct devlink *devlink, dev_info = &cdev->common_dev_info; - err = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (err) - return err; - memcpy(buf, cdev->hwfns[0].hw_info.part_num, sizeof(cdev->hwfns[0].hw_info.part_num)); buf[sizeof(cdev->hwfns[0].hw_info.part_num)] = 0; diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index e14686594a71..b962fc8e1397 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -994,9 +994,6 @@ static int nsim_dev_info_get(struct devlink *devlink, { int err; - err = devlink_info_driver_name_put(req, DRV_NAME); - if (err) - return err; err = devlink_info_version_stored_put_ext(req, "fw.mgmt", "10.20.30", DEVLINK_INFO_VERSION_TYPE_COMPONENT); if (err) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 154d58cbd9ce..4bbaccd543ad 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1647,10 +1647,6 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, char buf[32]; int err; - err = devlink_info_driver_name_put(req, KBUILD_MODNAME); - if (err) - return err; - fw_image = bp->fw_loader ? "loader" : "fw"; sprintf(buf, "%d.%d", bp->fw_tag, bp->fw_version); err = devlink_info_version_running_put(req, fw_image, buf); diff --git a/net/core/devlink.c b/net/core/devlink.c index cea154ddce7a..6478135d9ba1 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -6749,11 +6749,24 @@ int devlink_info_version_running_put_ext(struct devlink_info_req *req, } EXPORT_SYMBOL_GPL(devlink_info_version_running_put_ext); +static int devlink_nl_driver_info_get(struct device_driver *drv, + struct devlink_info_req *req) +{ + if (!drv) + return 0; + + if (drv->name[0]) + return devlink_info_driver_name_put(req, drv->name); + + return 0; +} + static int devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, enum devlink_command cmd, u32 portid, u32 seq, int flags, struct netlink_ext_ack *extack) { + struct device *dev = devlink_to_dev(devlink); struct devlink_info_req req = {}; void *hdr; int err; @@ -6771,6 +6784,10 @@ devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, if (err) goto err_cancel_msg; + err = devlink_nl_driver_info_get(dev->driver, &req); + if (err) + goto err_cancel_msg; + genlmsg_end(msg, hdr); return 0; From patchwork Sun Nov 27 13:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent MAILHOL X-Patchwork-Id: 13056747 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 ADB67C47088 for ; Sun, 27 Nov 2022 13:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbiK0NLS (ORCPT ); Sun, 27 Nov 2022 08:11:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiK0NKt (ORCPT ); Sun, 27 Nov 2022 08:10:49 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD473DFA4; Sun, 27 Nov 2022 05:10:26 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so628609pje.5; Sun, 27 Nov 2022 05:10:26 -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=OxNviUPHTCGHIw1xqWHS/MPtnV3RpWOBq4yIBMcYMgw=; b=aOwF2DGKnJ17bhHDKmrmab4OFrvr6sHKBHX0zow1gGQgrlsbBTABqy+qAAjNeapBBi yb0oyPbubMaIJKDGCsx7HqtkWHSdH9ZBdsyB9PZGDUQdbkxyTKkNN+cWCM0v4WrWG1N9 5GhzU7ErOeK7tsJPw/fx8AMbH6lRhB8iHDer2Ljp0aDgSvQo7qduzkO/0o5BfTfPylbF ycN4pZpl0KRyAD8zSld/LV5tUYiMIZCDjyYI1W0yhJyCQQsM4ZheZmsjywOWoFBQ1Xia b4mJhjqUjyH4mGJXzWd1IYcfxm5kp8fAjOn7762fKoQJEfY/vocYjmi118FGpgnnXlyd ge/w== 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=OxNviUPHTCGHIw1xqWHS/MPtnV3RpWOBq4yIBMcYMgw=; b=fn0xfGwBPhuWY9od2QZ8+mYXHxLP7Bfy7hbBBjRfVToKT1qD3bU/w1xcl0tKw/bhzu Til6X1pHaDfIIXmTLGsZ7AOGWko+Dv75+9DapiOtAPt6jonlh63WyKElUazDFKmw8N8K r1udfjZ4wWXBJb3U9tSy0pnbuTXZNVGPs38ecAC6m3qcjoPCDqgMTjrCadWFehY09P6K YMyozefl1a8ZS3F7LLzPPfXfAsHXaovwnm6/0kBNYLbr1MpbjZkyUY5Y11ytSrDKSRSU olkE0Jiuj2ozfaIxfWYpJU1y+KShc6jUqIrLy5sVshPDZnPk6g2gbQ5Z96//b5MZIacb rfNA== X-Gm-Message-State: ANoB5pkTKAp9FIl8VLK0VqmdH7PxxRQPXgLFtUTAm7dNuG/ll6e7EmN7 ZE/D9NzLAgGNQDwYMGer2Ho= X-Google-Smtp-Source: AA0mqf4kR8A7riSdhezb8YYOVkRVEthmKJ6bKxK4dqCAk0UCWiR/wf0G3/1Me0wOdistxQAfpt17yw== X-Received: by 2002:a17:902:82c3:b0:189:82da:7b63 with SMTP id u3-20020a17090282c300b0018982da7b63mr2667941plz.68.1669554626030; Sun, 27 Nov 2022 05:10:26 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q17-20020a170902eb9100b00188a908cbddsm6710225plg.302.2022.11.27.05.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 05:10:25 -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 Subject: [PATCH net-next v3 4/5] net: devlink: remove devlink_info_driver_name_put() Date: Sun, 27 Nov 2022 22:09:18 +0900 Message-Id: <20221127130919.638324-5-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221127130919.638324-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221127130919.638324-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 Now that the core sets the driver name attribute, drivers are not supposed to call devlink_info_driver_name_put() anymore. Remove it. Signed-off-by: Vincent Mailhol --- include/net/devlink.h | 2 -- net/core/devlink.c | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index 074a79b8933f..52d5fb67e9b8 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1746,8 +1746,6 @@ int devlink_region_snapshot_create(struct devlink_region *region, u8 *data, u32 snapshot_id); int devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn); -int devlink_info_driver_name_put(struct devlink_info_req *req, - const char *name); int devlink_info_board_serial_number_put(struct devlink_info_req *req, const char *bsn); diff --git a/net/core/devlink.c b/net/core/devlink.c index 6478135d9ba1..3babc16eeb6b 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -6633,14 +6633,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, return err; } -int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name) -{ - if (!req->msg) - return 0; - return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, name); -} -EXPORT_SYMBOL_GPL(devlink_info_driver_name_put); - int devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn) { if (!req->msg) @@ -6756,7 +6748,8 @@ static int devlink_nl_driver_info_get(struct device_driver *drv, return 0; if (drv->name[0]) - return devlink_info_driver_name_put(req, drv->name); + return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, + drv->name); return 0; } From patchwork Sun Nov 27 13:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent MAILHOL X-Patchwork-Id: 13056748 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 7AA0CC352A1 for ; Sun, 27 Nov 2022 13:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbiK0NLg (ORCPT ); Sun, 27 Nov 2022 08:11:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiK0NLL (ORCPT ); Sun, 27 Nov 2022 08:11:11 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA75B55B9; Sun, 27 Nov 2022 05:10:35 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id 9so8065764pfx.11; Sun, 27 Nov 2022 05:10:35 -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=Wa4XaW+1zFy7m2UqkW+jljIO+eXfIIcKkAfn67qndy0=; b=Fz4YmgLubHYugBiEpKCkEQVsqC0p6oTmC1aSPxRe0425jPACuV0TaRwy23+2inMQ5D hAkOlDFItx2njgVA7lFGT8MjQmmlpGxy+0cDMBDXCPHvJAeATGQuIdSydK6VsfFYra3C SbRVk7PjhEAWy3/35XVnnQvuwxpTkyQePnx8oNo+uBGTNFh3FHbSkUbqp7gx34+8vvCD zn3480b4Aqb5RP2H3pQvjaIm/+iGl074IAWcw30FW6cTlRIMKNPHpYsyBH+0uTlgKdwC 8nq/+E7TJ41/4r+m6xQInNdndeyZl1y8nXuom0L1pXNb3y82aD/fH1yhhSnvTsOeMpDo Rabg== 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=Wa4XaW+1zFy7m2UqkW+jljIO+eXfIIcKkAfn67qndy0=; b=67NWS9vKc2+LfVI8f1jaaJVTTPLdH0XoCl6/b4BNbrixu6bLo++eiekJreKK9t8vWK SypFDTHmdNAfLGZfaq8Z5EcGqLNeQpQMdRsO9TQ8fmxTg9p4ADwpPdr8HGK02q7bcagH VL/MAgLoFCk14LnEzTgZ+a41ibgz0aq1dXfDr9Ah9KVT0zFevd4YjQbQ8epSi3JrJCPC ApMoX+N+U5Rkezx5kNUfnRnSOyOs8HWPr4WvlhdzWCzAd2yJCPHGkdqnReQiEYKS+w9X /35cWVZrHPWyL4wi8zMCnXarQSoZdJQXcXNlso8XvlCvfOePpCuvGnA3kx9Gzc6884E5 ko4Q== X-Gm-Message-State: ANoB5pm7w2Iy2IbOV9rsac1ewtZXTgE3E+6VnM9NTSjVbk0NrIE8A9h4 5wyMMGqYMWdg+UQBKy1N5DA= X-Google-Smtp-Source: AA0mqf7kLDoeeNLlfufAXNlhL55OdaR+IG9ZLnQYsm7lgFdEW+DqYVZhNIldFwkJG2XMVMOj5Fm4Ig== X-Received: by 2002:aa7:8c19:0:b0:573:620a:3b1c with SMTP id c25-20020aa78c19000000b00573620a3b1cmr28111061pfd.50.1669554635218; Sun, 27 Nov 2022 05:10:35 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q17-20020a170902eb9100b00188a908cbddsm6710225plg.302.2022.11.27.05.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 05:10:34 -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 Subject: [PATCH net-next v3 5/5] net: devlink: make the devlink_ops::info_get() callback optional Date: Sun, 27 Nov 2022 22:09:19 +0900 Message-Id: <20221127130919.638324-6-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221127130919.638324-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221127130919.638324-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. Remove all the empty devlink_ops::info_get() functions from the drivers. 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 --- .../net/ethernet/fungible/funeth/funeth_devlink.c | 7 ------- .../net/ethernet/marvell/octeontx2/af/rvu_devlink.c | 7 ------- .../ethernet/marvell/octeontx2/nic/otx2_devlink.c | 8 -------- net/core/devlink.c | 13 ++++++------- 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/fungible/funeth/funeth_devlink.c b/drivers/net/ethernet/fungible/funeth/funeth_devlink.c index 6668375edff6..4fbeb3fd71a8 100644 --- a/drivers/net/ethernet/fungible/funeth/funeth_devlink.c +++ b/drivers/net/ethernet/fungible/funeth/funeth_devlink.c @@ -3,14 +3,7 @@ #include "funeth.h" #include "funeth_devlink.h" -static int fun_dl_info_get(struct devlink *dl, struct devlink_info_req *req, - struct netlink_ext_ack *extack) -{ - return 0; -} - static const struct devlink_ops fun_dl_ops = { - .info_get = fun_dl_info_get, }; struct devlink *fun_devlink_alloc(struct device *dev) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c index f15439d26d21..bda1a6fa2ec4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c @@ -1547,14 +1547,7 @@ static int rvu_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, return 0; } -static int rvu_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, - struct netlink_ext_ack *extack) -{ - return 0; -} - static const struct devlink_ops rvu_devlink_ops = { - .info_get = rvu_devlink_info_get, .eswitch_mode_get = rvu_devlink_eswitch_mode_get, .eswitch_mode_set = rvu_devlink_eswitch_mode_set, }; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c index 5cc6416cf1a6..63ef7c41d18d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c @@ -77,15 +77,7 @@ static const struct devlink_param otx2_dl_params[] = { otx2_dl_mcam_count_validate), }; -static int otx2_devlink_info_get(struct devlink *devlink, - struct devlink_info_req *req, - struct netlink_ext_ack *extack) -{ - return 0; -} - static const struct devlink_ops otx2_devlink_ops = { - .info_get = otx2_devlink_info_get, }; int otx2_register_dl(struct otx2_nic *pfvf) 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);