All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering
@ 2020-01-09  1:08 Jacob Keller
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot Jacob Keller
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09  1:08 UTC (permalink / raw)
  To: intel-wired-lan

This series consists of patches to enable devlink to request a snapshot via
a new DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT.

The netdevsim driver is modified to support the new trigger_snapshot
callback as an example of how this can be used.

There is also some fix ups for s/shapshot/snapshot/ in documentation
and the devlink_snapshot_id_get function.

Jacob Keller (3):
  devlink: correct misspelling of snapshot
  doc: fix typo of snapshot in documentation
  devlink: add support for triggering snapshots from userspace

The last patch is a patch to the iproute2 project to implement support for
the new command.

Jacob Keller (1):
  devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT

 Documentation/admin-guide/devices.txt       |  2 +-
 Documentation/media/v4l-drivers/meye.rst    |  2 +-
 drivers/net/ethernet/mellanox/mlx4/crdump.c |  6 +--
 drivers/net/netdevsim/dev.c                 | 37 +++++++++++-----
 include/net/devlink.h                       | 14 +++---
 include/uapi/linux/devlink.h                |  2 +
 net/core/devlink.c                          | 49 ++++++++++++++++++---
 7 files changed, 85 insertions(+), 27 deletions(-)

 devlink/devlink.c            | 20 ++++++++++++++++++++
 include/uapi/linux/devlink.h |  2 ++
 2 files changed, 22 insertions(+)

-- 
2.25.0.rc1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
@ 2020-01-09  1:08 ` Jacob Keller
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation Jacob Keller
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09  1:08 UTC (permalink / raw)
  To: intel-wired-lan

The function to obtain a unique snapshot id was mistakenly typo'd as
devlink_region_shapshot_id_get. Fix this typo by renaming the function
and all of its users.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/mellanox/mlx4/crdump.c | 2 +-
 drivers/net/netdevsim/dev.c                 | 2 +-
 include/net/devlink.h                       | 2 +-
 net/core/devlink.c                          | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c
index eaf08f7ad128..64ed725aec28 100644
--- a/drivers/net/ethernet/mellanox/mlx4/crdump.c
+++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c
@@ -182,7 +182,7 @@ int mlx4_crdump_collect(struct mlx4_dev *dev)
 	crdump_enable_crspace_access(dev, cr_space);
 
 	/* Get the available snapshot ID for the dumps */
-	id = devlink_region_shapshot_id_get(devlink);
+	id = devlink_region_snapshot_id_get(devlink);
 
 	/* Try to capture dumps */
 	mlx4_crdump_collect_crspace(dev, cr_space, id);
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 059711edfc61..4b39aba2e9c4 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -53,7 +53,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
 
 	get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE);
 
-	id = devlink_region_shapshot_id_get(priv_to_devlink(nsim_dev));
+	id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev));
 	err = devlink_region_snapshot_create(nsim_dev->dummy_region,
 					     dummy_data, id, kfree);
 	if (err) {
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 47f87b2fcf63..38b4acb93f74 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -938,7 +938,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);
+u32 devlink_region_snapshot_id_get(struct devlink *devlink);
 int devlink_region_snapshot_create(struct devlink_region *region,
 				   u8 *data, u32 snapshot_id,
 				   devlink_snapshot_data_dest_t *data_destructor);
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 4c63c9a4c09e..b6fc67dbd612 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -7563,7 +7563,7 @@ void devlink_region_destroy(struct devlink_region *region)
 EXPORT_SYMBOL_GPL(devlink_region_destroy);
 
 /**
- *	devlink_region_shapshot_id_get - get snapshot ID
+ *	devlink_region_snapshot_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
@@ -7571,7 +7571,7 @@ EXPORT_SYMBOL_GPL(devlink_region_destroy);
  *
  *	@devlink: devlink
  */
-u32 devlink_region_shapshot_id_get(struct devlink *devlink)
+u32 devlink_region_snapshot_id_get(struct devlink *devlink)
 {
 	u32 id;
 
@@ -7581,7 +7581,7 @@ u32 devlink_region_shapshot_id_get(struct devlink *devlink)
 
 	return id;
 }
-EXPORT_SYMBOL_GPL(devlink_region_shapshot_id_get);
+EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_get);
 
 /**
  *	devlink_region_snapshot_create - create a new snapshot
-- 
2.25.0.rc1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot Jacob Keller
@ 2020-01-09  1:08 ` Jacob Keller
  2020-01-09  7:01   ` Jiri Pirko
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace Jacob Keller
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jacob Keller @ 2020-01-09  1:08 UTC (permalink / raw)
  To: intel-wired-lan

A couple of locations accidentally misspelled snapshot as shapshot.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 Documentation/admin-guide/devices.txt    | 2 +-
 Documentation/media/v4l-drivers/meye.rst | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt
index 1c5d2281efc9..2a97aaec8b12 100644
--- a/Documentation/admin-guide/devices.txt
+++ b/Documentation/admin-guide/devices.txt
@@ -319,7 +319,7 @@
 		182 = /dev/perfctr	Performance-monitoring counters
 		183 = /dev/hwrng	Generic random number generator
 		184 = /dev/cpu/microcode CPU microcode update interface
-		186 = /dev/atomicps	Atomic shapshot of process state data
+		186 = /dev/atomicps	Atomic snapshot of process state data
 		187 = /dev/irnet	IrNET device
 		188 = /dev/smbusbios	SMBus BIOS
 		189 = /dev/ussp_ctl	User space serial port control
diff --git a/Documentation/media/v4l-drivers/meye.rst b/Documentation/media/v4l-drivers/meye.rst
index a572996cdbf6..dc57a6a91b43 100644
--- a/Documentation/media/v4l-drivers/meye.rst
+++ b/Documentation/media/v4l-drivers/meye.rst
@@ -95,7 +95,7 @@ so all video4linux tools (like xawtv) should work with this driver.
 
 Besides the video4linux interface, the driver has a private interface
 for accessing the Motion Eye extended parameters (camera sharpness,
-agc, video framerate), the shapshot and the MJPEG capture facilities.
+agc, video framerate), the snapshot and the MJPEG capture facilities.
 
 This interface consists of several ioctls (prototypes and structures
 can be found in include/linux/meye.h):
-- 
2.25.0.rc1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot Jacob Keller
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation Jacob Keller
@ 2020-01-09  1:08 ` Jacob Keller
  2020-01-09  7:05   ` Jiri Pirko
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 4/4] devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT Jacob Keller
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jacob Keller @ 2020-01-09  1:08 UTC (permalink / raw)
  To: intel-wired-lan

Currently, devlink region snapshots are captured by the driver at some
internal trigger. There is no standard method for userspace to request
that a snapshot be created.

For some use cases of regions, this is acceptable. The snapshots only
make sense if taken in response to some internal driver event.

However, regions could be used for other purposes. For example, a driver
might export a region that represents the contents of some portion of
the device flash. In this case, there is no event that triggers
a snapshot. Instead, it makes sense for user space to request a snapshot
in some manner.

Currently, drivers must implement such a trigger through an out-of-band
mechanism. The netdevsim driver does this through a debugfs file.

Create a standard interface for requesting snapshots via a new devlink
command: DEVLINK_CMG_REGION_TRIGGER_SNAPSHOT.

At region creation time, drivers may optionally define
a trigger_snapshot function callback. If not defined, the
DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP.

If defined, the command will call the trigger_snapshot function
callback, resulting in a new snapshot being created.

With this, there is a standard mechanism for requesting new snapshots of
a given devlink region.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/mellanox/mlx4/crdump.c |  4 +-
 drivers/net/netdevsim/dev.c                 | 37 +++++++++++++-----
 include/net/devlink.h                       | 12 ++++--
 include/uapi/linux/devlink.h                |  2 +
 net/core/devlink.c                          | 43 +++++++++++++++++++--
 5 files changed, 78 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c
index 64ed725aec28..4b1373414b0b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/crdump.c
+++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c
@@ -207,7 +207,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
 		devlink_region_create(devlink,
 				      region_cr_space_str,
 				      MAX_NUM_OF_DUMPS_TO_STORE,
-				      pci_resource_len(pdev, 0));
+				      pci_resource_len(pdev, 0), NULL);
 	if (IS_ERR(crdump->region_crspace))
 		mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
 			  region_cr_space_str,
@@ -218,7 +218,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
 		devlink_region_create(devlink,
 				      region_fw_health_str,
 				      MAX_NUM_OF_DUMPS_TO_STORE,
-				      HEALTH_BUFFER_SIZE);
+				      HEALTH_BUFFER_SIZE, NULL);
 	if (IS_ERR(crdump->region_fw_health))
 		mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
 			  region_fw_health_str,
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 4b39aba2e9c4..4ed9c8d8de7c 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -38,30 +38,46 @@ 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_trigger_snapshot(struct devlink *devlink,
+				     struct devlink_region *region,
+				     struct netlink_ext_ack *extack)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
 	void *dummy_data;
 	int err;
 	u32 id;
 
 	dummy_data = kmalloc(NSIM_DEV_DUMMY_REGION_SIZE, GFP_KERNEL);
-	if (!dummy_data)
+	if (!dummy_data) {
+		NL_SET_ERR_MSG(extack, "Out of memory");
 		return -ENOMEM;
+	}
 
 	get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE);
 
-	id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev));
-	err = devlink_region_snapshot_create(nsim_dev->dummy_region,
-					     dummy_data, id, kfree);
+	id = devlink_region_snapshot_id_get(devlink);
+	err = devlink_region_snapshot_create(region, dummy_data, id, kfree);
 	if (err) {
-		pr_err("Failed to create region snapshot\n");
+		NL_SET_ERR_MSG(extack, "Failed to create region snapshot");
 		kfree(dummy_data);
 		return err;
 	}
 
+	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;
+	int err;
+
+	err = nsim_dev_trigger_snapshot(priv_to_devlink(nsim_dev),
+					nsim_dev->dummy_region, NULL);
+	if (err)
+		return err;
+
 	return count;
 }
 
@@ -248,7 +264,8 @@ static int nsim_dev_dummy_region_init(struct nsim_dev *nsim_dev,
 	nsim_dev->dummy_region =
 		devlink_region_create(devlink, "dummy",
 				      NSIM_DEV_DUMMY_REGION_SNAPSHOT_MAX,
-				      NSIM_DEV_DUMMY_REGION_SIZE);
+				      NSIM_DEV_DUMMY_REGION_SIZE,
+				      nsim_dev_trigger_snapshot);
 	return PTR_ERR_OR_ZERO(nsim_dev->dummy_region);
 }
 
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 38b4acb93f74..f93b1a07c9f2 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -491,6 +491,10 @@ struct devlink_info_req;
 
 typedef void devlink_snapshot_data_dest_t(const void *data);
 
+typedef int devlink_trigger_snapshot_t(struct devlink *devlink,
+				       struct devlink_region *region,
+				       struct netlink_ext_ack *extack);
+
 struct devlink_fmsg;
 struct devlink_health_reporter;
 
@@ -933,10 +937,10 @@ void devlink_port_param_value_changed(struct devlink_port *devlink_port,
 				      u32 param_id);
 void devlink_param_value_str_fill(union devlink_param_value *dst_val,
 				  const char *src);
-struct devlink_region *devlink_region_create(struct devlink *devlink,
-					     const char *region_name,
-					     u32 region_max_snapshots,
-					     u64 region_size);
+struct devlink_region *
+devlink_region_create(struct devlink *devlink, const char *region_name,
+		      u32 region_max_snapshots, u64 region_size,
+		      devlink_trigger_snapshot_t *trigger_snapshot);
 void devlink_region_destroy(struct devlink_region *region);
 u32 devlink_region_snapshot_id_get(struct devlink *devlink);
 int devlink_region_snapshot_create(struct devlink_region *region,
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index ae37fd4d194a..19bec058691d 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -117,6 +117,8 @@ enum devlink_command {
 	DEVLINK_CMD_TRAP_GROUP_NEW,
 	DEVLINK_CMD_TRAP_GROUP_DEL,
 
+	DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT,
+
 	/* add new commands above here */
 	__DEVLINK_CMD_MAX,
 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b6fc67dbd612..ffc87dd54dbd 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -349,6 +349,7 @@ struct devlink_region {
 	u32 max_snapshots;
 	u32 cur_snapshots;
 	u64 size;
+	devlink_trigger_snapshot_t *trigger_snapshot;
 };
 
 struct devlink_snapshot {
@@ -4052,6 +4053,30 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
 	return err;
 }
 
+static int devlink_nl_cmd_region_trigger_snapshot(struct sk_buff *skb,
+						  struct genl_info *info)
+{
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_region *region;
+	const char *region_name;
+	struct sk_buff *msg;
+	u32 snapshot_id;
+	int err;
+
+	if (!info->attrs[DEVLINK_ATTR_REGION_NAME])
+		return -EINVAL;
+
+	region_name = nla_data(info->attrs[DEVLINK_ATTR_REGION_NAME]);
+	region = devlink_region_get_by_name(devlink, region_name);
+	if (!region)
+		return -EINVAL;
+
+	if (!region->trigger_snapshot)
+		return -EOPNOTSUPP;
+
+	return region->trigger_snapshot(devlink, region, info->extack);
+}
+
 struct devlink_info_req {
 	struct sk_buff *msg;
 };
@@ -6158,6 +6183,14 @@ static const struct genl_ops devlink_nl_ops[] = {
 		.flags = GENL_ADMIN_PERM,
 		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
 	},
+	{
+		.cmd = DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT,
+		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
+		.doit = devlink_nl_cmd_region_trigger_snapshot,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK |
+				  DEVLINK_NL_FLAG_NO_LOCK,
+	},
 	{
 		.cmd = DEVLINK_CMD_INFO_GET,
 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -7499,11 +7532,12 @@ EXPORT_SYMBOL_GPL(devlink_param_value_str_fill);
  *	@region_name: region name
  *	@region_max_snapshots: Maximum supported number of snapshots for region
  *	@region_size: size of region
+ *	@trigger_snapshot: function to trigger creation of snapshot
  */
-struct devlink_region *devlink_region_create(struct devlink *devlink,
-					     const char *region_name,
-					     u32 region_max_snapshots,
-					     u64 region_size)
+struct devlink_region *
+devlink_region_create(struct devlink *devlink, const char *region_name,
+		      u32 region_max_snapshots, u64 region_size,
+		      devlink_trigger_snapshot_t *trigger_snapshot)
 {
 	struct devlink_region *region;
 	int err = 0;
@@ -7525,6 +7559,7 @@ struct devlink_region *devlink_region_create(struct devlink *devlink,
 	region->max_snapshots = region_max_snapshots;
 	region->name = region_name;
 	region->size = region_size;
+	region->trigger_snapshot = trigger_snapshot;
 	INIT_LIST_HEAD(&region->snapshot_list);
 	list_add_tail(&region->list, &devlink->region_list);
 	devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW);
-- 
2.25.0.rc1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 4/4] devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
                   ` (2 preceding siblings ...)
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace Jacob Keller
@ 2020-01-09  1:08 ` Jacob Keller
  2020-01-09  7:00 ` [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jiri Pirko
  2020-01-09 18:59 ` Jiri Pirko
  5 siblings, 0 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09  1:08 UTC (permalink / raw)
  To: intel-wired-lan

Add support for the devlink command to trigger a snapshot if the region
supports it.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 devlink/devlink.c            | 20 ++++++++++++++++++++
 include/uapi/linux/devlink.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 95f05a0b..3a473531 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -4200,6 +4200,7 @@ static const char *cmd_obj(uint8_t cmd)
 	case DEVLINK_CMD_REGION_SET:
 	case DEVLINK_CMD_REGION_NEW:
 	case DEVLINK_CMD_REGION_DEL:
+	case DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT:
 		return "region";
 	case DEVLINK_CMD_FLASH_UPDATE:
 	case DEVLINK_CMD_FLASH_UPDATE_END:
@@ -6362,12 +6363,28 @@ static int cmd_region_read(struct dl *dl)
 	return err;
 }
 
+static int cmd_region_trigger(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT,
+			NLM_F_REQUEST | NLM_F_ACK);
+
+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION, 0);
+	if (err)
+		return err;
+
+	return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
+}
+
 static void cmd_region_help(void)
 {
 	pr_err("Usage: devlink region show [ DEV/REGION ]\n");
 	pr_err("       devlink region del DEV/REGION snapshot SNAPSHOT_ID\n");
 	pr_err("       devlink region dump DEV/REGION [ snapshot SNAPSHOT_ID ]\n");
 	pr_err("       devlink region read DEV/REGION [ snapshot SNAPSHOT_ID ] address ADDRESS length LENGTH\n");
+	pr_err("       devlink region trigger DEV/REGION\n");
 }
 
 static int cmd_region(struct dl *dl)
@@ -6389,6 +6406,9 @@ static int cmd_region(struct dl *dl)
 	} else if (dl_argv_match(dl, "read")) {
 		dl_arg_inc(dl);
 		return cmd_region_read(dl);
+	} else if (dl_argv_match(dl, "trigger")) {
+		dl_arg_inc(dl);
+		return cmd_region_trigger(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 3f82dedd..37348f84 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -117,6 +117,8 @@ enum devlink_command {
 	DEVLINK_CMD_TRAP_GROUP_NEW,
 	DEVLINK_CMD_TRAP_GROUP_DEL,
 
+	DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT,
+
 	/* add new commands above here */
 	__DEVLINK_CMD_MAX,
 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
                   ` (3 preceding siblings ...)
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 4/4] devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT Jacob Keller
@ 2020-01-09  7:00 ` Jiri Pirko
  2020-01-09 18:48   ` Jacob Keller
  2020-01-09 18:59 ` Jiri Pirko
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Pirko @ 2020-01-09  7:00 UTC (permalink / raw)
  To: intel-wired-lan

Thu, Jan 09, 2020 at 02:08:15AM CET, jacob.e.keller at intel.com wrote:
>This series consists of patches to enable devlink to request a snapshot via
>a new DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT.
>
>The netdevsim driver is modified to support the new trigger_snapshot
>callback as an example of how this can be used.
>
>There is also some fix ups for s/shapshot/snapshot/ in documentation
>and the devlink_snapshot_id_get function.

You can already trigger health reporter dump from userspace. Why don't
you use health reporter?


>
>Jacob Keller (3):
>  devlink: correct misspelling of snapshot
>  doc: fix typo of snapshot in documentation
>  devlink: add support for triggering snapshots from userspace
>
>The last patch is a patch to the iproute2 project to implement support for
>the new command.
>
>Jacob Keller (1):
>  devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT
>
> Documentation/admin-guide/devices.txt       |  2 +-
> Documentation/media/v4l-drivers/meye.rst    |  2 +-
> drivers/net/ethernet/mellanox/mlx4/crdump.c |  6 +--
> drivers/net/netdevsim/dev.c                 | 37 +++++++++++-----
> include/net/devlink.h                       | 14 +++---
> include/uapi/linux/devlink.h                |  2 +
> net/core/devlink.c                          | 49 ++++++++++++++++++---
> 7 files changed, 85 insertions(+), 27 deletions(-)
>
> devlink/devlink.c            | 20 ++++++++++++++++++++
> include/uapi/linux/devlink.h |  2 ++
> 2 files changed, 22 insertions(+)
>
>-- 
>2.25.0.rc1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation Jacob Keller
@ 2020-01-09  7:01   ` Jiri Pirko
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2020-01-09  7:01 UTC (permalink / raw)
  To: intel-wired-lan

Thu, Jan 09, 2020 at 02:08:17AM CET, jacob.e.keller at intel.com wrote:
>A couple of locations accidentally misspelled snapshot as shapshot.

This does not have anything to do with the rest of the set.

>
>Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>---
> Documentation/admin-guide/devices.txt    | 2 +-
> Documentation/media/v4l-drivers/meye.rst | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt
>index 1c5d2281efc9..2a97aaec8b12 100644
>--- a/Documentation/admin-guide/devices.txt
>+++ b/Documentation/admin-guide/devices.txt
>@@ -319,7 +319,7 @@
> 		182 = /dev/perfctr	Performance-monitoring counters
> 		183 = /dev/hwrng	Generic random number generator
> 		184 = /dev/cpu/microcode CPU microcode update interface
>-		186 = /dev/atomicps	Atomic shapshot of process state data
>+		186 = /dev/atomicps	Atomic snapshot of process state data
> 		187 = /dev/irnet	IrNET device
> 		188 = /dev/smbusbios	SMBus BIOS
> 		189 = /dev/ussp_ctl	User space serial port control
>diff --git a/Documentation/media/v4l-drivers/meye.rst b/Documentation/media/v4l-drivers/meye.rst
>index a572996cdbf6..dc57a6a91b43 100644
>--- a/Documentation/media/v4l-drivers/meye.rst
>+++ b/Documentation/media/v4l-drivers/meye.rst
>@@ -95,7 +95,7 @@ so all video4linux tools (like xawtv) should work with this driver.
> 
> Besides the video4linux interface, the driver has a private interface
> for accessing the Motion Eye extended parameters (camera sharpness,
>-agc, video framerate), the shapshot and the MJPEG capture facilities.
>+agc, video framerate), the snapshot and the MJPEG capture facilities.
> 
> This interface consists of several ioctls (prototypes and structures
> can be found in include/linux/meye.h):
>-- 
>2.25.0.rc1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace Jacob Keller
@ 2020-01-09  7:05   ` Jiri Pirko
  2020-01-09 18:50     ` Jacob Keller
  0 siblings, 1 reply; 14+ messages in thread
From: Jiri Pirko @ 2020-01-09  7:05 UTC (permalink / raw)
  To: intel-wired-lan

Thu, Jan 09, 2020 at 02:08:18AM CET, jacob.e.keller at intel.com wrote:
>Currently, devlink region snapshots are captured by the driver at some
>internal trigger. There is no standard method for userspace to request
>that a snapshot be created.
>
>For some use cases of regions, this is acceptable. The snapshots only
>make sense if taken in response to some internal driver event.
>
>However, regions could be used for other purposes. For example, a driver
>might export a region that represents the contents of some portion of
>the device flash. In this case, there is no event that triggers
>a snapshot. Instead, it makes sense for user space to request a snapshot
>in some manner.
>
>Currently, drivers must implement such a trigger through an out-of-band
>mechanism. The netdevsim driver does this through a debugfs file.
>
>Create a standard interface for requesting snapshots via a new devlink
>command: DEVLINK_CMG_REGION_TRIGGER_SNAPSHOT.
>
>At region creation time, drivers may optionally define
>a trigger_snapshot function callback. If not defined, the
>DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP.

Similar mechanism is already implemented for health reporters. Why that
wouln't work for you?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering
  2020-01-09  7:00 ` [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jiri Pirko
@ 2020-01-09 18:48   ` Jacob Keller
  0 siblings, 0 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09 18:48 UTC (permalink / raw)
  To: intel-wired-lan

On 1/8/2020 11:00 PM, Jiri Pirko wrote:
> Thu, Jan 09, 2020 at 02:08:15AM CET, jacob.e.keller at intel.com wrote:
>> There is also some fix ups for s/shapshot/snapshot/ in documentation
>> and the devlink_snapshot_id_get function.
> 
> You can already trigger health reporter dump from userspace. Why don't
> you use health reporter?
> 

Hmm. Mainly because the specific things I wanted to expose through
regions aren't really "health" information.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09  7:05   ` Jiri Pirko
@ 2020-01-09 18:50     ` Jacob Keller
  2020-01-09 18:58       ` Jiri Pirko
  0 siblings, 1 reply; 14+ messages in thread
From: Jacob Keller @ 2020-01-09 18:50 UTC (permalink / raw)
  To: intel-wired-lan

On 1/8/2020 11:05 PM, Jiri Pirko wrote:
> Thu, Jan 09, 2020 at 02:08:18AM CET, jacob.e.keller at intel.com wrote:
>> At region creation time, drivers may optionally define
>> a trigger_snapshot function callback. If not defined, the
>> DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP.
> 
> Similar mechanism is already implemented for health reporters. Why that
> wouln't work for you?
> 

Mostly, I didn't feel that the necessary information (flash contents)
really made sense as a health report. The intent is to enable diagnostic
tools to read the contents of the flash on a device.

I'm fine using the health interface but in this case features like
recovery method, etc do not make sense at all as it would not be
triggered in response to error conditions.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09 18:50     ` Jacob Keller
@ 2020-01-09 18:58       ` Jiri Pirko
  2020-01-09 19:07         ` Jacob Keller
  2020-01-09 19:35         ` Jacob Keller
  0 siblings, 2 replies; 14+ messages in thread
From: Jiri Pirko @ 2020-01-09 18:58 UTC (permalink / raw)
  To: intel-wired-lan

Thu, Jan 09, 2020 at 07:50:23PM CET, jacob.e.keller at intel.com wrote:
>On 1/8/2020 11:05 PM, Jiri Pirko wrote:
>> Thu, Jan 09, 2020 at 02:08:18AM CET, jacob.e.keller at intel.com wrote:
>>> At region creation time, drivers may optionally define
>>> a trigger_snapshot function callback. If not defined, the
>>> DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP.
>> 
>> Similar mechanism is already implemented for health reporters. Why that
>> wouln't work for you?
>> 
>
>Mostly, I didn't feel that the necessary information (flash contents)
>really made sense as a health report. The intent is to enable diagnostic
>tools to read the contents of the flash on a device.

I see.


>
>I'm fine using the health interface but in this case features like
>recovery method, etc do not make sense at all as it would not be
>triggered in response to error conditions.

Okay. Perhaps this is a usecase to have the regions.

Anyway, this patch does like 5 things in one. Please split it in
multiple patches, each doing one thing.

Thanks!


>
>Thanks,
>Jake

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering
  2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
                   ` (4 preceding siblings ...)
  2020-01-09  7:00 ` [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jiri Pirko
@ 2020-01-09 18:59 ` Jiri Pirko
  5 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2020-01-09 18:59 UTC (permalink / raw)
  To: intel-wired-lan

Hmm, could you send patchsets like this one to netdev mailing list?

Thanks!

Thu, Jan 09, 2020 at 02:08:15AM CET, jacob.e.keller at intel.com wrote:
>This series consists of patches to enable devlink to request a snapshot via
>a new DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT.
>
>The netdevsim driver is modified to support the new trigger_snapshot
>callback as an example of how this can be used.
>
>There is also some fix ups for s/shapshot/snapshot/ in documentation
>and the devlink_snapshot_id_get function.
>
>Jacob Keller (3):
>  devlink: correct misspelling of snapshot
>  doc: fix typo of snapshot in documentation
>  devlink: add support for triggering snapshots from userspace
>
>The last patch is a patch to the iproute2 project to implement support for
>the new command.
>
>Jacob Keller (1):
>  devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT
>
> Documentation/admin-guide/devices.txt       |  2 +-
> Documentation/media/v4l-drivers/meye.rst    |  2 +-
> drivers/net/ethernet/mellanox/mlx4/crdump.c |  6 +--
> drivers/net/netdevsim/dev.c                 | 37 +++++++++++-----
> include/net/devlink.h                       | 14 +++---
> include/uapi/linux/devlink.h                |  2 +
> net/core/devlink.c                          | 49 ++++++++++++++++++---
> 7 files changed, 85 insertions(+), 27 deletions(-)
>
> devlink/devlink.c            | 20 ++++++++++++++++++++
> include/uapi/linux/devlink.h |  2 ++
> 2 files changed, 22 insertions(+)
>
>-- 
>2.25.0.rc1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09 18:58       ` Jiri Pirko
@ 2020-01-09 19:07         ` Jacob Keller
  2020-01-09 19:35         ` Jacob Keller
  1 sibling, 0 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09 19:07 UTC (permalink / raw)
  To: intel-wired-lan

On 1/9/2020 10:58 AM, Jiri Pirko wrote:
> Thu, Jan 09, 2020 at 07:50:23PM CET, jacob.e.keller at intel.com wrote:
>> On 1/8/2020 11:05 PM, Jiri Pirko wrote:
>>> Thu, Jan 09, 2020 at 02:08:18AM CET, jacob.e.keller at intel.com wrote:
>>>> At region creation time, drivers may optionally define
>>>> a trigger_snapshot function callback. If not defined, the
>>>> DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP.
>>>
>>> Similar mechanism is already implemented for health reporters. Why that
>>> wouln't work for you?
>>>
>>
>> Mostly, I didn't feel that the necessary information (flash contents)
>> really made sense as a health report. The intent is to enable diagnostic
>> tools to read the contents of the flash on a device.
> 
> I see.
> 
>>
>> I'm fine using the health interface but in this case features like
>> recovery method, etc do not make sense at all as it would not be
>> triggered in response to error conditions.
> 
> Okay. Perhaps this is a usecase to have the regions.
> 
> Anyway, this patch does like 5 things in one. Please split it in
> multiple patches, each doing one thing.
> 
> Thanks!

I can split it into parts and expand on the reasoning for not using the
health interface.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace
  2020-01-09 18:58       ` Jiri Pirko
  2020-01-09 19:07         ` Jacob Keller
@ 2020-01-09 19:35         ` Jacob Keller
  1 sibling, 0 replies; 14+ messages in thread
From: Jacob Keller @ 2020-01-09 19:35 UTC (permalink / raw)
  To: intel-wired-lan



On 1/9/2020 10:58 AM, Jiri Pirko wrote:
> Anyway, this patch does like 5 things in one. Please split it in
> multiple patches, each doing one thing.

I sent the two typo fixes separately, and broke the last patch into 3
and sent them to netdev directly.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-01-09 19:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  1:08 [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jacob Keller
2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot Jacob Keller
2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation Jacob Keller
2020-01-09  7:01   ` Jiri Pirko
2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace Jacob Keller
2020-01-09  7:05   ` Jiri Pirko
2020-01-09 18:50     ` Jacob Keller
2020-01-09 18:58       ` Jiri Pirko
2020-01-09 19:07         ` Jacob Keller
2020-01-09 19:35         ` Jacob Keller
2020-01-09  1:08 ` [Intel-wired-lan] [PATCH 4/4] devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT Jacob Keller
2020-01-09  7:00 ` [Intel-wired-lan] [PATCH 0/4] devlink region snapshot triggering Jiri Pirko
2020-01-09 18:48   ` Jacob Keller
2020-01-09 18:59 ` Jiri Pirko

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.