devlink region snapshot triggering
Subsystems (6)
cover devlink region snapshot triggering
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(+)
Signature · 1 line
2.25.0.rc1
PATCH 1/4 devlink: correct misspelling of snapshot
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.
--- 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(-)
drivers/net/ethernet/mellanox/mlx4/crdump.c +1 -1
@@ -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);
drivers/net/netdevsim/dev.c +1 -1
@@ -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) {
include/net/devlink.h +1 -1
@@ -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);
net/core/devlink.c +3 -3
@@ -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
Signature · 1 line
2.25.0.rc1
PATCH 2/4 doc: fix typo of snapshot in documentation
In reply to Jacob KellerA couple of locations accidentally misspelled snapshot as shapshot.
--- Documentation/admin-guide/devices.txt | 2 +- Documentation/media/v4l-drivers/meye.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/devices.txt +1 -1
@@ -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
Documentation/media/v4l-drivers/meye.rst +1 -1
@@ -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):
Signature · 1 line
2.25.0.rc1
Jiri Pirko
maintainerPATCH 2/4 doc: fix typo of snapshot in documentation
Quoted 1 line · jacob.e.keller at intel.com
A couple of locations accidentally misspelled snapshot as shapshot.
This does not have anything to do with the rest of the set.
Quoted 36 lines
Signed-off-by Jacob Keller <[email protected]>---
Documentation/admin-guide/devices.txt| 2 +-Documentation/media/v4l-drivers/meye.rst| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)Documentation/admin-guide/devices.txt +1
-1@@ -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 controlDocumentation/media/v4l-drivers/meye.rst +0
-0@@ -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,
Documentation/media/v4l-drivers/meye.rst +1
-1-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):Signature · 1 line
2.25.0.rc1
PATCH 3/4 devlink: add support for triggering snapshots from userspace
In reply to Jacob KellerCurrently, 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.
--- 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(-)
drivers/net/ethernet/mellanox/mlx4/crdump.c +2 -2
@@ -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,
drivers/net/netdevsim/dev.c +27 -10
@@ -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); }
include/net/devlink.h +8 -4
@@ -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,
include/uapi/linux/devlink.h +2 -0
@@ -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
net/core/devlink.c +39 -4
74 lines not on this page · raw message
Signature · 1 line
2.25.0.rc1
Jiri Pirko
maintainerPATCH 3/4 devlink: add support for triggering snapshots from userspace
Quoted 16 lines · jacob.e.keller at intel.com
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.
Quoted 6 lines
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_snapshotfunction callback. If not defined, theDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTwill simply report EOPNOTSUPP.
Similar mechanism is already implemented for health reporters. Why that wouln't work for you?
PATCH 3/4 devlink: add support for triggering snapshots from userspace
Quoted 8 lines · Jiri Pirko
Quoted 3 lines · jacob.e.keller at intel.com
At region creation time, drivers may optionally define a
trigger_snapshotfunction callback. If not defined, theDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTwill 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
Jiri Pirko
maintainerPATCH 3/4 devlink: add support for triggering snapshots from userspace
Quoted 6 lines · jacob.e.keller at intel.com
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · jacob.e.keller at intel.com
At region creation time, drivers may optionally define a
trigger_snapshotfunction callback. If not defined, theDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTwill simply report EOPNOTSUPP.
Quoted 7 lines
Quoted 3 lines
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.
Quoted 4 lines
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!
Quoted 3 lines
Thanks,
Jake
PATCH 3/4 devlink: add support for triggering snapshots from userspace
Quoted 22 lines · Jiri Pirko
Quoted 6 lines · jacob.e.keller at intel.com
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · jacob.e.keller at intel.com
At region creation time, drivers may optionally define a
trigger_snapshotfunction callback. If not defined, theDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTwill simply report EOPNOTSUPP.Quoted 7 lines
Quoted 3 lines
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.
Quoted 4 lines
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.
Quoted 6 lines
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
PATCH 3/4 devlink: add support for triggering snapshots from userspace
In reply to Jiri PirkoQuoted 2 lines · Jiri Pirko
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
PATCH 4/4 devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT
In reply to Jacob KellerAdd support for the devlink command to trigger a snapshot if the region supports it.
--- devlink/devlink.c | 20 ++++++++++++++++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 22 insertions(+)
devlink/devlink.c +20 -0
@@ -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 ;
include/uapi/linux/devlink.h +2 -0
@@ -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
Signature · 1 line
2.21.0
Jiri Pirko
maintainercover devlink region snapshot triggering
In reply to Jacob KellerQuoted 8 lines · jacob.e.keller at intel.com
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_snapshotcallback 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_getfunction.
You can already trigger health reporter dump from userspace. Why don't you use health reporter?
Quoted 28 lines
Jacob Keller (3):
devlink: correct misspelling of snapshot
doc: fix typo of snapshot in documentation
devlink: add support for triggering snapshots from userspaceThe last patch is a patch to the iproute2 project to implement support for the new command.
Jacob Keller (1):
devlink: add support forDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTDocumentation/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(+)Signature · 1 line
2.25.0.rc1
cover devlink region snapshot triggering
Quoted 7 lines · Jiri Pirko
Quoted 2 lines · jacob.e.keller at intel.com
There is also some fix ups for s/shapshot/snapshot/ in documentation and the
devlink_snapshot_id_getfunction.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
Jiri Pirko
maintainercover devlink region snapshot triggering
In reply to Jacob KellerHmm, could you send patchsets like this one to netdev mailing list?
Thanks!
Quoted 36 lines · jacob.e.keller at intel.com
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_snapshotcallback 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_getfunction.Jacob Keller (3):
devlink: correct misspelling of snapshot
doc: fix typo of snapshot in documentation
devlink: add support for triggering snapshots from userspaceThe last patch is a patch to the iproute2 project to implement support for the new command.
Jacob Keller (1):
devlink: add support forDEVLINK_CMD_REGION_TRIGGER_SNAPSHOTDocumentation/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(+)Signature · 1 line
2.25.0.rc1