diff options
author | Alex Vesker <valex@mellanox.com> | 2018-07-12 08:13:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-12 20:37:12 -0400 |
commit | ccadfa444b34c6ec7bb458eee17fdd8c9a456c63 (patch) | |
tree | adb65c4f7fde4d7563889d9f89774c7097c3aaa0 /net/core/devlink.c | |
parent | b16ebe925a4400a2ec3dc663c81dce2fd9bf0998 (diff) |
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/devlink.c')
-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) | |||
4193 | } | 4193 | } |
4194 | EXPORT_SYMBOL_GPL(devlink_region_destroy); | 4194 | EXPORT_SYMBOL_GPL(devlink_region_destroy); |
4195 | 4195 | ||
4196 | /** | ||
4197 | * devlink_region_shapshot_id_get - get snapshot ID | ||
4198 | * | ||
4199 | * This callback should be called when adding a new snapshot, | ||
4200 | * Driver should use the same id for multiple snapshots taken | ||
4201 | * on multiple regions at the same time/by the same trigger. | ||
4202 | * | ||
4203 | * @devlink: devlink | ||
4204 | */ | ||
4205 | u32 devlink_region_shapshot_id_get(struct devlink *devlink) | ||
4206 | { | ||
4207 | u32 id; | ||
4208 | |||
4209 | mutex_lock(&devlink->lock); | ||
4210 | id = ++devlink->snapshot_id; | ||
4211 | mutex_unlock(&devlink->lock); | ||
4212 | |||
4213 | return id; | ||
4214 | } | ||
4215 | EXPORT_SYMBOL_GPL(devlink_region_shapshot_id_get); | ||
4216 | |||
4196 | static int __init devlink_module_init(void) | 4217 | static int __init devlink_module_init(void) |
4197 | { | 4218 | { |
4198 | return genl_register_family(&devlink_nl_family); | 4219 | return genl_register_family(&devlink_nl_family); |