lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190115005009.16025-5-jakub.kicinski@netronome.com>
Date:   Mon, 14 Jan 2019 16:50:06 -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 4/6] nfp: devlink: report fixed versions

For now we only use HWinfo for fixed versions.

Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
---
 .../net/ethernet/netronome/nfp/nfp_devlink.c  | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 4422da939937..c7759564316d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -192,6 +192,77 @@ nfp_devlink_serial_get(struct devlink *devlink, u8 *buf, size_t buf_len,
 	return 0;
 }
 
+static const struct nfp_devlink_versions_simple {
+	const char *key;
+	const char *hwinfo;
+} nfp_devlink_versions_hwinfo[] = {
+	{ "board.model",	"assembly.model", },
+	{ "board.partno",	"assembly.partno", },
+	{ "board.revision",	"assembly.revision", },
+	{ "board.vendor",	"assembly.vendor", },
+};
+
+static int
+nfp_devlink_versions_get_hwinfo(struct sk_buff *skb, struct nfp_nsp *nsp,
+				struct netlink_ext_ack *extack)
+{
+	unsigned int i;
+	int attr;
+	int err;
+
+	attr = DEVLINK_ATTR_INFO_VERSIONS_FIXED;
+
+	for (i = 0; i < ARRAY_SIZE(nfp_devlink_versions_hwinfo); i++) {
+		const struct nfp_devlink_versions_simple *info;
+		char buf[256] = {};
+
+		info = &nfp_devlink_versions_hwinfo[i];
+		strcpy(buf, info->hwinfo);
+
+		err = nfp_nsp_hwinfo_lookup(nsp, buf, sizeof(buf));
+		if (err == -ENOENT)
+			continue;
+		if (err) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "error reading versions string from FW");
+			return err;
+		}
+
+		err = devlink_versions_report(skb, attr, info->key, buf);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+static int
+nfp_devlink_versions_get(struct devlink *devlink, struct sk_buff *skb,
+			 struct netlink_ext_ack *extack)
+{
+	struct nfp_pf *pf = devlink_priv(devlink);
+	struct nfp_nsp *nsp;
+	int 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);
+	}
+
+	err = nfp_devlink_versions_get_hwinfo(skb, nsp, extack);
+	if (err)
+		goto err_close_nsp;
+
+	nfp_nsp_close(nsp);
+
+	return 0;
+
+err_close_nsp:
+	nfp_nsp_close(nsp);
+	return err;
+}
+
 const struct devlink_ops nfp_devlink_ops = {
 	.port_split		= nfp_devlink_port_split,
 	.port_unsplit		= nfp_devlink_port_unsplit,
@@ -200,6 +271,7 @@ const struct devlink_ops nfp_devlink_ops = {
 	.eswitch_mode_get	= nfp_devlink_eswitch_mode_get,
 	.eswitch_mode_set	= nfp_devlink_eswitch_mode_set,
 	.serial_get		= nfp_devlink_serial_get,
+	.versions_get		= nfp_devlink_versions_get,
 };
 
 int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
-- 
2.19.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ