net: devlink: region: Pass the region ops to the snapshot function

Pass the region to be snapshotted to the function performing the
snapshot. This allows one function to operate on numerous regions.

v4:
Add missing kerneldoc for ICE

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Andrew Lunn 2020-09-18 21:11:02 +02:00 committed by David S. Miller
parent e14e05e71d
commit d4602a9f47
4 changed files with 12 additions and 4 deletions

View File

@ -401,6 +401,7 @@ void ice_devlink_destroy_port(struct ice_pf *pf)
/** /**
* ice_devlink_nvm_snapshot - Capture a snapshot of the Shadow RAM contents * ice_devlink_nvm_snapshot - Capture a snapshot of the Shadow RAM contents
* @devlink: the devlink instance * @devlink: the devlink instance
* @ops: the devlink region being snapshotted
* @extack: extended ACK response structure * @extack: extended ACK response structure
* @data: on exit points to snapshot data buffer * @data: on exit points to snapshot data buffer
* *
@ -413,6 +414,7 @@ void ice_devlink_destroy_port(struct ice_pf *pf)
* error code on failure. * error code on failure.
*/ */
static int ice_devlink_nvm_snapshot(struct devlink *devlink, static int ice_devlink_nvm_snapshot(struct devlink *devlink,
const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack, u8 **data) struct netlink_ext_ack *extack, u8 **data)
{ {
struct ice_pf *pf = devlink_priv(devlink); struct ice_pf *pf = devlink_priv(devlink);
@ -456,6 +458,7 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
/** /**
* ice_devlink_devcaps_snapshot - Capture snapshot of device capabilities * ice_devlink_devcaps_snapshot - Capture snapshot of device capabilities
* @devlink: the devlink instance * @devlink: the devlink instance
* @ops: the devlink region being snapshotted
* @extack: extended ACK response structure * @extack: extended ACK response structure
* @data: on exit points to snapshot data buffer * @data: on exit points to snapshot data buffer
* *
@ -468,6 +471,7 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
*/ */
static int static int
ice_devlink_devcaps_snapshot(struct devlink *devlink, ice_devlink_devcaps_snapshot(struct devlink *devlink,
const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack, u8 **data) struct netlink_ext_ack *extack, u8 **data)
{ {
struct ice_pf *pf = devlink_priv(devlink); struct ice_pf *pf = devlink_priv(devlink);

View File

@ -40,7 +40,9 @@ static struct dentry *nsim_dev_ddir;
#define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32) #define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32)
static int static int
nsim_dev_take_snapshot(struct devlink *devlink, struct netlink_ext_ack *extack, nsim_dev_take_snapshot(struct devlink *devlink,
const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack,
u8 **data) u8 **data)
{ {
void *dummy_data; void *dummy_data;
@ -68,7 +70,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
devlink = priv_to_devlink(nsim_dev); devlink = priv_to_devlink(nsim_dev);
err = nsim_dev_take_snapshot(devlink, NULL, &dummy_data); err = nsim_dev_take_snapshot(devlink, NULL, NULL, &dummy_data);
if (err) if (err)
return err; return err;

View File

@ -566,7 +566,9 @@ struct devlink_info_req;
struct devlink_region_ops { struct devlink_region_ops {
const char *name; const char *name;
void (*destructor)(const void *data); void (*destructor)(const void *data);
int (*snapshot)(struct devlink *devlink, struct netlink_ext_ack *extack, int (*snapshot)(struct devlink *devlink,
const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack,
u8 **data); u8 **data);
void *priv; void *priv;
}; };

View File

@ -4347,7 +4347,7 @@ devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
} }
} }
err = region->ops->snapshot(devlink, info->extack, &data); err = region->ops->snapshot(devlink, region->ops, info->extack, &data);
if (err) if (err)
goto err_snapshot_capture; goto err_snapshot_capture;