From: Jiri Pirko <jiri@resnulli.us>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH 09/10] netdevsim: support taking immediate snapshot via devlink
Date: Wed, 25 Mar 2020 17:50:46 +0100 [thread overview]
Message-ID: <20200325165046.GA11304@nanopsycho.orion> (raw)
In-Reply-To: <20200324223445.2077900-10-jacob.e.keller@intel.com>
Tue, Mar 24, 2020 at 11:34:44PM CET, jacob.e.keller@intel.com wrote:
>Implement the .snapshot region operation for the dummy data region. This
>enables a region snapshot to be taken upon request via the new
>DEVLINK_CMD_REGION_SNAPSHOT command.
>
>Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>---
> drivers/net/netdevsim/dev.c | 27 +++++++++++++++----
> .../drivers/net/netdevsim/devlink.sh | 15 +++++++++++
> 2 files changed, 37 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
>index f9420b77e5fd..876efe71efff 100644
>--- a/drivers/net/netdevsim/dev.c
>+++ b/drivers/net/netdevsim/dev.c
>@@ -39,13 +39,11 @@ static struct dentry *nsim_dev_ddir;
>
> #define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32)
>
>-static ssize_t nsim_dev_take_snapshot_write(struct file *file,
>- const char __user *data,
>- size_t count, loff_t *ppos)
>+static int
>+nsim_dev_take_snapshot(struct devlink *devlink, struct netlink_ext_ack *extack,
>+ u8 **data)
> {
>- struct nsim_dev *nsim_dev = file->private_data;
> void *dummy_data;
>- int err, id;
>
> dummy_data = kmalloc(NSIM_DEV_DUMMY_REGION_SIZE, GFP_KERNEL);
> if (!dummy_data)
>@@ -53,6 +51,24 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
>
> get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE);
>
>+ *data = dummy_data;
>+
>+ return 0;
>+}
>+
>+static ssize_t nsim_dev_take_snapshot_write(struct file *file,
>+ const char __user *data,
>+ size_t count, loff_t *ppos)
>+{
>+ struct nsim_dev *nsim_dev = file->private_data;
>+ u8 *dummy_data;
>+ int err, id;
>+
>+ err = nsim_dev_take_snapshot(priv_to_devlink(nsim_dev), NULL,
>+ &dummy_data);
>+ if (err)
>+ return err;
>+
> id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev));
> if (id < 0) {
> pr_err("Failed to get snapshot id\n");
>@@ -346,6 +362,7 @@ static void nsim_devlink_param_load_driverinit_values(struct devlink *devlink)
> static const struct devlink_region_ops dummy_region_ops = {
> .name = "dummy",
> .destructor = &kfree,
>+ .snapshot = nsim_dev_take_snapshot,
> };
>
> static int nsim_dev_dummy_region_init(struct nsim_dev *nsim_dev,
>diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>index 025a84c2ab5a..f23383fd108c 100755
>--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>@@ -141,6 +141,21 @@ regions_test()
>
> check_region_snapshot_count dummy post-first-delete 2
>
>+ devlink region new $DL_HANDLE/dummy
Looks like you haven't run the selftest with the current patchset
version.
>+ check_err $? "Failed to create a new a snapshot"
>+
>+ check_region_snapshot_count dummy post-request 3
>+
>+ devlink region new $DL_HANDLE/dummy snapshot 25
>+ check_err $? "Failed to create a new snapshot with id 25"
>+
>+ check_region_snapshot_count dummy post-request 4
>+
>+ devlink region del $DL_HANDLE/dummy snapshot 25
>+ check_err $? "Failed to delete snapshot with id 25"
>+
>+ check_region_snapshot_count dummy post-request 3
>+
> log_test "regions test"
> }
>
>--
>2.24.1
>
next prev parent reply other threads:[~2020-03-25 16:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 22:34 [PATCH 00/10] implement DEVLINK_CMD_REGION_NEW Jacob Keller
2020-03-24 22:34 ` [PATCH 01/10] devlink: prepare to support region operations Jacob Keller
2020-03-24 22:34 ` [PATCH 02/10] devlink: convert snapshot destructor callback to region op Jacob Keller
2020-03-24 22:34 ` [PATCH 03/10] devlink: trivial: fix tab in function documentation Jacob Keller
2020-03-24 22:34 ` [PATCH 04/10] devlink: add function to take snapshot while locked Jacob Keller
2020-03-25 17:56 ` Jakub Kicinski
2020-03-24 22:34 ` [PATCH 05/10] devlink: extract snapshot id allocation to helper function Jacob Keller
2020-03-25 14:08 ` Jiri Pirko
2020-03-24 22:34 ` [PATCH 06/10] devlink: convert snapshot id getter to return an error Jacob Keller
2020-03-25 18:04 ` Jakub Kicinski
2020-03-25 19:13 ` Jiri Pirko
2020-03-26 1:33 ` Jacob Keller
2020-03-24 22:34 ` [PATCH] devlink: track snapshot id usage count using an xarray Jacob Keller
2020-03-25 16:08 ` Jiri Pirko
2020-03-26 1:16 ` Jacob Keller
2020-03-26 1:43 ` Jacob Keller
2020-03-24 22:34 ` [PATCH 08/10] devlink: implement DEVLINK_CMD_REGION_NEW Jacob Keller
2020-03-25 16:46 ` Jiri Pirko
2020-03-25 17:18 ` Jakub Kicinski
2020-03-25 17:20 ` Jiri Pirko
2020-03-25 17:46 ` Jakub Kicinski
2020-03-25 18:41 ` Jiri Pirko
2020-03-26 1:30 ` Jacob Keller
2020-03-24 22:34 ` [PATCH 09/10] netdevsim: support taking immediate snapshot via devlink Jacob Keller
2020-03-25 16:50 ` Jiri Pirko [this message]
2020-03-24 22:34 ` [PATCH 10/10] ice: add a devlink region for dumping NVM contents Jacob Keller
2020-03-25 17:18 ` Jiri Pirko
2020-03-25 13:49 ` [PATCH 00/10] implement DEVLINK_CMD_REGION_NEW Jiri Pirko
2020-03-25 13:50 ` Jiri Pirko
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=20200325165046.GA11304@nanopsycho.orion \
--to=jiri@resnulli.us \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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).