Commit f92970c6 authored by Shannon Nelson's avatar Shannon Nelson Committed by David S. Miller
Browse files

devlink: add timeout information to status_notify



Add a timeout element to the DEVLINK_CMD_FLASH_UPDATE_STATUS
netlink message for use by a userland utility to show that
a particular firmware flash activity may take a long but
bounded time to finish.  Also add a handy helper for drivers
to make use of the new timeout value.

UI usage hints:
 - if non-zero, add timeout display to the end of the status line
 	[component] status_msg  ( Xm Ys : Am Bs )
     using the timeout value for Am Bs and updating the Xm Ys
     every second
 - if the timeout expires while awaiting the next update,
   display something like
 	[component] status_msg  ( timeout reached : Am Bs )
 - if new status notify messages are received, remove
   the timeout and start over

Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e4be9e5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1403,6 +1403,10 @@ void devlink_flash_update_status_notify(struct devlink *devlink,
					const char *component,
					unsigned long done,
					unsigned long total);
void devlink_flash_update_timeout_notify(struct devlink *devlink,
					 const char *status_msg,
					 const char *component,
					 unsigned long timeout);

int devlink_traps_register(struct devlink *devlink,
			   const struct devlink_trap *traps,
+3 −0
Original line number Diff line number Diff line
@@ -462,6 +462,9 @@ enum devlink_attr {

	DEVLINK_ATTR_PORT_EXTERNAL,		/* u8 */
	DEVLINK_ATTR_PORT_CONTROLLER_NUMBER,	/* u32 */

	DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT,	/* u64 */

	/* add new attributes above here, update the policy in devlink.c */

	__DEVLINK_ATTR_MAX,
+23 −6
Original line number Diff line number Diff line
@@ -3024,7 +3024,9 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg,
					enum devlink_command cmd,
					const char *status_msg,
					const char *component,
					unsigned long done, unsigned long total)
					unsigned long done,
					unsigned long total,
					unsigned long timeout)
{
	void *hdr;

@@ -3052,6 +3054,9 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg,
	if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL,
			      total, DEVLINK_ATTR_PAD))
		goto nla_put_failure;
	if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT,
			      timeout, DEVLINK_ATTR_PAD))
		goto nla_put_failure;

out:
	genlmsg_end(msg, hdr);
@@ -3067,7 +3072,8 @@ static void __devlink_flash_update_notify(struct devlink *devlink,
					  const char *status_msg,
					  const char *component,
					  unsigned long done,
					  unsigned long total)
					  unsigned long total,
					  unsigned long timeout)
{
	struct sk_buff *msg;
	int err;
@@ -3081,7 +3087,7 @@ static void __devlink_flash_update_notify(struct devlink *devlink,
		return;

	err = devlink_nl_flash_update_fill(msg, devlink, cmd, status_msg,
					   component, done, total);
					   component, done, total, timeout);
	if (err)
		goto out_free_msg;

@@ -3097,7 +3103,7 @@ void devlink_flash_update_begin_notify(struct devlink *devlink)
{
	__devlink_flash_update_notify(devlink,
				      DEVLINK_CMD_FLASH_UPDATE,
				      NULL, NULL, 0, 0);
				      NULL, NULL, 0, 0, 0);
}
EXPORT_SYMBOL_GPL(devlink_flash_update_begin_notify);

@@ -3105,7 +3111,7 @@ void devlink_flash_update_end_notify(struct devlink *devlink)
{
	__devlink_flash_update_notify(devlink,
				      DEVLINK_CMD_FLASH_UPDATE_END,
				      NULL, NULL, 0, 0);
				      NULL, NULL, 0, 0, 0);
}
EXPORT_SYMBOL_GPL(devlink_flash_update_end_notify);

@@ -3117,10 +3123,21 @@ void devlink_flash_update_status_notify(struct devlink *devlink,
{
	__devlink_flash_update_notify(devlink,
				      DEVLINK_CMD_FLASH_UPDATE_STATUS,
				      status_msg, component, done, total);
				      status_msg, component, done, total, 0);
}
EXPORT_SYMBOL_GPL(devlink_flash_update_status_notify);

void devlink_flash_update_timeout_notify(struct devlink *devlink,
					 const char *status_msg,
					 const char *component,
					 unsigned long timeout)
{
	__devlink_flash_update_notify(devlink,
				      DEVLINK_CMD_FLASH_UPDATE_STATUS,
				      status_msg, component, 0, 0, timeout);
}
EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify);

static int devlink_nl_cmd_flash_update(struct sk_buff *skb,
				       struct genl_info *info)
{