devlink: Add support for creating region snapshots

Each device address region can store multiple snapshots,
each snapshot is identified using a different numerical ID.
This ID is used when deleting a snapshot or showing an address
region specific snapshot. This patch exposes a callback to add
a new snapshot to an address region.
The snapshot will be deleted using the destructor function
when destroying a region or when a snapshot delete command
from devlink user tool.

Signed-off-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Alex Vesker 2018-07-12 15:13:10 +03:00 committed by David S. Miller
parent ccadfa444b
commit d7e5272282
2 changed files with 108 additions and 0 deletions

View file

@ -401,6 +401,8 @@ enum devlink_param_generic_id {
struct devlink_region;
typedef void devlink_snapshot_data_dest_t(const void *data);
struct devlink_ops {
int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
int (*port_type_set)(struct devlink_port *devlink_port,
@ -553,6 +555,9 @@ struct devlink_region *devlink_region_create(struct devlink *devlink,
u64 region_size);
void devlink_region_destroy(struct devlink_region *region);
u32 devlink_region_shapshot_id_get(struct devlink *devlink);
int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
u8 *data, u32 snapshot_id,
devlink_snapshot_data_dest_t *data_destructor);
#else
@ -800,6 +805,14 @@ devlink_region_shapshot_id_get(struct devlink *devlink)
return 0;
}
static inline int
devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
u8 *data, u32 snapshot_id,
devlink_snapshot_data_dest_t *data_destructor)
{
return 0;
}
#endif
#endif /* _NET_DEVLINK_H_ */