[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190115005009.16025-7-jakub.kicinski@netronome.com>
Date: Mon, 14 Jan 2019 16:50:08 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, oss-drivers@...ronome.com,
jiri@...nulli.us, Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [RFC net-next 6/6] nfp: devlink: report the running and flashed versions
Report versions of firmware components using the new NSP command.
Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
---
.../net/ethernet/netronome/nfp/nfp_devlink.c | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index c7759564316d..a0a8c6232827 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -236,6 +236,48 @@ nfp_devlink_versions_get_hwinfo(struct sk_buff *skb, struct nfp_nsp *nsp,
return 0;
}
+static const struct nfp_devlink_versions {
+ enum nfp_nsp_versions id;
+ const char *key;
+} nfp_devlink_versions_nsp[] = {
+ { NFP_VERSIONS_BSP, "fw.mgmt", },
+ { NFP_VERSIONS_CPLD, "fw.cpld", },
+ { NFP_VERSIONS_APP, "fw.app", },
+};
+
+static int
+nfp_devlink_versions_get_nsp(struct sk_buff *skb, bool flash,
+ const u8 *buf, unsigned int size)
+{
+ unsigned int i;
+ int attr;
+ int err;
+
+ attr = flash ? DEVLINK_ATTR_INFO_VERSIONS_STORED :
+ DEVLINK_ATTR_INFO_VERSIONS_RUNNING;
+
+ for (i = 0; i < ARRAY_SIZE(nfp_devlink_versions_nsp); i++) {
+ const struct nfp_devlink_versions *info;
+ const char *version;
+
+ info = &nfp_devlink_versions_nsp[i];
+
+ version = nfp_nsp_versions_get(info->id, flash, buf, size);
+ if (IS_ERR(version)) {
+ if (PTR_ERR(version) == -ENOENT)
+ continue;
+ else
+ return PTR_ERR(version);
+ }
+
+ err = devlink_versions_report(skb, attr, info->key, version);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int
nfp_devlink_versions_get(struct devlink *devlink, struct sk_buff *skb,
struct netlink_ext_ack *extack)
@@ -254,6 +296,24 @@ nfp_devlink_versions_get(struct devlink *devlink, struct sk_buff *skb,
if (err)
goto err_close_nsp;
+ if (nfp_nsp_has_versions(nsp)) {
+ char buf[512] = {};
+
+ err = nfp_nsp_versions(nsp, buf, sizeof(buf));
+ if (err)
+ goto err_close_nsp;
+
+ err = nfp_devlink_versions_get_nsp(skb, false,
+ buf, sizeof(buf));
+ if (err)
+ goto err_close_nsp;
+
+ err = nfp_devlink_versions_get_nsp(skb, true,
+ buf, sizeof(buf));
+ if (err)
+ goto err_close_nsp;
+ }
+
nfp_nsp_close(nsp);
return 0;
--
2.19.2
Powered by blists - more mailing lists