Message ID | 20231013170755.2367410-4-ivecera@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2035292vqb; Fri, 13 Oct 2023 10:09:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErXDbO8WoI5gly7v1H0Pv9cV5xJjORWs7Bv/dg+hSm2mGQT3LaI4Y2ranAUg5ms2Emap0G X-Received: by 2002:a05:6358:9f93:b0:149:7198:bd46 with SMTP id fy19-20020a0563589f9300b001497198bd46mr19353753rwb.1.1697216952438; Fri, 13 Oct 2023 10:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697216952; cv=none; d=google.com; s=arc-20160816; b=CVGUec37+Fbhn2FjhuIPFom0OnltRjEwjmbiMUiGf+vZzrDC3wTwsq5Cf2nJ4ineQU xAQp88fU3qEhasEuGj2XjBz6Gd/g/z1KZK3921qRk+n9NWj82BanUjvRSYo2RLkDi0Vq OO7fvUsENtXMz+pIM6Q4N5M/enfaIsOid3VVaA2zy5QUSA/g5z+roPt/ID0aKGxbqebJ TlIyy9uQsaWWIuCguEKil/Zsjo7QcETFK32wZrIFuAeLNmzZrH6QFN68GWzK0d6p/lgH LJx9m/QfGXo9odsRsVq2XWmKPxOb/l17C4LcDKz67C20KFx5DAmR8CPXP0Ol25cQBCnO QTfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2xsezFWFByy4rpS2ZiIdJ03gAqw56BIfXZENvTM4VoQ=; fh=AByxgCPPHJFcr3Ywbvra8GdCH8cU/fyFb3UIpf51sPU=; b=Wb9YuT8axSpy8Eeys6tH1uummE3CSxueDJetou+fPzLGBOXwRryn5mTcPTBulGZTvw 1bpGk+1f0O8qbd4zX/YkMuSNqRglNOfkTQvYF2qhfSQMjZ+SNLAYZNZMBemYlacvEo4y KP4B/n8GsFvvM3Ob/JmZYaOpFVrnW3JRhI4OtsgRTnWdx9MFYBNNEzA4eO1cTb21/Phn /6BorNBNzSRm2aeNarwdC8cCiZPSSb/wVLwZJ++W042h9bf4w5xGTM03M6NCya8k/uNx N6zVLOeYGFGHbw+5IgvL/G1K9F39v4Gih93J87alLTwpDPRTvTD/NZgGvLW+0EOe42ps /GVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YAV2Ruiw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id g24-20020a633758000000b005859e8c7c22si643405pgn.658.2023.10.13.10.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 10:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YAV2Ruiw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3E789825CEED; Fri, 13 Oct 2023 10:09:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbjJMRJE (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 13:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbjJMRI7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 13:08:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F01CBF for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 10:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697216897; 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=2xsezFWFByy4rpS2ZiIdJ03gAqw56BIfXZENvTM4VoQ=; b=YAV2RuiwIsdm1QO22vrZK4TirbeizCKj/ykKBKhYlcQAuAGHpt73gkecBMBtHYJJ7ws9wm xCccs+vVEDYlYUQ3AjMV4Lg4xzV8ZyePjU50oAa+4ip75p3YXgFvRKx6F7Vta3dsy4xKfp BmktJyh1FJ7pDBETBx1OvFBwcz1wKho= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-218-Nf45X2WpPnS7TiydF3ZteA-1; Fri, 13 Oct 2023 13:08:04 -0400 X-MC-Unique: Nf45X2WpPnS7TiydF3ZteA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F0B7800B23; Fri, 13 Oct 2023 17:08:03 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.225.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE5831C060DF; Fri, 13 Oct 2023 17:08:01 +0000 (UTC) From: Ivan Vecera <ivecera@redhat.com> To: netdev@vger.kernel.org Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next 3/5] i40e: Add handler for devlink .info_get Date: Fri, 13 Oct 2023 19:07:53 +0200 Message-ID: <20231013170755.2367410-4-ivecera@redhat.com> In-Reply-To: <20231013170755.2367410-1-ivecera@redhat.com> References: <20231013170755.2367410-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 10:09:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779660963522537748 X-GMAIL-MSGID: 1779660963522537748 |
Series |
i40e: Add basic devlink support
|
|
Commit Message
Ivan Vecera
Oct. 13, 2023, 5:07 p.m. UTC
Provide devlink .info_get callback to allow the driver to report
detailed version information. The following info is reported:
"serial_number" -> The PCI DSN of the adapter
"fw.mgmt" -> The version of the firmware
"fw.mgmt.api" -> The API version of interface exposed over the AdminQ
"fw.psid" -> The version of the NVM image
"fw.bundle_id" -> Unique identifier for the combined flash image
"fw.undi" -> The combo image version
With this, 'devlink dev info' provides at least the same amount
information as is reported by ETHTOOL_GDRVINFO:
$ ethtool -i enp2s0f0 | egrep '(driver|firmware)'
driver: i40e
firmware-version: 9.30 0x8000e5f3 1.3429.0
$ devlink dev info pci/0000:02:00.0
pci/0000:02:00.0:
driver i40e
serial_number c0-de-b7-ff-ff-ef-ec-3c
versions:
running:
fw.mgmt 9.130.73618
fw.mgmt.api 1.15
fw.psid 9.30
fw.bundle_id 0x8000e5f3
fw.undi 1.3429.0
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
.../net/ethernet/intel/i40e/i40e_devlink.c | 90 +++++++++++++++++++
1 file changed, 90 insertions(+)
Comments
On Fri, 13 Oct 2023 19:07:53 +0200 Ivan Vecera wrote: > "serial_number" -> The PCI DSN of the adapter > "fw.mgmt" -> The version of the firmware > "fw.mgmt.api" -> The API version of interface exposed over the AdminQ > "fw.psid" -> The version of the NVM image Your board reports "fw.psid 9.30", this may not be right, PSID is more of a board+customer ID, IIUC. 9.30 looks like a version, not an ID. > "fw.bundle_id" -> Unique identifier for the combined flash image > "fw.undi" -> The combo image version UNDI means PXE. Is that whave "combo image" means for Intel?
On 16. 10. 23 16:56, Jakub Kicinski wrote: > On Fri, 13 Oct 2023 19:07:53 +0200 Ivan Vecera wrote: >> "serial_number" -> The PCI DSN of the adapter >> "fw.mgmt" -> The version of the firmware >> "fw.mgmt.api" -> The API version of interface exposed over the AdminQ >> "fw.psid" -> The version of the NVM image > > Your board reports "fw.psid 9.30", this may not be right, > PSID is more of a board+customer ID, IIUC. 9.30 looks like > a version, not an ID. Maybe plain 'fw' should be used for this '9.30' as this is a version of the whole software package provided by Intel for these adapters (e.g. https://www.intel.com/content/www/us/en/download/18190/non-volatile-memory-nvm-update-utility-for-intel-ethernet-network-adapter-700-series.html). Thoughts? >> "fw.bundle_id" -> Unique identifier for the combined flash image >> "fw.undi" -> The combo image version > > UNDI means PXE. Is that whave "combo image" means for Intel? Combo image version (aka CIVD) is reported by nvmupdate tool and this should be version of OROM that contains PXE, EFI images that each of them can have specific version but this CIVD should be overall OROM version for this combination of PXE and EFI. I hope I'm right. Thanks, Ivan
On Tue, 17 Oct 2023 11:56:20 +0200 Ivan Vecera wrote: > > Your board reports "fw.psid 9.30", this may not be right, > > PSID is more of a board+customer ID, IIUC. 9.30 looks like > > a version, not an ID. > > Maybe plain 'fw' should be used for this '9.30' as this is a version > of the whole software package provided by Intel for these adapters > (e.g. > https://www.intel.com/content/www/us/en/download/18190/non-volatile-memory-nvm-update-utility-for-intel-ethernet-network-adapter-700-series.html). > > Thoughts? Hm, that could be better, yes. Jake, any guidance? > > UNDI means PXE. Is that whave "combo image" means for Intel? > > Combo image version (aka CIVD) is reported by nvmupdate tool and this > should be version of OROM that contains PXE, EFI images that each of > them can have specific version but this CIVD should be overall OROM > version for this combination of PXE and EFI. I hope I'm right. Sounds good then!
On 10/17/2023 8:21 AM, Jakub Kicinski wrote: > On Tue, 17 Oct 2023 11:56:20 +0200 Ivan Vecera wrote: >>> Your board reports "fw.psid 9.30", this may not be right, >>> PSID is more of a board+customer ID, IIUC. 9.30 looks like >>> a version, not an ID. >> >> Maybe plain 'fw' should be used for this '9.30' as this is a version >> of the whole software package provided by Intel for these adapters >> (e.g. >> https://www.intel.com/content/www/us/en/download/18190/non-volatile-memory-nvm-update-utility-for-intel-ethernet-network-adapter-700-series.html). >> >> Thoughts? > > Hm, that could be better, yes. > > Jake, any guidance? Hm. The ice driver has 'fw.psid.api' which is documented as: * - ``fw.psid.api`` - running - 0.80 - Version defining the format of the flash contents. I think we settled on this as well back when I was working on the ice version. See https://lore.kernel.org/netdev/70001e87-b369-bab4-f318-ad4514e7dcfb@intel.com/ However, looking at the code more closely, this does appear to match the ice driver's implementation if you use "fw.psid.api". I believe the intent for this is a version that indicates the format or layout of the NVM contents. Given that ice uses fw.psid.api for what appears to be the same purpose I would propose that here as well. > >>> UNDI means PXE. Is that whave "combo image" means for Intel? >> >> Combo image version (aka CIVD) is reported by nvmupdate tool and this >> should be version of OROM that contains PXE, EFI images that each of >> them can have specific version but this CIVD should be overall OROM >> version for this combination of PXE and EFI. I hope I'm right. > > Sounds good then! Yes that sounds correct. That's what we do in ice as well. I'm going to review the whole patch now since I hadn't noticed this previously. Thanks, Jake
On 10/13/2023 10:07 AM, Ivan Vecera wrote: > Provide devlink .info_get callback to allow the driver to report > detailed version information. The following info is reported: > > "serial_number" -> The PCI DSN of the adapter > "fw.mgmt" -> The version of the firmware > "fw.mgmt.api" -> The API version of interface exposed over the AdminQ > "fw.psid" -> The version of the NVM image > "fw.bundle_id" -> Unique identifier for the combined flash image > "fw.undi" -> The combo image version > > With this, 'devlink dev info' provides at least the same amount > information as is reported by ETHTOOL_GDRVINFO: > > $ ethtool -i enp2s0f0 | egrep '(driver|firmware)' > driver: i40e > firmware-version: 9.30 0x8000e5f3 1.3429.0 > > $ devlink dev info pci/0000:02:00.0 > pci/0000:02:00.0: > driver i40e > serial_number c0-de-b7-ff-ff-ef-ec-3c > versions: > running: > fw.mgmt 9.130.73618 The ice driver used fw.mgmt.build for the fw_build value, rather than combining it into the fw.mgmt value. > fw.mgmt.api 1.15 > fw.psid 9.30 As discussed in the other thread, ice used fw.psid.api > fw.bundle_id 0x8000e5f3 > fw.undi 1.3429.0 > Does i40e have a netlist? The ice driver reports netlist versions as well. It also reports the DDP version information, but I don't think i40e supports that either if I recall.. > Signed-off-by: Ivan Vecera <ivecera@redhat.com> > --- > .../net/ethernet/intel/i40e/i40e_devlink.c | 90 +++++++++++++++++++ > 1 file changed, 90 insertions(+) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c b/drivers/net/ethernet/intel/i40e/i40e_devlink.c > index 66b7f5be45ae..fb6144d74c98 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c > @@ -5,7 +5,97 @@ > #include "i40e.h" > #include "i40e_devlink.h" > > +static void i40e_info_get_dsn(struct i40e_pf *pf, char *buf, size_t len) > +{ > + u8 dsn[8]; > + > + put_unaligned_be64(pci_get_dsn(pf->pdev), dsn); > + > + snprintf(buf, len, "%8phD", dsn); > +} > + > +static void i40e_info_fw_mgmt(struct i40e_hw *hw, char *buf, size_t len) > +{ > + struct i40e_adminq_info *aq = &hw->aq; > + > + snprintf(buf, len, "%u.%u.%05d", > + aq->fw_maj_ver, aq->fw_min_ver, aq->fw_build); > +} > + > +static void i40e_info_fw_api(struct i40e_hw *hw, char *buf, size_t len) > +{ > + struct i40e_adminq_info *aq = &hw->aq; > + > + snprintf(buf, len, "%u.%u", aq->api_maj_ver, aq->api_min_ver); > +} > + > +enum i40e_devlink_version_type { > + I40E_DL_VERSION_RUNNING, > +}; > + > +static int i40e_devlink_info_put(struct devlink_info_req *req, > + enum i40e_devlink_version_type type, > + const char *key, const char *value) > +{ > + if (!strlen(value)) > + return 0; > + > + switch (type) { > + case I40E_DL_VERSION_RUNNING: > + return devlink_info_version_running_put(req, key, value); > + } > + return 0; > +} > + > +static int i40e_devlink_info_get(struct devlink *dl, > + struct devlink_info_req *req, > + struct netlink_ext_ack *extack) > +{ > + struct i40e_pf *pf = devlink_priv(dl); > + struct i40e_hw *hw = &pf->hw; > + char buf[32]; > + int err; > + > + i40e_info_get_dsn(pf, buf, sizeof(buf)); > + err = devlink_info_serial_number_put(req, buf); > + if (err) > + return err; > + > + i40e_info_fw_mgmt(hw, buf, sizeof(buf)); > + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, > + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, buf); > + if (err) > + return err; > + > + i40e_info_fw_api(hw, buf, sizeof(buf)); > + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, > + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API, > + buf); > + if (err) > + return err; > + > + i40e_info_nvm_ver(hw, buf, sizeof(buf)); > + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, > + DEVLINK_INFO_VERSION_GENERIC_FW_PSID, buf); > + if (err) > + return err; > + > + i40e_info_eetrack(hw, buf, sizeof(buf)); > + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, > + DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID, > + buf); > + if (err) > + return err; > + > + i40e_info_civd_ver(hw, buf, sizeof(buf)); > + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, > + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, buf); > + > + return err; > +} The ice driver created a struct list and loop flow to iterate this. I'm wondering if it could make sense to extract that logic into devlink core, so that drivers just need to implement a map between version names and functions which extract the name. It seems like it would be straight forward to implement with a setup, the list mapping info names to version getters, and a teardown. Hmm... > + > static const struct devlink_ops i40e_devlink_ops = { > + .info_get = i40e_devlink_info_get, > }; > > /**
On 17. 10. 23 19:17, Jacob Keller wrote: > > > On 10/13/2023 10:07 AM, Ivan Vecera wrote: >> Provide devlink .info_get callback to allow the driver to report >> detailed version information. The following info is reported: >> >> "serial_number" -> The PCI DSN of the adapter >> "fw.mgmt" -> The version of the firmware >> "fw.mgmt.api" -> The API version of interface exposed over the AdminQ >> "fw.psid" -> The version of the NVM image >> "fw.bundle_id" -> Unique identifier for the combined flash image >> "fw.undi" -> The combo image version >> >> With this, 'devlink dev info' provides at least the same amount >> information as is reported by ETHTOOL_GDRVINFO: >> >> $ ethtool -i enp2s0f0 | egrep '(driver|firmware)' >> driver: i40e >> firmware-version: 9.30 0x8000e5f3 1.3429.0 >> >> $ devlink dev info pci/0000:02:00.0 >> pci/0000:02:00.0: >> driver i40e >> serial_number c0-de-b7-ff-ff-ef-ec-3c >> versions: >> running: >> fw.mgmt 9.130.73618 > > The ice driver used fw.mgmt.build for the fw_build value, rather than > combining it into the fw.mgmt value. OK, will fix by follow up. >> fw.mgmt.api 1.15 >> fw.psid 9.30 > > As discussed in the other thread, ice used fw.psid.api OK, will change it to fw.psid.api. >> fw.bundle_id 0x8000e5f3 >> fw.undi 1.3429.0 >> > > Does i40e have a netlist? The ice driver reports netlist versions as > well. It also reports the DDP version information, but I don't think > i40e supports that either if I recall.. i40e supports to load DDP in runtime by ethtool flash function and the name and version of DDP package could be provided IMHO. >> Signed-off-by: Ivan Vecera <ivecera@redhat.com> >> --- >> .../net/ethernet/intel/i40e/i40e_devlink.c | 90 +++++++++++++++++++ >> 1 file changed, 90 insertions(+) >> >> diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c b/drivers/net/ethernet/intel/i40e/i40e_devlink.c >> index 66b7f5be45ae..fb6144d74c98 100644 >> --- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c >> +++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c >> @@ -5,7 +5,97 @@ >> #include "i40e.h" >> #include "i40e_devlink.h" >> >> +static void i40e_info_get_dsn(struct i40e_pf *pf, char *buf, size_t len) >> +{ >> + u8 dsn[8]; >> + >> + put_unaligned_be64(pci_get_dsn(pf->pdev), dsn); >> + >> + snprintf(buf, len, "%8phD", dsn); >> +} >> + >> +static void i40e_info_fw_mgmt(struct i40e_hw *hw, char *buf, size_t len) >> +{ >> + struct i40e_adminq_info *aq = &hw->aq; >> + >> + snprintf(buf, len, "%u.%u.%05d", >> + aq->fw_maj_ver, aq->fw_min_ver, aq->fw_build); >> +} >> + >> +static void i40e_info_fw_api(struct i40e_hw *hw, char *buf, size_t len) >> +{ >> + struct i40e_adminq_info *aq = &hw->aq; >> + >> + snprintf(buf, len, "%u.%u", aq->api_maj_ver, aq->api_min_ver); >> +} >> + >> +enum i40e_devlink_version_type { >> + I40E_DL_VERSION_RUNNING, >> +}; >> + >> +static int i40e_devlink_info_put(struct devlink_info_req *req, >> + enum i40e_devlink_version_type type, >> + const char *key, const char *value) >> +{ >> + if (!strlen(value)) >> + return 0; >> + >> + switch (type) { >> + case I40E_DL_VERSION_RUNNING: >> + return devlink_info_version_running_put(req, key, value); >> + } >> + return 0; >> +} >> + >> +static int i40e_devlink_info_get(struct devlink *dl, >> + struct devlink_info_req *req, >> + struct netlink_ext_ack *extack) >> +{ >> + struct i40e_pf *pf = devlink_priv(dl); >> + struct i40e_hw *hw = &pf->hw; >> + char buf[32]; >> + int err; >> + >> + i40e_info_get_dsn(pf, buf, sizeof(buf)); >> + err = devlink_info_serial_number_put(req, buf); >> + if (err) >> + return err; >> + >> + i40e_info_fw_mgmt(hw, buf, sizeof(buf)); >> + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, >> + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, buf); >> + if (err) >> + return err; >> + >> + i40e_info_fw_api(hw, buf, sizeof(buf)); >> + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, >> + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API, >> + buf); >> + if (err) >> + return err; >> + >> + i40e_info_nvm_ver(hw, buf, sizeof(buf)); >> + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, >> + DEVLINK_INFO_VERSION_GENERIC_FW_PSID, buf); >> + if (err) >> + return err; >> + >> + i40e_info_eetrack(hw, buf, sizeof(buf)); >> + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, >> + DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID, >> + buf); >> + if (err) >> + return err; >> + >> + i40e_info_civd_ver(hw, buf, sizeof(buf)); >> + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, >> + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, buf); >> + >> + return err; >> +} > > The ice driver created a struct list and loop flow to iterate this. I'm > wondering if it could make sense to extract that logic into devlink > core, so that drivers just need to implement a map between version names > and functions which extract the name. > > It seems like it would be straight forward to implement with a setup, > the list mapping info names to version getters, and a teardown. > > Hmm... > >> + >> static const struct devlink_ops i40e_devlink_ops = { >> + .info_get = i40e_devlink_info_get, >> }; >> >> /** >
diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c b/drivers/net/ethernet/intel/i40e/i40e_devlink.c index 66b7f5be45ae..fb6144d74c98 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c +++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c @@ -5,7 +5,97 @@ #include "i40e.h" #include "i40e_devlink.h" +static void i40e_info_get_dsn(struct i40e_pf *pf, char *buf, size_t len) +{ + u8 dsn[8]; + + put_unaligned_be64(pci_get_dsn(pf->pdev), dsn); + + snprintf(buf, len, "%8phD", dsn); +} + +static void i40e_info_fw_mgmt(struct i40e_hw *hw, char *buf, size_t len) +{ + struct i40e_adminq_info *aq = &hw->aq; + + snprintf(buf, len, "%u.%u.%05d", + aq->fw_maj_ver, aq->fw_min_ver, aq->fw_build); +} + +static void i40e_info_fw_api(struct i40e_hw *hw, char *buf, size_t len) +{ + struct i40e_adminq_info *aq = &hw->aq; + + snprintf(buf, len, "%u.%u", aq->api_maj_ver, aq->api_min_ver); +} + +enum i40e_devlink_version_type { + I40E_DL_VERSION_RUNNING, +}; + +static int i40e_devlink_info_put(struct devlink_info_req *req, + enum i40e_devlink_version_type type, + const char *key, const char *value) +{ + if (!strlen(value)) + return 0; + + switch (type) { + case I40E_DL_VERSION_RUNNING: + return devlink_info_version_running_put(req, key, value); + } + return 0; +} + +static int i40e_devlink_info_get(struct devlink *dl, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct i40e_pf *pf = devlink_priv(dl); + struct i40e_hw *hw = &pf->hw; + char buf[32]; + int err; + + i40e_info_get_dsn(pf, buf, sizeof(buf)); + err = devlink_info_serial_number_put(req, buf); + if (err) + return err; + + i40e_info_fw_mgmt(hw, buf, sizeof(buf)); + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, buf); + if (err) + return err; + + i40e_info_fw_api(hw, buf, sizeof(buf)); + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API, + buf); + if (err) + return err; + + i40e_info_nvm_ver(hw, buf, sizeof(buf)); + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_PSID, buf); + if (err) + return err; + + i40e_info_eetrack(hw, buf, sizeof(buf)); + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID, + buf); + if (err) + return err; + + i40e_info_civd_ver(hw, buf, sizeof(buf)); + err = i40e_devlink_info_put(req, I40E_DL_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, buf); + + return err; +} + static const struct devlink_ops i40e_devlink_ops = { + .info_get = i40e_devlink_info_get, }; /**