From fccc7648415e9e8ed21bee8c1e2b6c385dae4aa3 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Sat, 24 Sep 2022 14:41:03 +0800 Subject: [PATCH] nvme: Add wrappers for firmware commands This change adds nvme_dev wrappers for the firmware download and firmware commit commands, allowing access over a MI channel. We need a bump to libnvme for the underlying MI firmware calls. Signed-off-by: Jeremy Kerr --- nvme-wrap.c | 12 ++++++++++++ nvme-wrap.h | 6 ++++++ nvme.c | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/nvme-wrap.c b/nvme-wrap.c index 7b2c4f2c..63274fe4 100644 --- a/nvme-wrap.c +++ b/nvme-wrap.c @@ -323,6 +323,18 @@ int nvme_cli_get_log_persistent_event(struct nvme_dev *dev, pevent_log); } +int nvme_cli_fw_download(struct nvme_dev *dev, + struct nvme_fw_download_args *args) +{ + return do_admin_args_op(fw_download, dev, args); +} + +int nvme_cli_fw_commit(struct nvme_dev *dev, + struct nvme_fw_commit_args *args) +{ + return do_admin_args_op(fw_commit, dev, args); +} + /* The MI & direct interfaces don't have an exactly-matching API for * ns_mgmt_create, as we don't support a timeout for MI. */ diff --git a/nvme-wrap.h b/nvme-wrap.h index dc7e0447..db76ba65 100644 --- a/nvme-wrap.h +++ b/nvme-wrap.h @@ -112,4 +112,10 @@ int nvme_cli_get_log_zns_changed_zones(struct nvme_dev *dev, __u32 nsid, int nvme_cli_get_log_persistent_event(struct nvme_dev *dev, enum nvme_pevent_log_action action, __u32 size, void *pevent_log); + +int nvme_cli_fw_download(struct nvme_dev *dev, + struct nvme_fw_download_args *args); + +int nvme_cli_fw_commit(struct nvme_dev *dev, + struct nvme_fw_commit_args *args); #endif /* _NVME_WRAP_H */ diff --git a/nvme.c b/nvme.c index 47ce9d6e..0c85d182 100644 --- a/nvme.c +++ b/nvme.c @@ -4186,14 +4186,13 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin struct nvme_fw_download_args args = { .args_size = sizeof(args), - .fd = dev_fd(dev), .offset = cfg.offset, .data_len = cfg.xfer, .data = fw_buf, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = NULL, }; - err = nvme_fw_download(&args); + err = nvme_cli_fw_download(dev, &args); if (err < 0) { fprintf(stderr, "fw-download: %s\n", nvme_strerror(errno)); break; @@ -4283,14 +4282,13 @@ static int fw_commit(int argc, char **argv, struct command *cmd, struct plugin * struct nvme_fw_commit_args args = { .args_size = sizeof(args), - .fd = dev_fd(dev), .slot = cfg.slot, .action = cfg.action, .bpid = cfg.bpid, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = &result, }; - err = nvme_fw_commit(&args); + err = nvme_cli_fw_commit(dev, &args); if (err < 0) fprintf(stderr, "fw-commit: %s\n", nvme_strerror(errno)); else if (err != 0) -- 2.50.1