[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190116052356.18086-7-jakub.kicinski@netronome.com>
Date: Tue, 15 Jan 2019 21:23:55 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, jiri@...nulli.us, f.fainelli@...il.com,
andrew@...n.ch, mkubecek@...e.cz, eugenem@...com,
jonathan.lemon@...il.com, oss-drivers@...ronome.com,
Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [RFC net-next v2 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 | 73 +++++++++++++++++++
include/net/devlink.h | 7 ++
2 files changed, 80 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 63b2fa37256c..e3d23724a37c 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -207,11 +207,54 @@ nfp_devlink_versions_get_hwinfo(struct nfp_pf *pf, struct devlink_info_req *req)
return 0;
}
+static const struct nfp_devlink_versions {
+ enum nfp_nsp_versions id;
+ const char *key;
+} nfp_devlink_versions_nsp[] = {
+ { NFP_VERSIONS_BSP, DEVLINK_VERSION_GENERIC_FW_MGMT, },
+ { NFP_VERSIONS_CPLD, "fw.cpld", },
+ { NFP_VERSIONS_APP, DEVLINK_VERSION_GENERIC_FW_APP, },
+};
+
+static int
+nfp_devlink_versions_get_nsp(struct devlink_info_req *req, bool flash,
+ const u8 *buf, unsigned int size)
+{
+ enum devlink_version_type type;
+ unsigned int i;
+ int err;
+
+ type = flash ? DEVLINK_VERSION_STORED : DEVLINK_VERSION_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_info_report_version(req, type,
+ info->key, version);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int
nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
struct netlink_ext_ack *extack)
{
struct nfp_pf *pf = devlink_priv(devlink);
+ struct nfp_nsp *nsp;
const char *sn;
int err;
@@ -226,7 +269,37 @@ nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
return err;
}
+ nsp = nfp_nsp_open(pf->cpp);
+ if (IS_ERR(nsp)) {
+ NL_SET_ERR_MSG_MOD(extack, "can't access NSP");
+ return PTR_ERR(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(req, false,
+ buf, sizeof(buf));
+ if (err)
+ goto err_close_nsp;
+
+ err = nfp_devlink_versions_get_nsp(req, true,
+ buf, sizeof(buf));
+ if (err)
+ goto err_close_nsp;
+ }
+
+ nfp_nsp_close(nsp);
+
return nfp_devlink_versions_get_hwinfo(pf, req);
+
+err_close_nsp:
+ nfp_nsp_close(nsp);
+ return err;
}
const struct devlink_ops nfp_devlink_ops = {
diff --git a/include/net/devlink.h b/include/net/devlink.h
index dc08301028a9..9270f1a21f08 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -424,6 +424,13 @@ enum devlink_param_generic_id {
/* Revision of board design */
#define DEVLINK_VERSION_GENERIC_BOARD_REV "board.rev"
+/* Control processor FW version, FW is responsible for house keeping tasks,
+ * PHY control etc.
+ */
+#define DEVLINK_VERSION_GENERIC_FW_MGMT "fw.mgmt"
+/* Data path microcode controlling high-speed packet processing */
+#define DEVLINK_VERSION_GENERIC_FW_APP "fw.app"
+
enum devlink_version_type {
DEVLINK_VERSION_FIXED,
DEVLINK_VERSION_STORED,
--
2.19.2
Powered by blists - more mailing lists