]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
devlink: Add callback to query for snapshot id before snapshot create
authorAlex Vesker <valex@mellanox.com>
Thu, 12 Jul 2018 12:13:09 +0000 (15:13 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 13 Jul 2018 00:37:12 +0000 (17:37 -0700)
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>
include/net/devlink.h
net/core/devlink.c

index e5397652f2fb100ad38cd79f03ea5ac716d9dc50..f27d8593687a445184ef2be5cc340cdc59aaa148 100644 (file)
@@ -29,6 +29,7 @@ struct devlink {
        struct list_head resource_list;
        struct list_head param_list;
        struct list_head region_list;
+       u32 snapshot_id;
        struct devlink_dpipe_headers *dpipe_headers;
        const struct devlink_ops *ops;
        struct device *dev;
@@ -551,6 +552,7 @@ struct devlink_region *devlink_region_create(struct devlink *devlink,
                                             u32 region_max_snapshots,
                                             u64 region_size);
 void devlink_region_destroy(struct devlink_region *region);
+u32 devlink_region_shapshot_id_get(struct devlink *devlink);
 
 #else
 
@@ -792,6 +794,12 @@ devlink_region_destroy(struct devlink_region *region)
 {
 }
 
+static inline u32
+devlink_region_shapshot_id_get(struct devlink *devlink)
+{
+       return 0;
+}
+
 #endif
 
 #endif /* _NET_DEVLINK_H_ */
index cac856136ac65b4e176bdbc0eb84fcd856c294ee..6c92ddd2465da9c3dd8fb52091b8d7f8076e465c 100644 (file)
@@ -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);