netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Vesker <valex@mellanox.com>
To: netdev@vger.kernel.org, jiri@mellanox.com
Cc: dsahern@gmail.com, andrew@lunn.ch, rahul.lakkireddy@chelsio.com,
	jakub.kicinski@netronome.com, Alex Vesker <valex@mellanox.com>
Subject: [PATCH net-next v3 02/11] devlink: Add callback to query for snapshot id before snapshot create
Date: Thu, 12 Jul 2018 15:13:09 +0300	[thread overview]
Message-ID: <1531397598-11207-3-git-send-email-valex@mellanox.com> (raw)
In-Reply-To: <1531397598-11207-1-git-send-email-valex@mellanox.com>

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>
---
 include/net/devlink.h |  8 ++++++++
 net/core/devlink.c    | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index e539765..f27d859 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -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 @@ static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
 {
 }
 
+static inline u32
+devlink_region_shapshot_id_get(struct devlink *devlink)
+{
+	return 0;
+}
+
 #endif
 
 #endif /* _NET_DEVLINK_H_ */
diff --git a/net/core/devlink.c b/net/core/devlink.c
index cac8561..6c92ddd 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);
-- 
1.8.3.1

  parent reply	other threads:[~2018-07-12 12:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 12:13 [PATCH net-next v3 00/11] devlink: Add support for region access Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 01/11] devlink: Add support for creating and destroying regions Alex Vesker
2018-07-12 12:13 ` Alex Vesker [this message]
2018-07-13  0:51   ` [PATCH net-next v3 02/11] devlink: Add callback to query for snapshot id before snapshot create Jakub Kicinski
2018-07-15  7:43     ` Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 03/11] devlink: Add support for creating region snapshots Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 04/11] devlink: Add support for region get command Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 05/11] devlink: Extend the support querying for region snapshot IDs Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 06/11] devlink: Add support for region snapshot delete command Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 07/11] devlink: Add support for region snapshot read command Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 08/11] net/mlx4_core: Add health buffer address capability Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 09/11] net/mlx4_core: Add Crdump FW snapshot support Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 10/11] devlink: Add generic parameters region_snapshot Alex Vesker
2018-07-12 12:13 ` [PATCH net-next v3 11/11] net/mlx4_core: Use devlink region_snapshot parameter Alex Vesker
2018-07-13  0:37 ` [PATCH net-next v3 00/11] devlink: Add support for region access David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531397598-11207-3-git-send-email-valex@mellanox.com \
    --to=valex@mellanox.com \
    --cc=andrew@lunn.ch \
    --cc=dsahern@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=rahul.lakkireddy@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).