diff options
author | Alex Vesker <valex@mellanox.com> | 2018-07-12 15:13:09 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-12 17:37:12 -0700 |
commit | ccadfa444b34c6ec7bb458eee17fdd8c9a456c63 (patch) | |
tree | adb65c4f7fde4d7563889d9f89774c7097c3aaa0 /net/core | |
parent | b16ebe925a4400a2ec3dc663c81dce2fd9bf0998 (diff) | |
download | linux-stable-ccadfa444b34c6ec7bb458eee17fdd8c9a456c63.tar.gz linux-stable-ccadfa444b34c6ec7bb458eee17fdd8c9a456c63.tar.bz2 linux-stable-ccadfa444b34c6ec7bb458eee17fdd8c9a456c63.zip |
devlink: Add callback to query for snapshot id before snapshot create
To restrict the driver with the snapshot ID selection a new callback
is introduced for the driver to get the snapshot ID before creating
a new snapshot. This will also allow giving the same ID for multiple
snapshots taken of different regions on the same time.
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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index cac856136ac6..6c92ddd2465d 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4193,6 +4193,27 @@ void devlink_region_destroy(struct devlink_region *region) } EXPORT_SYMBOL_GPL(devlink_region_destroy); +/** + * devlink_region_shapshot_id_get - get snapshot ID + * + * This callback should be called when adding a new snapshot, + * Driver should use the same id for multiple snapshots taken + * on multiple regions at the same time/by the same trigger. + * + * @devlink: devlink + */ +u32 devlink_region_shapshot_id_get(struct devlink *devlink) +{ + u32 id; + + mutex_lock(&devlink->lock); + id = ++devlink->snapshot_id; + mutex_unlock(&devlink->lock); + + return id; +} +EXPORT_SYMBOL_GPL(devlink_region_shapshot_id_get); + static int __init devlink_module_init(void) { return genl_register_family(&devlink_nl_family); |