]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Add wrappers for firmware commands
authorJeremy Kerr <jk@codeconstruct.com.au>
Sat, 24 Sep 2022 06:41:03 +0000 (14:41 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Tue, 27 Sep 2022 08:21:29 +0000 (16:21 +0800)
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 <jk@codeconstruct.com.au>
nvme-wrap.c
nvme-wrap.h
nvme.c

index 7b2c4f2cf4bfceef34808f25b1f646d95626021f..63274fe4cfe2cf14f91e6a84aebbc74661668844 100644 (file)
@@ -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.
  */
index dc7e04473bd5d4dfa771785593d24d77155e15c3..db76ba65521f4eaae9c82b368ec1c74eb615c3da 100644 (file)
@@ -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 47ce9d6e10df6e6793a7d870d6a3b6517689e2b5..0c85d182f7f91cfe1246065b7d8709cc7f4487c4 100644 (file)
--- 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)