From: Jacob Keller Date: Mon, 5 Dec 2022 22:59:31 +0000 (-0800) Subject: devlink: support direct region read requests X-Git-Tag: v6.2.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74e7181c60b8ffc75503ff7eea7d4a719d636fd;p=thirdparty%2Fiproute2.git devlink: support direct region read requests The kernel has gained support for reading from regions without needing to create a snapshot. To use this support, the DEVLINK_ATTR_REGION_DIRECT attribute must be added to the command. For the "read" command, if the user did not specify a snapshot, add the new attribute to request a direct read. The "dump" command will still require a snapshot. While technically a dump could be performed without a snapshot it is not guaranteed to be atomic unless the region size is no larger than 256 bytes. Signed-off-by: Jacob Keller Signed-off-by: David Ahern --- diff --git a/devlink/devlink.c b/devlink/devlink.c index 4a5eee7a1..e62215f84 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -8603,8 +8603,8 @@ static int cmd_region_read(struct dl *dl) int err; err = dl_argv_parse(dl, DL_OPT_HANDLE_REGION | DL_OPT_REGION_ADDRESS | - DL_OPT_REGION_LENGTH | DL_OPT_REGION_SNAPSHOT_ID, - 0); + DL_OPT_REGION_LENGTH, + DL_OPT_REGION_SNAPSHOT_ID); if (err) return err; @@ -8613,6 +8613,10 @@ static int cmd_region_read(struct dl *dl) dl_opts_put(nlh, dl); + /* If user didn't provide a snapshot id, perform a direct read */ + if (!(dl->opts.present & DL_OPT_REGION_SNAPSHOT_ID)) + mnl_attr_put(nlh, DEVLINK_ATTR_REGION_DIRECT, 0, NULL); + pr_out_section_start(dl, "read"); err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_region_read_cb, dl); pr_out_section_end(dl);