All of lore.kernel.org
 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,
	Alex Vesker <valex@mellanox.com>
Subject: [PATCH net-next v2 05/11] devlink: Extend the support querying for region snapshot IDs
Date: Wed, 11 Jul 2018 13:43:02 +0300	[thread overview]
Message-ID: <1531305788-29420-6-git-send-email-valex@mellanox.com> (raw)
In-Reply-To: <1531305788-29420-1-git-send-email-valex@mellanox.com>

Extend the support for DEVLINK_CMD_REGION_GET command to also
return the IDs of the snapshot currently present on the region.
Each reply will include a nested snapshots attribute that
can contain multiple snapshot attributes each with an ID.

Signed-off-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 include/uapi/linux/devlink.h |  3 +++
 net/core/devlink.c           | 53 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index d1dbc5d..42fcb55 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -267,6 +267,9 @@ enum devlink_attr {
 
 	DEVLINK_ATTR_REGION_NAME,               /* string */
 	DEVLINK_ATTR_REGION_SIZE,               /* u32 */
+	DEVLINK_ATTR_REGION_SNAPSHOTS,          /* nested */
+	DEVLINK_ATTR_REGION_SNAPSHOT,           /* nested */
+	DEVLINK_ATTR_REGION_SNAPSHOT_ID,        /* u32 */
 
 	/* add new attributes above here, update the policy in devlink.c */
 
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 221ddb6..cb75e26 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -3149,6 +3149,55 @@ static void devlink_param_unregister_one(struct devlink *devlink,
 	kfree(param_item);
 }
 
+static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg,
+					     struct devlink *devlink,
+					     struct devlink_snapshot *snapshot)
+{
+	struct nlattr *snap_attr;
+	int err;
+
+	snap_attr = nla_nest_start(msg, DEVLINK_ATTR_REGION_SNAPSHOT);
+	if (!snap_attr)
+		return -EINVAL;
+
+	err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id);
+	if (err)
+		goto nla_put_failure;
+
+	nla_nest_end(msg, snap_attr);
+	return 0;
+
+nla_put_failure:
+	nla_nest_cancel(msg, snap_attr);
+	return err;
+}
+
+static int devlink_nl_region_snapshots_id_put(struct sk_buff *msg,
+					      struct devlink *devlink,
+					      struct devlink_region *region)
+{
+	struct devlink_snapshot *snapshot;
+	struct nlattr *snapshots_attr;
+	int err;
+
+	snapshots_attr = nla_nest_start(msg, DEVLINK_ATTR_REGION_SNAPSHOTS);
+	if (!snapshots_attr)
+		return -EINVAL;
+
+	list_for_each_entry(snapshot, &region->snapshot_list, list) {
+		err = devlink_nl_region_snapshot_id_put(msg, devlink, snapshot);
+		if (err)
+			goto nla_put_failure;
+	}
+
+	nla_nest_end(msg, snapshots_attr);
+	return 0;
+
+nla_put_failure:
+	nla_nest_cancel(msg, snapshots_attr);
+	return err;
+}
+
 static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
 				  enum devlink_command cmd, u32 portid,
 				  u32 seq, int flags,
@@ -3175,6 +3224,10 @@ static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
 	if (err)
 		goto nla_put_failure;
 
+	err = devlink_nl_region_snapshots_id_put(msg, devlink, region);
+	if (err)
+		goto nla_put_failure;
+
 	genlmsg_end(msg, hdr);
 	return 0;
 
-- 
1.8.3.1

  parent reply	other threads:[~2018-07-11 10:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 10:42 [PATCH net-next v2 00/11] devlink: Add support for region access Alex Vesker
2018-07-11 10:42 ` [PATCH net-next v2 01/11] devlink: Add support for creating and destroying regions Alex Vesker
2018-07-11 10:42 ` [PATCH net-next v2 02/11] devlink: Add callback to query for snapshot id before snapshot create Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 03/11] devlink: Add support for creating region snapshots Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 04/11] devlink: Add support for region get command Alex Vesker
2018-07-11 18:52   ` Jakub Kicinski
2018-07-11 10:43 ` Alex Vesker [this message]
2018-07-11 10:43 ` [PATCH net-next v2 06/11] devlink: Add support for region snapshot delete command Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 07/11] devlink: Add support for region snapshot read command Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 08/11] net/mlx4_core: Add health buffer address capability Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 09/11] net/mlx4_core: Add Crdump FW snapshot support Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 10/11] devlink: Add generic parameters region_snapshot Alex Vesker
2018-07-11 10:43 ` [PATCH net-next v2 11/11] net/mlx4_core: Use devlink region_snapshot parameter Alex Vesker
2018-07-11 18:48 ` [PATCH net-next v2 00/11] devlink: Add support for region access Jakub Kicinski
2018-07-11 18:48   ` Jakub Kicinski
2018-07-12  6:21   ` Alex Vesker
2018-08-15 20:25   ` Johannes Berg

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=1531305788-29420-6-git-send-email-valex@mellanox.com \
    --to=valex@mellanox.com \
    --cc=andrew@lunn.ch \
    --cc=dsahern@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.