[net-next,v3] ethtool: doc: clarify what drivers can implement in their get_drvinfo()
Message ID | 20221113083404.86983-1-mailhol.vincent@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1608394wru; Sun, 13 Nov 2022 01:16:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YVEQrYD2+FF+sL38L10aF+KZQmcg37ix2UTguOBaD2lAqzI98l/UpbIfB/4wia1wyCtN8 X-Received: by 2002:aa7:c384:0:b0:461:5f19:61da with SMTP id k4-20020aa7c384000000b004615f1961damr7714574edq.34.1668331013535; Sun, 13 Nov 2022 01:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668331013; cv=none; d=google.com; s=arc-20160816; b=h7EVVtcGyk5TQ0GPp22FHCwsPIr1s1PB+G/TUZ3HvkUWZuHHiHdQjdFqDSw61fl1X4 oVqtJAXmnR5PZ5gqgeCuiqzAedvPGDH0wIyyISzM5yfFV/5l6gIc8wduDvoN5HB0NjT9 KHO+71kWBGhpR/dDUbl+LBOf53211BSLC2PFBpvInWKfY4EfAtlZoaWcze5DDh1YYAzt Mv35AsiF9QsXS3h0Qs5mHe2BsNpbc/1ch3MKqKiAARW03B0FyyzaU+VJpMmTXxfsOf6q it09Wmq7TziKjcb+gsF0iz/JxxZhcda+cXB8gBIJ+2KhsFFKep6PIlf1U5zgFkluJsPD gvWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rh1rcfsF2jelBwTxQVNXFFfPTHy9LFON9Yin67rbwwM=; b=m2YwOM8ItD5YFJ8gik42LJLfUUccqRojruHEws7PtHDgLB2Ls7HS1iOJET6bpKxu5r jbhMRnRH3EdyDQcfHKc8QLSiwrYw+aMkzPe2LVRw2dhuf0HSMl2m75iWQu3OmR1KH6Y5 VUNtcIyYOh0Lk34cpzg31KPnoTIsGRXj4GOcJSJwNkR7FjVGAT7HXQSHvFAchkmFdu7E vB91rxql2xcEeJEwARLCLbQzYKogGxvLlwSGSL3fRa8RNcnpvEiqpNO69vQiP2lYX0sK MzH86hyoT88wBRzaOf8nMneyGaMvvrxHCqcNTF/U+t/EnBh6LAdsFLxIbMPoSHmCMHyN xFPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bGoFUf6A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga9-20020a1709070c0900b007a7d37e4684si7650112ejc.803.2022.11.13.01.16.27; Sun, 13 Nov 2022 01:16:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bGoFUf6A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235219AbiKMIeV (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Sun, 13 Nov 2022 03:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiKMIeT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 13 Nov 2022 03:34:19 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96772E0EC; Sun, 13 Nov 2022 00:34:18 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso11233807pjg.5; Sun, 13 Nov 2022 00:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:sender:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Rh1rcfsF2jelBwTxQVNXFFfPTHy9LFON9Yin67rbwwM=; b=bGoFUf6AIiMKEx+ETMtwz9F237JjvBCmBsp6iZBsU6VMaocGgUdpJvVQzOc31QsdxM b+wSWpFoQUtPRsuZHtf1G59/D5ue81BMCaGpjMIJEvDGWVIfRNbb2x8Oc2mCdpzMBLMT VlBEHnkqnDCDKIomrI0sAEhgNng2fZxndtXCcdBySITB46VEnY7ZwCWUFmub0NA4npn5 yK5lsMBDjTwN2TML+YOH/+Yo35x2AwvnZxftB1ePxpk+KAOS6Gv3kF5jLVCeHAkBmPHb c/Gr1pyJLDuSNtG8iBwnMsvzPjiOaNRcZaLFqg/Gsi+H/FwPUtLobt5HVofDxQlM3P8w 4oIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:sender:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Rh1rcfsF2jelBwTxQVNXFFfPTHy9LFON9Yin67rbwwM=; b=RnqdJAGv9l+oQpjoL47AhQyMO/sHsOw9/cnHOkMNHBXvx1lE6/ziGhgC0sxWFjRP+a YAWSISdjas4WsBbJYq45cJHdpHX7L/1UF5s7/Q1mOWgLQku8M3Frxf0LcFc4p+WbbcFD bnJ+5D4luKlj3OizXko9LRHDcFrgckomcPh04ScXhrI+r/q8JjdDk7F8Kwox0Y9G90j/ 1zNkytjzS+yCgsZKrzkXlywxU0PNyBmafwLI3PcIecbcjgNlf2MQ5YFPcMnJJq46huWe vygEalRYsJa7qE4Ff2WrBXUu6wXvHUvKiM6JIW2JmOHbYQYID7J5SCsSvsQCTV9UmCd3 7SuQ== X-Gm-Message-State: ANoB5pklAIBOkQ3rINyoR2YHmpRvU68i/Xd7onMH4M4a4zXek8YPTaqB SiXWXn7aKJNb3wwAl8cf98w= X-Received: by 2002:a17:90a:ad49:b0:213:3521:f83a with SMTP id w9-20020a17090aad4900b002133521f83amr9035387pjv.84.1668328458038; Sun, 13 Nov 2022 00:34:18 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id lt15-20020a17090b354f00b002130c269b6fsm4284366pjb.1.2022.11.13.00.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 00:34:17 -0800 (PST) From: Vincent Mailhol <mailhol.vincent@wanadoo.fr> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org Cc: Vincent Mailhol <mailhol.vincent@wanadoo.fr>, Andrew Lunn <andrew@lunn.ch>, Oleksij Rempel <linux@rempel-privat.de>, Dan Williams <dan.j.williams@intel.com>, Petr Machata <petrm@nvidia.com>, Hao Chen <chenhao288@hisilicon.com>, Amit Cohen <amcohen@nvidia.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Sean Anderson <sean.anderson@seco.com>, linux-kernel@vger.kernel.org, Leon Romanovsky <leonro@mellanox.com>, Leon Romanovsky <leonro@nvidia.com> Subject: [PATCH net-next v3] ethtool: doc: clarify what drivers can implement in their get_drvinfo() Date: Sun, 13 Nov 2022 17:34:04 +0900 Message-Id: <20221113083404.86983-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221111030838.1059-1-mailhol.vincent@wanadoo.fr> References: <20221111030838.1059-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Sender: Vincent Mailhol <vincent.mailhol@gmail.com> Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749168208676495794?= X-GMAIL-MSGID: =?utf-8?q?1749371860694815516?= |
Series |
[net-next,v3] ethtool: doc: clarify what drivers can implement in their get_drvinfo()
|
|
Commit Message
Vincent Mailhol
Nov. 13, 2022, 8:34 a.m. UTC
Many of the drivers which implement ethtool_ops::get_drvinfo() will prints the .driver, .version or .bus_info of struct ethtool_drvinfo. To have a glance of current state, do: $ git grep -W "get_drvinfo(struct" Printing in those three fields is useless because: - since [1], the driver version should be the kernel version (at least for upstream drivers). Arguably, out of tree drivers might still want to set a custom version, but out of tree is not our focus. - since [2], the core is able to provide default values for .driver and .bus_info. In summary, drivers may provide .fw_version and .erom_version, the rest is expected to be done by the core. Update the doc to reflect the facts. Also update the dummy driver and simply remove the callback in order not to confuse the newcomers: most of the drivers will not need this callback function any more. [1] commit 6a7e25c7fb48 ("net/core: Replace driver version to be kernel version") Link: https://git.kernel.org/torvalds/linux/c/6a7e25c7fb48 [2] commit edaf5df22cb8 ("ethtool: ethtool_get_drvinfo: populate drvinfo fields even if callback exits") Link: https://git.kernel.org/netdev/net-next/c/edaf5df22cb8 Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> --- Arguably, dummy.c is code and not documentation, but for me, it makes sense to treat it as documentation, thus I am putting everything in one single patch. * Changelog * v2 -> v3: * add Reviewed-by: Leon Romanovsky <leonro@nvidia.com> tag. * use shorter links. v1 -> v2: * forgot the net-next prefix in the patch subject... Sorry for the noise. --- drivers/net/dummy.c | 7 ------- include/uapi/linux/ethtool.h | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-)
Comments
On Sun, 13 Nov 2022 17:34:04 +0900 Vincent Mailhol wrote: > - * Drivers should set at most @driver, @version, @fw_version and > - * @bus_info in their get_drvinfo() implementation. The ethtool > - * core fills in the other fields using other driver operations. > + * Drivers should set at most @fw_version and @erom_version in their > + * get_drvinfo() implementation. The ethtool core fills in the other > + * fields using other driver operations. Can I still nit pick the working on v3? :) Almost half of the fields are not filled in by other operations, so how about we cut deeper? Even @erom_version is only filled in by a single driver, and pretty much deprecated (devlink is much more flexible for all FW version reporting and flashing). How about: * Majority of the drivers should no longer implement this callback. * Most fields are correctly filled in by the core using system * information, or populated using other driver operations.
On Tue. 15 Nov. 2022 at 14:27, Jakub Kicinski <kuba@kernel.org> wrote: > On Sun, 13 Nov 2022 17:34:04 +0900 Vincent Mailhol wrote: > > - * Drivers should set at most @driver, @version, @fw_version and > > - * @bus_info in their get_drvinfo() implementation. The ethtool > > - * core fills in the other fields using other driver operations. > > + * Drivers should set at most @fw_version and @erom_version in their > > + * get_drvinfo() implementation. The ethtool core fills in the other > > + * fields using other driver operations. > > Can I still nit pick the working on v3? :) Nitpicks are welcome! > Almost half of the fields are not filled in by other operations, > so how about we cut deeper? Even @erom_version is only filled in by > a single driver, and pretty much deprecated I do not like to say that it is "pretty much deprecated". Either it is deprecated and we can start to clean things up, or it is not and people can continue to use it. It is good to have a clear position, whatever it is. > (devlink is much more flexible for all FW version reporting and flashing). Side note, I just started to study devlink. > How about: > > * Majority of the drivers should no longer implement this callback. > * Most fields are correctly filled in by the core using system > * information, or populated using other driver operations. > * Majority of the drivers should no longer implement this callback. ^^^^ In this context, "this callback" is not defined (there is no prior mention in this struct doc). I will replace it with "the drv_info() callback". I am fine to try to discourage the developper from implementing the callback. But I still want a small note to state the facts (c.f. above comment, unless we explicitly deprecate the drv_info(), I do not think we should try to completely hide its existence). What about this: diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index dc2aa3d75b39..fe4d8dddb0a7 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -159,8 +159,10 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) * in its bus driver structure (e.g. pci_driver::name). Must * not be an empty string. * @version: Driver version string; may be an empty string - * @fw_version: Firmware version string; may be an empty string - * @erom_version: Expansion ROM version string; may be an empty string + * @fw_version: Firmware version string; drivers can set it; may be an + * empty string + * @erom_version: Expansion ROM version string; drivers can set it; + * may be an empty string * @bus_info: Device bus address. This should match the dev_name() * string for the underlying bus device, if there is one. May be * an empty string. @@ -180,9 +182,10 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) * Users can use the %ETHTOOL_GSSET_INFO command to get the number of * strings in any string set (from Linux 2.6.34). * - * Drivers should set at most @driver, @version, @fw_version and - * @bus_info in their get_drvinfo() implementation. The ethtool - * core fills in the other fields using other driver operations. + * Majority of the drivers should no longer implement the + * get_drvinfo() callback. Most fields are correctly filled in by the + * core using system information, or populated using other driver + * operations. */ struct ethtool_drvinfo { __u32 cmd; Yours sincerely, Vincent Mailhol
On Tue, 15 Nov 2022 16:52:39 +0900 Vincent MAILHOL wrote: > - * @fw_version: Firmware version string; may be an empty string > - * @erom_version: Expansion ROM version string; may be an empty string > + * @fw_version: Firmware version string; drivers can set it; may be an > + * empty string > + * @erom_version: Expansion ROM version string; drivers can set it; > + * may be an empty string "drivers can set it" rings a little odd to my non-native-English- -speaker's ear. Perhaps "driver-defined;" ? Either way is fine, tho. > * @bus_info: Device bus address. This should match the dev_name() > * string for the underlying bus device, if there is one. May be > * an empty string. > @@ -180,9 +182,10 @@ static inline __u32 ethtool_cmd_speed(const > struct ethtool_cmd *ep) > * Users can use the %ETHTOOL_GSSET_INFO command to get the number of > * strings in any string set (from Linux 2.6.34). > * > - * Drivers should set at most @driver, @version, @fw_version and > - * @bus_info in their get_drvinfo() implementation. The ethtool > - * core fills in the other fields using other driver operations. > + * Majority of the drivers should no longer implement the > + * get_drvinfo() callback. Most fields are correctly filled in by the > + * core using system information, or populated using other driver > + * operations. SG! Good point on the doc being for the struct. We can make the notice even stronger if you want by saying s/Majority of the/Modern/
On Tue. 16 Nov. 2022 at 01:28, Jakub Kicinski <kuba@kernel.org> wrote: > On Tue, 15 Nov 2022 16:52:39 +0900 Vincent MAILHOL wrote: > > - * @fw_version: Firmware version string; may be an empty string > > - * @erom_version: Expansion ROM version string; may be an empty string > > + * @fw_version: Firmware version string; drivers can set it; may be an > > + * empty string > > + * @erom_version: Expansion ROM version string; drivers can set it; > > + * may be an empty string > > "drivers can set it" rings a little odd to my non-native-English- > -speaker's ear. Perhaps "driver-defined;" ? Either way is fine, tho. I am not a native speaker either so I won't argue here. Changed to "driver defined" in v4. > > * @bus_info: Device bus address. This should match the dev_name() > > * string for the underlying bus device, if there is one. May be > > * an empty string. > > @@ -180,9 +182,10 @@ static inline __u32 ethtool_cmd_speed(const > > struct ethtool_cmd *ep) > > * Users can use the %ETHTOOL_GSSET_INFO command to get the number of > > * strings in any string set (from Linux 2.6.34). > > * > > - * Drivers should set at most @driver, @version, @fw_version and > > - * @bus_info in their get_drvinfo() implementation. The ethtool > > - * core fills in the other fields using other driver operations. > > + * Majority of the drivers should no longer implement the > > + * get_drvinfo() callback. Most fields are correctly filled in by the > > + * core using system information, or populated using other driver > > + * operations. > > SG! Good point on the doc being for the struct. We can make the notice > even stronger if you want by saying s/Majority of the/Modern/ "Modern drivers should no longer..." sounds like an unconditional interdiction. I changed it to "Modern drivers no longer have to..." to nuance the terms and suggest that they remain some edge cases. I sent the v4 but messed up the In-Reply-To tag so it became a new thread: https://lore.kernel.org/netdev/20221115233524.805956-1-mailhol.vincent@wanadoo.fr/T/#u Yours sincerely, Vincent Mailhol
On Wed. 16 Nov. 2022 at 09:30, Vincent MAILHOL <mailhol.vincent@wanadoo.fr> wrote: > On Tue. 16 Nov. 2022 at 01:28, Jakub Kicinski <kuba@kernel.org> wrote: > > On Tue, 15 Nov 2022 16:52:39 +0900 Vincent MAILHOL wrote: > > SG! Good point on the doc being for the struct. That comment just made me realize that actually, struct ethtool_ops is also outdated: https://elixir.bootlin.com/linux/latest/source/include/linux/ethtool.h#L462 Please ignore the v4, I will send another patch to also fix the struct ethtool_ops doc. Yours sincerely, Vincent Mailhol
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index aa0fc00faecb..c4b1b0aa438a 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c @@ -99,14 +99,7 @@ static const struct net_device_ops dummy_netdev_ops = { .ndo_change_carrier = dummy_change_carrier, }; -static void dummy_get_drvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) -{ - strscpy(info->driver, DRV_NAME, sizeof(info->driver)); -} - static const struct ethtool_ops dummy_ethtool_ops = { - .get_drvinfo = dummy_get_drvinfo, .get_ts_info = ethtool_op_get_ts_info, }; diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f341de2ae612..fcee5dbf6c06 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -180,9 +180,9 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) * Users can use the %ETHTOOL_GSSET_INFO command to get the number of * strings in any string set (from Linux 2.6.34). * - * Drivers should set at most @driver, @version, @fw_version and - * @bus_info in their get_drvinfo() implementation. The ethtool - * core fills in the other fields using other driver operations. + * Drivers should set at most @fw_version and @erom_version in their + * get_drvinfo() implementation. The ethtool core fills in the other + * fields using other driver operations. */ struct ethtool_drvinfo { __u32 cmd;