1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

devlink: collect flash notify params into a struct

The dev flash status notify function parameter lists are getting
rather long, so add a struct to be filled and passed rather than
continuously changing the function signatures.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Shannon Nelson 2020-09-17 18:13:24 -07:00 committed by David S. Miller
parent f92970c694
commit 6700acc5f1
2 changed files with 50 additions and 23 deletions

View file

@ -391,6 +391,25 @@ struct devlink_param_gset_ctx {
enum devlink_param_cmode cmode; enum devlink_param_cmode cmode;
}; };
/**
* struct devlink_flash_notify - devlink dev flash notify data
* @status_msg: current status string
* @component: firmware component being updated
* @done: amount of work completed of total amount
* @total: amount of work expected to be done
* @timeout: expected max timeout in seconds
*
* These are values to be given to userland to be displayed in order
* to show current activity in a firmware update process.
*/
struct devlink_flash_notify {
const char *status_msg;
const char *component;
unsigned long done;
unsigned long total;
unsigned long timeout;
};
/** /**
* struct devlink_param - devlink configuration parameter data * struct devlink_param - devlink configuration parameter data
* @name: name of the parameter * @name: name of the parameter

View file

@ -3022,11 +3022,7 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
static int devlink_nl_flash_update_fill(struct sk_buff *msg, static int devlink_nl_flash_update_fill(struct sk_buff *msg,
struct devlink *devlink, struct devlink *devlink,
enum devlink_command cmd, enum devlink_command cmd,
const char *status_msg, struct devlink_flash_notify *params)
const char *component,
unsigned long done,
unsigned long total,
unsigned long timeout)
{ {
void *hdr; void *hdr;
@ -3040,22 +3036,22 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg,
if (cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS) if (cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS)
goto out; goto out;
if (status_msg && if (params->status_msg &&
nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG, nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG,
status_msg)) params->status_msg))
goto nla_put_failure; goto nla_put_failure;
if (component && if (params->component &&
nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,
component)) params->component))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE, if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE,
done, DEVLINK_ATTR_PAD)) params->done, DEVLINK_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL, if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL,
total, DEVLINK_ATTR_PAD)) params->total, DEVLINK_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT,
timeout, DEVLINK_ATTR_PAD)) params->timeout, DEVLINK_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
out: out:
@ -3069,11 +3065,7 @@ nla_put_failure:
static void __devlink_flash_update_notify(struct devlink *devlink, static void __devlink_flash_update_notify(struct devlink *devlink,
enum devlink_command cmd, enum devlink_command cmd,
const char *status_msg, struct devlink_flash_notify *params)
const char *component,
unsigned long done,
unsigned long total,
unsigned long timeout)
{ {
struct sk_buff *msg; struct sk_buff *msg;
int err; int err;
@ -3086,8 +3078,7 @@ static void __devlink_flash_update_notify(struct devlink *devlink,
if (!msg) if (!msg)
return; return;
err = devlink_nl_flash_update_fill(msg, devlink, cmd, status_msg, err = devlink_nl_flash_update_fill(msg, devlink, cmd, params);
component, done, total, timeout);
if (err) if (err)
goto out_free_msg; goto out_free_msg;
@ -3101,17 +3092,21 @@ out_free_msg:
void devlink_flash_update_begin_notify(struct devlink *devlink) void devlink_flash_update_begin_notify(struct devlink *devlink)
{ {
struct devlink_flash_notify params = { 0 };
__devlink_flash_update_notify(devlink, __devlink_flash_update_notify(devlink,
DEVLINK_CMD_FLASH_UPDATE, DEVLINK_CMD_FLASH_UPDATE,
NULL, NULL, 0, 0, 0); &params);
} }
EXPORT_SYMBOL_GPL(devlink_flash_update_begin_notify); EXPORT_SYMBOL_GPL(devlink_flash_update_begin_notify);
void devlink_flash_update_end_notify(struct devlink *devlink) void devlink_flash_update_end_notify(struct devlink *devlink)
{ {
struct devlink_flash_notify params = { 0 };
__devlink_flash_update_notify(devlink, __devlink_flash_update_notify(devlink,
DEVLINK_CMD_FLASH_UPDATE_END, DEVLINK_CMD_FLASH_UPDATE_END,
NULL, NULL, 0, 0, 0); &params);
} }
EXPORT_SYMBOL_GPL(devlink_flash_update_end_notify); EXPORT_SYMBOL_GPL(devlink_flash_update_end_notify);
@ -3121,9 +3116,16 @@ void devlink_flash_update_status_notify(struct devlink *devlink,
unsigned long done, unsigned long done,
unsigned long total) unsigned long total)
{ {
struct devlink_flash_notify params = {
.status_msg = status_msg,
.component = component,
.done = done,
.total = total,
};
__devlink_flash_update_notify(devlink, __devlink_flash_update_notify(devlink,
DEVLINK_CMD_FLASH_UPDATE_STATUS, DEVLINK_CMD_FLASH_UPDATE_STATUS,
status_msg, component, done, total, 0); &params);
} }
EXPORT_SYMBOL_GPL(devlink_flash_update_status_notify); EXPORT_SYMBOL_GPL(devlink_flash_update_status_notify);
@ -3132,9 +3134,15 @@ void devlink_flash_update_timeout_notify(struct devlink *devlink,
const char *component, const char *component,
unsigned long timeout) unsigned long timeout)
{ {
struct devlink_flash_notify params = {
.status_msg = status_msg,
.component = component,
.timeout = timeout,
};
__devlink_flash_update_notify(devlink, __devlink_flash_update_notify(devlink,
DEVLINK_CMD_FLASH_UPDATE_STATUS, DEVLINK_CMD_FLASH_UPDATE_STATUS,
status_msg, component, 0, 0, timeout); &params);
} }
EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify); EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify);