From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
jiri@resnulli.us, andrew@lunn.ch, f.fainelli@gmail.com,
mkubecek@suse.cz, eugenem@fb.com, jonathan.lemon@gmail.com,
Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 2/7] devlink: add version reporting to devlink info API
Date: Mon, 28 Jan 2019 19:34:15 -0800 [thread overview]
Message-ID: <20190129033420.27235-3-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20190129033420.27235-1-jakub.kicinski@netronome.com>
ethtool -i has a few fixed-size fields which can be used to report
firmware version and expansion ROM version. Unfortunately, modern
hardware has more firmware components. There is usually some
datapath microcode, management controller, PXE drivers, and a
CPLD load. Running ethtool -i on modern controllers reveals the
fact that vendors cram multiple values into firmware version field.
Here are some examples from systems I could lay my hands on quickly:
tg3: "FFV20.2.17 bc 5720-v1.39"
i40e: "6.01 0x800034a4 1.1747.0"
nfp: "0.0.3.5 0.25 sriov-2.1.16 nic"
Add a new devlink API to allow retrieving multiple versions, and
provide user-readable name for those versions.
While at it break down the versions into three categories:
- fixed - this is the board/fixed component version, usually vendors
report information like the board version in the PCI VPD,
but it will benefit from naming and common API as well;
- running - this is the running firmware version;
- stored - this is firmware in the flash, after firmware update
this value will reflect the flashed version, while the
running version may only be updated after reboot.
RFCv2:
- remove the nesting in attr DEVLINK_ATTR_INFO_VERSIONS (now
versions are mixed with other info attrs)l
- have the driver report versions from the same callback as
other info.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
include/net/devlink.h | 18 ++++++++++++++++
include/uapi/linux/devlink.h | 5 +++++
net/core/devlink.c | 40 ++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index d8d425028d55..f53ace3ac4b3 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -419,6 +419,12 @@ enum devlink_param_generic_id {
.validate = _validate, \
}
+enum devlink_version_type {
+ DEVLINK_VERSION_FIXED,
+ DEVLINK_VERSION_STORED,
+ DEVLINK_VERSION_RUNNING,
+};
+
struct devlink_region;
struct devlink_info_req;
@@ -590,6 +596,10 @@ int devlink_info_report_serial_number(struct devlink_info_req *req,
const char *sn);
int devlink_info_report_driver_name(struct devlink_info_req *req,
const char *name);
+int devlink_info_report_version(struct devlink_info_req *req,
+ enum devlink_version_type type,
+ const char *version_name,
+ const char *version_value);
#else
@@ -862,6 +872,14 @@ devlink_info_report_serial_number(struct devlink_info_req *req, const char *sn)
{
return 0;
}
+
+static inline int
+devlink_info_report_version(struct devlink_info_req *req,
+ enum devlink_version_type type,
+ const char *version_name, const char *version_value)
+{
+ return 0;
+}
#endif
#endif /* _NET_DEVLINK_H_ */
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index c4b5d923f59f..e8d449a203ec 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -289,6 +289,11 @@ enum devlink_attr {
DEVLINK_ATTR_INFO_DRV_NAME, /* string */
DEVLINK_ATTR_INFO_SERIAL_NUMBER, /* string */
+ DEVLINK_ATTR_INFO_VERSION_FIXED, /* nested */
+ DEVLINK_ATTR_INFO_VERSION_RUNNING, /* nested */
+ DEVLINK_ATTR_INFO_VERSION_STORED, /* nested */
+ DEVLINK_ATTR_INFO_VERSION_NAME, /* string */
+ DEVLINK_ATTR_INFO_VERSION_VALUE, /* string */
/* add new attributes above here, update the policy in devlink.c */
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 844e086ff038..f0c5f9bd96b7 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -3615,6 +3615,46 @@ int devlink_info_report_serial_number(struct devlink_info_req *req,
}
EXPORT_SYMBOL_GPL(devlink_info_report_serial_number);
+int devlink_info_report_version(struct devlink_info_req *req,
+ enum devlink_version_type type,
+ const char *version_name,
+ const char *version_value)
+{
+ static const enum devlink_attr type2attr[] = {
+ [DEVLINK_VERSION_FIXED] = DEVLINK_ATTR_INFO_VERSION_FIXED,
+ [DEVLINK_VERSION_STORED] = DEVLINK_ATTR_INFO_VERSION_STORED,
+ [DEVLINK_VERSION_RUNNING] = DEVLINK_ATTR_INFO_VERSION_RUNNING,
+ };
+ struct nlattr *nest;
+ int err;
+
+ if (type >= ARRAY_SIZE(type2attr) || !type2attr[type])
+ return -EINVAL;
+
+ nest = nla_nest_start(req->msg, type2attr[type]);
+ if (!nest)
+ return -EMSGSIZE;
+
+ err = nla_put_string(req->msg, DEVLINK_ATTR_INFO_VERSION_NAME,
+ version_name);
+ if (err)
+ goto nla_put_failure;
+
+ err = nla_put_string(req->msg, DEVLINK_ATTR_INFO_VERSION_VALUE,
+ version_value);
+ if (err)
+ goto nla_put_failure;
+
+ nla_nest_end(req->msg, nest);
+
+ return 0;
+
+nla_put_failure:
+ nla_nest_cancel(req->msg, nest);
+ return err;
+}
+EXPORT_SYMBOL_GPL(devlink_info_report_version);
+
static int
devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink,
enum devlink_command cmd, u32 portid,
--
2.19.2
next prev parent reply other threads:[~2019-01-29 3:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 3:34 [PATCH net-next 0/7] devlink: add device (driver) information API Jakub Kicinski
2019-01-29 3:34 ` [PATCH net-next 1/7] devlink: add device " Jakub Kicinski
2019-01-29 3:34 ` Jakub Kicinski [this message]
2019-01-29 3:34 ` [PATCH net-next 3/7] nfp: devlink: report driver name and serial number Jakub Kicinski
2019-01-29 3:34 ` [PATCH net-next 4/7] nfp: devlink: report fixed versions Jakub Kicinski
2019-01-29 3:34 ` [PATCH net-next 5/7] nfp: nsp: add support for versions command Jakub Kicinski
2019-01-29 3:34 ` [PATCH net-next 6/7] nfp: devlink: report the running and flashed versions Jakub Kicinski
2019-01-29 3:34 ` [PATCH net-next 7/7] ethtool: add compat for devlink info Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190129033420.27235-3-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=eugenem@fb.com \
--cc=f.fainelli@gmail.com \
--cc=jiri@resnulli.us \
--cc=jonathan.lemon@gmail.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).