Skip to contentSkip to conversation

devlink: add commands to query flash and reload support

RFC PATCH In review Jacob Keller 2 participants 3 messages Jul 14, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 devlink: add commands to query flash and reload support

Most devlink commands operate on objects, such as regions, devices for information, etc. These commands have non-destructive operations that can confirm whether a given device supports some operation.

The DEVLINK_CMD_FLASH_UPDATE and DEVLINK_CMD_RELOAD do not have any non-destructive way to check if a given device supports the operation. A user must issue a command that could have consequences to determine whether support is available.

In some cases a user (or script!) might want to know whether a flash update or driver reload is possible without actually triggering it yet. In addition, users might want to be aware of what options a driver supports for these commands.

To allow this, introduce DEVLINK_CMD_FLASH_SUPPORT and DEVLINK_CMD_RELOAD_SUPPORT. These commands query the driver support for these operations and return a message indicating if there is support, and also what flags the driver supports.

For flash update, we return whether or not the driver accepts per-component updates, and whether or not the driver accepts overwrite mask settings.

For reload, we return the reload actions supported and the reload limits supported.

This allows querying the capability of these functions without triggering any side effects.

---
I'm not sure if this is the best direction to go for implementing this. At first I considered a single "DEVINK_CMD_SUPPORT" or similar which could return a large list of every operation type that could be handled by the driver. It turns out this is not that useful for most operations because there already exist non-destructive queries like _GET

However, this implementation basically requires us to always remember to update the support query and its not really tied explicitly to the command implementation. These could diverge over time.

I still think it's valuable because a system administrator may want to be able to tell whether or not an operation will succeed before potentially triggering it, especially in scripts. I've been asked a few times by some of the folks here "how do I tell if the device supports flash update?" and I've had to say "well, you try it, and if it fails you know it doesn't!"

Technically in some cases we can sort of fake a query by issuing something like a flash update with invalid file parameters. A user might be able to tell based on the feedback of the error code. This relies on the order of the checks and could fail if we ever refactored to make the command validate file name first.

In addition, there's no simple way to just query "what all actions does this driver support?" etc.

I think the ability to query the support for these commands is very useful. I am not totally convinced that this is the best implementation, since it really makes it easy to forget to update the _SUPPORT command when we add new attributes in the future.

Thoughts?

 include/uapi/linux/devlink.h |   6 +
 net/core/devlink.c           | 237 +++++++++++++++++++++++++++++++++++
 2 files changed, 243 insertions(+)
include/uapi/linux/devlink.h +6 -0
index 32f53a0069d6..c886d939d29d 100644
@@ -131,6 +131,9 @@ enum devlink_command {
 	DEVLINK_CMD_RATE_NEW,
 	DEVLINK_CMD_RATE_DEL,
 
+	DEVLINK_CMD_FLASH_SUPPORT,	/* can dump */
+	DEVLINK_CMD_RELOAD_SUPPORT,	/* can dump */
+
 	/* add new commands above here */
 	__DEVLINK_CMD_MAX,
 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@@ -551,6 +554,9 @@ enum devlink_attr {
 	DEVLINK_ATTR_RATE_NODE_NAME,		/* string */
 	DEVLINK_ATTR_RATE_PARENT_NODE_NAME,	/* string */
 
+	DEVLINK_ATTR_FLASH_SUPPORT_COMPONENT,		/* flag */
+	DEVLINK_ATTR_FLASH_SUPPORT_OVERWRITE_MASK,	/* flag */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
net/core/devlink.c +237 -0

261 lines not on this page · raw message

base-commit: 5e437416ff66981d8154687cfdf7de50b1d82bfc

Signature · 1 line
2.31.1.331.gb0c09ab8796f
#1 lore raw
Quoted 1 line

I'm not sure if this is the best direction to go for implementing this.

Hi Jacob

Maybe add a --dry-run option? That would allow the driver to also read the firmware file, make sure it can parse it, it fits the actual hardware, and the CRC is O.K, etc.

We just need to make sure that if it fails with -EOPNOTSUPP, is it clear if --dry-run itself is not supported, or the operation is not supported. extack should help with that.

Andrew

#2 lore raw
Quoted 19 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Wednesday, July 14, 2021 1:26 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]; Jakub Kicinski <[email protected]>; Jiri Pirko <[email protected]>
Subject: Re: [PATCH net-next RFC] devlink: add commands to query flash and reload support

Quoted 1 line

I'm not sure if this is the best direction to go for implementing this.

Hi Jacob

Maybe add a --dry-run option? That would allow the driver to also read the firmware file, make sure it can parse it, it fits the actual hardware, and the CRC is O.K, etc.

Quoted 5 lines

We just need to make sure that if it fails with -EOPNOTSUPP, is it clear if --dry-run itself is not supported, or the operation is not supported. extack should help with that.

Andrew

That approach could be useful. It doesn't give an easy way to dump all of the supported flags, but that's not super critical. I think a dry-run makes a lot of sense for flash update.

I can go that approach for these two and see how it turns out.

Thanks,
Jake