diff --git a/libnvme/examples/mi-mctp-csi-test.c b/libnvme/examples/mi-mctp-csi-test.c index b8ed0d0f47..de6985cee5 100644 --- a/libnvme/examples/mi-mctp-csi-test.c +++ b/libnvme/examples/mi-mctp-csi-test.c @@ -91,7 +91,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv) nvme_init_get_log(&cmd, NVME_NSID_NONE, lid, NVME_CSI_NVM, buf, sizeof(buf)); - rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (rc) { warn("can't perform Get Log page command"); return -1; diff --git a/libnvme/examples/mi-mctp.c b/libnvme/examples/mi-mctp.c index dab5a1a195..0f866dedc9 100644 --- a/libnvme/examples/mi-mctp.c +++ b/libnvme/examples/mi-mctp.c @@ -216,7 +216,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv) if (partial) cmd.data_len = offsetof(struct nvme_id_ctrl, rab); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); if (rc) { warn("can't perform Admin Identify command"); return -1; @@ -399,7 +399,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv) nvme_init_get_log(&cmd, NVME_NSID_NONE, lid, NVME_CSI_NVM, buf, sizeof(buf)); - rc = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + rc = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (rc) { warn("can't perform Get Log page command"); return -1; @@ -566,7 +566,7 @@ int do_security_info(nvme_mi_ep_t ep, int argc, char **argv) } nvme_init_security_receive(&cmd, 0, 0, 0, 0, 0, data, data_len); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); if (rc) { warnx("can't perform Security Receive command: rc %d", rc); return -1; diff --git a/libnvme/libnvme/nvme.i b/libnvme/libnvme/nvme.i index 2f2d3a6e14..6907b430e5 100644 --- a/libnvme/libnvme/nvme.i +++ b/libnvme/libnvme/nvme.i @@ -824,7 +824,7 @@ struct nvme_ns { Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ nvme_init_get_log_supported_log_pages(&cmd, NVME_CSI_NVM, &log); - ret = nvme_get_log(nvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(nvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ if (ret) { diff --git a/libnvme/src/libnvme.map b/libnvme/src/libnvme.map index db16b79199..e0e81af3c4 100644 --- a/libnvme/src/libnvme.map +++ b/libnvme/src/libnvme.map @@ -13,8 +13,6 @@ LIBNVME_1_16 { LIBNVME_2_0 { global: - nvme_admin_passthru64; - nvme_admin_passthru; nvme_close; nvme_create_ctrl; nvme_create_global_ctx; @@ -132,8 +130,6 @@ LIBNVME_2_0 { nvme_init_logging; nvme_insert_tls_key; nvme_insert_tls_key_versioned; - nvme_io_passthru64; - nvme_io_passthru; nvme_ipaddrs_eq; nvme_lookup_ctrl; nvme_lookup_host; @@ -244,18 +240,15 @@ LIBNVME_2_0 { nvme_scan_topology; nvme_set_application; nvme_set_debug; + nvme_set_dry_run; nvme_set_keyring; nvme_set_property; nvme_set_root; nvme_skip_namespaces; nvme_status_to_errno; nvme_status_to_string; - nvme_submit_admin_passthru64; nvme_submit_admin_passthru; - nvme_submit_io_passthru64; nvme_submit_io_passthru; - nvme_submit_passthru64; - nvme_submit_passthru; nvme_subsys_filter; nvme_subsystem_first_ctrl; nvme_subsystem_first_ns; @@ -281,6 +274,9 @@ LIBNVME_2_0 { nvme_transport_handle_is_chardev; nvme_transport_handle_is_direct; nvme_transport_handle_is_mi; + nvme_transport_handle_set_decide_retry; + nvme_transport_handle_set_submit_entry; + nvme_transport_handle_set_submit_exit; nvme_unlink_ctrl; nvme_update_config; nvme_update_key; diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 7660b5f33a..7a9c8e4d30 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -1134,7 +1134,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args, nvme_msg(ctx, LOG_DEBUG, "%s: get header (try %d/%d)\n", name, retries, args->max_retries); nvme_init_get_log_discovery(&cmd, 0, log, DISCOVERY_HEADER_LEN); - err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN, NULL); + err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN); if (err) { nvme_msg(ctx, LOG_INFO, "%s: discover try %d/%d failed, errno %d status 0x%x\n", @@ -1168,8 +1168,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args, cmd.cdw10 |= NVME_FIELD_ENCODE(args->lsp, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) { nvme_msg(ctx, LOG_INFO, "%s: discover try %d/%d failed, errno %d status 0x%x\n", @@ -1184,7 +1183,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args, nvme_msg(ctx, LOG_DEBUG, "%s: get header again\n", name); nvme_init_get_log_discovery(&cmd, 0, log, DISCOVERY_HEADER_LEN); - err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN, NULL); + err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN); if (err) { nvme_msg(ctx, LOG_INFO, "%s: discover try %d/%d failed, errno %d status 0x%x\n", @@ -1669,7 +1668,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, nvmf_fill_die(die, c->s->h, tel, trtype, adrfam, reg_addr, tsas); nvme_init_dim_send(&cmd, tas, dim, tdl); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** diff --git a/libnvme/src/nvme/ioctl.c b/libnvme/src/nvme/ioctl.c index 796c105b02..36ccae6bf1 100644 --- a/libnvme/src/nvme/ioctl.c +++ b/libnvme/src/nvme/ioctl.c @@ -27,8 +27,6 @@ #include #include "ioctl.h" -#include "util.h" -#include "log.h" #include "private.h" static int nvme_verify_chr(struct nvme_transport_handle *hdl) @@ -99,126 +97,106 @@ int nvme_get_nsid(struct nvme_transport_handle *hdl, __u32 *nsid) return 0; } -__attribute__((weak)) -int nvme_submit_passthru64(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd64 *cmd, - __u64 *result) +void *__nvme_submit_entry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd) { - int err = ioctl(hdl->fd, ioctl_cmd, cmd); - - if (err >= 0 && result) - *result = cmd->result; - if (err < 0) - return -errno; - return err; + return NULL; } -__attribute__((weak)) -int nvme_submit_passthru(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd *cmd, __u32 *result) +void __nvme_submit_exit(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err, void *user_data) { - int err = ioctl(hdl->fd, ioctl_cmd, cmd); - - if (err >= 0 && result) - *result = cmd->result; - if (err < 0) - return -errno; - return err; } -static int nvme_passthru64(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, __u8 opcode, - __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, - __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, - __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, - void *metadata, __u32 timeout_ms, __u64 *result) +bool __nvme_decide_retry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err) { - struct nvme_passthru_cmd64 cmd = { - .opcode = opcode, - .flags = flags, - .rsvd1 = rsvd, - .nsid = nsid, - .cdw2 = cdw2, - .cdw3 = cdw3, - .metadata = (__u64)(uintptr_t)metadata, - .addr = (__u64)(uintptr_t)data, - .metadata_len = metadata_len, - .data_len = data_len, - .cdw10 = cdw10, - .cdw11 = cdw11, - .cdw12 = cdw12, - .cdw13 = cdw13, - .cdw14 = cdw14, - .cdw15 = cdw15, - .timeout_ms = timeout_ms, - }; - - return nvme_submit_passthru64(hdl, ioctl_cmd, &cmd, result); + return false; } -static int nvme_passthru(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, __u8 opcode, - __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, - __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, - __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, - void *data, __u32 metadata_len, void *metadata, - __u32 timeout_ms, __u32 *result) +/* + * The 64 bit version is the preferred version to use, but for backwards + * compatibility keep a 32 version. + */ +static int nvme_submit_passthru32(struct nvme_transport_handle *hdl, + unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd) { - struct nvme_passthru_cmd cmd = { - .opcode = opcode, - .flags = flags, - .rsvd1 = rsvd, - .nsid = nsid, - .cdw2 = cdw2, - .cdw3 = cdw3, - .metadata = (__u64)(uintptr_t)metadata, - .addr = (__u64)(uintptr_t)data, - .metadata_len = metadata_len, - .data_len = data_len, - .cdw10 = cdw10, - .cdw11 = cdw11, - .cdw12 = cdw12, - .cdw13 = cdw13, - .cdw14 = cdw14, - .cdw15 = cdw15, - .timeout_ms = timeout_ms, - }; - - return nvme_submit_passthru(hdl, ioctl_cmd, &cmd, result); + struct linux_passthru_cmd32 cmd32; + void *user_data; + int err = 0; + + user_data = hdl->submit_entry(hdl, cmd); + if (hdl->ctx->dry_run) + goto out; + + memcpy(&cmd32, cmd, offsetof(struct linux_passthru_cmd32, result)); + cmd32.result = 0; + + do { + err = ioctl(hdl->fd, ioctl_cmd, &cmd32); + if (err >= 0) + break; + err = -errno; + } while (hdl->decide_retry(hdl, cmd, err)); + +out: + cmd->result = cmd32.result; + hdl->submit_exit(hdl, cmd, err, user_data); + return err; } -int nvme_submit_admin_passthru64(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd64 *cmd, - __u64 *result) +/* + * supported since kernel 5.4, see + * 65e68edce0db ("nvme: allow 64-bit results in passthru commands") + */ +static int nvme_submit_passthru64(struct nvme_transport_handle *hdl, + unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd) { - return nvme_submit_passthru64(hdl, NVME_IOCTL_ADMIN64_CMD, cmd, result); + void *user_data; + int err = 0; + + user_data = hdl->submit_entry(hdl, cmd); + if (hdl->ctx->dry_run) + goto out; + + do { + /* + * struct nvme_passtrhu_cmd is identically to struct + * linux_passthru_cmd64, thus just pass it in directly. + */ + err = ioctl(hdl->fd, ioctl_cmd, cmd); + if (err >= 0) + break; + err = -errno; + } while (hdl->decide_retry(hdl, cmd, err)); + +out: + hdl->submit_exit(hdl, cmd, err, user_data); + return err; } -int nvme_admin_passthru64(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, - __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, - __u32 cdw15, __u32 data_len, void *data, - __u32 metadata_len, void *metadata, __u32 timeout_ms, - __u64 *result) +int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd) { - return nvme_passthru64(hdl, NVME_IOCTL_ADMIN64_CMD, opcode, flags, rsvd, - nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, - cdw14, cdw15, data_len, data, metadata_len, - metadata, timeout_ms, result); + if (hdl->ioctl64) + return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd); + return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd); } -int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, __u32 *result) +int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd) { switch (hdl->type) { case NVME_TRANSPORT_HANDLE_TYPE_DIRECT: - return nvme_submit_passthru(hdl, NVME_IOCTL_ADMIN_CMD, cmd, result); + if (hdl->ioctl64) + return nvme_submit_passthru64(hdl, + NVME_IOCTL_ADMIN64_CMD, cmd); + if (cmd->opcode == nvme_admin_fabrics) + return -ENOTSUP; + return nvme_submit_passthru32(hdl, + NVME_IOCTL_ADMIN_CMD, cmd); case NVME_TRANSPORT_HANDLE_TYPE_MI: - return nvme_mi_admin_admin_passthru( - hdl, cmd->opcode, cmd->flags, cmd->rsvd1, - cmd->nsid, cmd->cdw2, cmd->cdw3, cmd->cdw10, - cmd->cdw11, cmd->cdw12, cmd->cdw13, - cmd->cdw14, cmd->cdw15, - cmd->data_len, (void *)(uintptr_t)cmd->addr, - cmd->metadata_len, (void *)(uintptr_t)cmd->metadata, - cmd->timeout_ms, result); + return nvme_mi_admin_admin_passthru(hdl, cmd); default: break; } @@ -226,19 +204,6 @@ int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, struct nvme_pa return -ENOTSUP; } -int nvme_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, - __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, - __u32 cdw15, __u32 data_len, void *data, - __u32 metadata_len, void *metadata, __u32 timeout_ms, - __u32 *result) -{ - return nvme_passthru(hdl, NVME_IOCTL_ADMIN_CMD, opcode, flags, rsvd, - nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, - cdw14, cdw15, data_len, data, metadata_len, - metadata, timeout_ms, result); -} - static bool force_4k; __attribute__((constructor)) @@ -264,6 +229,8 @@ enum { /* * gcc specific attribute, call automatically on the library loading. * if IORING_OP_URING_CMD is not supported, fallback to ioctl interface. + * + * The uring API expects the command of type struct nvme_passthru_cmd64. */ __attribute__((constructor)) static void nvme_uring_cmd_probe() @@ -356,7 +323,7 @@ static bool nvme_uring_is_usable(struct nvme_transport_handle *hdl) int nvme_get_log(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, bool rae, - __u32 xfer_len, __u32 *result) + __u32 xfer_len) { __u64 offset = 0, xfer, data_len = cmd->data_len; __u64 start = (__u64)cmd->cdw13 << 32 | cmd->cdw12; @@ -431,12 +398,12 @@ int nvme_get_log(struct nvme_transport_handle *hdl, if (ret) nvme_uring_cmd_exit(&ring); } else { - ret = nvme_submit_admin_passthru(hdl, cmd, result); + ret = nvme_submit_admin_passthru(hdl, cmd); if (ret) return ret; } #else /* CONFIG_LIBURING */ - ret = nvme_submit_admin_passthru(hdl, cmd, result); + ret = nvme_submit_admin_passthru(hdl, cmd); #endif /* CONFIG_LIBURING */ if (ret) return ret; @@ -470,7 +437,7 @@ static int read_ana_chunk(struct nvme_transport_handle *hdl, enum nvme_log_ana_l int ret; nvme_init_get_log_ana(&cmd, lsp, *read - log, *read, len); - ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); if (ret) return ret; @@ -580,38 +547,3 @@ int nvme_get_ana_log_atomic(struct nvme_transport_handle *hdl, bool rae, bool rg return -EAGAIN; } - -int nvme_submit_io_passthru64(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd64 *cmd, - __u64 *result) -{ - return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd, result); -} - -int nvme_io_passthru64(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, - __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, - __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, - void *metadata, __u32 timeout_ms, __u64 *result) -{ - return nvme_passthru64(hdl, NVME_IOCTL_IO64_CMD, opcode, flags, rsvd, - nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, - cdw14, cdw15, data_len, data, metadata_len, metadata, - timeout_ms, result); -} - -int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, __u32 *result) -{ - return nvme_submit_passthru(hdl, NVME_IOCTL_IO_CMD, cmd, result); -} - -int nvme_io_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, - __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, - __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, - void *metadata, __u32 timeout_ms, __u32 *result) -{ - return nvme_passthru(hdl, NVME_IOCTL_IO_CMD, opcode, flags, rsvd, nsid, - cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, cdw14, - cdw15, data_len, data, metadata_len, metadata, - timeout_ms, result); -} diff --git a/libnvme/src/nvme/ioctl.h b/libnvme/src/nvme/ioctl.h index 7181ea7b78..8e8d20d678 100644 --- a/libnvme/src/nvme/ioctl.h +++ b/libnvme/src/nvme/ioctl.h @@ -68,52 +68,10 @@ * @cdw14: Command Dword 14 (command specific) * @cdw15: Command Dword 15 (command specific) * @timeout_ms: If non-zero, overrides system default timeout in milliseconds - * @result: Set on completion to the command's CQE DWORD 0 controller response - */ -struct nvme_passthru_cmd { - __u8 opcode; - __u8 flags; - __u16 rsvd1; - __u32 nsid; - __u32 cdw2; - __u32 cdw3; - __u64 metadata; - __u64 addr; - __u32 metadata_len; - __u32 data_len; - __u32 cdw10; - __u32 cdw11; - __u32 cdw12; - __u32 cdw13; - __u32 cdw14; - __u32 cdw15; - __u32 timeout_ms; - __u32 result; -}; - -/** - * struct nvme_passthru_cmd64 - 64-bit nvme passthrough command structure - * @opcode: Operation code, see &enum nvme_io_opcodes and &enum nvme_admin_opcodes - * @flags: Not supported: intended for command flags (eg: SGL, FUSE) - * @rsvd1: Reserved for future use - * @nsid: Namespace Identifier, or Fabrics type - * @cdw2: Command Dword 2 (no spec defined use) - * @cdw3: Command Dword 3 (no spec defined use) - * @metadata: User space address to metadata buffer (NULL if not used) - * @addr: User space address to data buffer (NULL if not used) - * @metadata_len: Metadata buffer transfer length - * @data_len: Data buffer transfer length - * @cdw10: Command Dword 10 (command specific) - * @cdw11: Command Dword 11 (command specific) - * @cdw12: Command Dword 12 (command specific) - * @cdw13: Command Dword 13 (command specific) - * @cdw14: Command Dword 14 (command specific) - * @cdw15: Command Dword 15 (command specific) - * @timeout_ms: If non-zero, overrides system default timeout in milliseconds * @rsvd2: Reserved for future use (and fills an implicit struct pad * @result: Set on completion to the command's CQE DWORD 0-1 controller response */ -struct nvme_passthru_cmd64 { +struct nvme_passthru_cmd { __u8 opcode; __u8 flags; __u16 rsvd1; @@ -181,10 +139,6 @@ struct nvme_uring_cmd { #define NVME_IOCTL_RESET _IO('N', 0x44) #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45) #define NVME_IOCTL_RESCAN _IO('N', 0x46) -#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_passthru_cmd) -#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd) -#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64) -#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64) /* io_uring async commands: */ #define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd) @@ -494,207 +448,31 @@ enum nvme_cmd_dword_fields { #define NVME_FIELD_DECODE(value, shift, mask) \ (((value) >> (shift)) & (mask)) -/** - * nvme_submit_admin_passthru64() - Submit a 64-bit nvme passthrough admin - * command - * @hdl: Transport handle - * @cmd: The nvme admin command to send - * @result: Optional field to return the result from the CQE DW0-1 - * - * Uses NVME_IOCTL_ADMIN64_CMD for the ioctl request. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_submit_admin_passthru64(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd64 *cmd, - __u64 *result); - -/** - * nvme_admin_passthru64() - Submit a 64-bit nvme passthrough command - * @hdl: Transport handle - * @opcode: The nvme io command to send - * @flags: NVMe command flags (not used) - * @rsvd: Reserved for future use - * @nsid: Namespace identifier - * @cdw2: Command dword 2 - * @cdw3: Command dword 3 - * @cdw10: Command dword 10 - * @cdw11: Command dword 11 - * @cdw12: Command dword 12 - * @cdw13: Command dword 13 - * @cdw14: Command dword 14 - * @cdw15: Command dword 15 - * @data_len: Length of the data transferred in this command in bytes - * @data: Pointer to user address of the data buffer - * @metadata_len:Length of metadata transferred in this command - * @metadata: Pointer to user address of the metadata buffer - * @timeout_ms: How long the kernel waits for the command to complete - * @result: Optional field to return the result from the CQE dword 0 - * - * Parameterized form of nvme_submit_admin_passthru64(). This sets up and - * submits a &struct nvme_passthru_cmd64. - * - * Known values for @opcode are defined in &enum nvme_admin_opcode. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_admin_passthru64(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, - __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, void *metadata, - __u32 timeout_ms, __u64 *result); - /** * nvme_submit_admin_passthru() - Submit an nvme passthrough admin command * @hdl: Transport handle * @cmd: The nvme admin command to send - * @result: Optional field to return the result from the CQE DW0 * * Uses NVME_IOCTL_ADMIN_CMD for the ioctl request. * * Return: 0 on success, the nvme command status if a response was * received (see &enum nvme_status_field) or a negative error otherwise. */ -int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, - __u32 *result); - -/** - * nvme_admin_passthru() - Submit an nvme passthrough command - * @hdl: Transport handle - * @opcode: The nvme io command to send - * @flags: NVMe command flags (not used) - * @rsvd: Reserved for future use - * @nsid: Namespace identifier - * @cdw2: Command dword 2 - * @cdw3: Command dword 3 - * @cdw10: Command dword 10 - * @cdw11: Command dword 11 - * @cdw12: Command dword 12 - * @cdw13: Command dword 13 - * @cdw14: Command dword 14 - * @cdw15: Command dword 15 - * @data_len: Length of the data transferred in this command in bytes - * @data: Pointer to user address of the data buffer - * @metadata_len:Length of metadata transferred in this command - * @metadata: Pointer to user address of the metadata buffer - * @timeout_ms: How long the kernel waits for the command to complete - * @result: Optional field to return the result from the CQE dword 0 - * - * Parameterized form of nvme_submit_admin_passthru(). This sets up and - * submits a &struct nvme_passthru_cmd. - * - * Known values for @opcode are defined in &enum nvme_admin_opcode. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, - __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, void *metadata, - __u32 timeout_ms, __u32 *result); - -/** - * nvme_submit_io_passthru64() - Submit a 64-bit nvme passthrough command - * @hdl: Transport handle - * @cmd: The nvme io command to send - * @result: Optional field to return the result from the CQE DW0-1 - * - * Uses NVME_IOCTL_IO64_CMD for the ioctl request. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_submit_io_passthru64(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd64 *cmd, - __u64 *result); - -/** - * nvme_io_passthru64() - Submit an nvme io passthrough command - * @hdl: Transport handle - * @opcode: The nvme io command to send - * @flags: NVMe command flags (not used) - * @rsvd: Reserved for future use - * @nsid: Namespace identifier - * @cdw2: Command dword 2 - * @cdw3: Command dword 3 - * @cdw10: Command dword 10 - * @cdw11: Command dword 11 - * @cdw12: Command dword 12 - * @cdw13: Command dword 13 - * @cdw14: Command dword 14 - * @cdw15: Command dword 15 - * @data_len: Length of the data transferred in this command in bytes - * @data: Pointer to user address of the data buffer - * @metadata_len:Length of metadata transferred in this command - * @metadata: Pointer to user address of the metadata buffer - * @timeout_ms: How long the kernel waits for the command to complete - * @result: Optional field to return the result from the CQE dword 0 - * - * Parameterized form of nvme_submit_io_passthru64(). This sets up and submits - * a &struct nvme_passthru_cmd64. - * - * Known values for @opcode are defined in &enum nvme_io_opcode. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_io_passthru64(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, - __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, void *metadata, - __u32 timeout_ms, __u64 *result); +int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); /** * nvme_submit_io_passthru() - Submit an nvme passthrough command * @hdl: Transport handle * @cmd: The nvme io command to send - * @result: Optional field to return the result from the CQE dword 0 - * @result: Optional field to return the result from the CQE DW0 * * Uses NVME_IOCTL_IO_CMD for the ioctl request. * * Return: 0 on success, the nvme command status if a response was * received (see &enum nvme_status_field) or a negative error otherwise. */ -int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, - __u32 *result); - -/** - * nvme_io_passthru() - Submit an nvme io passthrough command - * @hdl: Transport handle - * @opcode: The nvme io command to send - * @flags: NVMe command flags (not used) - * @rsvd: Reserved for future use - * @nsid: Namespace identifier - * @cdw2: Command dword 2 - * @cdw3: Command dword 3 - * @cdw10: Command dword 10 - * @cdw11: Command dword 11 - * @cdw12: Command dword 12 - * @cdw13: Command dword 13 - * @cdw14: Command dword 14 - * @cdw15: Command dword 15 - * @data_len: Length of the data transferred in this command in bytes - * @data: Pointer to user address of the data buffer - * @metadata_len:Length of metadata transferred in this command - * @metadata: Pointer to user address of the metadata buffer - * @timeout_ms: How long the kernel waits for the command to complete - * @result: Optional field to return the result from the CQE dword 0 - * - * Parameterized form of nvme_submit_io_passthru(). This sets up and submits - * a &struct nvme_passthru_cmd. - * - * Known values for @opcode are defined in &enum nvme_io_opcode. - * - * Return: 0 on success, the nvme command status if a response was - * received (see &enum nvme_status_field) or a negative error otherwise. - */ -int nvme_io_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, __u16 rsvd, - __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, - __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, void *metadata, - __u32 timeout_ms, __u32 *result); +int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); /** * nvme_subsystem_reset() - Initiate a subsystem reset @@ -1320,14 +1098,13 @@ nvme_init_zns_identify_ctrl(struct nvme_passthru_cmd *cmd, * @cmd: Passthru command * @rae: Retain asynchronous events * @xfer_len: Max log transfer size per request to split the total. - * @result: The command completion result from CQE dword0 * * Return: 0 on success, the nvme command status if a response was * received (see &enum nvme_status_field) or a negative error otherwise. */ int nvme_get_log(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, bool rae, - __u32 xfer_len, __u32 *result); + __u32 xfer_len); /** * nvme_init_get_log_lpo() - Initializes passthru command with a @@ -4257,7 +4034,7 @@ nvme_init_set_property(struct nvme_passthru_cmd *cmd, __u32 offset, __u64 value) * This is an NVMe-over-Fabrics specific command. */ static inline void -nvme_init_get_property(struct nvme_passthru_cmd64 *cmd, __u32 offset) +nvme_init_get_property(struct nvme_passthru_cmd *cmd, __u32 offset) { memset(cmd, 0, sizeof(*cmd)); @@ -4384,7 +4161,7 @@ static inline int nvme_flush(struct nvme_transport_handle *hdl, __u32 nsid) cmd.opcode = nvme_cmd_flush; cmd.nsid = nsid; - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } /** @@ -4438,18 +4215,11 @@ nvme_init_dsm(struct nvme_passthru_cmd *cmd, * the command-specific init function (like nvme_init_zns_append). */ static inline int -nvme_init_var_size_tags(struct nvme_passthru_cmd64 *cmd, +nvme_init_var_size_tags(struct nvme_passthru_cmd *cmd, __u8 pif, __u8 sts, __u64 reftag, __u64 storage_tag) { __u32 cdw2 = 0, cdw3 = 0, cdw14 = 0; - /* - * Ignore warning about array subscript is out of bounds, - * which is not correct - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" - switch (pif) { case NVME_NVM_PIF_16B_GUARD: cdw14 = NVME_FIELD_ENCODE(reftag, @@ -4509,8 +4279,6 @@ nvme_init_var_size_tags(struct nvme_passthru_cmd64 *cmd, cmd->cdw14 = cdw14; return 0; - -#pragma GCC diagnostic pop } /** @@ -4521,24 +4289,15 @@ nvme_init_var_size_tags(struct nvme_passthru_cmd64 *cmd, * @lbatm: Logical block application tag mask */ static inline void -nvme_init_app_tag(struct nvme_passthru_cmd64 *cmd, +nvme_init_app_tag(struct nvme_passthru_cmd *cmd, __u16 lbat, __u16 lbatm) { - /* - * Ignore warning about array subscript is out of bounds, - * which is not correct - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" - cmd->cdw15 = NVME_FIELD_ENCODE(lbat, NVME_IOCS_COMMON_CDW15_ELBAT_SHIFT, NVME_IOCS_COMMON_CDW15_ELBAT_MASK) | NVME_FIELD_ENCODE(lbatm, NVME_IOCS_COMMON_CDW15_ELBATM_SHIFT, NVME_IOCS_COMMON_CDW15_ELBATM_MASK); - -#pragma GCC diagnostic pop } /** @@ -5274,7 +5033,7 @@ nvme_init_zns_report_zones(struct nvme_passthru_cmd *cmd, __u32 nsid, * Initializes the passthru command buffer for the ZNS Append command. */ static inline void -nvme_init_zns_append(struct nvme_passthru_cmd64 *cmd, __u32 nsid, +nvme_init_zns_append(struct nvme_passthru_cmd *cmd, __u32 nsid, __u64 zslba, __u16 nlb, __u16 control, __u16 cev, __u16 dspec, void *data, __u32 data_len, void *metadata, __u32 metadata_len) { @@ -5650,7 +5409,7 @@ nvme_identify(struct nvme_transport_handle *hdl, __u32 nsid, enum nvme_csi csi, nvme_init_identify(&cmd, nsid, csi, cns, data, len); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** * nvme_identify_ctrl() - Submit an Identify Controller command @@ -5673,7 +5432,7 @@ nvme_identify_ctrl(struct nvme_transport_handle *hdl, nvme_init_identify_ctrl(&cmd, id); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5697,7 +5456,7 @@ nvme_identify_active_ns_list(struct nvme_transport_handle *hdl, nvme_init_identify_active_ns_list(&cmd, nsid, ns_list); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5722,7 +5481,7 @@ nvme_identify_ns(struct nvme_transport_handle *hdl, nvme_init_identify_ns(&cmd, nsid, ns); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5748,7 +5507,7 @@ nvme_identify_csi_ns(struct nvme_transport_handle *hdl, __u32 nsid, nvme_init_identify_csi_ns(&cmd, nsid, csi, uidx, id_ns); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5771,7 +5530,7 @@ nvme_identify_uuid_list(struct nvme_transport_handle *hdl, nvme_init_identify_uuid_list(&cmd, uuid_list); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5797,7 +5556,7 @@ nvme_identify_csi_ns_user_data_format(struct nvme_transport_handle *hdl, nvme_init_identify_csi_ns_user_data_format(&cmd, csi, fidx, uidx, data); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5820,7 +5579,7 @@ nvme_identify_ns_granularity(struct nvme_transport_handle *hdl, nvme_init_identify_ns_granularity(&cmd, gr_list); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5845,7 +5604,7 @@ nvme_identify_ns_descs_list(struct nvme_transport_handle *hdl, nvme_init_identify_ns_descs_list(&cmd, nsid, descs); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5869,7 +5628,7 @@ nvme_zns_identify_ns(struct nvme_transport_handle *hdl, nvme_init_zns_identify_ns(&cmd, nsid, data); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -5895,7 +5654,7 @@ nvme_get_log_simple(struct nvme_transport_handle *hdl, nvme_init_get_log(&cmd, NVME_NSID_ALL, lid, NVME_CSI_NVM, data, len); - return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); } /** @@ -5919,7 +5678,7 @@ nvme_get_log_supported_log_pages(struct nvme_transport_handle *hdl, nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_SUPPORTED_LOG_PAGES, NVME_CSI_NVM, log, sizeof(*log)); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } @@ -5949,7 +5708,7 @@ nvme_get_log_error(struct nvme_transport_handle *hdl, __u32 nsid, nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_ERROR, NVME_CSI_NVM, err_log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -5978,7 +5737,7 @@ nvme_get_log_fw_slot(struct nvme_transport_handle *hdl, __u32 nsid, nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_FW_SLOT, NVME_CSI_NVM, fw_log, sizeof(*fw_log)); - return nvme_get_log(hdl, &cmd, false, sizeof(*fw_log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*fw_log)); } /** @@ -6008,7 +5767,7 @@ nvme_get_log_changed_ns_list(struct nvme_transport_handle *hdl, __u32 nsid, nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_CHANGED_NS, NVME_CSI_NVM, ns_log, sizeof(*ns_log)); - return nvme_get_log(hdl, &cmd, true, sizeof(*ns_log), NULL); + return nvme_get_log(hdl, &cmd, true, sizeof(*ns_log)); } /** @@ -6037,7 +5796,7 @@ nvme_get_log_cmd_effects(struct nvme_transport_handle *hdl, nvme_init_get_log_cmd_effects(&cmd, csi, effects_log); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6067,7 +5826,7 @@ nvme_get_log_device_self_test(struct nvme_transport_handle *hdl, nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_DEVICE_SELF_TEST, NVME_CSI_NVM, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6097,7 +5856,7 @@ nvme_get_log_create_telemetry_host_mcda(struct nvme_transport_handle *hdl, nvme_init_get_log_create_telemetry_host_mcda(&cmd, mcda, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6124,7 +5883,7 @@ nvme_get_log_create_telemetry_host(struct nvme_transport_handle *hdl, nvme_init_get_log_create_telemetry_host(&cmd, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6154,7 +5913,7 @@ nvme_get_log_telemetry_host(struct nvme_transport_handle *hdl, nvme_init_get_log_telemetry_host(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6183,7 +5942,7 @@ nvme_get_log_telemetry_ctrl(struct nvme_transport_handle *hdl, bool rae, nvme_init_get_log_telemetry_ctrl(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6213,7 +5972,7 @@ nvme_get_log_endurance_group(struct nvme_transport_handle *hdl, nvme_init_get_log_endurance_group(&cmd, endgid, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6243,7 +6002,7 @@ nvme_get_log_predictable_lat_nvmset(struct nvme_transport_handle *hdl, nvme_init_get_log_predictable_lat_nvmset(&cmd, nvmsetid, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6273,7 +6032,7 @@ nvme_get_log_predictable_lat_event(struct nvme_transport_handle *hdl, nvme_init_get_log_predictable_lat_event(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6304,7 +6063,7 @@ nvme_get_log_fdp_configurations(struct nvme_transport_handle *hdl, nvme_init_get_log_fdp_configurations(&cmd, egid, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6334,7 +6093,7 @@ nvme_get_log_reclaim_unit_handle_usage(struct nvme_transport_handle *hdl, nvme_init_get_log_reclaim_unit_handle_usage(&cmd, egid, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6364,7 +6123,7 @@ nvme_get_log_fdp_stats(struct nvme_transport_handle *hdl, nvme_init_get_log_fdp_stats(&cmd, egid, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6397,7 +6156,7 @@ nvme_get_log_fdp_events(struct nvme_transport_handle *hdl, nvme_init_get_log_fdp_events(&cmd, egid, host_events, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6429,7 +6188,7 @@ nvme_get_log_ana(struct nvme_transport_handle *hdl, bool rae, nvme_init_get_log_ana(&cmd, lsp, lpo, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6482,7 +6241,7 @@ nvme_get_log_lba_status(struct nvme_transport_handle *hdl, nvme_init_get_log_lba_status(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6512,7 +6271,7 @@ nvme_get_log_endurance_grp_evt(struct nvme_transport_handle *hdl, nvme_init_get_log_endurance_grp_evt(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6537,7 +6296,7 @@ nvme_get_log_fid_supported_effects(struct nvme_transport_handle *hdl, nvme_init_get_log_fid_supported_effects(&cmd, csi, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6562,7 +6321,7 @@ nvme_get_log_mi_cmd_supported_effects(struct nvme_transport_handle *hdl, nvme_init_get_log_mi_cmd_supported_effects(&cmd, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -6591,7 +6350,7 @@ nvme_get_log_boot_partition(struct nvme_transport_handle *hdl, nvme_init_get_log_boot_partition(&cmd, lsp, part, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6624,7 +6383,7 @@ nvme_get_log_rotational_media_info(struct nvme_transport_handle *hdl, nvme_init_get_log_rotational_media_info(&cmd, endgid, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6653,7 +6412,7 @@ nvme_get_log_dispersed_ns_participating_nss(struct nvme_transport_handle *hdl, nvme_init_get_log_dispersed_ns_participating_nss(&cmd, nsid, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6679,7 +6438,7 @@ nvme_get_log_mgmt_addr_list(struct nvme_transport_handle *hdl, nvme_init_get_log_mgmt_addr_list(&cmd, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6713,7 +6472,7 @@ nvme_get_log_phy_rx_eom(struct nvme_transport_handle *hdl, nvme_init_get_log_phy_rx_eom(&cmd, lsp, controller, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6744,7 +6503,7 @@ nvme_get_log_reachability_groups(struct nvme_transport_handle *hdl, nvme_init_get_log_reachability_groups(&cmd, rgo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6778,7 +6537,7 @@ nvme_get_log_reachability_associations(struct nvme_transport_handle *hdl, nvme_init_get_log_reachability_associations(&cmd, rao, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6806,7 +6565,7 @@ nvme_get_log_changed_alloc_ns_list(struct nvme_transport_handle *hdl, nvme_init_get_log_changed_ns(&cmd, log); - return nvme_get_log(hdl, &cmd, true, len, NULL); + return nvme_get_log(hdl, &cmd, true, len); } /** @@ -6832,7 +6591,7 @@ nvme_get_log_discovery(struct nvme_transport_handle *hdl, nvme_init_get_log_discovery(&cmd, lpo, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6861,7 +6620,7 @@ nvme_get_log_host_discovery(struct nvme_transport_handle *hdl, nvme_init_get_log_host_discovery(&cmd, allhoste, log, len); - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -6887,7 +6646,7 @@ nvme_get_log_ave_discovery(struct nvme_transport_handle *hdl, nvme_init_get_log_ave_discovery(&cmd, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6913,7 +6672,7 @@ nvme_get_log_pull_model_ddc_req(struct nvme_transport_handle *hdl, nvme_init_get_log_pull_model_ddc_req(&cmd, log, len); - return nvme_get_log(hdl, &cmd, rae, len, NULL); + return nvme_get_log(hdl, &cmd, rae, len); } /** @@ -6944,7 +6703,7 @@ nvme_get_log_media_unit_stat(struct nvme_transport_handle *hdl, nvme_init_get_log_media_unit_stat(&cmd, domid, mus); - return nvme_get_log(hdl, &cmd, false, sizeof(*mus), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*mus)); } /** @@ -6977,7 +6736,7 @@ nvme_get_log_support_cap_config_list(struct nvme_transport_handle *hdl, nvme_init_get_log_support_cap_config_list(&cmd, domid, cap); - return nvme_get_log(hdl, &cmd, false, sizeof(*cap), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*cap)); } /** @@ -7000,7 +6759,7 @@ nvme_get_log_reservation(struct nvme_transport_handle *hdl, nvme_init_get_log_reservation(&cmd, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -7027,7 +6786,7 @@ nvme_get_log_sanitize(struct nvme_transport_handle *hdl, nvme_init_get_log_sanitize(&cmd, log); - return nvme_get_log(hdl, &cmd, rae, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, rae, sizeof(*log)); } /** @@ -7055,7 +6814,7 @@ nvme_get_log_zns_changed_zones(struct nvme_transport_handle *hdl, nvme_init_get_log_zns_changed_zones(&cmd, nsid, log); - return nvme_get_log(hdl, &cmd, rae, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, rae, sizeof(*log)); } /** @@ -7087,7 +6846,7 @@ nvme_get_log_persistent_event(struct nvme_transport_handle *hdl, * Call the generic log execution function. * The data length is determined by the 'len' parameter. */ - return nvme_get_log(hdl, &cmd, false, len, NULL); + return nvme_get_log(hdl, &cmd, false, len); } /** @@ -7117,7 +6876,7 @@ nvme_get_log_lockdown(struct nvme_transport_handle *hdl, nvme_init_get_log_lockdown(&cmd, cnscp, log); - return nvme_get_log(hdl, &cmd, false, sizeof(*log), NULL); + return nvme_get_log(hdl, &cmd, false, sizeof(*log)); } /** @@ -7142,7 +6901,7 @@ nvme_get_log_smart(struct nvme_transport_handle *hdl, nvme_init_get_log_smart(&cmd, nsid, smart_log); - return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); } /** @@ -7170,9 +6929,10 @@ nvme_get_log_smart(struct nvme_transport_handle *hdl, static inline int nvme_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u8 fid, bool sv, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u8 uidx, - __u32 cdw15, void *data, __u32 len, __u32 *result) + __u32 cdw15, void *data, __u32 len, __u64 *result) { struct nvme_passthru_cmd cmd; + int err; nvme_init_set_features(&cmd, fid, sv); cmd.nsid = nsid; @@ -7186,7 +6946,10 @@ nvme_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u8 fid, cmd.data_len = len; cmd.addr = (__u64)(uintptr_t)data; - return nvme_submit_admin_passthru(hdl, &cmd, result); + err = nvme_submit_admin_passthru(hdl, &cmd); + if (result) + *result = cmd.result; + return err; } /** @@ -7207,15 +6970,19 @@ nvme_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u8 fid, */ static inline int nvme_set_features_simple(struct nvme_transport_handle *hdl, - __u32 nsid, __u8 fid, bool sv, __u32 cdw11, __u32 *result) + __u32 nsid, __u8 fid, bool sv, __u32 cdw11, __u64 *result) { struct nvme_passthru_cmd cmd; + int err; nvme_init_set_features(&cmd, fid, sv); cmd.nsid = nsid; cmd.cdw11 = cdw11; - return nvme_submit_admin_passthru(hdl, &cmd, result); + err = nvme_submit_admin_passthru(hdl, &cmd); + if (result) + *result = cmd.result; + return err; } /** @@ -7238,9 +7005,10 @@ static inline int nvme_get_features(struct nvme_transport_handle *hdl, __u32 nsid, __u8 fid, enum nvme_get_features_sel sel, __u32 cdw11, __u8 uidx, void *data, - __u32 len, __u32 *result) + __u32 len, __u64 *result) { struct nvme_passthru_cmd cmd; + int err; nvme_init_get_features(&cmd, fid, sel); @@ -7252,7 +7020,10 @@ nvme_get_features(struct nvme_transport_handle *hdl, __u32 nsid, cmd.data_len = len; cmd.addr = (__u64)(uintptr_t)data; - return nvme_submit_admin_passthru(hdl, &cmd, result); + err = nvme_submit_admin_passthru(hdl, &cmd); + if (result) + *result = cmd.result; + return err; } /** @@ -7271,12 +7042,16 @@ nvme_get_features(struct nvme_transport_handle *hdl, __u32 nsid, */ static inline int nvme_get_features_simple(struct nvme_transport_handle *hdl, __u8 fid, - enum nvme_get_features_sel sel, __u32 *result) + enum nvme_get_features_sel sel, __u64 *result) { struct nvme_passthru_cmd cmd; + int err; nvme_init_get_features(&cmd, fid, sel); - return nvme_submit_admin_passthru(hdl, &cmd, result); + err = nvme_submit_admin_passthru(hdl, &cmd); + if (result) + *result = cmd.result; + return err; } #endif /* _LIBNVME_IOCTL_H */ diff --git a/libnvme/src/nvme/linux.c b/libnvme/src/nvme/linux.c index f1fc7f6a27..219224bf43 100644 --- a/libnvme/src/nvme/linux.c +++ b/libnvme/src/nvme/linux.c @@ -41,6 +41,39 @@ #include "base64.h" #include "crc32.h" +void nvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable) +{ + ctx->dry_run = enable; +} + +void nvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, + void *(*submit_entry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd)) +{ + hdl->submit_entry = submit_entry; + if (!hdl->submit_exit) + hdl->submit_exit = __nvme_submit_exit; +} + +void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, + void (*submit_exit)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, + int err, void *user_data)) +{ + hdl->submit_exit = submit_exit; + if (!hdl->submit_exit) + hdl->submit_exit = __nvme_submit_exit; +} + +void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, + bool (*decide_retry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err)) +{ + hdl->decide_retry = decide_retry; + if (!hdl->decide_retry) + hdl->decide_retry = __nvme_decide_retry; +} + static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl, const char *devname) { _cleanup_free_ char *path = NULL; @@ -74,6 +107,10 @@ static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl return -EINVAL; } + ret = ioctl(hdl->fd, NVME_IOCTL_ADMIN64_CMD, NULL); + if (ret == -1 && errno != ENOTTY) + hdl->ioctl64 = true; + return 0; } @@ -92,6 +129,9 @@ struct nvme_transport_handle *__nvme_create_transport_handle(struct nvme_global_ return NULL; hdl->ctx = ctx; + hdl->submit_entry = __nvme_submit_entry; + hdl->submit_exit = __nvme_submit_exit; + hdl->decide_retry = __nvme_decide_retry; return hdl; } @@ -112,9 +152,13 @@ int nvme_open(struct nvme_global_ctx *ctx, const char *name, return -ENOMEM; } - if (!strcmp(name, "NVME_TEST_FD")) { + if (!strncmp(name, "NVME_TEST_FD", 12)) { hdl->type = NVME_TRANSPORT_HANDLE_TYPE_DIRECT; hdl->fd = 0xFD; + + if (!strcmp(name, "NVME_TEST_FD64")) + hdl->ioctl64 = true; + *hdlp = hdl; return 0; } @@ -195,7 +239,7 @@ int nvme_fw_download_seq(struct nvme_transport_handle *hdl, __u32 size, err = nvme_init_fw_download(&cmd, data, MIN(xfer, size), offset); if (err) break; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) break; @@ -214,7 +258,7 @@ int nvme_set_etdas(struct nvme_transport_handle *hdl, bool *changed) int err; nvme_init_get_features_host_behavior(&cmd, 0, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -226,7 +270,7 @@ int nvme_set_etdas(struct nvme_transport_handle *hdl, bool *changed) da4.etdas = 1; nvme_init_set_features_host_behavior(&cmd, false, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -241,7 +285,7 @@ int nvme_clear_etdas(struct nvme_transport_handle *hdl, bool *changed) int err; nvme_init_get_features_host_behavior(&cmd, 0, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -252,7 +296,7 @@ int nvme_clear_etdas(struct nvme_transport_handle *hdl, bool *changed) da4.etdas = 0; nvme_init_set_features_host_behavior(&cmd, false, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -268,7 +312,7 @@ int nvme_get_uuid_list(struct nvme_transport_handle *hdl, struct nvme_id_uuid_li memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); nvme_init_identify_ctrl(&cmd, &ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) { fprintf(stderr, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err); return err; @@ -276,7 +320,7 @@ int nvme_get_uuid_list(struct nvme_transport_handle *hdl, struct nvme_id_uuid_li if ((ctrl.ctratt & NVME_CTRL_CTRATT_UUID_LIST) == NVME_CTRL_CTRATT_UUID_LIST) { nvme_init_identify_uuid_list(&cmd, uuid_list); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); } return err; @@ -293,7 +337,7 @@ int nvme_get_telemetry_max(struct nvme_transport_handle *hdl, enum nvme_telemetr return -ENOMEM; nvme_init_identify_ctrl(&cmd, id_ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -336,14 +380,14 @@ int nvme_get_telemetry_log(struct nvme_transport_handle *hdl, bool create, bool if (ctrl) { nvme_init_get_log_telemetry_ctrl(&cmd, 0, log, xfer); - err = nvme_get_log(hdl, &cmd, true, xfer, NULL); + err = nvme_get_log(hdl, &cmd, true, xfer); } else { if (create) { nvme_init_get_log_create_telemetry_host_mcda(&cmd, da, log); - err = nvme_get_log(hdl, &cmd, false, xfer, NULL); + err = nvme_get_log(hdl, &cmd, false, xfer); } else { nvme_init_get_log_telemetry_host(&cmd, 0, log, xfer); - err = nvme_get_log(hdl, &cmd, false, xfer, NULL); + err = nvme_get_log(hdl, &cmd, false, xfer); } } @@ -389,7 +433,7 @@ int nvme_get_telemetry_log(struct nvme_transport_handle *hdl, bool create, bool nvme_init_get_log_telemetry_ctrl(&cmd, 0, log, *size); else nvme_init_get_log_telemetry_host(&cmd, 0, log, *size); - err = nvme_get_log(hdl, &cmd, rae, max_data_tx, NULL); + err = nvme_get_log(hdl, &cmd, rae, max_data_tx); if (err) return err; @@ -448,7 +492,7 @@ int nvme_get_lba_status_log(struct nvme_transport_handle *hdl, bool rae, struct return -ENOMEM; nvme_init_get_log_lba_status(&cmd, 0, log, sizeof(*buf)); - err = nvme_get_log(hdl, &cmd, true, sizeof(*buf), NULL); + err = nvme_get_log(hdl, &cmd, true, sizeof(*buf)); if (err) { *log = NULL; return err; @@ -469,7 +513,7 @@ int nvme_get_lba_status_log(struct nvme_transport_handle *hdl, bool rae, struct buf = tmp; nvme_init_get_log_lba_status(&cmd, 0, buf, size); - err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); if (err) { *log = NULL; return err; @@ -492,7 +536,7 @@ static int nvme_ns_attachment(struct nvme_transport_handle *hdl, __u32 nsid, else nvme_init_ns_detach_ctrls(&cmd, nsid, &cntlist); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } int nvme_namespace_attach_ctrls(struct nvme_transport_handle *hdl, __u32 nsid, @@ -528,7 +572,7 @@ int nvme_get_ana_log_len(struct nvme_transport_handle *hdl, size_t *analen) return -ENOMEM; nvme_init_identify_ctrl(&cmd, ctrl); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (ret) return ret; @@ -548,7 +592,7 @@ int nvme_get_logical_block_size(struct nvme_transport_handle *hdl, __u32 nsid, i return -ENOMEM; nvme_init_identify_ns(&cmd, nsid, ns); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (ret) return ret; diff --git a/libnvme/src/nvme/linux.h b/libnvme/src/nvme/linux.h index 6149c14339..f136e0a011 100644 --- a/libnvme/src/nvme/linux.h +++ b/libnvme/src/nvme/linux.h @@ -287,6 +287,70 @@ bool nvme_transport_handle_is_direct(struct nvme_transport_handle *hdl); */ bool nvme_transport_handle_is_mi(struct nvme_transport_handle *hdl); +/** + * nvme_transport_handle_set_submit_entry() - Install a submit-entry callback + * @hdl: Transport handle to configure + * @submit_entry: Callback invoked immediately before a passthrough command is + * submitted. The function receives the command about to be issued + * and may return an opaque pointer representing per-command + * context. This pointer is later passed unmodified to the + * submit-exit callback. Implementations typically use this hook + * for logging, tracing, or allocating per-command state. + * + * Installs a user-defined callback that is invoked at the moment a passthrough + * command enters the NVMe submission path. Passing NULL removes any previously + * installed callback. + * + * Return: None. + */ +void nvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, + void *(*submit_entry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd)); + +/** + * nvme_transport_handle_set_submit_exit() - Install a submit-exit callback + * @hdl: Transport handle to configure + * @submit_exit: Callback invoked after a passthrough command completes. The + * function receives the command, the completion status @err + * (0 for success, a negative errno, or an NVMe status value), and + * the @user_data pointer returned earlier by the submit-entry + * callback. Implementations typically use this hook for logging, + * tracing, or freeing per-command state. + * + * Installs a callback that is invoked when a passthrough command leaves the + * NVMe submission path. Passing NULL removes any previously installed callback. + * + * Return: None. + */ +void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, + void (*submit_exit)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, + int err, void *user_data)); + +/** + * nvme_transport_handle_set_decide_retry() - Install a retry-decision callback + * @hdl: Transport handle to configure + * @decide_retry: Callback used to determine whether a passthrough command + * should be retried after an error. The function is called with + * the command that failed and the error code returned by the + * kernel or device. The callback should return true if the + * submission path should retry the command, or false if the + * error is final. + * + * Installs a user-provided callback to control retry behavior for + * passthrough commands issued through @hdl. This allows transports or + * higher-level logic to implement custom retry policies, such as retrying on + * transient conditions like -EAGAIN or device-specific status codes. + * + * Passing NULL clears any previously installed callback and reverts to the + * default behavior (no retries). + * + * Return: None. + */ +void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, + bool (*decide_retry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err)); + /** * enum nvme_hmac_alg - HMAC algorithm * @NVME_HMAC_ALG_NONE: No HMAC algorithm @@ -636,41 +700,15 @@ int nvme_import_tls_key_versioned(const char *encoded_key, unsigned char *hmac, size_t *key_len, unsigned char **key); -/** - * nvme_submit_passthru - Low level ioctl wrapper for passthru commands - * @hdl: Transport handle - * @ioctl_cmd: IOCTL command id - * @cmd: Passhtru command - * @result: Optional field to return the result - * - * This is a low level library function which should not be used directly. It is - * exposed as weak symbol so that the user application is able to provide their own - * implementation of this function with additional debugging or logging code. - * - * Return: The value from the ioctl system call (see ioctl documentation) or - * a negative error code otherwise. - */ -__attribute__((weak)) -int nvme_submit_passthru(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd *cmd, __u32 *result); /** - * nvme_submit_passthru64 - Low level ioctl wrapper for passthru commands - * @hdl: Transport handle - * @ioctl_cmd: IOCTL command id - * @cmd: Passhtru command - * @result: Optional field to return the result - * - * This is a low level library function which should not be used directly. It is - * exposed as weak symbol so that the user application is able to provide their own - * implementation of this function with additional debugging or logging code. + * nvme_set_dry_run() - Set global dry run state + * @ctx: struct nvme_global_ctx object + * @enable: Enable/disable dry run state * - * Return: The value from the ioctl system call (see ioctl documentation) or - * a negative error code otherwise. + * When dry_run is enabled, any IOCTL commands send via the passthru + * interface wont be executed. */ -__attribute__((weak)) -int nvme_submit_passthru64(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd64 *cmd, - __u64 *result); +void nvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable); #endif /* _LIBNVME_LINUX_H */ diff --git a/libnvme/src/nvme/mi.c b/libnvme/src/nvme/mi.c index 594794060d..820d3f5261 100644 --- a/libnvme/src/nvme/mi.c +++ b/libnvme/src/nvme/mi.c @@ -255,7 +255,7 @@ void nvme_mi_ep_probe(struct nvme_mi_ep *ep) */ nvme_init_identify_ctrl(&cmd, &id); cmd.data_len = offsetof(struct nvme_id_ctrl, rab); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); if (rc) { nvme_msg(ep->ctx, LOG_WARNING, "Identify Controller failed, no quirks applied\n"); @@ -696,7 +696,7 @@ static void nvme_mi_control_init_resp(struct nvme_mi_resp *resp, resp->hdr_len = sizeof(*control_resp); } -static int nvme_mi_admin_parse_status(struct nvme_mi_resp *resp, __u32 *result) +static int nvme_mi_admin_parse_status(struct nvme_mi_resp *resp, __u64 *result) { struct nvme_mi_admin_resp_hdr *admin_hdr; struct nvme_mi_msg_resp *resp_hdr; @@ -862,12 +862,8 @@ int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, return 0; } -int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, - __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, - __u32 cdw10, __u32 cdw11, __u32 cdw12, - __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, - void *metadata, __u32 timeout_ms, __u32 *result) +int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd) { /* Input parameters flags, rsvd, metadata, metadata_len are not used */ struct nvme_mi_admin_resp_hdr resp_hdr; @@ -876,7 +872,7 @@ int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, struct nvme_mi_req req; unsigned int timeout_save = 0; int rc; - int direction = opcode & 0x3; + int direction = cmd->opcode & 0x3; bool has_write_data = false; bool has_read_data = false; @@ -886,67 +882,67 @@ int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, return -EINVAL; } - if (data_len > 4096) { + if (cmd->data_len > 4096) { nvme_msg(hdl->ctx, LOG_ERR, "nvme_mi_admin_admin_passthru doesn't support data_len over 4096 bytes.\n"); return -EINVAL; } - if (data != NULL && data_len != 0) { + if (cmd->addr != 0 && cmd->data_len != 0) { if (direction == NVME_DATA_TFR_HOST_TO_CTRL) has_write_data = true; if (direction == NVME_DATA_TFR_CTRL_TO_HOST) has_read_data = true; } - nvme_mi_admin_init_req(hdl->ep, &req, &req_hdr, hdl->id, opcode); - req_hdr.cdw1 = cpu_to_le32(nsid); - req_hdr.cdw2 = cpu_to_le32(cdw2); - req_hdr.cdw3 = cpu_to_le32(cdw3); - req_hdr.cdw10 = cpu_to_le32(cdw10); - req_hdr.cdw11 = cpu_to_le32(cdw11); - req_hdr.cdw12 = cpu_to_le32(cdw12); - req_hdr.cdw13 = cpu_to_le32(cdw13); - req_hdr.cdw14 = cpu_to_le32(cdw14); - req_hdr.cdw15 = cpu_to_le32(cdw15); + nvme_mi_admin_init_req(hdl->ep, &req, &req_hdr, hdl->id, cmd->opcode); + req_hdr.cdw1 = cpu_to_le32(cmd->nsid); + req_hdr.cdw2 = cpu_to_le32(cmd->cdw2); + req_hdr.cdw3 = cpu_to_le32(cmd->cdw3); + req_hdr.cdw10 = cpu_to_le32(cmd->cdw10); + req_hdr.cdw11 = cpu_to_le32(cmd->cdw11); + req_hdr.cdw12 = cpu_to_le32(cmd->cdw12); + req_hdr.cdw13 = cpu_to_le32(cmd->cdw13); + req_hdr.cdw14 = cpu_to_le32(cmd->cdw14); + req_hdr.cdw15 = cpu_to_le32(cmd->cdw15); req_hdr.doff = 0; - if (data_len != 0) { - req_hdr.dlen = cpu_to_le32(data_len); + if (cmd->data_len != 0) { + req_hdr.dlen = cpu_to_le32(cmd->data_len); /* Bit 0 set to 1 means DLEN contains a value */ req_hdr.flags = 0x1; } if (has_write_data) { - req.data = data; - req.data_len = data_len; + req.data = (void *)(uintptr_t)cmd->addr; + req.data_len = cmd->data_len; } nvme_mi_admin_init_resp(&resp, &resp_hdr); if (has_read_data) { - resp.data = data; - resp.data_len = data_len; + resp.data = (void *)(uintptr_t)cmd->addr; + resp.data_len = cmd->data_len; } /* if the user has specified a custom timeout, save the current * timeout and override */ - if (timeout_ms != 0) { + if (cmd->timeout_ms != 0) { timeout_save = nvme_mi_ep_get_timeout(hdl->ep); - nvme_mi_ep_set_timeout(hdl->ep, timeout_ms); + nvme_mi_ep_set_timeout(hdl->ep, cmd->timeout_ms); } rc = nvme_mi_submit(hdl->ep, &req, &resp); - if (timeout_ms != 0) + if (cmd->timeout_ms != 0) nvme_mi_ep_set_timeout(hdl->ep, timeout_save); if (rc) return rc; - rc = nvme_mi_admin_parse_status(&resp, result); + rc = nvme_mi_admin_parse_status(&resp, &cmd->result); if (rc) return rc; - if (has_read_data && (resp.data_len != data_len)) + if (has_read_data && (resp.data_len != cmd->data_len)) return -EPROTO; return 0; diff --git a/libnvme/src/nvme/mi.h b/libnvme/src/nvme/mi.h index 813427d393..732f471bed 100644 --- a/libnvme/src/nvme/mi.h +++ b/libnvme/src/nvme/mi.h @@ -1364,24 +1364,7 @@ int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, /** * nvme_mi_admin_admin_passthru() - Submit an nvme admin passthrough command * @hdl: Transport handle to send command to - * @opcode: The nvme admin command to send - * @flags: NVMe command flags (not used) - * @rsvd: Reserved for future use - * @nsid: Namespace identifier - * @cdw2: Command dword 2 - * @cdw3: Command dword 3 - * @cdw10: Command dword 10 - * @cdw11: Command dword 11 - * @cdw12: Command dword 12 - * @cdw13: Command dword 13 - * @cdw14: Command dword 14 - * @cdw15: Command dword 15 - * @data_len: Length of the data transferred in this command in bytes - * @data: Pointer to user address of the data buffer - * @metadata_len:Length of metadata transferred in this command(not used) - * @metadata: Pointer to user address of the metadata buffer(not used) - * @timeout_ms: How long to wait for the command to complete - * @result: Optional field to return the result from the CQE dword 0 + * @cmd: The nvme admin command to send * * Send a customized NVMe Admin command request message and get the corresponding * response message. @@ -1394,12 +1377,8 @@ int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise. */ -int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, __u8 opcode, __u8 flags, - __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, - __u32 cdw10, __u32 cdw11, __u32 cdw12, - __u32 cdw13, __u32 cdw14, __u32 cdw15, - __u32 data_len, void *data, __u32 metadata_len, - void *metadata, __u32 timeout_ms, __u32 *result); +int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); /** * nvme_mi_control() - Perform a Control Primitive command diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h index 84b9103806..e7825376b4 100644 --- a/libnvme/src/nvme/private.h +++ b/libnvme/src/nvme/private.h @@ -24,6 +24,54 @@ const char *nvme_slots_sysfs_dir(void); const char *nvme_uuid_ibm_filename(void); const char *nvme_dmi_entries_dir(void); +struct linux_passthru_cmd32 { + __u8 opcode; + __u8 flags; + __u16 rsvd1; + __u32 nsid; + __u32 cdw2; + __u32 cdw3; + __u64 metadata; + __u64 addr; + __u32 metadata_len; + __u32 data_len; + __u32 cdw10; + __u32 cdw11; + __u32 cdw12; + __u32 cdw13; + __u32 cdw14; + __u32 cdw15; + __u32 timeout_ms; + __u32 result; +}; + +struct linux_passthru_cmd64 { + __u8 opcode; + __u8 flags; + __u16 rsvd1; + __u32 nsid; + __u32 cdw2; + __u32 cdw3; + __u64 metadata; + __u64 addr; + __u32 metadata_len; + __u32 data_len; + __u32 cdw10; + __u32 cdw11; + __u32 cdw12; + __u32 cdw13; + __u32 cdw14; + __u32 cdw15; + __u32 timeout_ms; + __u32 rsvd2; + __u64 result; +}; + +#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct linux_passthru_cmd32) +#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct linux_passthru_cmd32) +#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct linux_passthru_cmd64) +#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct linux_passthru_cmd64) + struct nvme_log { int fd; int level; @@ -42,9 +90,18 @@ struct nvme_transport_handle { enum nvme_transport_handle_type type; char *name; + void *(*submit_entry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); + void (*submit_exit)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, + int err, void *user_data); + bool (*decide_retry)(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err); + /* direct */ int fd; struct stat stat; + bool ioctl64; /* mi */ struct nvme_mi_ep *ep; @@ -211,6 +268,7 @@ struct nvme_global_ctx { bool modified; bool mi_probe_enabled; bool create_only; + bool dry_run; struct nvme_fabric_options *options; }; @@ -222,6 +280,13 @@ int json_update_config(struct nvme_global_ctx *ctx, const char *config_file); int json_dump_tree(struct nvme_global_ctx *ctx); +void *__nvme_submit_entry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); +void __nvme_submit_exit(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err, void *user_data); +bool __nvme_decide_retry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err); + struct nvme_transport_handle *__nvme_open(struct nvme_global_ctx *ctx, const char *name); struct nvme_transport_handle *__nvme_create_transport_handle(struct nvme_global_ctx *ctx); int __nvme_transport_handle_open_mi(struct nvme_transport_handle *hdl, const char *devname); diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 2c7a9c066d..c4d5a94b89 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -1289,7 +1289,7 @@ int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id) struct nvme_passthru_cmd cmd; nvme_init_identify_ctrl(&cmd, id); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } nvme_ns_t nvme_ctrl_first_ns(nvme_ctrl_t c) @@ -2459,7 +2459,7 @@ int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns) struct nvme_passthru_cmd cmd; nvme_init_identify_ns(&cmd, nvme_ns_get_nsid(n), ns); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs) @@ -2468,7 +2468,7 @@ int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs) struct nvme_passthru_cmd cmd; nvme_init_identify_ns_descs_list(&cmd, nvme_ns_get_nsid(n), descs); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count) @@ -2484,7 +2484,7 @@ int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count) nvme_init_verify(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, NULL, 0, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_write_uncorrectable(nvme_ns_t n, off_t offset, size_t count) @@ -2500,7 +2500,7 @@ int nvme_ns_write_uncorrectable(nvme_ns_t n, off_t offset, size_t count) nvme_init_write_uncorrectable(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_write_zeros(nvme_ns_t n, off_t offset, size_t count) @@ -2515,7 +2515,7 @@ int nvme_ns_write_zeros(nvme_ns_t n, off_t offset, size_t count) nvme_init_write_zeros(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_write(nvme_ns_t n, void *buf, off_t offset, size_t count) @@ -2531,7 +2531,7 @@ int nvme_ns_write(nvme_ns_t n, void *buf, off_t offset, size_t count) nvme_init_write(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count) @@ -2547,7 +2547,7 @@ int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count) nvme_init_read(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_compare(nvme_ns_t n, void *buf, off_t offset, size_t count) @@ -2563,7 +2563,7 @@ int nvme_ns_compare(nvme_ns_t n, void *buf, off_t offset, size_t count) nvme_init_compare(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd, NULL); + return nvme_submit_io_passthru(hdl, &cmd); } int nvme_ns_flush(nvme_ns_t n) diff --git a/libnvme/test/ioctl/features.c b/libnvme/test/ioctl/features.c index ed81ff297a..5c4eddcf1e 100644 --- a/libnvme/test/ioctl/features.c +++ b/libnvme/test/ioctl/features.c @@ -26,7 +26,6 @@ static struct nvme_transport_handle *test_hdl; static void test_set_features(void) { - uint32_t result = 0; uint8_t data[256]; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_set_features, @@ -58,16 +57,16 @@ static void test_set_features(void) cmd.data_len = sizeof(data); cmd.addr = (__u64)(uintptr_t)data; cmd.timeout_ms = TEST_TIMEOUT; - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_features(void) { - uint32_t result = 0; uint8_t data[256], get_data[sizeof(data)] = {}; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_get_features, @@ -92,11 +91,12 @@ static void test_get_features(void) cmd.data_len = sizeof(get_data); cmd.addr = (__u64)(uintptr_t)get_data; cmd.timeout_ms = TEST_TIMEOUT; - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(get_data, data, sizeof(data), "incorrect data"); } @@ -112,7 +112,6 @@ static void test_get_features_data(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(data, sizeof(data)); @@ -121,11 +120,12 @@ static void test_get_features_data(void) cmd.nsid = TEST_NSID; cmd.data_len = sizeof(get_data); cmd.addr = (__u64)(uintptr_t)get_data; - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(get_data, data, sizeof(data), "incorrect data"); } @@ -139,16 +139,16 @@ static void test_set_arbitration(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_arbitration(&cmd, false, AB, LPW, MPW, HPW); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_arbitration(void) @@ -159,16 +159,16 @@ static void test_get_arbitration(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_arbitration(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_power_mgmt(void) @@ -182,16 +182,16 @@ static void test_set_power_mgmt(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_power_mgmt(&cmd, true, PS, WH); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_power_mgmt(void) @@ -202,16 +202,16 @@ static void test_get_power_mgmt(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_power_mgmt(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_lba_range(void) @@ -228,18 +228,18 @@ static void test_set_lba_range(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&range_types, sizeof(range_types)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_lba_range(&cmd, TEST_NSID, false, NUM, &range_types); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_lba_range(void) @@ -254,18 +254,18 @@ static void test_get_lba_range(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&range_types, sizeof(range_types)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_lba_range(&cmd, TEST_NSID, TEST_SEL, &get_range_types); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&get_range_types, &range_types, sizeof(range_types), "incorrect LBA range types"); } @@ -284,16 +284,16 @@ static void test_set_temp_thresh(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_temp_thresh(&cmd, true, TMPTH, TMPSEL, THSEL, 0); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_temp_thresh(void) @@ -309,16 +309,16 @@ static void test_get_temp_thresh(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_temp_thresh(&cmd, TEST_SEL, 0, 0); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_err_recovery(void) @@ -333,16 +333,16 @@ static void test_set_err_recovery(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_err_recovery(&cmd, TEST_NSID, false, TLER, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_err_recovery(void) @@ -354,16 +354,16 @@ static void test_get_err_recovery(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_err_recovery(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_volatile_wc(void) @@ -376,16 +376,16 @@ static void test_set_volatile_wc(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_volatile_wc(&cmd, true, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_volatile_wc(void) @@ -397,16 +397,16 @@ static void test_get_volatile_wc(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_volatile_wc(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_num_queues(void) @@ -417,16 +417,16 @@ static void test_get_num_queues(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_num_queues(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_irq_coalesce(void) @@ -439,16 +439,16 @@ static void test_set_irq_coalesce(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_irq_coalesce(&cmd, false, THR, TIME); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_irq_coalesce(void) @@ -459,16 +459,16 @@ static void test_get_irq_coalesce(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_irq_coalesce(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_irq_config(void) @@ -483,16 +483,16 @@ static void test_set_irq_config(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_irq_config(&cmd, true, IV, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_irq_config(void) @@ -505,16 +505,16 @@ static void test_get_irq_config(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_irq_config(&cmd, TEST_SEL, IV, false); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_write_atomic(void) @@ -526,16 +526,16 @@ static void test_set_write_atomic(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_write_atomic(&cmd, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_write_atomic(void) @@ -546,16 +546,16 @@ static void test_get_write_atomic(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_write_atomic(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_async_event(void) @@ -569,16 +569,16 @@ static void test_set_async_event(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_async_event(&cmd, true, EVENTS); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_async_event(void) @@ -589,16 +589,16 @@ static void test_get_async_event(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_async_event(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_auto_pst(void) @@ -613,17 +613,17 @@ static void test_set_auto_pst(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&apst, sizeof(apst)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_auto_pst(&cmd, false, true, &apst); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_auto_pst(void) @@ -637,17 +637,17 @@ static void test_get_auto_pst(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&apst, sizeof(apst)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_auto_pst(&cmd, TEST_SEL, &get_apst); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&get_apst, &apst, sizeof(apst), "incorrect apst"); } @@ -662,17 +662,17 @@ static void test_get_host_mem_buf(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&attrs, sizeof(attrs)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_mem_buf(&cmd, TEST_SEL, &get_attrs); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&get_attrs, &attrs, sizeof(attrs), "incorrect attrs"); } @@ -693,13 +693,12 @@ static void test_set_timestamp(void) .cdw10 = (uint32_t)1 << 31 /* SAVE */ | NVME_FEAT_FID_TIMESTAMP, }; - uint32_t result = 0; struct nvme_passthru_cmd cmd; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_timestamp(&cmd, true, timestamp, &buf); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -714,13 +713,12 @@ static void test_get_timestamp(void) .out_data = &ts, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&ts, sizeof(ts)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_timestamp(&cmd, TEST_SEL, &get_ts); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(&get_ts, &ts, sizeof(ts), "incorrect timestamp"); @@ -734,16 +732,16 @@ static void test_get_kato(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_kato(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_hctm(void) @@ -756,16 +754,16 @@ static void test_set_hctm(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_hctm(&cmd, false, TMT2, TMT1); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_hctm(void) @@ -776,16 +774,16 @@ static void test_get_hctm(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_hctm(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_nopsc(void) @@ -798,16 +796,16 @@ static void test_set_nopsc(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_nopsc(&cmd, true, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_nopsc(void) @@ -818,16 +816,16 @@ static void test_get_nopsc(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_nopsc(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_rrl(void) @@ -842,16 +840,16 @@ static void test_set_rrl(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_rrl(&cmd, false, NVMSETID, RRL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_rrl(void) @@ -863,16 +861,16 @@ static void test_get_rrl(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_rrl(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_plm_config(void) @@ -890,17 +888,17 @@ static void test_set_plm_config(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&config, sizeof(config)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_plm_config(&cmd, true, NVMSETID, true, &config); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_plm_config(void) @@ -916,18 +914,18 @@ static void test_get_plm_config(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&config, sizeof(config)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_plm_config(&cmd, TEST_SEL, NVMSETID, &get_config); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&get_config, &config, sizeof(config), "incorrect PLM config"); } @@ -943,16 +941,16 @@ static void test_set_plm_window(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_plm_window(&cmd, false, NVMSETID, SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_plm_window(void) @@ -965,16 +963,16 @@ static void test_get_plm_window(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_plm_window(&cmd, TEST_SEL, NVMSETID); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_lba_sts_interval(void) @@ -988,16 +986,16 @@ static void test_set_lba_sts_interval(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_lba_sts_interval(&cmd, true, LSIRI, LSIPI); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_lba_sts_interval(void) @@ -1008,16 +1006,16 @@ static void test_get_lba_sts_interval(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_lba_sts_interval(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_host_behavior(void) @@ -1031,13 +1029,12 @@ static void test_set_host_behavior(void) .cdw10 = NVME_FEAT_FID_HOST_BEHAVIOR, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&behavior, sizeof(behavior)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_behavior(&cmd, false, &behavior); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1053,17 +1050,17 @@ static void test_get_host_behavior(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&behavior, sizeof(behavior)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_behavior(&cmd, TEST_SEL, &get_behavior); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&get_behavior, &behavior, sizeof(behavior), "incorrect behavior"); } @@ -1076,16 +1073,16 @@ static void test_set_sanitize(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_sanitize(&cmd, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_sanitize(void) @@ -1096,16 +1093,16 @@ static void test_get_sanitize(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_sanitize(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_endurance_evt_cfg(void) @@ -1120,16 +1117,16 @@ static void test_set_endurance_evt_cfg(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_endurance_evt_cfg(&cmd, true, ENDGID, EGWARN); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_endurance_event_cfg(void) @@ -1142,16 +1139,16 @@ static void test_get_endurance_event_cfg(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_endurance_event_cfg(&cmd, TEST_SEL, ENDGID); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_iocs_profile(void) @@ -1167,7 +1164,7 @@ static void test_set_iocs_profile(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_iocs_profile(&cmd, false, IOCSI); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1180,16 +1177,16 @@ static void test_get_iocs_profile(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_iocs_profile(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_sw_progress(void) @@ -1203,16 +1200,16 @@ static void test_set_sw_progress(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_sw_progress(&cmd, true, PBSLC); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_sw_progress(void) @@ -1223,16 +1220,16 @@ static void test_get_sw_progress(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_sw_progress(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_host_id(void) @@ -1247,13 +1244,12 @@ static void test_set_host_id(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_id(&cmd, true, false,hostid); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1275,7 +1271,7 @@ static void test_set_host_id_extended(void) arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_id(&cmd, false, true, hostid); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1291,14 +1287,13 @@ static void test_get_host_id(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_id(&cmd, TEST_SEL, false, get_hostid, sizeof(hostid)); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(get_hostid, hostid, sizeof(hostid), "incorrect host identifier"); @@ -1316,14 +1311,13 @@ static void test_get_host_id_extended(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_id(&cmd, TEST_SEL, true, get_hostid, sizeof(hostid)); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(get_hostid, hostid, sizeof(hostid), "incorrect host identifier"); @@ -1341,16 +1335,16 @@ static void test_set_resv_mask(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_mask(&cmd, TEST_NSID, true, MASK); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_resv_mask(void) @@ -1362,16 +1356,16 @@ static void test_get_resv_mask(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_resv_mask(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_resv_persist(void) @@ -1384,16 +1378,16 @@ static void test_set_resv_persist(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_persist(&cmd, TEST_NSID, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_resv_persist(void) @@ -1405,16 +1399,16 @@ static void test_get_resv_persist(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_resv_persist(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_write_protect(void) @@ -1431,16 +1425,16 @@ static void test_set_write_protect(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_write_protect(&cmd, TEST_NSID, true, STATE); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_write_protect(void) @@ -1452,16 +1446,16 @@ static void test_get_write_protect(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_write_protect(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } /* @@ -1480,16 +1474,16 @@ static void test_set_status_code_error(void) .err = TEST_SC, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_async_event(&cmd, false, EVENTS); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected %d", err, TEST_SC); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_set_kernel_error(void) @@ -1500,19 +1494,19 @@ static void test_set_kernel_error(void) .nsid = TEST_NSID, .cdw10 = NVME_FEAT_FID_RESV_MASK, .cdw11 = MASK, - .result = TEST_RESULT, + .result = 0, .err = -EIO, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_mask(&cmd, TEST_NSID, false, MASK); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EIO, "got error %d, expected -EIO", err); - check(!result, "result unexpectedly set to %" PRIu32, result); + check(!cmd.result, + "result unexpectedly set to %" PRIu64, (uint64_t)cmd.result); } /* @@ -1529,16 +1523,16 @@ static void test_get_status_code_error(void) .err = TEST_SC, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_kato(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected %d", err, TEST_SC); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_get_kernel_error(void) @@ -1546,19 +1540,19 @@ static void test_get_kernel_error(void) struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_get_features, .cdw10 = TEST_SEL << 8 | NVME_FEAT_FID_NUM_QUEUES, - .result = TEST_RESULT, + .result = 0, .err = -EBUSY, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_num_queues(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EBUSY, "got error %d, expected -EBUSY", err); - check(!result, "result unexpectedly set to %" PRIu32, result); + check(!cmd.result, + "result unexpectedly set to %" PRIu64, (uint64_t)cmd.result); } static void test_lm_set_features_ctrl_data_queue(void) @@ -1575,17 +1569,17 @@ static void test_lm_set_features_ctrl_data_queue(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_set_features_ctrl_data_queue(&cmd, TEST_CDQID, hp, tpt, etpt); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d, errno %m", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); } static void test_lm_get_features_ctrl_data_queue(void) @@ -1601,18 +1595,18 @@ static void test_lm_get_features_ctrl_data_queue(void) .result = TEST_RESULT, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_get_features_ctrl_data_queue(&cmd, TEST_SEL, TEST_CDQID, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d, errno %m", err); - check(result == TEST_RESULT, - "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); + check(cmd.result == TEST_RESULT, + "got result %" PRIu64 ", expected %" PRIu32, + (uint64_t)cmd.result, TEST_RESULT); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -1632,7 +1626,7 @@ int main(void) nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!nvme_open(ctx, "NVME_TEST_FD64", &test_hdl), "opening test link failed"); RUN_TEST(set_features); diff --git a/libnvme/test/ioctl/identify.c b/libnvme/test/ioctl/identify.c index 3bf3b1247b..cdafd22b1e 100644 --- a/libnvme/test/ioctl/identify.c +++ b/libnvme/test/ioctl/identify.c @@ -37,7 +37,7 @@ static void test_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -58,7 +58,7 @@ static void test_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ctrl(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -80,7 +80,7 @@ static void test_active_ns_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_active_ns_list(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -105,7 +105,7 @@ static void test_ns_descs(void) check(id, "memory allocation failed"); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_descs_list(&cmd, TEST_NSID, id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(id, expected_id, sizeof(expected_id), "incorrect identify data"); @@ -128,7 +128,7 @@ static void test_nvmset_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, TEST_NVMSETID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -153,7 +153,7 @@ static void test_ns_csi(void) arbitrary(expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ns(&cmd, TEST_NSID, TEST_CSI, TEST_UUID, id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(id, expected_id, sizeof(id), "incorrect identify data"); @@ -176,7 +176,7 @@ static void test_zns_identify_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_zns_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -198,7 +198,7 @@ static void test_nvm_identify_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ctrl(&cmd, NVME_CSI_NVM, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -220,7 +220,7 @@ static void test_zns_identify_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_zns_identify_ctrl(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -243,7 +243,7 @@ static void test_active_ns_list_csi(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_active_ns_list(&cmd, TEST_NSID, TEST_CSI, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -266,7 +266,7 @@ static void test_independent_identify_ns(void) set_mock_admin_cmds(&mock_admin_cmd, 1); /* That's a mouthful! */ nvme_init_identify_csi_independent_identify_id_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -288,7 +288,7 @@ static void test_allocated_ns_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_allocated_ns_list(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -310,7 +310,7 @@ static void test_allocated_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_allocated_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -333,7 +333,7 @@ static void test_nsid_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_ctrl_list(&cmd, TEST_NSID, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -355,7 +355,7 @@ static void test_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ctrl_list(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -377,7 +377,7 @@ static void test_primary_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_primary_ctrl_cap(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -399,7 +399,7 @@ static void test_secondary_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_secondary_ctrl_list(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -420,7 +420,7 @@ static void test_ns_granularity(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_granularity(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -441,7 +441,7 @@ static void test_uuid(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_uuid_list(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -463,7 +463,7 @@ static void test_domain_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_domain_list(&cmd, TEST_DOMID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -485,7 +485,7 @@ static void test_endurance_group_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_endurance_group_id(&cmd, TEST_ENDGID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -508,7 +508,7 @@ static void test_allocated_ns_list_csi(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_allocated_ns_list(&cmd, TEST_NSID, TEST_CSI, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -530,7 +530,7 @@ static void test_iocs(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_command_set_structure(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -556,7 +556,7 @@ static void test_status_code_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, TEST_NVMSETID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected TEST_SC", err); } @@ -576,7 +576,7 @@ static void test_kernel_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EIO, "got error %d, expected -EIO", err); } @@ -601,7 +601,7 @@ static void test_identify_ns_csi_user_data_format(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_user_data_format(&cmd, NVME_CSI_NVM, TEST_FIDX, TEST_UUID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -626,7 +626,7 @@ static void test_identify_iocs_ns_csi_user_data_format(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ns_user_data_format(&cmd, TEST_CSI, TEST_FIDX, TEST_UUID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); diff --git a/libnvme/test/ioctl/logs.c b/libnvme/test/ioctl/logs.c index 9955a3fbe9..a641470d24 100644 --- a/libnvme/test/ioctl/logs.c +++ b/libnvme/test/ioctl/logs.c @@ -42,7 +42,7 @@ static void test_get_log_sanitize(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_sanitize(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d, errno %m", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -65,7 +65,7 @@ static void test_get_log_mgmt_addr_list(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_mgmt_addr_list(&cmd, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -90,7 +90,7 @@ static void test_get_log_supported_log_pages(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_supported_log_pages(&cmd, NVME_CSI_NVM, &log); err = nvme_get_log(test_hdl, &cmd, !TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -114,7 +114,7 @@ static void test_get_log_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_error(&cmd, 1, &log); err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -138,7 +138,7 @@ static void test_get_log_smart(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_smart(&cmd, TEST_NSID, &log); err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -162,7 +162,7 @@ static void test_get_log_fw_slot(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_fw_slot(&cmd, &log); err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -185,8 +185,7 @@ static void test_get_log_changed_ns_list(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_changed_ns(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -210,7 +209,7 @@ static void test_get_log_cmd_effects(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_cmd_effects(&cmd, TEST_CSI, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -233,7 +232,7 @@ static void test_get_log_device_self_test(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_device_self_test(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -258,7 +257,7 @@ static void test_get_log_create_telemetry_host_mcda(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_create_telemetry_host_mcda(&cmd, TEST_MCDA, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -284,7 +283,7 @@ static void test_get_log_create_telemetry_host(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_create_telemetry_host(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -312,7 +311,7 @@ static void test_get_log_telemetry_host(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_telemetry_host(&cmd, TEST_OFFSET, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -341,8 +340,7 @@ static void test_get_log_telemetry_ctrl(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_telemetry_ctrl(&cmd, TEST_OFFSET, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -366,7 +364,7 @@ static void test_get_log_endurance_group(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_endurance_group(&cmd, TEST_ENDGID, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -390,7 +388,7 @@ static void test_get_log_predictable_lat_nvmset(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_predictable_lat_nvmset(&cmd, TEST_NVMSETID, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -416,8 +414,7 @@ static void test_get_log_predictable_lat_event(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_predictable_lat_event(&cmd, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -443,7 +440,7 @@ static void test_get_log_fdp_configurations(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_fdp_configurations(&cmd, TEST_ENDGID, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -470,7 +467,7 @@ static void test_get_log_reclaim_unit_handle_usage(void) nvme_init_get_log_reclaim_unit_handle_usage(&cmd, TEST_ENDGID, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -496,7 +493,7 @@ static void test_get_log_fdp_stats(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_fdp_stats(&cmd, TEST_ENDGID, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -523,7 +520,7 @@ static void test_get_log_fdp_events(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_fdp_events(&cmd, TEST_EVENTS, TEST_ENDGID, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -550,8 +547,7 @@ static void test_get_log_ana(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_ana(&cmd, TEST_ANA_LSP, TEST_OFFSET, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -576,8 +572,7 @@ static void test_get_log_ana_groups(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_ana_groups(&cmd, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -602,8 +597,7 @@ static void test_get_log_lba_status(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_lba_status(&cmd, TEST_OFFSET, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -629,8 +623,7 @@ static void test_get_log_endurance_grp_evt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_endurance_grp_evt(&cmd, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -654,8 +647,7 @@ static void test_get_log_fid_supported_effects(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_fid_supported_effects(&cmd, NVME_CSI_NVM, &log); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -679,8 +671,7 @@ static void test_get_log_mi_cmd_supported_effects(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_mi_cmd_supported_effects(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -704,8 +695,7 @@ static void test_get_log_boot_partition(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_boot_partition(&cmd, TEST_LSP, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -730,7 +720,7 @@ static void test_get_log_rotational_media_info(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_rotational_media_info(&cmd, TEST_ENDGID, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -754,7 +744,7 @@ static void test_get_log_dispersed_ns_participating_nss(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_dispersed_ns_participating_nss(&cmd, TEST_NSID, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -779,7 +769,7 @@ static void test_get_log_phy_rx_eom(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_phy_rx_eom(&cmd, TEST_LSP, TEST_CNTID, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -804,8 +794,7 @@ static void test_get_log_reachability_groups(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_reachability_groups(&cmd, TEST_LSP != 0, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -830,8 +819,7 @@ static void test_get_log_reachability_associations(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_reachability_associations(&cmd, TEST_LSP != 0, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -855,8 +843,7 @@ static void test_get_log_changed_alloc_ns(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_changed_alloc_ns(&cmd, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -880,8 +867,7 @@ static void test_get_log_discovery(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_discovery(&cmd, TEST_OFFSET_32, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -907,8 +893,7 @@ static void test_get_log_host_discover(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_host_discovery(&cmd, TEST_LSP != 0, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -932,8 +917,7 @@ static void test_get_log_ave_discover(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_ave_discovery(&cmd, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -957,8 +941,7 @@ static void test_get_log_pull_model_ddc_req(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_pull_model_ddc_req(&cmd, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -982,7 +965,7 @@ static void test_get_log_media_unit_stat(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_media_unit_stat(&cmd, TEST_DOMID, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -1006,7 +989,7 @@ static void test_get_log_support_cap_config_list(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_support_cap_config_list(&cmd, TEST_DOMID, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -1029,8 +1012,7 @@ static void test_get_log_reservation(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_reservation(&cmd, &log); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -1055,8 +1037,7 @@ static void test_get_log_zns_changed_zones(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_zns_changed_zones(&cmd, TEST_NSID, &log); - err = nvme_get_log(test_hdl, &cmd, TEST_RAE, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, TEST_RAE, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -1081,7 +1062,7 @@ static void test_get_log_persistent_event(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_persistent_event(&cmd, TEST_PEVENT, &log, sizeof(log)); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); @@ -1105,7 +1086,7 @@ static void test_get_log_lockdown(void) arbitrary(&expected_log, sizeof(expected_log)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_log_lockdown(&cmd, TEST_LSP, &log); - err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(test_hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); end_mock_cmds(); check(err == 0, "get log returned error %d", err); cmp(&log, &expected_log, sizeof(log), "incorrect log data"); diff --git a/libnvme/test/ioctl/misc.c b/libnvme/test/ioctl/misc.c index 3c8571460c..7ac6519d86 100644 --- a/libnvme/test/ioctl/misc.c +++ b/libnvme/test/ioctl/misc.c @@ -7,6 +7,7 @@ #include #include #include +#include #define TEST_FD 0xFD #define TEST_NSID 0x12345678 @@ -22,7 +23,6 @@ static void test_format_nvm(void) enum nvme_cmd_format_ses ses = NVME_FORMAT_SES_USER_DATA_ERASE; __u32 nsid = TEST_NSID; __u8 lbaf = 0x1F; - __u32 result = 0; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_format_nvm, .nsid = nsid, @@ -35,10 +35,10 @@ static void test_format_nvm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_format_nvm(&cmd, nsid, lbaf, mset, pi, pil, ses); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_ns_mgmt(void) @@ -47,7 +47,6 @@ static void test_ns_mgmt(void) enum nvme_ns_mgmt_sel sel = NVME_NS_MGMT_SEL_CREATE; __u32 nsid = TEST_NSID; __u8 csi = TEST_CSI; - __u32 result = 0; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_ns_mgmt, .nsid = nsid, @@ -63,10 +62,10 @@ static void test_ns_mgmt(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt(&cmd, nsid, sel, csi, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -76,7 +75,6 @@ static void test_ns_mgmt_create(void) enum nvme_ns_mgmt_sel sel = NVME_NS_MGMT_SEL_CREATE; __u32 nsid = NVME_NSID_NONE; __u8 csi = NVME_CSI_ZNS; - __u32 result = 0; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_ns_mgmt, .nsid = nsid, @@ -92,10 +90,11 @@ static void test_ns_mgmt_create(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_ZNS, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == TEST_NSID, "returned result %u", result); + check(cmd.result == TEST_NSID, + "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -111,14 +110,14 @@ static void test_ns_mgmt_delete(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt_delete(&cmd, TEST_NSID); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } static void test_get_property(void) { - __u64 expected_result, result; + __u64 expected_result; arbitrary(&expected_result, sizeof(expected_result)); struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_fabrics, @@ -127,21 +126,20 @@ static void test_get_property(void) .cdw11 = NVME_REG_ACQ, .result = expected_result, }; - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_property(&cmd, NVME_REG_ACQ); - err = nvme_submit_admin_passthru64(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "returned wrong result"); + check(cmd.result == expected_result, "returned wrong result"); } static void test_set_property(void) { __u64 value = 0xffffffff; - __u32 result; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_fabrics, .nsid = nvme_fabrics_type_property_set, @@ -155,10 +153,10 @@ static void test_set_property(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_property(&cmd, NVME_REG_BPMBL, value); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_ns_attach(void) @@ -166,7 +164,6 @@ static void test_ns_attach(void) struct nvme_ctrl_list expected_ctrlist, ctrlist; enum nvme_ns_attach_sel sel = NVME_NS_ATTACH_SEL_CTRL_ATTACH; __u32 nsid = TEST_NSID; - __u32 result; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_ns_attach, .nsid = nsid, @@ -180,10 +177,10 @@ static void test_ns_attach(void) arbitrary(&expected_ctrlist, sizeof(expected_ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_attach(&cmd, nsid, sel, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&expected_ctrlist, &ctrlist, sizeof(expected_ctrlist), "incorrect data"); } @@ -204,7 +201,7 @@ static void test_ns_attach_ctrls(void) arbitrary(&ctrlist, sizeof(ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_attach_ctrls(&cmd, TEST_NSID, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -225,14 +222,13 @@ static void test_ns_detach_ctrls(void) arbitrary(&ctrlist, sizeof(ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_detach_ctrls(&cmd, TEST_NSID, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } static void test_fw_download(void) { - __u32 result = 0; __u8 expected_data[8], data[8]; __u32 data_len = sizeof(expected_data); __u32 offset = 120; @@ -251,10 +247,10 @@ static void test_fw_download(void) set_mock_admin_cmds(&mock_admin_cmd, 1); err = nvme_init_fw_download(&cmd, data, data_len, offset); check(err == 0, "download initializing error %d", err); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_fw_commit(void) @@ -268,15 +264,14 @@ static void test_fw_commit(void) .cdw10 = (bpid << 31) | (action << 3) | slot, }; struct nvme_passthru_cmd cmd; - __u32 result = 0; int err; set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_fw_commit(&cmd, slot, action, bpid); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_security_send(void) @@ -285,7 +280,6 @@ static void test_security_send(void) __u32 data_len = sizeof(expected_data); __u32 nsid = TEST_NSID; __u32 tl = 0xffff; - __u32 result = 0; __u8 nssf = 0x1; __u16 spsp = 0x0101; __u8 secp = 0xE9; @@ -305,17 +299,16 @@ static void test_security_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_security_send(&cmd, nsid, nssf, spsp, secp, tl, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } static void test_security_receive(void) { __u8 expected_data[8], data[8]; - __u32 result = 0; __u32 al = 0xffff; __u16 spsp = 0x0101; __u8 secp = 0xE9; @@ -335,10 +328,10 @@ static void test_security_receive(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_security_receive(&cmd, TEST_NSID, nssf, spsp, secp, al, data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -350,7 +343,6 @@ static void test_get_lba_status(void) enum nvme_lba_status_atype atype = 0x11; __u32 mndw = (lba_status_size - 1) >> 2; __u64 slba = 0x123456789; - __u32 result = 0; __u16 rl = 0x42; int err; @@ -378,10 +370,10 @@ static void test_get_lba_status(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_lba_status(&cmd, TEST_NSID, slba, mndw, atype, rl, lbas); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned wrong result"); + check(cmd.result == 0, "returned wrong result"); cmp(lbas, expected_lbas, lba_status_size, "incorrect lbas"); } @@ -393,7 +385,6 @@ static void test_directive_send(void) __u8 expected_data[8], data[8]; __u32 data_len = sizeof(expected_data); __u16 dspec = 0x0; - __u32 result = 0; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_directive_send, .nsid = TEST_NSID, @@ -410,10 +401,10 @@ static void test_directive_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send(&cmd, TEST_NSID, doper, dtype, dspec, expected_data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned wrong result"); + check(cmd.result == 0, "returned wrong result"); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -438,7 +429,7 @@ static void test_directive_send_id_endir(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_id_endir(&cmd, TEST_NSID, true, NVME_DIRECTIVE_DTYPE_STREAMS, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect id"); @@ -460,7 +451,7 @@ static void test_directive_send_stream_release_identifier(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_stream_release_identifier(&cmd, TEST_NSID, stream_id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -478,7 +469,7 @@ static void test_directive_send_stream_release_resource(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_stream_release_resource(&cmd, TEST_NSID); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -499,17 +490,16 @@ static void test_directive_recv(void) .out_data = &expected_data, }; struct nvme_passthru_cmd cmd; - uint32_t result = 0; int err; arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv(&cmd, TEST_NSID, doper, dtype, dspec, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned wrong result"); + check(cmd.result == 0, "returned wrong result"); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -531,7 +521,7 @@ static void test_directive_recv_identify_parameters(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_identify_parameters(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect id"); @@ -555,7 +545,7 @@ static void test_directive_recv_stream_parameters(void) arbitrary(&expected_params, sizeof(expected_params)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_parameters(&cmd, TEST_NSID, ¶ms); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(¶ms, &expected_params, sizeof(params), "incorrect params"); @@ -593,7 +583,7 @@ static void test_directive_recv_stream_status(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_status(&cmd, TEST_NSID, nr_entries, status); - err = nvme_submit_admin_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(status, expected_status, stream_status_size, "incorrect status"); @@ -601,7 +591,7 @@ static void test_directive_recv_stream_status(void) static void test_directive_recv_stream_allocate(void) { - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; __u16 nsr = 0x67; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_directive_recv, @@ -616,15 +606,15 @@ static void test_directive_recv_stream_allocate(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_allocate(&cmd, TEST_NSID, nsr); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } void test_capacity_mgmt(void) { - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; __u16 elid = 0x12; __u64 cap = 0x0000567800001234; __u8 op = 0x3; @@ -641,15 +631,15 @@ void test_capacity_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_capacity_mgmt(&cmd, op, elid, cap); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } static void test_lockdown(void) { - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; __u8 prhbt = !!true; __u8 uuidx = 0x34; __u8 ofi = 0x12; @@ -667,17 +657,17 @@ static void test_lockdown(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lockdown(&cmd, scp, prhbt, ifc, ofi, uuidx); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } static void test_sanitize_nvm(void) { enum nvme_sanitize_sanact sanact = NVME_SANITIZE_SANACT_START_CRYPTO_ERASE; - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; __u32 ovrpat = 0x101010; bool oipbp = false; __u8 owpass = 0x2; @@ -697,15 +687,15 @@ static void test_sanitize_nvm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_sanitize_nvm(&cmd, sanact, ause, owpass, oipbp, ndas, emvs, ovrpat); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } static void test_dev_self_test(void) { - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_dev_self_test, .nsid = TEST_NSID, @@ -717,17 +707,17 @@ static void test_dev_self_test(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_dev_self_test(&cmd, TEST_NSID, NVME_DST_STC_ABORT); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } static void test_virtual_mgmt(void) { enum nvme_virt_mgmt_act act = NVME_VIRT_MGMT_ACT_ASSIGN_SEC_CTRL; enum nvme_virt_mgmt_rt rt = NVME_VIRT_MGMT_RT_VI_RESOURCE; - __u32 expected_result = 0x45, result = 0; + __u64 expected_result = 0x45; __u16 cntlid = 0x0; __u16 nr = 0xff; struct mock_cmd mock_admin_cmd = { @@ -741,10 +731,10 @@ static void test_virtual_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_virtual_mgmt(&cmd, act, rt, cntlid, nr); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == expected_result, "wrong result"); + check(cmd.result == expected_result, "wrong result"); } static void test_flush(void) @@ -765,7 +755,6 @@ static void test_flush(void) static void test_read(void) { __u8 expected_data[512], data[512] = {}; - __u32 result = 0; __u64 slba = 0xffffffffff; __u16 nlb = 0x3; __u16 control = NVME_IO_FUA; @@ -790,17 +779,16 @@ static void test_read(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_read(&cmd, TEST_NSID, slba, nlb, control, dsm, 0, data, sizeof(data), NULL, 0); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_write(void) { __u8 expected_data[512]; - __u32 result = 0; __u64 slba = 0xfffffffabcde; __u16 nlb = 0x5; __u16 control = NVME_IO_FUA; @@ -826,17 +814,16 @@ static void test_write(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_write(&cmd, TEST_NSID, slba, nlb, control, dspec, dsm, 0, expected_data, sizeof(expected_data), NULL, 0); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_compare(void) { __u8 expected_data[512], data[512] = {}; - __u32 result = 0; __u64 slba = 0xabcde; __u16 nlb = 0x0; __u16 control = NVME_IO_LR; @@ -861,16 +848,15 @@ static void test_compare(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_compare(&cmd, TEST_NSID, slba, nlb, control, cev, data, sizeof(data), NULL, 0); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_write_zeros(void) { - __u32 result = 0; __u64 slba = 0x0; __u16 nlb = 0xffff; __u16 control = NVME_IO_LR; @@ -894,16 +880,15 @@ static void test_write_zeros(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_write_zeros(&cmd, TEST_NSID, slba, nlb, control, dspec, dsm, cev); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_write_uncorrectable(void) { - __u32 result = 0; __u64 slba = 0x0; __u16 nlb = 0x0; __u16 control = 0x0; @@ -926,16 +911,15 @@ static void test_write_uncorrectable(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_write_uncorrectable(&cmd, TEST_NSID, slba, nlb, control, dspec); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_verify(void) { - __u32 result = 0; __u64 slba = 0xffffffffffffffff; __u16 nlb = 0xffff; __u16 control = 0xffff; @@ -957,17 +941,16 @@ static void test_verify(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_verify(&cmd, TEST_NSID, slba, nlb, control, cev, NULL, 0, NULL, 0); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + nvme_init_app_tag(&cmd, apptag, appmask); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_dsm(void) { struct nvme_passthru_cmd cmd; - __u32 result = 0; __u16 nr_ranges = 0xab; int dsm_size = sizeof(struct nvme_dsm_range) * nr_ranges; @@ -990,10 +973,10 @@ static void test_dsm(void) arbitrary(dsm, dsm_size); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_dsm(&cmd, TEST_NSID, nr_ranges, 0, 0, 1, dsm, dsm_size); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_copy(void) @@ -1004,7 +987,6 @@ static void test_copy(void) stcr = false, fua = false, lr = false; __u8 cetype = 0, dtype = 0, desfmt = 0xf; __u64 sdlba = 0xfffff; - __u32 result = 0; _cleanup_free_ struct nvme_copy_range *copy = NULL; @@ -1030,10 +1012,10 @@ static void test_copy(void) nvme_init_copy(&cmd, TEST_NSID, sdlba, nr, desfmt, prinfor, prinfow, cetype, dtype, stcw, stcr, fua, lr, cev, dspec, (void *)copy); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_resv_acquire(void) @@ -1043,7 +1025,6 @@ static void test_resv_acquire(void) __le64 expected_payload[2] = { htole64(1), htole64(2) }; __le64 payload[2]; bool iekey = true; - __u32 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_cmd_resv_acquire, .nsid = TEST_NSID, @@ -1058,10 +1039,10 @@ static void test_resv_acquire(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_acquire(&cmd, TEST_NSID, racqa, iekey, false, rtype, 1, 2, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_resv_register(void) @@ -1071,7 +1052,6 @@ static void test_resv_register(void) __le64 expected_payload[2] = { 0xffffffffffffffff, 0 }; __le64 payload[2]; bool iekey = true; - __u32 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_cmd_resv_register, .nsid = TEST_NSID, @@ -1086,10 +1066,10 @@ static void test_resv_register(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_register(&cmd, TEST_NSID, rrega, iekey, false, cptpl, 0xffffffffffffffff, 0, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_resv_release(void) @@ -1099,7 +1079,6 @@ static void test_resv_release(void) __le64 expected_payload[1] = { 0xffffffffffffffff }; __le64 payload[1]; bool iekey = true; - __u32 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_cmd_resv_release, .nsid = TEST_NSID, @@ -1114,17 +1093,16 @@ static void test_resv_release(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_release(&cmd, TEST_NSID, rrela, iekey, false, rtype, 0xffffffffffffffff, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_resv_report(void) { struct nvme_resv_status expected_status, status = {}; __u32 len = sizeof(status); - __u32 result = 0; bool eds = false; bool disnsrs = true; struct mock_cmd mock_io_cmd = { @@ -1141,10 +1119,10 @@ static void test_resv_report(void) arbitrary(&expected_status, sizeof(expected_status)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_report(&cmd, TEST_NSID, eds, disnsrs, &status, len); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&status, &expected_status, sizeof(status), "incorrect status"); } @@ -1168,7 +1146,7 @@ static void test_io_mgmt_recv(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_io_mgmt_recv(&cmd, TEST_NSID, mo, mos, data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1194,7 +1172,7 @@ static void test_io_mgmt_send(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_io_mgmt_send(&cmd, TEST_NSID, mo, mos, data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1219,7 +1197,7 @@ static void test_fdp_reclaim_unit_handle_status(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_fdp_reclaim_unit_handle_status(&cmd, TEST_NSID, &data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1242,7 +1220,7 @@ static void test_fdp_reclaim_unit_handle_update(void) arbitrary(&pids, sizeof(pids)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_fdp_reclaim_unit_handle_update(&cmd, TEST_NSID, &pids, npids); - err = nvme_submit_io_passthru(test_hdl, &cmd, NULL); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -1251,7 +1229,6 @@ static void test_dim_send(void) { __u8 expected_data[8], data[8] = {}; __u32 data_len = sizeof(data); - __u32 result = 0; __u8 tas = 0xf; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_discovery_info_mgmt, @@ -1266,16 +1243,15 @@ static void test_dim_send(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_dim_send(&cmd, tas, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } static void test_lm_cdq_delete(void) { - __u32 result = 0; __u8 expected_data[8], data[8] = {}; __u16 mos = 0x1; __u16 cdqid = 0x3; @@ -1296,10 +1272,10 @@ static void test_lm_cdq_delete(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_cdq_delete(&cmd, mos, cdqid); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -1307,7 +1283,6 @@ static void test_lm_track_send(void) { __u8 sel = NVME_LM_SEL_DELETE_CDQ; __u16 cdqid = 0x3; - __u32 result = 0; __u16 mos = 0x1; struct mock_cmd mock_admin_cmd = { .opcode = nvme_admin_track_send, @@ -1319,10 +1294,10 @@ static void test_lm_track_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_track_send(&cmd, sel, mos, cdqid); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); } static void test_lm_migration_send(void) @@ -1332,7 +1307,6 @@ static void test_lm_migration_send(void) __u64 offset = 0xffffffffff; __u32 numd = 8; __u16 cntlid = 0x2; - __u32 result = 0; __u16 mos = 0x1; __u8 uidx = 0x4; __u8 stype = 0x1; @@ -1358,10 +1332,10 @@ static void test_lm_migration_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_migration_send(&cmd, sel, mos, cntlid, stype, dudmq, csvi, csuuidi, offset, uidx, &data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -1374,7 +1348,6 @@ static void test_lm_migration_recv(void) __u32 numd = 8 - 1; __u16 cntlid = 0x2; __u8 csuidxp = 0x5; - __u32 result = 0; __u16 mos = 0x1; __u8 uidx = 0x4; struct mock_cmd mock_admin_cmd = { @@ -1396,10 +1369,10 @@ static void test_lm_migration_recv(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_migration_recv(&cmd, offset, mos, cntlid, csuuidi, sel, uidx, csuidxp, data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd, &result); + err = nvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -1419,7 +1392,7 @@ int main(void) nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!nvme_open(ctx, "NVME_TEST_FD64", &test_hdl), "opening test link failed"); RUN_TEST(format_nvm); diff --git a/libnvme/test/ioctl/mock.c b/libnvme/test/ioctl/mock.c index da3caba895..8fb32d08c9 100644 --- a/libnvme/test/ioctl/mock.c +++ b/libnvme/test/ioctl/mock.c @@ -8,6 +8,7 @@ #include #include +#include #include "mock.h" #include "util.h" @@ -174,12 +175,12 @@ int ioctl(int fd, int request, ...) mock_cmds->remaining_cmds--; if (result64) { - execute_ioctl((struct nvme_passthru_cmd64 *)cmd, mock_cmd); + execute_ioctl((struct linux_passthru_cmd64 *)cmd, mock_cmd); } else { check((uint32_t)mock_cmd->result == mock_cmd->result, "expected 64-bit %s for result %" PRIu64, __func__, mock_cmd->result); - execute_ioctl((struct nvme_passthru_cmd *)cmd, mock_cmd); + execute_ioctl((struct linux_passthru_cmd32 *)cmd, mock_cmd); } if (mock_cmd->err < 0) { errno = -mock_cmd->err; diff --git a/libnvme/test/ioctl/zns.c b/libnvme/test/ioctl/zns.c index 1697ad377f..56ababbc9a 100644 --- a/libnvme/test/ioctl/zns.c +++ b/libnvme/test/ioctl/zns.c @@ -6,6 +6,7 @@ #include "util.h" #include #include +#include #define TEST_FD 0xFD #define TEST_NSID 0x12345678 @@ -41,7 +42,7 @@ static void test_zns_append(void) .data_len = sizeof(expected_data), .out_data = &expected_data, }; - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; int err; arbitrary(&expected_data, sizeof(expected_data)); @@ -51,7 +52,7 @@ static void test_zns_append(void) if (elbas) nvme_init_var_size_tags(&cmd, pif, sts, reftag, storage_tag); nvme_init_app_tag(&cmd, lbat, lbatm); - err = nvme_submit_io_passthru64(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(result == 0, "wrong result"); @@ -64,7 +65,7 @@ static void test_zns_report_zones(void) __u8 expected_data[8], data[8] = {}; bool extended = true; bool partial = true; - __u32 result = 0; + __u64 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_zns_cmd_mgmt_recv, .nsid = TEST_NSID, @@ -82,10 +83,10 @@ static void test_zns_report_zones(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_report_zones(&cmd, TEST_NSID, TEST_SLBA, opts, extended, partial, &data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(result == 0, "returned result %"PRIu64, (uint64_t)result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -96,7 +97,7 @@ static void test_zns_mgmt_send(void) __u64 slba = TEST_SLBA; bool select_all = true; __u8 zsaso = 0x1; - __u32 result = 0; + __u64 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_zns_cmd_mgmt_send, .nsid = TEST_NSID, @@ -114,10 +115,10 @@ static void test_zns_mgmt_send(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_mgmt_send(&cmd, TEST_NSID, slba, zsa, select_all, zsaso, false, data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(result == 0, "returned result %"PRIu64, (uint64_t)result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } @@ -127,7 +128,7 @@ static void test_zns_mgmt_recv(void) __u8 expected_data[8], data[8] = {}; __u16 zrasf = (__u16)NVME_ZNS_ZRAS_REPORT_ALL; bool zras_feat = false; - __u32 result = 0; + __u64 result = 0; struct mock_cmd mock_io_cmd = { .opcode = nvme_zns_cmd_mgmt_recv, .nsid = TEST_NSID, @@ -143,10 +144,10 @@ static void test_zns_mgmt_recv(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_mgmt_recv(&cmd, TEST_NSID, 0, zra, zrasf, zras_feat, data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd, &result); + err = nvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); - check(result == 0, "returned result %u", result); + check(result == 0, "returned result %"PRIu64, (uint64_t)result); cmp(&data, &expected_data, sizeof(data), "incorrect data"); } diff --git a/libnvme/test/mi-mctp.c b/libnvme/test/mi-mctp.c index 7571abd6e9..ce283da71e 100644 --- a/libnvme/test/mi-mctp.c +++ b/libnvme/test/mi-mctp.c @@ -425,7 +425,7 @@ static void test_admin_resp_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf_len = 8; nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); } @@ -452,7 +452,7 @@ static void test_admin_resp_sizes(nvme_mi_ep_t ep, struct test_peer *peer) for (i = 8; i <= 4096 + 8; i+=4) { peer->tx_buf_len = i; nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); } @@ -577,7 +577,7 @@ static void test_mpr_admin(nvme_mi_ep_t ep, struct test_peer *peer) hdl = nvme_mi_init_transport_handle(ep, 1); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); nvme_close(hdl); @@ -604,7 +604,7 @@ static void test_mpr_admin_quirked(nvme_mi_ep_t ep, struct test_peer *peer) hdl = nvme_mi_init_transport_handle(ep, 1); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); nvme_close(hdl); diff --git a/libnvme/test/mi.c b/libnvme/test/mi.c index 95b648fe4c..f748b3e269 100644 --- a/libnvme/test/mi.c +++ b/libnvme/test/mi.c @@ -449,7 +449,7 @@ static void test_admin_id(nvme_mi_ep_t ep) assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); } @@ -505,7 +505,7 @@ static void test_admin_err_mi_resp(nvme_mi_ep_t ep) assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc != 0); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); @@ -569,7 +569,7 @@ static void test_admin_err_nvme_resp(nvme_mi_ep_t ep) assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc != 0); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_NVME); assert(nvme_status_get_value(rc) == @@ -969,7 +969,6 @@ static void test_get_features(nvme_mi_ep_t ep) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; - uint32_t res; int rc; test_set_transport_callback(ep, test_admin_get_features_cb, NULL); @@ -978,9 +977,9 @@ static void test_get_features(nvme_mi_ep_t ep) assert(hdl); nvme_init_get_features(&cmd, NVME_FEAT_FID_ARBITRATION, 0); - rc = nvme_submit_admin_passthru(hdl, &cmd, &res); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); - assert(res == 0x04030201); + assert(cmd.result == 0x04030201); } /* Set Features callback for timestamp */ @@ -1040,7 +1039,6 @@ static void test_set_features(nvme_mi_ep_t ep) struct nvme_timestamp tstmp = { 0 }; struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; - uint32_t res; int rc; test_set_transport_callback(ep, test_admin_set_features_cb, NULL); @@ -1049,7 +1047,7 @@ static void test_set_features(nvme_mi_ep_t ep) assert(hdl); nvme_init_set_features_timestamp(&cmd, true, 0x050403020100, &tstmp); - rc = nvme_submit_admin_passthru(hdl, &cmd, &res); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); } @@ -1119,7 +1117,7 @@ static void test_admin_id_alloc_ns_list(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_allocated_ns_list(&cmd, 1, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le32_to_cpu(list.ns[0]) == 2); @@ -1142,7 +1140,7 @@ static void test_admin_id_active_ns_list(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_active_ns_list(&cmd, 1, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le32_to_cpu(list.ns[0]) == 4); @@ -1207,7 +1205,7 @@ static void test_admin_id_alloc_ns(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_allocated_ns(&cmd, 1, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le64_to_cpu(id.nsze) == 1); } @@ -1227,7 +1225,7 @@ static void test_admin_id_active_ns(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_ns(&cmd, 1, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le64_to_cpu(id.nsze) == 1); } @@ -1274,7 +1272,7 @@ static void test_admin_id_ns_ctrl_list(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_ns_ctrl_list(&cmd, 0x01020304, 5, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1317,7 +1315,7 @@ static void test_admin_id_secondary_ctrl_list(struct nvme_mi_ep *ep) assert(hdl); nvme_init_identify_secondary_ctrl_list(&cmd, 5, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1381,7 +1379,7 @@ static void test_admin_ns_mgmt_create(struct nvme_mi_ep *ep) struct nvme_ns_mgmt_host_sw_specified data = { 0 }; struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; - __u32 ns; + __u64 ns; int rc; test_set_transport_callback(ep, test_admin_ns_mgmt_cb, NULL); @@ -1390,13 +1388,14 @@ static void test_admin_ns_mgmt_create(struct nvme_mi_ep *ep) assert(hdl); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_NVM, &data); - rc = nvme_submit_admin_passthru(hdl, &cmd, &ns); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); + ns = cmd.result; assert(ns == 0x01020304); data.nsze = cpu_to_le64(42); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_NVM, &data); - rc = nvme_submit_admin_passthru(hdl, &cmd, &ns); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(rc); } @@ -1412,7 +1411,7 @@ static void test_admin_ns_mgmt_delete(struct nvme_mi_ep *ep) assert(hdl); nvme_init_ns_mgmt_delete(&cmd, 0x05060708); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1481,7 +1480,7 @@ static void test_admin_ns_attach(struct nvme_mi_ep *ep) assert(hdl); nvme_init_ns_attach_ctrls(&cmd, 0x02030405, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1506,7 +1505,7 @@ static void test_admin_ns_detach(struct nvme_mi_ep *ep) assert(hdl); nvme_init_ns_detach_ctrls(&cmd, 0x02030405, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1587,7 +1586,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 0; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* largest len */ @@ -1595,7 +1594,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 0; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* offset value */ @@ -1603,7 +1602,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 4096; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1657,7 +1656,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 0; info.action = 0; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* all ones */ @@ -1665,7 +1664,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 0x7; info.action = 0x7; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* correct fields */ @@ -1673,7 +1672,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 2; info.action = 3; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1743,7 +1742,7 @@ static void test_admin_format_nvm(struct nvme_mi_ep *ep) nvme_init_format_nvm(&cmd, args.nsid, args.lbaf, args.mset, args.pi, args.pil, args.ses); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); args.nsid = ~args.nsid; @@ -1755,7 +1754,7 @@ static void test_admin_format_nvm(struct nvme_mi_ep *ep) nvme_init_format_nvm(&cmd, args.nsid, args.lbaf, args.mset, args.pi, args.pil, args.ses); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1821,7 +1820,7 @@ static void test_admin_sanitize_nvm(struct nvme_mi_ep *ep) nvme_init_sanitize_nvm(&cmd, args.sanact, args.ause, args.owpass, args.oipbp, args.ndas, args.emvs, args.ovrpat); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); args.sanact = 0x0; @@ -1833,7 +1832,7 @@ static void test_admin_sanitize_nvm(struct nvme_mi_ep *ep) nvme_init_sanitize_nvm(&cmd, args.sanact, args.ause, args.owpass, args.oipbp, args.ndas, args.emvs, args.ovrpat); - rc = nvme_submit_admin_passthru(hdl, &cmd, NULL); + rc = nvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1913,7 +1912,7 @@ static void test_admin_get_log_split(struct nvme_mi_ep *ep) nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_ERROR, NVME_CSI_NVM, buf, sizeof(buf)); - rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); assert(!rc); /* we should have sent three commands */ diff --git a/libnvme/test/test.c b/libnvme/test/test.c index e39e9477b8..0b24c1db4c 100644 --- a/libnvme/test/test.c +++ b/libnvme/test/test.c @@ -62,10 +62,8 @@ static int test_ctrl(nvme_ctrl_t c) struct nvme_ctrl_list ctrlist = { 0 }; struct nvme_id_ctrl id = { 0 }; - __u32 result; - nvme_init_identify_ctrl(&cmd, &id); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (ret) { printf("ERROR: no identify for:%s\n", nvme_ctrl_get_name(c)); return ret; @@ -75,7 +73,7 @@ static int test_ctrl(nvme_ctrl_t c) } nvme_init_get_log_smart(&cmd, NVME_NSID_ALL, &smart); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (ret) { printf("ERROR: no smart log for:%s %#x\n", nvme_ctrl_get_name(c), ret); return ret; @@ -95,49 +93,49 @@ static int test_ctrl(nvme_ctrl_t c) printf(" model:%-.40s\n", id.mn); nvme_init_identify_allocated_ns_list(&cmd, 0, &ns_list); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Allocated NS List\n"); else printf(" ERROR: Allocated NS List:%x\n", ret); nvme_init_identify_active_ns_list(&cmd, 0, &ns_list); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Active NS List\n"); else printf(" ERROR: Active NS List:%x\n", ret); nvme_init_identify_ctrl_list(&cmd, 0, &ctrlist); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Ctrl List\n"); else printf(" ERROR: CtrlList:%x\n", ret); nvme_init_identify_ctrl_list(&cmd, 1, &ctrlist); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: NSID Ctrl List\n"); else printf(" ERROR: NSID CtrlList:%x\n", ret); nvme_init_identify_primary_ctrl_cap(&cmd, 0, &prim); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify Primary\n"); else printf(" ERROR: Identify Primary:%x\n", ret); nvme_init_identify_secondary_ctrl_list(&cmd, 0, &sec); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify Secondary\n"); else printf(" ERROR: Identify Secondary:%x\n", ret); nvme_init_identify_ns_granularity(&cmd, &gran); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify NS granularity\n"); else printf(" ERROR: Identify NS granularity:%x\n", ret); nvme_init_identify_uuid_list(&cmd, &uuid); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify UUID List\n"); else @@ -147,161 +145,175 @@ static int test_ctrl(nvme_ctrl_t c) printf(" SMART: Current temperature:%d percent used:%d%%\n", temp, smart.percent_used); nvme_init_get_log_sanitize(&cmd, &sanlog); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Sanitize Log:\n"); else printf(" ERROR: Sanitize Log:%x\n", ret); nvme_init_get_log_reservation(&cmd, &resvnotify); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Reservation Log\n"); else printf(" ERROR: Reservation Log:%x\n", ret); nvme_init_get_log_ana_groups(&cmd, analog, sizeof(buf)); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" ANA Groups\n"); else printf(" ERROR: ANA Groups:%x\n", ret); nvme_init_get_log_endurance_group(&cmd, 0, &eglog); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Endurance Group\n"); else printf(" ERROR: Endurance Group:%x\n", ret); nvme_init_get_log_telemetry_ctrl(&cmd, 0, telem, sizeof(buf)); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Telemetry Controller\n"); else printf(" ERROR: Telemetry Controller:%x\n", ret); nvme_init_get_log_device_self_test(&cmd, &st); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Device Self Test\n"); else printf(" ERROR: Device Self Test:%x\n", ret); nvme_init_get_log_cmd_effects(&cmd, NVME_CSI_NVM, &cfx); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Command Effects\n"); else printf(" ERROR: Command Effects:%x\n", ret); nvme_init_get_log_changed_alloc_ns(&cmd, &ns_list, sizeof(ns_list)); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Change NS List\n"); else printf(" ERROR: Change NS List:%x\n", ret); nvme_init_get_log_fw_slot(&cmd, &fw); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" FW Slot\n"); else printf(" ERROR: FW Slot%x\n", ret); nvme_init_get_log_error(&cmd, 64, error); - ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!ret) printf(" Error Log\n"); else printf(" ERROR: Error Log:%x\n", ret); printf("\nFeatures\n"); nvme_init_get_features_arbitration(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Arbitration:%x\n", result); + printf(" Arbitration:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Arbitration:%x\n", ret); nvme_init_get_features_power_mgmt(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Power Management:%x\n", result); + printf(" Power Management:%" PRIu64 "x\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Power Management:%x\n", ret); nvme_init_get_features_temp_thresh(&cmd, sel, 0, 0); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Temperature Threshold:%x\n", result); + printf(" Temperature Threshold:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Temperature Threshold:%x\n", ret); nvme_init_get_features_volatile_wc(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Volatile Write Cache:%x\n", result); + printf(" Volatile Write Cache:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Volatile Write Cache:%x\n", ret); nvme_init_get_features_num_queues(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Number of Queues:%x\n", result); + printf(" Number of Queues:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Number of Queues:%x\n", ret); nvme_init_get_features_irq_coalesce(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" IRQ Coalescing:%x\n", result); + printf(" IRQ Coalescing:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: IRQ Coalescing:%x\n", ret); nvme_init_get_features_write_atomic(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Write Atomic:%x\n", result); + printf(" Write Atomic:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Write Atomic:%x\n", ret); nvme_init_get_features_async_event(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Asycn Event Config:%x\n", result); + printf(" Asycn Event Config:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Asycn Event Config:%x\n", ret); nvme_init_get_features_hctm(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" HCTM:%x\n", result); + printf(" HCTM:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: HCTM:%x\n", ret); nvme_init_get_features_nopsc(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" NOP Power State Config:%x\n", result); + printf(" NOP Power State Config:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: NOP Power State Configrbitration:%x\n", ret); nvme_init_get_features_rrl(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Read Recover Levels:%x\n", result); + printf(" Read Recover Levels:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Read Recover Levels:%x\n", ret); nvme_init_get_features_lba_sts_interval(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" LBA Status Interval:%x\n", result); + printf(" LBA Status Interval:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: LBA Status Interval:%x\n", ret); nvme_init_get_features_sanitize(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Sanitize:%x\n", result); + printf(" Sanitize:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: SW Progress Marker:%x\n", ret); nvme_init_get_features_sw_progress(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" SW Progress Marker:%x\n", result); + printf(" SW Progress Marker:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Sanitize:%x\n", ret); nvme_init_get_features_resv_mask(&cmd, 0, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Reservation Mask:%x\n", result); + printf(" Reservation Mask:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Reservation Mask:%x\n", ret); nvme_init_get_features_resv_persist(&cmd, 0, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Reservation Persistence:%x\n", result); + printf(" Reservation Persistence:%" PRIu64 "\n", + (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Reservation Persistence:%x\n", ret); return 0; @@ -314,7 +326,7 @@ static int test_namespace(nvme_ns_t n) struct nvme_passthru_cmd cmd; struct nvme_id_ns ns = { 0 }, allocated = { 0 }; struct nvme_ns_id_desc *descs; - __u32 result = 0; + __u64 result = 0; __u8 flbas; ret = nvme_ns_identify(n, &ns); @@ -327,7 +339,7 @@ static int test_namespace(nvme_ns_t n) 1 << ns.lbaf[flbas].ds); nvme_init_identify_allocated_ns(&cmd, nsid, &allocated); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Identify allocated ns\n"); else @@ -337,7 +349,7 @@ static int test_namespace(nvme_ns_t n) return -1; nvme_init_identify_ns_descs_list(&cmd, nsid, descs); - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Identify NS Descriptors\n"); else @@ -345,9 +357,9 @@ static int test_namespace(nvme_ns_t n) free(descs); nvme_init_get_features_write_protect(&cmd, nsid, NVME_GET_FEATURES_SEL_CURRENT); - ret = nvme_submit_admin_passthru(hdl, &cmd, &result); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) - printf(" Write Protect:%x\n", result); + printf(" Write Protect:%" PRIu64 "\n", (uint64_t)result); else if (ret > 0) printf(" ERROR: Write Protect:%x\n", ret); return 0; diff --git a/libnvme/test/zns.c b/libnvme/test/zns.c index 5296b757e9..76a8d36eef 100644 --- a/libnvme/test/zns.c +++ b/libnvme/test/zns.c @@ -26,16 +26,15 @@ static void show_zns_properties(nvme_ns_t n) struct nvme_zns_id_ns zns_ns; struct nvme_zns_id_ctrl zns_ctrl; struct nvme_zone_report *zr; - __u32 result; zr = calloc(1, 0x1000); if (!zr) return; nvme_init_zns_identify_ns(&cmd, nvme_ns_get_nsid(n), &zns_ns); - if (nvme_submit_admin_passthru(hdl, &cmd, &result)) { - fprintf(stderr, "failed to identify zns ns, result %x\n", - le32_to_cpu(result)); + if (nvme_submit_admin_passthru(hdl, &cmd)) { + fprintf(stderr, "failed to identify zns ns, result %" PRIx64 "\n", + (uint64_t)cmd.result); free(zr); return; } @@ -45,7 +44,7 @@ static void show_zns_properties(nvme_ns_t n) le32_to_cpu(zns_ns.mor)); nvme_init_zns_identify_ctrl(&cmd, &zns_ctrl); - if (nvme_submit_admin_passthru(hdl, &cmd, &result)) { + if (nvme_submit_admin_passthru(hdl, &cmd)) { fprintf(stderr, "failed to identify zns ctrl\n");; free(zr); return; @@ -55,9 +54,9 @@ static void show_zns_properties(nvme_ns_t n) nvme_init_zns_report_zones(&cmd, nvme_ns_get_nsid(n), 0, NVME_ZNS_ZRAS_REPORT_ALL, false, true, (void *)zr, 0x1000); - if (nvme_submit_io_passthru(hdl, &cmd, &result)) { - fprintf(stderr, "failed to report zones, result %x\n", - le32_to_cpu(result)); + if (nvme_submit_io_passthru(hdl, &cmd)) { + fprintf(stderr, "failed to report zones, result %" PRIx64"\n", + (uint64_t)cmd.result); free(zr); return; } diff --git a/logging.c b/logging.c index a8b1bd16cd..b57d257f35 100644 --- a/logging.c +++ b/logging.c @@ -81,13 +81,6 @@ static void nvme_show_common(struct nvme_passthru_cmd *cmd) static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err) { nvme_show_common(cmd); - nvme_show_key_value("result ", "%08x", cmd->result); - nvme_show_key_value("err ", "%d", err); -} - -static void nvme_show_command64(struct nvme_passthru_cmd64 *cmd, int err) -{ - nvme_show_common((struct nvme_passthru_cmd *)cmd); nvme_show_key_value("result ", "%"PRIx64"", (uint64_t)(uintptr_t)cmd->result); nvme_show_key_value("err ", "%d", err); } @@ -107,71 +100,41 @@ static void nvme_log_retry(int errnum) printf("passthru command returned '%s'\n", strerror(errnum)); } -int nvme_submit_passthru(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd *cmd, __u32 *result) +void *nvme_submit_entry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd) { - struct timeval start; - struct timeval end; - int err = 0; + memset(&sb, 0, sizeof(sb)); if (log_level >= LOG_DEBUG) - gettimeofday(&start, NULL); - - if (!nvme_cfg.dry_run) { -retry: - err = ioctl(nvme_transport_handle_get_fd(hdl), ioctl_cmd, cmd); - if ((err && (errno == EAGAIN || - (errno == EINTR && !nvme_sigint_received))) && - !nvme_cfg.no_retries) { - nvme_log_retry(errno); - goto retry; - } - } - - if (log_level >= LOG_DEBUG) { - gettimeofday(&end, NULL); - nvme_show_command(cmd, err); - nvme_show_latency(start, end); - } - - if (err >= 0 && result) - *result = cmd->result; + gettimeofday(&sb.start, NULL); - return err; + return &sb; } -int nvme_submit_passthru64(struct nvme_transport_handle *hdl, unsigned long ioctl_cmd, - struct nvme_passthru_cmd64 *cmd, - __u64 *result) +void nvme_submit_exit(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err, void *user_data) { - struct timeval start; - struct timeval end; - int err = 0; - - if (log_level >= LOG_DEBUG) - gettimeofday(&start, NULL); - - if (!nvme_cfg.dry_run) { -retry: - err = ioctl(nvme_transport_handle_get_fd(hdl), ioctl_cmd, cmd); - if ((err && (errno == EAGAIN || - (errno == EINTR && !nvme_sigint_received))) && - !nvme_cfg.no_retries) { - nvme_log_retry(errno); - goto retry; - } - } + struct submit_data *sb = user_data; if (log_level >= LOG_DEBUG) { - gettimeofday(&end, NULL); - nvme_show_command64(cmd, err); - nvme_show_latency(start, end); + gettimeofday(&sb->end, NULL); + nvme_show_command(cmd, err); + nvme_show_latency(sb->start, sb->end); } +} + +bool nvme_decide_retry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err) +{ + if (!nvme_cfg.no_retries) + return false; - if (err >= 0 && result) - *result = cmd->result; + if (err != -EAGAIN || + !(err == -EINTR && !nvme_sigint_received)) + return false; - return err; + nvme_log_retry(errno); + return true; } static void nvme_show_req_admin(const struct nvme_mi_admin_req_hdr *hdr, size_t hdr_len, diff --git a/logging.h b/logging.h index 6899a4f298..57ab5906e1 100644 --- a/logging.h +++ b/logging.h @@ -19,6 +19,16 @@ extern int log_level; +struct nvme_transport_handle; +struct nvme_passthru_cmd; + +void *nvme_submit_entry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd); +void nvme_submit_exit(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err, void *user_data); +bool nvme_decide_retry(struct nvme_transport_handle *hdl, + struct nvme_passthru_cmd *cmd, int err); + int map_log_level(int verbose, bool quiet); #endif // DEBUG_H_ diff --git a/nvme-print-binary.c b/nvme-print-binary.c index 17def142b0..608aee6dad 100644 --- a/nvme-print-binary.c +++ b/nvme-print-binary.c @@ -275,7 +275,7 @@ static void binary_sanitize_log(struct nvme_sanitize_log_page *sanitize, d_raw((unsigned char *)sanitize, sizeof(*sanitize)); } -static void binary_directive(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, +static void binary_directive(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len) { if (!buf) diff --git a/nvme-print-json.c b/nvme-print-json.c index b3ad275f68..ce5c6fc192 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -821,7 +821,7 @@ static void json_ana_log(struct nvme_ana_log *ana_log, const char *devname, json_print(r); } -static void json_select_result(enum nvme_features_id fid, __u32 result) +static void json_select_result(enum nvme_features_id fid, __u64 result) { struct json_object *r = json_r ? json_r : json_create_object(); char json_str[STR_LEN]; @@ -4174,7 +4174,7 @@ static void json_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges) json_print(r); } -static void json_lba_status_info(__u32 result) +static void json_lba_status_info(__u64 result) { struct json_object *r = json_create_object(); @@ -4974,7 +4974,7 @@ static void json_directive_show_fields(__u8 dtype, __u8 doper, unsigned int resu } } -static void json_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, +static void json_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len) { struct json_object *r = json_create_object(); @@ -4989,7 +4989,7 @@ static void json_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __ obj_add_str(r, "spec", json_str); sprintf(json_str, "%#x", nsid); obj_add_str(r, "NSID", json_str); - sprintf(json_str, "%#x", result); + sprintf(json_str, "%#"PRIx64, (uint64_t)result); obj_add_result(r, json_str); if (verbose_mode()) { diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index d8ba76aa58..5121dfafd5 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -4699,7 +4699,7 @@ static void stdout_sanitize_log(struct nvme_sanitize_log_page *sanitize, stdout_sanitize_log_ssi(sanitize->ssi, status); } -static void stdout_select_result(enum nvme_features_id fid, __u32 result) +static void stdout_select_result(enum nvme_features_id fid, __u64 result) { if (result & 0x1) printf(" Feature is saveable\n"); @@ -4868,23 +4868,23 @@ static void stdout_directive_show_fields(__u8 dtype, __u8 doper, } } -static void stdout_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, +static void stdout_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len) { - printf("dir-receive: type:%#x operation:%#x spec:%#x nsid:%#x result:%#x\n", - type, oper, spec, nsid, result); + printf("dir-receive: type:%#x operation:%#x spec:%#x nsid:%#x result:%#"PRIx64"\n", + type, oper, spec, nsid, (uint64_t)result); if (stdout_print_ops.flags & VERBOSE) stdout_directive_show_fields(type, oper, result, buf); else if (buf) d(buf, len, 16, 1); } -static void stdout_lba_status_info(__u32 result) +static void stdout_lba_status_info(__u64 result) { printf("\tLBA Status Information Poll Interval (LSIPI) : %u\n", - NVME_FEAT_LBAS_LSIPI(result)); + (__u32)NVME_FEAT_LBAS_LSIPI(result)); printf("\tLBA Status Information Report Interval (LSIRI): %u\n", - NVME_FEAT_LBAS_LSIRI(result)); + (__u32)NVME_FEAT_LBAS_LSIRI(result)); } void stdout_d(unsigned char *buf, int len, int width, int group) diff --git a/nvme-print.c b/nvme-print.c index 1bdcbb27bc..bc7a8ef64b 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1005,7 +1005,7 @@ const char *nvme_select_to_string(int sel) return "Reserved"; } -void nvme_show_select_result(enum nvme_features_id fid, __u32 result) +void nvme_show_select_result(enum nvme_features_id fid, __u64 result) { nvme_print(select_result, NORMAL, fid, result); } @@ -1191,7 +1191,7 @@ const char *nvme_bpwps_to_string(__u8 bpwps) } } -void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, +void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len, nvme_print_flags_t flags) { nvme_print(directive, flags, type, oper, spec, nsid, result, buf, len); @@ -1209,7 +1209,7 @@ const char *nvme_plm_window_to_string(__u32 plm) } } -void nvme_show_lba_status_info(__u32 result) +void nvme_show_lba_status_info(__u64 result) { nvme_print(lba_status_info, NORMAL, result); } diff --git a/nvme-print.h b/nvme-print.h index 708e8cd330..f630c0538a 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -31,7 +31,7 @@ struct print_ops { void (*ctrl_list)(struct nvme_ctrl_list *ctrl_list); void (*ctrl_registers)(void *bar, bool fabrics); void (*ctrl_register)(int offset, uint64_t value); - void (*directive)(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, void *buf, __u32 len); + void (*directive)(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len); void (*discovery_log)(struct nvmf_discovery_log *log, int numrec); void (*effects_log_list)(struct list_head *list); void (*endurance_group_event_agg_log)(struct nvme_aggregate_endurance_group_event *endurance_log, __u64 log_entries, __u32 size, const char *devname); @@ -71,7 +71,7 @@ struct print_ops { void (*resv_report)(struct nvme_resv_status *status, int bytes, bool eds); void (*sanitize_log_page)(struct nvme_sanitize_log_page *sanitize_log, const char *devname); void (*secondary_ctrl_list)(const struct nvme_secondary_ctrl_list *sc_list, __u32 count); - void (*select_result)(enum nvme_features_id fid, __u32 result); + void (*select_result)(enum nvme_features_id fid, __u64 result); void (*self_test_log)(struct nvme_self_test_log *self_test, __u8 dst_entries, __u32 size, const char *devname); void (*single_property)(int offset, uint64_t value64); void (*smart_log)(struct nvme_smart_log *smart, unsigned int nsid, const char *devname); @@ -87,7 +87,7 @@ struct print_ops { void (*show_feature_fields)(enum nvme_features_id fid, unsigned int result, unsigned char *buf); void (*id_ctrl_rpmbs)(__le32 ctrl_rpmbs); void (*lba_range)(struct nvme_lba_range_type *lbrt, int nr_ranges); - void (*lba_status_info)(__u32 result); + void (*lba_status_info)(__u64 result); void (*d)(unsigned char *buf, int len, int width, int group); void (*show_init)(void); void (*show_finish)(void); @@ -158,7 +158,7 @@ struct print_ops *nvme_get_stdout_print_ops(nvme_print_flags_t flags); struct print_ops *nvme_get_binary_print_ops(nvme_print_flags_t flags); void nvme_show_status(int status); -void nvme_show_lba_status_info(__u32 result); +void nvme_show_lba_status_info(__u64 result); void nvme_show_relatives(struct nvme_global_ctx *ctx, const char *name, nvme_print_flags_t flags); void nvme_show_id_iocs(struct nvme_id_iocs *iocs, nvme_print_flags_t flags); @@ -258,9 +258,9 @@ void nvme_show_topology_tabular(struct nvme_global_ctx *ctx, nvme_print_flags_t void nvme_feature_show(enum nvme_features_id fid, int sel, unsigned int result); void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, unsigned char *buf); -void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, +void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u64 result, void *buf, __u32 len, nvme_print_flags_t flags); -void nvme_show_select_result(enum nvme_features_id fid, __u32 result); +void nvme_show_select_result(enum nvme_features_id fid, __u64 result); void nvme_show_zns_id_ctrl(struct nvme_zns_id_ctrl *ctrl, nvme_print_flags_t flags); diff --git a/nvme-rpmb.c b/nvme-rpmb.c index 040781725c..5e955846c7 100644 --- a/nvme-rpmb.c +++ b/nvme-rpmb.c @@ -278,7 +278,7 @@ static int send_rpmb_req(struct nvme_transport_handle *hdl, unsigned char tgt, nvme_init_security_send(&cmd, NVME_NSID_NONE, tgt, RPMB_NVME_SPSP, RPMB_NVME_SECP, 0, req, size); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } static int recv_rpmb_rsp(struct nvme_transport_handle *hdl, int tgt, int size, @@ -288,7 +288,7 @@ static int recv_rpmb_rsp(struct nvme_transport_handle *hdl, int tgt, int size, nvme_init_security_receive(&cmd, 0, tgt, RPMB_NVME_SPSP, RPMB_NVME_SECP, 0, rsp, size); - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /* Initialize nonce value in rpmb request frame */ diff --git a/nvme.c b/nvme.c index da858e5823..f078d0adcc 100644 --- a/nvme.c +++ b/nvme.c @@ -406,6 +406,11 @@ int parse_and_open(struct nvme_global_ctx **ctx, return -ENXIO; } + nvme_transport_handle_set_submit_entry(hdl_new, nvme_submit_entry); + nvme_transport_handle_set_submit_exit(hdl_new , nvme_submit_exit); + nvme_transport_handle_set_decide_retry(hdl_new, nvme_decide_retry); + nvme_set_dry_run(ctx_new, argconfig_parse_seen(opts, "dry_run")); + *ctx = ctx_new; *hdl = hdl_new; return 0; @@ -1040,7 +1045,7 @@ static int get_effects_log(int argc, char **argv, struct command *acmd, struct p _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; struct list_head log_pages; nvme_effects_log_node_t *node; @@ -1098,9 +1103,10 @@ static int get_effects_log(int argc, char **argv, struct command *acmd, struct p munmap(bar, getpagesize()); } else { nvme_init_get_property(&cmd, NVME_REG_CAP); - err = nvme_submit_admin_passthru64(hdl, &cmd, &cap); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) goto cleanup_list; + cap = cmd.result; } if (NVME_CAP_CSS(cap) & NVME_CAP_CSS_NVM) @@ -2174,7 +2180,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug } nvme_init_io_mgmt_send(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (!err) printf("io-mgmt-send: Success, mos:%u mo:%u nsid:%d\n", cfg.mos, cfg.mo, cfg.nsid); @@ -2237,7 +2243,7 @@ static int io_mgmt_recv(int argc, char **argv, struct command *acmd, struct plug nvme_init_io_mgmt_recv(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (!err) { printf("io-mgmt-recv: Success, mos:%u mo:%u nsid:%d\n", cfg.mos, cfg.mo, cfg.nsid); @@ -2450,7 +2456,7 @@ static int get_log(int argc, char **argv, struct command *acmd, struct plugin *p NVME_LOG_CDW14_OT_SHIFT, NVME_LOG_CDW14_OT_MASK); - err = nvme_get_log(hdl, &cmd, cfg.rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, cfg.rae, NVME_LOG_PAGE_PDU_SIZE); if (!err) { if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", nvme_transport_handle_get_name(hdl), @@ -2675,7 +2681,7 @@ static int list_ctrl(int argc, char **argv, struct command *acmd, struct plugin nvme_init_identify_ns_ctrl_list(&cmd, cfg.namespace_id, cfg.cntid, cntlist); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_list_ctrl(cntlist, flags); else if (err > 0) @@ -2857,7 +2863,7 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *acmd, nvme_init_identify_endurance_group_id(&cmd, cfg.endgrp_id, endgrp_list); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_endurance_group_list(endgrp_list, flags); else if (err > 0) @@ -2951,7 +2957,7 @@ static int delete_ns(int argc, char **argv, struct command *acmd, struct plugin } nvme_init_ns_mgmt_delete(&cmd, cfg.namespace_id); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); ns_mgmt_show_status(hdl, err, acmd->name, cfg.namespace_id); return err; @@ -3036,7 +3042,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s else nvme_init_ns_detach_ctrls(&cmd, cfg.nsid, cntlist); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); ns_mgmt_show_status(hdl, err, acmd->name, cfg.nsid); return err; @@ -3410,7 +3416,8 @@ static int create_ns(int argc, char **argv, struct command *acmd, struct plugin data->phndl[i] = cpu_to_le16(phndl[i]); nvme_init_ns_mgmt_create(&cmd, cfg.csi, data); - err = nvme_submit_admin_passthru(hdl, &cmd, &nsid); + err = nvme_submit_admin_passthru(hdl, &cmd); + nsid = cmd.result; ns_mgmt_show_status(hdl, err, acmd->name, nsid); return err; @@ -3646,7 +3653,7 @@ static int nvm_id_ctrl(int argc, char **argv, struct command *acmd, return -ENOMEM; nvme_init_identify_csi_ctrl(&cmd, NVME_CSI_NVM, ctrl_nvm); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_id_ctrl_nvm(ctrl_nvm, flags); else if (err > 0) @@ -3937,7 +3944,7 @@ static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plu if (cfg.force) { nvme_init_identify_allocated_ns(&cmd, cfg.namespace_id, ns); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); } else { err = nvme_identify_ns(hdl, cfg.namespace_id, ns); } @@ -4013,7 +4020,7 @@ static int cmd_set_independent_id_ns(int argc, char **argv, struct command *acmd nvme_init_identify_csi_independent_identify_id_ns(&cmd, cfg.namespace_id, ns); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_cmd_set_independent_id_ns(ns, cfg.namespace_id, flags); else if (err > 0) @@ -4106,7 +4113,7 @@ static int id_nvmset(int argc, char **argv, struct command *acmd, struct plugin nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, cfg.nvmset_id, nvmset); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_id_nvmset(nvmset, cfg.nvmset_id, flags); else if (err > 0) @@ -4219,7 +4226,7 @@ static int id_iocs(int argc, char **argv, struct command *acmd, struct plugin *p return -ENOMEM; nvme_init_identify_command_set_structure(&cmd, cfg.cntid, iocs); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { printf("NVMe Identify I/O Command Set:\n"); nvme_show_id_iocs(iocs, flags); @@ -4272,7 +4279,7 @@ static int id_domain(int argc, char **argv, struct command *acmd, struct plugin return -ENOMEM; nvme_init_identify_domain_list(&cmd, cfg.dom_id, id_domain); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { printf("NVMe Identify command for Domain List is successful:\n"); printf("NVMe Identify Domain List:\n"); @@ -4340,7 +4347,6 @@ static int virtual_mgmt(int argc, char **argv, struct command *acmd, struct plug _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; struct nvme_passthru_cmd cmd; - __u32 result; int err; struct config { @@ -4368,9 +4374,10 @@ static int virtual_mgmt(int argc, char **argv, struct command *acmd, struct plug return err; nvme_init_virtual_mgmt(&cmd, cfg.act, cfg.rt, cfg.cntlid, cfg.nr); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) - printf("success, Number of Controller Resources Modified (NRM):%#x\n", result); + printf("success, Number of Controller Resources Modified (NRM):%" PRIu64"\n", + (uint64_t)cmd.result); else if (err > 0) nvme_show_status(err); else @@ -4425,7 +4432,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *acmd, struct return -ENOMEM; nvme_init_identify_primary_ctrl_cap(&cmd, cfg.cntlid, caps); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_primary_ctrl_cap(caps, flags); else if (err > 0) @@ -4485,7 +4492,7 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *acmd, stru return -ENOMEM; nvme_init_identify_secondary_ctrl_list(&cmd, cfg.cntid, sc_list); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_list_secondary_ctrl(sc_list, cfg.num_entries, flags); else if (err > 0) @@ -4583,7 +4590,7 @@ static void abort_self_test(struct nvme_transport_handle *hdl, __u32 nsid) int err; nvme_init_dev_self_test(&cmd, nsid, NVME_DST_STC_ABORT); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("Aborting device self-test operation\n"); else if (err > 0) @@ -4670,7 +4677,7 @@ static int device_self_test(int argc, char **argv, struct command *acmd, struct } nvme_init_dev_self_test(&cmd, cfg.namespace_id, cfg.stc); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { if (cfg.stc == NVME_ST_CODE_ABORT) printf("Aborting device self-test operation\n"); @@ -4749,7 +4756,7 @@ static int self_test_log(int argc, char **argv, struct command *acmd, struct plu } static int get_feature_id(struct nvme_transport_handle *hdl, struct feat_cfg *cfg, - void **buf, __u32 *result) + void **buf, __u64 *result) { if (!cfg->data_len) nvme_get_feature_length(cfg->feature_id, cfg->cdw11, @@ -4779,7 +4786,7 @@ static int filter_out_flags(int status) return status & (NVME_VAL(SCT) | NVME_VAL(SC)); } -static void get_feature_id_print(struct feat_cfg cfg, int err, __u32 result, +static void get_feature_id_print(struct feat_cfg cfg, int err, __u64 result, void *buf, nvme_print_flags_t flags) { int status = filter_out_flags(err); @@ -4824,8 +4831,8 @@ static int get_feature_id_changed(struct nvme_transport_handle *hdl, struct feat { int err; int err_def = 0; - __u32 result; - __u32 result_def; + __u64 result; + __u64 result_def; _cleanup_free_ void *buf = NULL; _cleanup_free_ void *buf_def = NULL; @@ -5000,7 +5007,7 @@ static int fw_download_single(struct nvme_transport_handle *hdl, void *fw_buf, if (err) return err; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) return 0; @@ -5225,12 +5232,13 @@ static bool fw_commit_support_mud(struct nvme_transport_handle *hdl) return false; } -static void fw_commit_print_mud(struct nvme_transport_handle *hdl, __u32 result) +static void fw_commit_print_mud(struct nvme_transport_handle *hdl, __u64 result) { if (!fw_commit_support_mud(hdl)) return; - printf("Multiple Update Detected (MUD) Value: %u\n", result); + printf("Multiple Update Detected (MUD) Value: %#" PRIx64 "\n", + (uint64_t)result); if (result & 0x1) printf("Detected an overlapping firmware/boot partition image update command\n" @@ -5255,7 +5263,6 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; struct nvme_passthru_cmd cmd; - __u32 result; int err; nvme_print_flags_t flags; @@ -5300,7 +5307,7 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin } nvme_init_fw_commit(&cmd, cfg.slot, cfg.action, cfg.bpid); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { nvme_show_error("fw-commit: %s", nvme_strerror(err)); } else if (err > 0) { @@ -5332,7 +5339,7 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin if (cfg.action == 6 || cfg.action == 7) printf(" bpid:%d", cfg.bpid); printf("\n"); - fw_commit_print_mud(hdl, result); + fw_commit_print_mud(hdl, cmd.result); } return err; @@ -5519,7 +5526,7 @@ static int sanitize_cmd(int argc, char **argv, struct command *acmd, struct plug nvme_init_sanitize_nvm(&cmd, cfg.sanact, cfg.ause, cfg.owpass, cfg.oipbp, cfg.no_dealloc, cfg.emvs, cfg.ovrpat); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("sanitize: %s", nvme_strerror(err)); else if (err > 0) @@ -5530,13 +5537,15 @@ static int sanitize_cmd(int argc, char **argv, struct command *acmd, struct plug static int nvme_get_single_property(struct nvme_transport_handle *hdl, struct get_reg_config *cfg, __u64 *value) { - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; int err; nvme_init_get_property(&cmd, cfg->offset); - err = nvme_submit_admin_passthru64(hdl, &cmd, value); - if (!err) + err = nvme_submit_admin_passthru(hdl, &cmd); + if (!err) { + *value = cmd.result; return 0; + } if (cfg->fabrics && nvme_is_fabrics_optional_reg(cfg->offset)) { *value = -1; @@ -5759,7 +5768,7 @@ static bool is_reg_selected(struct get_reg_config *cfg, int offset) static int get_register_properties(struct nvme_transport_handle *hdl, void **pbar, struct get_reg_config *cfg) { - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; int offset = NVME_REG_CRTO; __u64 value; int size; @@ -5777,13 +5786,15 @@ static int get_register_properties(struct nvme_transport_handle *hdl, void **pba continue; nvme_init_get_property(&cmd, offset); - err = nvme_submit_admin_passthru64(hdl, &cmd, &value); + err = nvme_submit_admin_passthru(hdl, &cmd); if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INVALID_FIELD)) { value = -1; } else if (err) { nvme_show_error("get-property: %s", nvme_strerror(err)); free(bar); return err; + } else { + value = cmd.result; } if (nvme_is_64bit_reg(offset)) @@ -5975,7 +5986,7 @@ static int nvme_set_single_property(struct nvme_transport_handle *hdl, int offse int err; nvme_init_set_property(&cmd, offset, value); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("set-property: %s", nvme_strerror(err)); else if (!err) @@ -6576,7 +6587,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin nvme_init_format_nvm(&cmd, cfg.namespace_id, cfg.lbaf, cfg.mset, cfg.pi, cfg.pil, cfg.ses); cmd.timeout_ms = timeout_ms; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { nvme_show_error("format: %s", nvme_strerror(err)); } else if (err != 0) { @@ -6644,7 +6655,7 @@ static int set_feature(int argc, char **argv, struct command *acmd, struct plugi _cleanup_free_ void *buf = NULL; _cleanup_fd_ int ffd = STDIN_FILENO; int err; - __u32 result; + __u64 result; nvme_print_flags_t flags; struct config { @@ -6869,7 +6880,7 @@ static int sec_send(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_security_send(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.tl, sec_buf, cfg.tl); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("security-send: %s", nvme_strerror(err)); else if (err > 0) @@ -6891,7 +6902,6 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin * _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; _cleanup_free_ void *buf = NULL; struct nvme_passthru_cmd cmd; - __u32 result; __u32 dw12 = 0; _cleanup_fd_ int ffd = STDIN_FILENO; int err; @@ -6994,14 +7004,15 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_directive_send(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype, cfg.dspec, buf, cfg.data_len); cmd.cdw12 = dw12; - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { nvme_show_error("dir-send: %s", nvme_strerror(err)); return err; } if (!err) { - printf("dir-send: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#x\n", - cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id, result); + printf("dir-send: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#" PRIx64 "\n", + cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id, + (uint64_t)cmd.result); if (buf) { if (!cfg.raw_binary) d(buf, cfg.data_len, 16, 1); @@ -7067,7 +7078,7 @@ static int write_uncor(int argc, char **argv, struct command *acmd, struct plugi nvme_init_write_uncorrectable(&cmd, cfg.namespace_id, cfg.start_block, cfg.block_count, cfg.dtype << 4, cfg.dspec); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("write uncorrectable: %s", nvme_strerror(err)); else if (err != 0) @@ -7134,7 +7145,6 @@ static int write_zeroes(int argc, char **argv, struct command *acmd, struct plug struct nvme_passthru_cmd cmd; __u8 sts = 0, pif = 0; __u16 control = 0; - __u32 result = 0; int err; const char *desc = @@ -7259,11 +7269,9 @@ static int write_zeroes(int argc, char **argv, struct command *acmd, struct plug nvme_init_write_zeros(&cmd, cfg.namespace_id, cfg.start_block, cfg.block_count, control, cfg.dspec, 0, 0); - nvme_init_var_size_tags((struct nvme_passthru_cmd64 *)&cmd, pif, sts, - cfg.ref_tag, cfg.storage_tag); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, cfg.app_tag, - cfg.app_tag_mask); - err = nvme_submit_io_passthru(hdl, &cmd, &result); + nvme_init_var_size_tags(&cmd, pif, sts, cfg.ref_tag, cfg.storage_tag); + nvme_init_app_tag(&cmd, cfg.app_tag, cfg.app_tag_mask); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("write-zeroes: %s", nvme_strerror(err)); else if (err != 0) @@ -7271,7 +7279,7 @@ static int write_zeroes(int argc, char **argv, struct command *acmd, struct plug else { printf("NVME Write Zeroes Success\n"); if (cfg.nsz && argconfig_parse_seen(opts, "verbose")) { - if (result & 0x1) + if (cmd.result & 0x1) printf("All logical blocks in the entire namespace cleared to zero\n"); else printf("%d logical blocks cleared to zero\n", cfg.block_count); @@ -7381,7 +7389,7 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nb); nvme_init_dsm(&cmd, cfg.namespace_id, nb, cfg.idr, cfg.idw, cfg.ad, dsm, sizeof(*dsm) * nb); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("data-set management: %s", nvme_strerror(err)); else if (err != 0) @@ -7629,11 +7637,9 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_copy(&cmd, cfg.namespace_id, cfg.sdlba, nr, cfg.format, cfg.prinfor, cfg.prinfow, 0, cfg.dtype, false, false, cfg.fua, cfg.lr, 0, cfg.dspec, copy->f0); - nvme_init_var_size_tags((struct nvme_passthru_cmd64 *)&cmd, pif, sts, - cfg.ilbrt, 0); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, cfg.lbat, - cfg.lbatm); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + nvme_init_var_size_tags(&cmd, pif, sts, cfg.ilbrt, 0); + nvme_init_app_tag(&cmd, cfg.lbat, cfg.lbatm); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("NVMe Copy: %s", nvme_strerror(err)); else if (err != 0) @@ -7757,7 +7763,7 @@ static int resv_acquire(int argc, char **argv, struct command *acmd, struct plug nvme_init_resv_acquire(&cmd, cfg.namespace_id, cfg.racqa, cfg.iekey, false, cfg.rtype, cfg.crkey, cfg.prkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("reservation acquire: %s", nvme_strerror(err)); else if (err > 0) @@ -7839,7 +7845,7 @@ static int resv_register(int argc, char **argv, struct command *acmd, struct plu nvme_init_resv_register(&cmd, cfg.namespace_id, cfg.rrega, cfg.iekey, false, cfg.cptpl, cfg.crkey, cfg.nrkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("reservation register: %s", nvme_strerror(err)); else if (err > 0) @@ -7916,7 +7922,7 @@ static int resv_release(int argc, char **argv, struct command *acmd, struct plug nvme_init_resv_release(&cmd, cfg.nsid, cfg.rrela, cfg.iekey, false, cfg.rtype, cfg.crkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("reservation release: %s", nvme_strerror(err)); else if (err != 0) @@ -8010,7 +8016,7 @@ static int resv_report(int argc, char **argv, struct command *acmd, struct plugi return -ENOMEM; nvme_init_resv_report(&cmd, cfg.nsid, cfg.eds, false, status, size); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (!err) nvme_show_resv_report(status, size, cfg.eds, flags); else if (err > 0) @@ -8357,13 +8363,11 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char NVME_FIELD_ENCODE(cfg.dsmgmt, NVME_IOCS_COMMON_CDW13_DSM_SHIFT, NVME_IOCS_COMMON_CDW13_DSM_MASK); - nvme_init_var_size_tags((struct nvme_passthru_cmd64 *)&cmd, pif, sts, - cfg.ref_tag, cfg.storage_tag); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, cfg.app_tag, - cfg.app_tag_mask); + nvme_init_var_size_tags(&cmd, pif, sts, cfg.ref_tag, cfg.storage_tag); + nvme_init_app_tag(&cmd, cfg.app_tag, cfg.app_tag_mask); gettimeofday(&start_time, NULL); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); if (cfg.latency) printf(" latency: %s: %llu us\n", command, elapsed_utime(start_time, end_time)); @@ -8525,11 +8529,9 @@ static int verify_cmd(int argc, char **argv, struct command *acmd, struct plugin nvme_init_verify(&cmd, cfg.namespace_id, cfg.start_block, cfg.block_count, control, 0, NULL, 0, NULL, 0); - nvme_init_var_size_tags((struct nvme_passthru_cmd64 *)&cmd, pif, sts, - cfg.ref_tag, cfg.storage_tag); - nvme_init_app_tag((struct nvme_passthru_cmd64 *)&cmd, cfg.app_tag, - cfg.app_tag_mask); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + nvme_init_var_size_tags(&cmd, pif, sts, cfg.ref_tag, cfg.storage_tag); + nvme_init_app_tag(&cmd, cfg.app_tag, cfg.app_tag_mask); + err = nvme_submit_io_passthru(hdl, &cmd); if (err < 0) nvme_show_error("verify: %s", nvme_strerror(err)); else if (err != 0) @@ -8605,7 +8607,7 @@ static int sec_recv(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_security_receive(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.al, sec_buf, cfg.size); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { nvme_show_error("security receive: %s", nvme_strerror(err)); } else if (err > 0) { @@ -8687,7 +8689,7 @@ static int get_lba_status(int argc, char **argv, struct command *acmd, nvme_init_get_lba_status(&cmd, cfg.namespace_id, cfg.slba, cfg.mndw, cfg.atype, cfg.rl, buf); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_lba_status(buf, buf_len, flags); else if (err > 0) @@ -8715,7 +8717,6 @@ static int capacity_mgmt(int argc, char **argv, struct command *acmd, struct plu _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; struct nvme_passthru_cmd cmd; int err = -1; - __u32 result; nvme_print_flags_t flags; struct config { @@ -8756,13 +8757,15 @@ static int capacity_mgmt(int argc, char **argv, struct command *acmd, struct plu nvme_init_capacity_mgmt(&cmd, cfg.operation, cfg.element_id, (__u64)cfg.dw12 << 32 | cfg.dw11); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { printf("Capacity Management Command is Success\n"); if (cfg.operation == 1) - printf("Created Element Identifier for Endurance Group is: %u\n", result); + printf("Created Element Identifier for Endurance Group is: %" PRIu64 "\n", + (uint64_t)cmd.result); else if (cfg.operation == 3) - printf("Created Element Identifier for NVM Set is: %u\n", result); + printf("Created Element Identifier for NVM Set is: %" PRIu64 "\n", + (uint64_t)cmd.result); } else if (err > 0) { nvme_show_status(err); } else if (err < 0) { @@ -8782,7 +8785,6 @@ static int dir_receive(int argc, char **argv, struct command *acmd, struct plugi _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; _cleanup_free_ void *buf = NULL; struct nvme_passthru_cmd cmd; - __u32 result; __u32 dw12 = 0; int err; @@ -8871,10 +8873,10 @@ static int dir_receive(int argc, char **argv, struct command *acmd, struct plugi nvme_init_directive_recv(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype, cfg.dspec, buf, cfg.data_len); cmd.cdw12 = dw12; - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_directive_show(cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id, - result, buf, cfg.data_len, flags); + cmd.result, buf, cfg.data_len, flags); else if (err > 0) nvme_show_status(err); else if (err < 0) @@ -8963,7 +8965,7 @@ static int lockdown_cmd(int argc, char **argv, struct command *acmd, struct plug nvme_init_lockdown(&cmd, cfg.scp, cfg.prhbt, cfg.ifc, cfg.ofi, cfg.uuid); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("lockdown: %s", nvme_strerror(err)); else if (err > 0) @@ -9031,7 +9033,6 @@ static int passthru(int argc, char **argv, bool admin, void *data = NULL; _cleanup_free_ void *mdata = NULL; int err = 0; - __u32 result; const char *cmd_name = NULL; struct timeval start_time, end_time; nvme_print_flags_t flags_t; @@ -9189,26 +9190,28 @@ static int passthru(int argc, char **argv, bool admin, gettimeofday(&start_time, NULL); + struct nvme_passthru_cmd cmd = { + .opcode = cfg.opcode, + .flags = cfg.flags, + .nsid = cfg.namespace_id, + .cdw2 = cfg.cdw2, + .cdw3 = cfg.cdw3, + .metadata = (__u64)(uintptr_t)mdata, + .addr = (__u64)(uintptr_t)data, + .metadata_len = cfg.metadata_len, + .data_len = cfg.data_len, + .cdw10 = cfg.cdw10, + .cdw11 = cfg.cdw11, + .cdw12 = cfg.cdw12, + .cdw13 = cfg.cdw13, + .cdw14 = cfg.cdw14, + .cdw15 = cfg.cdw15, + .timeout_ms = nvme_cfg.timeout, + }; if (admin) - err = nvme_admin_passthru(hdl, cfg.opcode, cfg.flags, - cfg.rsvd, - cfg.namespace_id, cfg.cdw2, - cfg.cdw3, cfg.cdw10, - cfg.cdw11, cfg.cdw12, cfg.cdw13, - cfg.cdw14, - cfg.cdw15, cfg.data_len, data, - cfg.metadata_len, - mdata, nvme_cfg.timeout, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); else - err = nvme_io_passthru(hdl, cfg.opcode, cfg.flags, - cfg.rsvd, - cfg.namespace_id, cfg.cdw2, cfg.cdw3, - cfg.cdw10, - cfg.cdw11, cfg.cdw12, cfg.cdw13, - cfg.cdw14, - cfg.cdw15, cfg.data_len, data, - cfg.metadata_len, - mdata, nvme_cfg.timeout, &result); + err = nvme_submit_io_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); cmd_name = nvme_cmd_to_string(admin, cfg.opcode); @@ -9222,8 +9225,10 @@ static int passthru(int argc, char **argv, bool admin, } else if (err) { nvme_show_status(err); } else { - fprintf(stderr, "%s Command %s is Success and result: 0x%08x\n", admin ? "Admin" : "IO", - strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific", result); + fprintf(stderr, "%s Command %s is Success and result: 0x%" PRIx64 "\n", + admin ? "Admin" : "IO", + strcmp(cmd_name, "Unknown") ? + cmd_name : "Vendor Specific", (uint64_t)cmd.result); if (cfg.read) passthru_print_read_output(cfg, data, dfd, mdata, mfd, err); } @@ -10264,14 +10269,24 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) } } - err = nvme_admin_passthru(hdl, admin_opcode, 0, 0, cfg.namespace_id, 0, 0, - cfg.nmimt << 11 | 4, cfg.opcode, cfg.nmd0, cfg.nmd1, 0, 0, - cfg.data_len, data, 0, NULL, 0, &result); + struct nvme_passthru_cmd cmd = { + .opcode = admin_opcode, + .nsid = cfg.namespace_id, + .cdw10 = cfg.nmimt << 11 | 4, + .cdw11 = cfg.opcode, + .cdw12 = cfg.nmd0, + .cdw13 = cfg.nmd1, + .addr = (__u64)(uintptr_t)data, + .data_len = cfg.data_len, + }; + + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { nvme_show_error("nmi_recv: %s", nvme_strerror(err)); } else if (err) { nvme_show_status(err); } else { + result = cmd.result; printf( "%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)\n", nvme_cmd_to_string(true, admin_opcode), result, result & 0xff, result >> 8); @@ -10415,7 +10430,7 @@ static int get_dispersed_ns_psub(struct nvme_transport_handle *hdl, __u32 nsid, (void *)log->participating_nss, psub_list_len); cmd.cdw12 = header_len & 0xffffffff; cmd.cdw13 = header_len >> 32; - err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) goto err_free; @@ -10474,6 +10489,7 @@ static int get_log_offset(struct nvme_transport_handle *hdl, __u32 len, void **log) { struct nvme_passthru_cmd cmd; + int err; args->lpo = *offset, args->log = *log + *offset, @@ -10501,8 +10517,10 @@ static int get_log_offset(struct nvme_transport_handle *hdl, NVME_LOG_CDW14_OT_SHIFT, NVME_LOG_CDW14_OT_MASK); - return nvme_get_log(hdl, &cmd, args->rae, - NVME_LOG_PAGE_PDU_SIZE, args->result); + err = nvme_get_log(hdl, &cmd, args->rae, NVME_LOG_PAGE_PDU_SIZE); + if (*args->result) + *args->result = cmd.result; + return err; } static int get_reachability_group_desc(struct nvme_transport_handle *hdl, struct nvme_get_log_args *args, diff --git a/nvme.h b/nvme.h index 84792f7b57..054976d1bf 100644 --- a/nvme.h +++ b/nvme.h @@ -139,6 +139,6 @@ static inline int nvme_get_nsid_log(struct nvme_transport_handle *hdl, nvme_init_get_log(&cmd, nsid, lid, NVME_CSI_NVM, log, len); - return nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); } #endif /* _NVME_H */ diff --git a/plugins/amzn/amzn-nvme.c b/plugins/amzn/amzn-nvme.c index 61c44d1550..014a3c3ad8 100644 --- a/plugins/amzn/amzn-nvme.c +++ b/plugins/amzn/amzn-nvme.c @@ -520,7 +520,7 @@ static int get_stats(int argc, char **argv, struct command *acmd, nvme_init_get_log(&cmd, nsid, AMZN_NVME_STATS_LOGPAGE_ID, NVME_CSI_NVM, &log, len); - rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (rc != 0) { fprintf(stderr, "[ERROR] %s: Failed to get log page, rc = %d\n", __func__, rc); diff --git a/plugins/dera/dera-nvme.c b/plugins/dera/dera-nvme.c index f7f20cae47..7a0d54ea8a 100644 --- a/plugins/dera/dera-nvme.c +++ b/plugins/dera/dera-nvme.c @@ -107,7 +107,7 @@ static int nvme_dera_get_device_status(struct nvme_transport_handle *hdl, enum d .cdw12 = 0x104, }; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err && result) *result = cmd.result; diff --git a/plugins/fdp/fdp.c b/plugins/fdp/fdp.c index 00ba0335d6..445a68ccce 100644 --- a/plugins/fdp/fdp.c +++ b/plugins/fdp/fdp.c @@ -341,7 +341,7 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, &hdr, sizeof(hdr)); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -354,7 +354,7 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin return -ENOMEM; nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, buf, len); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -419,7 +419,7 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin buf[i] = cpu_to_le16(pids[i]); nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, buf, npids); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -522,7 +522,7 @@ static int fdp_feature(int argc, char **argv, struct command *acmd, struct plugi _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; bool enabling_conf_idx = false; - __u32 result; + __u64 result; int err = -1; struct config { diff --git a/plugins/feat/feat-nvme.c b/plugins/feat/feat-nvme.c index e7b7607279..17a42803fa 100644 --- a/plugins/feat/feat-nvme.c +++ b/plugins/feat/feat-nvme.c @@ -52,7 +52,7 @@ static const char *volatile_wc_feat = "volatile write cache feature"; static int feat_get(struct nvme_transport_handle *hdl, const __u8 fid, __u32 cdw11, __u8 sel, const char *feat) { - __u32 result; + __u64 result; int err; __u32 len = 0; @@ -92,7 +92,7 @@ static int power_mgmt_set(struct nvme_transport_handle *hdl, const __u8 fid, __u8 ps, __u8 wh, bool sv) { __u32 cdw11 = NVME_SET(ps, FEAT_PWRMGMT_PS) | NVME_SET(wh, FEAT_PWRMGMT_WH); - __u32 result; + __u64 result; int err; err = nvme_set_features(hdl, 0, fid, sv, cdw11, 0, 0, 0, 0, NULL, 0, @@ -152,7 +152,7 @@ static int feat_power_mgmt(int argc, char **argv, struct command *acmd, struct p static int perfc_set(struct nvme_transport_handle *hdl, __u8 fid, __u32 cdw11, struct perfc_config *cfg, bool sv) { - __u32 result; + __u64 result; int err; _cleanup_fd_ int ffd = STDIN_FILENO; @@ -254,7 +254,7 @@ static int hctm_set(struct nvme_transport_handle *hdl, const __u8 fid, { __u32 cdw11 = NVME_SET(tmt1, FEAT_HCTM_TMT1) | NVME_SET(tmt2, FEAT_HCTM_TMT2); - __u32 result; + __u64 result; int err; err = nvme_set_features(hdl, 0, fid, sv, cdw11, 0, 0, 0, 0, NULL, 0, @@ -312,7 +312,7 @@ static int feat_hctm(int argc, char **argv, struct command *acmd, struct plugin static int timestamp_set(struct nvme_transport_handle *hdl, const __u8 fid, __u64 tstmp, bool sv) { - __u32 result; + __u64 result; int err; struct nvme_timestamp ts; __le64 timestamp = cpu_to_le64(tstmp); @@ -372,23 +372,24 @@ static int temp_thresh_set(struct nvme_transport_handle *hdl, const __u8 fid, struct argconfig_commandline_options *opts, struct temp_thresh_config *cfg) { - __u32 result; - int err; enum nvme_get_features_sel sel = NVME_GET_FEATURES_SEL_CURRENT; struct nvme_passthru_cmd cmd; __u16 tmpth; __u8 tmpsel; __u8 thsel; __u8 tmpthh; - bool sv = argconfig_parse_seen(opts, "save"); + int err; + bool sv; + sv = argconfig_parse_seen(opts, "save"); if (sv) sel = NVME_GET_FEATURES_SEL_SAVED; nvme_init_get_features_temp_thresh(&cmd, sel, cfg->tmpsel, cfg->thsel); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { - nvme_feature_decode_temp_threshold(result, &tmpth, &tmpsel, &thsel, &tmpthh); + nvme_feature_decode_temp_threshold(cmd.result, &tmpth, + &tmpsel, &thsel, &tmpthh); if (!argconfig_parse_seen(opts, "tmpth")) cfg->tmpth = tmpth; if (!argconfig_parse_seen(opts, "tmpthh")) @@ -396,8 +397,8 @@ static int temp_thresh_set(struct nvme_transport_handle *hdl, const __u8 fid, } nvme_init_set_features_temp_thresh(&cmd, sv, cfg->tmpth, cfg->tmpsel, - cfg->thsel, cfg->tmpthh); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + cfg->thsel, cfg->tmpthh); + err = nvme_submit_admin_passthru(hdl, &cmd); nvme_show_init(); @@ -456,19 +457,20 @@ static int arbitration_set(struct nvme_transport_handle *hdl, const __u8 fid, struct arbitration_config *cfg) { enum nvme_get_features_sel sel = NVME_GET_FEATURES_SEL_CURRENT; - bool sv = argconfig_parse_seen(opts, "save"); struct nvme_passthru_cmd cmd; __u8 ab, lpw, mpw, hpw; - __u32 result; + bool sv; int err; + sv = argconfig_parse_seen(opts, "save"); if (sv) sel = NVME_GET_FEATURES_SEL_SAVED; nvme_init_get_features_arbitration(&cmd, sel); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { - nvme_feature_decode_arbitration(result, &ab, &lpw, &mpw, &hpw); + nvme_feature_decode_arbitration(cmd.result, &ab, + &lpw, &mpw, &hpw); if (!argconfig_parse_seen(opts, "ab")) cfg->ab = ab; if (!argconfig_parse_seen(opts, "lpw")) @@ -480,8 +482,8 @@ static int arbitration_set(struct nvme_transport_handle *hdl, const __u8 fid, } nvme_init_set_features_arbitration(&cmd, sv, cfg->ab, cfg->lpw, - cfg->mpw, cfg->hpw); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + cfg->mpw, cfg->hpw); + err = nvme_submit_admin_passthru(hdl, &cmd); nvme_show_init(); @@ -536,7 +538,7 @@ static int volatile_wc_set(struct nvme_transport_handle *hdl, const __u8 fid, bool wce, bool sv) { __u32 cdw11 = NVME_SET(wce, FEAT_VWC_WCE); - __u32 result; + __u64 result; int err; err = nvme_set_features(hdl, 0, fid, sv, cdw11, 0, 0, 0, 0, NULL, 0, diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 1182c27987..6b7fe4206a 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -35,12 +35,12 @@ static int nvme_vucmd(struct nvme_transport_handle *hdl, unsigned char opcode, cmd.nsid = 0xffffffff; cmd.addr = (__u64)(__u64)(uintptr_t)data; cmd.data_len = data_len; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } static int getlogpage(struct nvme_transport_handle *hdl, unsigned char ilogid, unsigned char ilsp, char *data, int data_len, - unsigned int *result) + __u64 *result) { struct nvme_passthru_cmd cmd; @@ -50,7 +50,7 @@ static int getlogpage(struct nvme_transport_handle *hdl, unsigned char ilogid, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - return nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, result); + return nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); } static int getvsctype(struct nvme_transport_handle *hdl) @@ -137,8 +137,9 @@ static int getvsc_eventlog(struct nvme_transport_handle *hdl, FILE *fp) int getlogpage_eventlog(struct nvme_transport_handle *hdl, FILE *fp) { - unsigned int i, result, total_size; + unsigned int i, total_size; char data[4096]; + __u64 result; int ret = 0; result = 0; diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index ef22ef58ea..545f44a615 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -1073,7 +1073,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *acmd, struct if (media_version[0] == 1000) { __u32 thresholds[OPTANE_V1000_BUCKET_LEN] = {0}; - __u32 result; + __u64 result; err = nvme_get_features(hdl, 0, 0xf7, 0, cfg.write ? 0x1 : 0x0, @@ -1227,7 +1227,7 @@ static int read_entire_cmd(struct nvme_passthru_cmd *cmd, int total_size, dword_tfer = min(max_tfer, total_size); while (total_size > 0) { - err = nvme_submit_admin_passthru(hdl, cmd, NULL); + err = nvme_submit_admin_passthru(hdl, cmd); if (err) { fprintf(stderr, "failed on cmd.data_len %u cmd.cdw13 %u cmd.cdw12 %x cmd.cdw10 %u err %x remaining size %d\n", @@ -1537,7 +1537,7 @@ static int enable_lat_stats_tracking(int argc, char **argv, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; void *buf = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -1579,8 +1579,8 @@ static int enable_lat_stats_tracking(int argc, char **argv, data_len, &result); if (!err) { printf( - "Latency Statistics Tracking (FID 0x%X) is currently (%i).\n", - fid, result); + "Latency Statistics Tracking (FID 0x%X) is currently (%"PRIu64").\n", + fid, (uint64_t)result); } else { printf("Could not read feature id 0xE2.\n"); return err; @@ -1620,7 +1620,7 @@ static int set_lat_stats_thresholds(int argc, char **argv, const __u32 sv = 0; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err, num; struct config { diff --git a/plugins/lm/lm-nvme.c b/plugins/lm/lm-nvme.c index fdf6f42f82..6f65f6b3d8 100644 --- a/plugins/lm/lm-nvme.c +++ b/plugins/lm/lm-nvme.c @@ -62,7 +62,6 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu struct lba_migration_queue_entry_type_0 *queue = NULL; _cleanup_huge_ struct nvme_mem_huge mh = { 0, }; struct nvme_passthru_cmd cmd; - __u32 result; int err = -1; struct config { @@ -109,14 +108,14 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu nvme_init_lm_cdq_create(&cmd, NVME_SET(cfg.qt, LM_QT), cfg.cntlid, cfg.sz, queue); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno)); else if (err) nvme_show_status(err); else printf("Create CDQ Successful: CDQID=0x%04x\n", - NVME_GET(result, LM_CREATE_CDQ_CDQID)); + NVME_GET((__u32)cmd.result, LM_CREATE_CDQ_CDQID)); return err; } @@ -149,7 +148,7 @@ static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plu return err; nvme_init_lm_cdq_delete(&cmd, 0, cfg.cdqid); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno)); else if (err > 0) @@ -234,7 +233,7 @@ static int lm_track_send(int argc, char **argv, struct command *acmd, struct plu } nvme_init_lm_track_send(&cmd, cfg.sel, cfg.mos, cfg.cdqid); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("ERROR: nvme_lm_track_send() failed %s", strerror(errno)); else if (err) @@ -383,7 +382,7 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct cfg.stype, cfg.dudmq, cfg.csvi, cfg.csuuidi, cfg.offset, cfg.uidx, data, (cfg.numd << 2)); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("ERROR: nvme_lm_migration_send() failed %s", strerror(errno)); else if (err > 0) @@ -419,7 +418,7 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct struct nvme_passthru_cmd cmd; nvme_print_flags_t flags; void *data = NULL; - __u32 result = 0; + __u64 result = 0; int err = -1; __u16 mos; @@ -497,15 +496,17 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct nvme_init_lm_migration_recv(&cmd, cfg.offset, mos, cfg.cntlid, cfg.csuuidi, cfg.sel, cfg.uidx, 0, data, (cfg.numd + 1) << 2); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) nvme_show_error("ERROR: nvme_lm_migration_recv() failed %s", strerror(errno)); else if (err) nvme_show_status(err); else if (cfg.sel == NVME_LM_SEL_GET_CONTROLLER_STATE) { if (flags == NORMAL) - printf("CDW0: 0x%x: Controller %sSuspended\n", result, - (result & NVME_LM_GET_CONTROLLER_STATE_CSUP) ? "" : "NOT "); + printf("CDW0: 0x%"PRIu64": Controller %sSuspended\n", + (uint64_t)cmd.result, + (result & NVME_LM_GET_CONTROLLER_STATE_CSUP) ? + "" : "NOT "); if (cfg.output && strlen(cfg.output)) { if (fwrite(data, 1, cfg.numd << 2, fd) != (cfg.numd << 2)) { diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index 70de8bbf53..57c6d5bd1d 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -476,7 +476,7 @@ static int mb_get_powermanager_status(int argc, char **argv, struct command *acm struct plugin *plugin) { const char *desc = "Get Memblaze power management ststus\n (value 0 - 25w, 1 - 20w, 2 - 15w)"; - __u32 result; + __u64 result; __u32 feature_id = MB_FEAT_POWER_MGMT; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -494,8 +494,9 @@ static int mb_get_powermanager_status(int argc, char **argv, struct command *acm if (err < 0) perror("get-feature"); if (!err) - printf("get-feature:0x%02x (%s), %s value: %#08x\n", feature_id, - mb_feature_to_string(feature_id), nvme_select_to_string(0), result); + printf("get-feature:0x%02x (%s), %s value: %#016" PRIx64 "\n", + feature_id, mb_feature_to_string(feature_id), + nvme_select_to_string(0), (uint64_t)result); else if (err > 0) nvme_show_status(err); return err; @@ -509,7 +510,7 @@ static int mb_set_powermanager_status(int argc, char **argv, struct command *acm const char *save = "specifies that the controller shall save the attribute"; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -562,7 +563,7 @@ static int mb_set_high_latency_log(int argc, char **argv, struct command *acmd, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -744,7 +745,7 @@ static int memblaze_fw_commit(struct nvme_transport_handle *hdl, int select) .cdw12 = select, }; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } static int mb_selective_download(int argc, char **argv, struct command *acmd, struct plugin *plugin) @@ -850,7 +851,7 @@ static int mb_selective_download(int argc, char **argv, struct command *acmd, st perror("fw-download"); goto out_free; } - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { perror("fw-download"); goto out_free; @@ -1012,7 +1013,7 @@ static int memblaze_clear_error_log(int argc, char **argv, struct command *acmd, int err; - __u32 result; + __u64 result; struct config { __u32 feature_id; @@ -1065,7 +1066,7 @@ static int mb_set_lat_stats(int argc, char **argv, struct command *acmd, struct _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; void *buf = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -1104,8 +1105,8 @@ static int mb_set_lat_stats(int argc, char **argv, struct command *acmd, struct err = nvme_get_features(hdl, nsid, fid, sel, cdw11, 0, buf, data_len, &result); if (!err) { - printf("Latency Statistics Tracking (FID 0x%X) is currently (%i).\n", fid, - result); + printf("Latency Statistics Tracking (FID 0x%X) is currently (%"PRIu64").\n", + fid, (uint64_t)result); } else { printf("Could not read feature id 0xE2.\n"); return err; @@ -1739,7 +1740,7 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s // Set feature - uint32_t result = 0; + __u64 result = 0; err = nvme_set_features(hdl, 0, FID_LATENCY_FEATURE, 0, 0 | cfg.perf_monitor, 0 | cfg.cmd_mask, @@ -1748,7 +1749,8 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s ((cfg.de_allocate_trim_threshold & 0xff) << 16), 0, 0, NULL, 0, &result); if (!err) - printf("%s have done successfully. result = %#" PRIx32 ".\n", acmd->name, result); + printf("%s have done successfully. result = %#" PRIx64 ".\n", + acmd->name, (uint64_t)result); else if (err > 0) nvme_show_status(err); else @@ -1759,7 +1761,8 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s static int mb_get_latency_feature(int argc, char **argv, struct command *acmd, struct plugin *plugin) { - int err = 0; + __u64 res = 0; + int err; // Get the configuration @@ -1775,11 +1778,10 @@ static int mb_get_latency_feature(int argc, char **argv, struct command *acmd, s // Get feature - uint32_t result = 0; - err = nvme_get_features_simple(hdl, FID_LATENCY_FEATURE, - NVME_GET_FEATURES_SEL_CURRENT, &result); + NVME_GET_FEATURES_SEL_CURRENT, &res); if (!err) { + uint32_t result = res; printf("%s have done successfully. result = %#" PRIx32 ".\n", acmd->name, result); printf("latency statistics enable status = %d\n", (result & (0x01 << 0)) >> 0); diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index 1bb100dd7f..08d1e98257 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -468,7 +468,7 @@ static int NVMEGetLogPage(struct nvme_transport_handle *hdl, unsigned char ucLog cmd.addr = (__u64) (uintptr_t) pTempPtr; cmd.nsid = 0xFFFFFFFF; cmd.data_len = uiXferDwords * 4; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); ullBytesRead += uiXferDwords * 4; if (ucLogID == 0x07 || ucLogID == 0x08 || ucLogID == 0xE9) pTempPtr = pBuffer + (ullBytesRead - offset); @@ -556,7 +556,8 @@ static int micron_fw_commit(struct nvme_transport_handle *hdl, int select) .cdw10 = 8, .cdw12 = select, }; - return ioctl(nvme_transport_handle_get_fd(hdl), NVME_IOCTL_ADMIN_CMD, &cmd); + + return nvme_submit_admin_passthru(hdl, &cmd); } static int micron_selective_download(int argc, char **argv, @@ -659,7 +660,7 @@ static int micron_selective_download(int argc, char **argv, perror("fw-download"); goto out_free; } - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { perror("fw-download"); goto out_free; @@ -690,7 +691,7 @@ static int micron_selective_download(int argc, char **argv, static int micron_smbus_option(int argc, char **argv, struct command *command, struct plugin *plugin) { - __u32 result = 0; + __u64 result = 0; __u32 cdw11 = 0; const char *desc = "Enable/Disable/Get status of SMBUS option on controller"; const char *option = "enable or disable or status"; @@ -958,7 +959,7 @@ static int micron_pcie_stats(int argc, char **argv, admin_cmd.addr = (__u64)(uintptr_t)&pcie_error_counters; admin_cmd.data_len = sizeof(pcie_error_counters); admin_cmd.cdw10 = 1; - err = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!err) { counters = true; correctable_errors = 10; @@ -1100,7 +1101,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, FILE *fp; char *res; const char *desc = "Clear PCIe Device Correctable Errors"; - __u32 result = 0; + __u64 result = 0; __u8 fid = MICRON_FEATURE_CLEAR_PCI_CORRECTABLE_ERRORS; OPT_ARGS(opts) = { @@ -1128,7 +1129,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, admin_cmd.opcode = 0xD6; admin_cmd.addr = 0; admin_cmd.cdw10 = 0; - err = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!err) { printf("Device correctable error counters are cleared!\n"); goto out; @@ -2397,7 +2398,7 @@ static int GetFeatureSettings(struct nvme_transport_handle *hdl, const char *dir { unsigned char *bufp, buf[4096] = { 0 }; int i, err, len, errcnt = 0; - __u32 attrVal = 0; + __u64 attrVal = 0; char msg[256] = { 0 }; struct features { @@ -2501,7 +2502,7 @@ static int micron_drive_info(int argc, char **argv, struct command *acmd, admin_cmd.addr = (__u64) (uintptr_t) &dinfo; admin_cmd.data_len = (__u32)sizeof(dinfo); admin_cmd.cdw12 = 3; - err = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &admin_cmd); if (err) { fprintf(stderr, "ERROR : drive-info opcode failed with 0x%x\n", err); return -1; @@ -2874,7 +2875,7 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *acm struct plugin *plugin) { int err = 0; - __u32 result = 0; + __u64 result = 0; const char *desc = "Enable, Disable or Get cmd latency monitoring stats"; const char *option = "enable or disable or status, default is status"; const char *cmdstr = @@ -3233,7 +3234,7 @@ static int micron_clr_fw_activation_history(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Clear FW activation history"; - __u32 result = 0; + __u64 result = 0; __u8 fid = MICRON_FEATURE_CLEAR_FW_ACTIVATION_HISTORY; enum eDriveModel model = UNKNOWN_MODEL; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; @@ -3267,7 +3268,7 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, struct command *command, struct plugin *plugin) { int err = 0; - __u32 result = 0; + __u64 result = 0; const char *desc = "Enable or Disable Controller telemetry log generation"; const char *option = "enable or disable or status"; const char *select = @@ -3367,7 +3368,7 @@ int nvme_get_log_lpo(struct nvme_transport_handle *hdl, __u8 log_id, __u32 lpo, nvme_init_get_log(&cmd, NVME_NSID_ALL, log_id, NVME_CSI_NVM, ptr, xfer_len); nvme_init_get_log_lpo(&cmd, lpo); - ret = nvme_get_log(hdl, &cmd, false, xfer_len, NULL); + ret = nvme_get_log(hdl, &cmd, false, xfer_len); if (ret) return ret; offset += xfer_len; @@ -3480,7 +3481,7 @@ static int GetOcpEnhancedTelemetryLog(struct nvme_transport_handle *hdl, const c /* Enable ETDAS */ unsigned int uiBufferSize = 512; unsigned char pBuffer[512] = { 0 }; - __u32 result = 0; + __u64 result = 0; pBuffer[1] = 1; diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index 8d64c9668c..05ee21cd57 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -745,7 +745,7 @@ static int nvme_get_ontap_c2_log(struct nvme_transport_handle *hdl, __u32 nsid, get_log.cdw10 |= ONTAP_C2_LOG_NSINFO_LSP << 8; get_log.cdw11 = numdu; - err = nvme_submit_admin_passthru(hdl, &get_log, NULL); + err = nvme_submit_admin_passthru(hdl, &get_log); if (err) { fprintf(stderr, "ioctl error %0x\n", err); return 1; diff --git a/plugins/ocp/ocp-clear-features.c b/plugins/ocp/ocp-clear-features.c index bccbc8809d..2b5b8cb046 100644 --- a/plugins/ocp/ocp-clear-features.c +++ b/plugins/ocp/ocp-clear-features.c @@ -16,7 +16,7 @@ static int ocp_clear_feature(int argc, char **argv, const char *desc, const __u8 { _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result = 0; + __u64 result = 0; __u32 clear = 1 << 31; __u8 uuid_index = 0; bool uuid = true; @@ -67,7 +67,7 @@ int get_ocp_error_counters(int argc, char **argv, struct command *acmd, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; bool uuid; __u8 uuid_index = 0; @@ -107,8 +107,8 @@ int get_ocp_error_counters(int argc, char **argv, struct command *acmd, err = nvme_get_features(hdl, cfg.nsid, OCP_FID_CPCIE, cfg.sel, 0, uuid_index, NULL, 0, &result); if (!err) { - printf("get-feature:0xC3 %s value: %#08x\n", - nvme_select_to_string(cfg.sel), result); + printf("get-feature:0xC3 %s value: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(0xC3, result); diff --git a/plugins/ocp/ocp-fw-activation-history.c b/plugins/ocp/ocp-fw-activation-history.c index 02c45bc539..efe64528b9 100644 --- a/plugins/ocp/ocp-fw-activation-history.c +++ b/plugins/ocp/ocp-fw-activation-history.c @@ -58,8 +58,7 @@ int ocp_fw_activation_history_log(int argc, char **argv, struct command *acmd, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) nvme_show_status(err); diff --git a/plugins/ocp/ocp-hardware-component-log.c b/plugins/ocp/ocp-hardware-component-log.c index 6a50839b63..8339a11d84 100644 --- a/plugins/ocp/ocp-hardware-component-log.c +++ b/plugins/ocp/ocp-hardware-component-log.c @@ -188,8 +188,7 @@ static int get_hwcomp_log_data(struct nvme_transport_handle *hdl, struct hwcomp_ cmd.cdw14 |= NVME_FIELD_ENCODE(uidx, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { print_info_error("error: ocp: failed to get hwcomp log size (ret: %d)\n", ret); return ret; @@ -229,8 +228,7 @@ static int get_hwcomp_log_data(struct nvme_transport_handle *hdl, struct hwcomp_ (enum nvme_cmd_get_log_lid)OCP_LID_HWCOMP, NVME_CSI_NVM, log->desc, len); nvme_init_get_log_lpo(&cmd, desc_offset); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { print_info_error("error: ocp: failed to get log page (hwcomp: %02X, ret: %d)\n", OCP_LID_HWCOMP, ret); diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index 6624766623..d7efc2cdb0 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -298,7 +298,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, int err = -1; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; struct feature_latency_monitor buf = { 0 }; __u32 nsid = NVME_NSID_ALL; struct stat nvme_stat; @@ -422,7 +422,7 @@ static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; bool uuid; __u8 uuid_index = 0; @@ -462,8 +462,8 @@ static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command err = nvme_get_features(hdl, cfg.nsid, OCP_FID_LM, cfg.sel, 0, uuid_index, NULL, 0, &result); if (!err) { - printf("get-feature:0xC5 %s value: %#08x\n", - nvme_select_to_string(cfg.sel), result); + printf("get-feature:0xC5 %s value: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(0xC5, result); @@ -500,7 +500,7 @@ static int eol_plp_failure_mode_get(struct nvme_transport_handle *hdl, const __u __u8 sel, bool uuid) { __u8 uidx = 0; - __u32 result; + __u64 result; int err; if (uuid) { @@ -531,7 +531,7 @@ static int eol_plp_failure_mode_set(struct nvme_transport_handle *hdl, const __u const __u8 fid, __u8 mode, bool sv, bool uuid) { - __u32 result; + __u64 result; int err; __u8 uidx = 0; @@ -689,7 +689,7 @@ static int get_telemetry_data(struct nvme_transport_handle *hdl, __u32 ns, __u8 cmd.cdw12 = (__u32)(0x00000000FFFFFFFF & offset); cmd.cdw13 = (__u32)((0xFFFFFFFF00000000 & offset) >> 8); cmd.cdw14 = 0; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } static void print_telemetry_data_area_1(struct telemetry_data_area_1 *da1, @@ -838,7 +838,7 @@ static int extract_dump_get_log(struct nvme_transport_handle *hdl, char *feature nvme_init_get_log(&cmd, nsid, log_id, NVME_CSI_NVM, data, transfersize); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); if (err) { if (i > 0) goto close_output; @@ -1218,7 +1218,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl, cmd.cdw10 |= NVME_FIELD_ENCODE(NVME_LOG_TELEM_HOST_LSP_CREATE, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err < 0) nvme_show_error("Failed to fetch the log from drive.\n"); else if (err > 0) { @@ -1255,7 +1255,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl, nvme_init_get_log(&cmd, NVME_NSID_ALL, log_id, NVME_CSI_NVM, telemetry_log, bs); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err < 0) { nvme_show_error("Failed to fetch the log from drive.\n"); break; @@ -1938,7 +1938,7 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *ac static int ocp_set_telemetry_profile(struct nvme_transport_handle *hdl, __u8 tps) { - __u32 result; + __u64 result; int err; __u8 uidx = 0; @@ -2013,7 +2013,7 @@ static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct comma _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; bool uuid; __u8 uuid_index = 0; @@ -2053,8 +2053,8 @@ static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct comma err = nvme_get_features(hdl, cfg.nsid, OCP_FID_TEL_CFG, cfg.sel, 0, uuid_index, NULL, 0, &result); if (!err) { - printf("get-feature:0xC8 %s value: %#08x\n", - nvme_select_to_string(cfg.sel), result); + printf("get-feature:0xC8 %s value: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(0xC8, result); @@ -2077,7 +2077,7 @@ set_dssd_power_state(struct nvme_transport_handle *hdl, const __u8 fid, __u8 power_state, bool sv, bool uuid) { - __u32 result; + __u64 result; int err; __u8 uidx = 0; @@ -2154,7 +2154,7 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *a static int get_dssd_power_state(struct nvme_transport_handle *hdl, const __u32 nsid, const __u8 fid, __u8 sel, bool uuid) { - __u32 result; + __u64 result; int err; __u8 uuid_index = 0; @@ -2169,7 +2169,8 @@ static int get_dssd_power_state(struct nvme_transport_handle *hdl, const __u32 n err = nvme_get_features(hdl, nsid, fid, sel, 0, uuid_index, NULL, 0, &result); if (!err) { - printf("get-feature:0xC7 %s value: %#08x\n", nvme_select_to_string(sel), result); + printf("get-feature:0xC7 %s value: %#016"PRIx64"\n", + nvme_select_to_string(sel), (uint64_t)result); if (sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(fid, result); @@ -2246,7 +2247,7 @@ static int set_plp_health_check_interval(int argc, char **argv, struct command * _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int err; - __u32 result; + __u64 result; __u8 uidx = 0; struct config { @@ -2305,7 +2306,7 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command * const __u8 fid = 0xc6; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -2328,7 +2329,8 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command * err = nvme_get_features(hdl, nsid, OCP_FID_PLPI, cfg.sel, 0, 0, NULL, 0, &result); if (!err) { - printf("get-feature:0xC6 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result); + printf("get-feature:0xC6 %s value: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(fid, result); @@ -2356,7 +2358,7 @@ static int set_dssd_async_event_config(int argc, char **argv, struct command *ac _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int err; - __u32 result; + __u64 result; __u8 uidx = 0; struct config { @@ -2411,7 +2413,7 @@ static int get_dssd_async_event_config(int argc, char **argv, struct command *ac const __u8 fid = OCP_FID_DAEC; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -2433,7 +2435,8 @@ static int get_dssd_async_event_config(int argc, char **argv, struct command *ac err = nvme_get_features(hdl, nsid, fid, cfg.sel, 0, 0, NULL, 0, &result); if (!err) { - printf("get-feature:0xC9 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result); + printf("get-feature:0xC9 %s value: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(fid, result); @@ -2672,7 +2675,7 @@ static int error_injection_get(struct nvme_transport_handle *hdl, const __u8 sel _cleanup_free_ struct erri_entry *entry = NULL; struct erri_get_cq_entry cq_entry; const __u8 fid = OCP_FID_ERRI; - __u32 *result = (__u32 *)&cq_entry; + __u64 result; __u32 data_len = 0; __u8 uidx = 0; int err; @@ -2696,13 +2699,14 @@ static int error_injection_get(struct nvme_transport_handle *hdl, const __u8 sel } err = nvme_get_features(hdl, 0, fid, sel, 0, uidx, entry, - data_len, result); + data_len, &result); if (!err) { + cq_entry.nume = result; nvme_show_result("Number of Error Injections (feature: %#0*x): %#0*x (%s: %d)", fid ? 4 : 2, fid, cq_entry.nume ? 10 : 8, cq_entry.nume, nvme_select_to_string(sel), cq_entry.nume); if (sel == NVME_GET_FEATURES_SEL_SUPPORTED) - nvme_show_select_result(fid, *result); + nvme_show_select_result(fid, result); for (i = 0; i < cq_entry.nume; i++) { printf("Entry: %d, Flags: %x (%s%s), Type: %x (%s), NRTDP: %d\n", i, entry[i].flags, entry[i].enable ? "Enabled" : "Disabled", @@ -2850,7 +2854,7 @@ static int enable_ieee1667_silo_get(struct nvme_transport_handle *hdl, const __u { struct ieee1667_get_cq_entry cq_entry = { 0 }; const __u8 fid = OCP_FID_1667; - __u32 result; + __u64 result; __u8 uidx = 0; int err; @@ -2912,6 +2916,7 @@ static int enable_ieee1667_silo_set(struct nvme_transport_handle *hdl, bool save = argconfig_parse_seen(opts, "save"); struct ieee1667_get_cq_entry cq_entry; const __u8 fid = OCP_FID_1667; + __u64 result; __u32 cdw11; __u8 uidx = 0; int err; @@ -2927,7 +2932,8 @@ static int enable_ieee1667_silo_set(struct nvme_transport_handle *hdl, cdw11 = OCP_SET(enable, ENABLE_IEEE1667_SILO); err = nvme_set_features(hdl, NVME_NSID_NONE, fid, save, - cdw11, 0, 0, uidx, 0, NULL, 0, (__u32 *)&cq_entry); + cdw11, 0, 0, uidx, 0, NULL, 0, &result); + memcpy(&cq_entry, &result, sizeof(cq_entry)); if (err > 0) { nvme_show_status(err); } else if (err < 0) { diff --git a/plugins/ocp/ocp-smart-extended-log.c b/plugins/ocp/ocp-smart-extended-log.c index d2341356f4..3eef14a9a7 100644 --- a/plugins/ocp/ocp-smart-extended-log.c +++ b/plugins/ocp/ocp-smart-extended-log.c @@ -56,8 +56,7 @@ static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format, cmd.cdw14 |= NVME_FIELD_ENCODE(uidx, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (strcmp(format, "json")) fprintf(stderr, "NVMe Status:%s(%x)\n", diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c index 665c0c2163..a8c09992bc 100644 --- a/plugins/ocp/ocp-utils.c +++ b/plugins/ocp/ocp-utils.c @@ -56,5 +56,5 @@ int ocp_get_log_simple(struct nvme_transport_handle *hdl, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); } diff --git a/plugins/sandisk/sandisk-nvme.c b/plugins/sandisk/sandisk-nvme.c index 022df96562..eba5db105e 100644 --- a/plugins/sandisk/sandisk-nvme.c +++ b/plugins/sandisk/sandisk-nvme.c @@ -186,7 +186,7 @@ static __u32 sndk_dump_udui_data(struct nvme_transport_handle *hdl, admin_cmd.data_len = dataLen; admin_cmd.cdw10 = ((dataLen >> 2) - 1); admin_cmd.cdw12 = offset; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: SNDK: reading DUI data failed\n"); nvme_show_status(ret); @@ -497,11 +497,11 @@ static int sndk_clear_assert_dump(int argc, char **argv, static int sndk_do_sn861_drive_resize(struct nvme_transport_handle *hdl, uint64_t new_size, - __u32 *result) + __u64 *result) { - int ret; - struct nvme_passthru_cmd admin_cmd; uint8_t buffer[SNDK_NVME_SN861_DRIVE_RESIZE_BUFFER_SIZE] = {0}; + struct nvme_passthru_cmd admin_cmd; + int ret; memset(&admin_cmd, 0, sizeof(struct nvme_passthru_cmd)); admin_cmd.opcode = SNDK_NVME_SN861_DRIVE_RESIZE_OPCODE; @@ -513,7 +513,9 @@ static int sndk_do_sn861_drive_resize(struct nvme_transport_handle *hdl, admin_cmd.addr = (__u64)(uintptr_t)buffer; admin_cmd.data_len = SNDK_NVME_SN861_DRIVE_RESIZE_BUFFER_SIZE; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, result); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + if (result) + *result = admin_cmd.result; return ret; } @@ -528,7 +530,7 @@ static int sndk_drive_resize(int argc, char **argv, uint64_t capabilities = 0; int ret; uint32_t device_id = -1, vendor_id = -1; - __u32 result; + __u64 result; struct config { uint64_t size; @@ -561,8 +563,8 @@ static int sndk_drive_resize(int argc, char **argv, fprintf(stderr, "The drive-resize command was successful. A system "); fprintf(stderr, "shutdown is required to complete the operation.\n"); } else - fprintf(stderr, "ERROR: SNDK: %s failure, ret: %d, result: 0x%x\n", - __func__, ret, result); + fprintf(stderr, "ERROR: SNDK: %s failure, ret: %d, result: 0x%"PRIx64"\n", + __func__, ret, (uint64_t)result); } else { /* Fallback to WDC plugin command if otherwise not supported */ return run_wdc_drive_resize(argc, argv, command, plugin); @@ -920,7 +922,7 @@ static int sndk_vs_fw_activate_history(int argc, char **argv, static int sndk_do_clear_fw_activate_history_fid(struct nvme_transport_handle *hdl) { int ret = -1; - __u32 result; + __u64 result; __u32 value = 1 << 31; /* Bit 31 - Clear Firmware Update History Log */ ret = nvme_set_features_simple(hdl, SNDK_NVME_CLEAR_FW_ACT_HIST_VU_FID, 0, value, diff --git a/plugins/sandisk/sandisk-utils.c b/plugins/sandisk/sandisk-utils.c index 4029f7898b..2d3a766b4a 100644 --- a/plugins/sandisk/sandisk-utils.c +++ b/plugins/sandisk/sandisk-utils.c @@ -452,7 +452,7 @@ bool sndk_get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: SNDK: Unable to get 0x%x Log Page with uuid %d, ret = 0x%x\n", @@ -479,7 +479,7 @@ bool sndk_get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: SNDK: Unable to read 0x%x Log with uuid %d, ret = 0x%x\n", @@ -860,7 +860,7 @@ int sndk_UtilsSnprintf(char *buffer, unsigned int sizeOfBuffer, int sndk_check_ctrl_telemetry_option_disabled(struct nvme_transport_handle *hdl) { int err; - __u32 result; + __u64 result; err = nvme_get_features(hdl, 0, SNDK_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 1d2f768b91..23783a5c60 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -57,7 +57,7 @@ int nvme_query_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u32 data_len }; rc = ioctl(nvme_transport_handle_get_fd(hdl), SFX_GET_FREESPACE, data); - return rc ? nvme_submit_admin_passthru(hdl, &cmd, NULL) : 0; + return rc ? nvme_submit_admin_passthru(hdl, &cmd) : 0; } int nvme_change_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u64 capacity) @@ -69,7 +69,7 @@ int nvme_change_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u64 capacit .cdw11 = (capacity >> 32), }; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } int nvme_sfx_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 fid, __u32 value) @@ -81,7 +81,7 @@ int nvme_sfx_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 f .cdw11 = value, }; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } int nvme_sfx_get_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 fid, __u32 *result) @@ -93,7 +93,7 @@ int nvme_sfx_get_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 f .cdw10 = fid, }; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err && result) *result = cmd.result; @@ -560,7 +560,7 @@ int sfx_nvme_get_log(struct nvme_transport_handle *hdl, __u32 nsid, __u8 log_id, cmd.cdw10 = log_id | (numdl << 16); cmd.cdw11 = numdu; - return nvme_submit_admin_passthru(hdl, &cmd, NULL); + return nvme_submit_admin_passthru(hdl, &cmd); } /** @@ -1244,7 +1244,7 @@ static int nvme_dump_evtlog(struct nvme_transport_handle *hdl, __u32 namespace_i cmd.cdw10 |= NVME_FIELD_ENCODE(lsp, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) { fprintf(stderr, "Unable to get evtlog lsp=0x%x, ret = 0x%x\n", lsp, err); @@ -1257,7 +1257,7 @@ static int nvme_dump_evtlog(struct nvme_transport_handle *hdl, __u32 namespace_i cmd.cdw10 |= NVME_FIELD_ENCODE(lsp, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) { fprintf(stderr, "Unable to get evtlog lsp=0x%x, ret = 0x%x\n", lsp, err); @@ -1299,8 +1299,7 @@ static int nvme_dump_evtlog(struct nvme_transport_handle *hdl, __u32 namespace_i NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); nvme_init_get_log_lpo(&cmd, lpo); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) { fprintf(stderr, "Unable to get evtlog offset=0x%x len 0x%x ret = 0x%x\n", @@ -1461,7 +1460,7 @@ static int nvme_expand_cap(struct nvme_transport_handle *hdl, __u32 namespace_id .cdw10 = 0x0e, }; - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (err) { fprintf(stderr, "Create ns failed\n"); nvme_show_status(err); @@ -1555,7 +1554,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin struct nvme_smart_log smart_log = { 0 }; struct nvme_additional_smart_log additional_smart_log = { 0 }; struct sfx_freespace_ctx sfx_freespace = { 0 }; - unsigned int get_feat_result, pcie_correctable, pcie_fatal, pcie_nonfatal; + unsigned int pcie_correctable, pcie_fatal, pcie_nonfatal; unsigned long long capacity; bool capacity_valid = false; int err, fd, len, sector_size; @@ -1563,6 +1562,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin char path[512], numa_node[5], vendor[10], form_factor[15], temperature[10], io_speed[15]; char chr_dev[8], serial_number[21], model_number[41], firmware_revision[9], pcie_status[9]; struct json_object *root, *dev_stats, *link_stats, *crit_stats; + __u64 get_feat_result; double write_amp; struct config { diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index d1d48cbea1..44956c5d09 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -1455,7 +1455,7 @@ static int clear_fw_activate_history(int argc, char **argv, struct command *acmd _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; struct nvme_id_ctrl ctrl; char modelNo[40]; - __u32 result; + __u64 result; struct config { bool save; @@ -1514,7 +1514,7 @@ static int vs_clr_pcie_correctable_errs(int argc, char **argv, struct command *a _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -1654,8 +1654,7 @@ static int get_host_tele(int argc, char **argv, struct command *acmd, struct plu nvme_init_get_log(&cmd, cfg.namespace_id, cfg.log_id, NVME_CSI_NVM, log, bytesToGet); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, true, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!err) { offset += (__le64)bytesToGet; @@ -1761,8 +1760,7 @@ static int get_ctrl_tele(int argc, char **argv, struct command *acmd, struct plu nvme_init_get_log(&cmd, cfg.namespace_id, log_id, NVME_CSI_NVM, log, bytesToGet); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, true, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!err) { offset += (__le64)bytesToGet; @@ -1881,8 +1879,7 @@ static int vs_internal_log(int argc, char **argv, struct command *acmd, struct p nvme_init_get_log(&cmd, cfg.namespace_id, log_id, NVME_CSI_NVM, log, bytesToGet); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, true, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (!err) { offset += (__le64)bytesToGet; diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 1a44f32743..3c43602778 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -180,7 +180,7 @@ static int get_additional_feature(int argc, char **argv, struct command *acmd, s _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; void *buf = NULL; - __u32 result; + __u64 result; int err; struct config { @@ -261,7 +261,7 @@ static int set_additional_feature(int argc, char **argv, struct command *acmd, s _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; _cleanup_free_ void *buf = NULL; int ffd = STDIN_FILENO; - __u32 result; + __u64 result; int err; struct config { diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 3e91205162..3146823175 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -108,8 +108,7 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *a cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (!err) { if (flags & BINARY) d_raw((unsigned char *)&gc_log, sizeof(gc_log)); diff --git a/plugins/solidigm/solidigm-internal-logs.c b/plugins/solidigm/solidigm-internal-logs.c index 105f1b9e5c..49700353ab 100644 --- a/plugins/solidigm/solidigm-internal-logs.c +++ b/plugins/solidigm/solidigm-internal-logs.c @@ -182,7 +182,7 @@ static int cmd_dump_repeat(struct nvme_passthru_cmd *cmd, __u32 total_dw_size, cmd->cdw10 = force_max_transfer ? INTERNAL_LOG_MAX_DWORD_TRANSFER : dword_tfer; cmd->data_len = dword_tfer * 4; - err = nvme_submit_admin_passthru(hdl, cmd, NULL); + err = nvme_submit_admin_passthru(hdl, cmd); if (err) return err; @@ -572,16 +572,15 @@ static int ilog_dump_telemetry(struct nvme_transport_handle *hdl, struct ilog *i mdts = ilog->id_ctrl.mdts; if (da == 4) { - __u32 result; nvme_init_get_features_host_behavior(&cmd, 0, &prev); - int err = nvme_submit_admin_passthru(hdl, &cmd, &result); + int err = nvme_submit_admin_passthru(hdl, &cmd); if (!err && !prev.etdas) { struct nvme_feat_host_behavior da4_enable = prev; da4_enable.etdas = 1; nvme_init_set_features_host_behavior(&cmd, 0, &da4_enable); - nvme_submit_admin_passthru(hdl, &cmd, NULL); + nvme_submit_admin_passthru(hdl, &cmd); host_behavior_changed = true; } } @@ -609,7 +608,7 @@ static int ilog_dump_telemetry(struct nvme_transport_handle *hdl, struct ilog *i if (host_behavior_changed) { nvme_init_set_features_host_behavior(&cmd, 0, &prev); - nvme_submit_admin_passthru(hdl, &cmd, NULL); + nvme_submit_admin_passthru(hdl, &cmd); } if (err) diff --git a/plugins/solidigm/solidigm-latency-tracking.c b/plugins/solidigm/solidigm-latency-tracking.c index e51db52f66..f6142ea9e1 100644 --- a/plugins/solidigm/solidigm-latency-tracking.c +++ b/plugins/solidigm/solidigm-latency-tracking.c @@ -269,7 +269,7 @@ static void latency_tracker_parse(struct latency_tracker *lt) #define LATENCY_TRACKING_FID 0xe2 #define LATENCY_TRACKING_FID_DATA_LEN 32 -static int latency_tracking_is_enable(struct latency_tracker *lt, __u32 *enabled) +static int latency_tracking_is_enable(struct latency_tracker *lt, __u64 *enabled) { return nvme_get_features(lt->hdl, 0, LATENCY_TRACKING_FID, 0, 0, lt->uuid_index, NULL, @@ -278,7 +278,7 @@ static int latency_tracking_is_enable(struct latency_tracker *lt, __u32 *enabled static int latency_tracking_enable(struct latency_tracker *lt) { - __u32 result; + __u64 result; int err; if (!(lt->cfg.enable || lt->cfg.disable)) @@ -331,8 +331,7 @@ static int latency_tracker_get_log(struct latency_tracker *lt) cmd.cdw14 |= NVME_FIELD_ENCODE(lt->uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(lt->hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(lt->hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) return err; @@ -351,7 +350,7 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *acm const char *desc = "Get and Parse Solidigm Latency Tracking Statistics log."; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 enabled; + __u64 enabled; int err; struct latency_tracker lt = { @@ -421,8 +420,9 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *acm } else if (lt.print_flags == BINARY) { putchar(enabled); } else { - printf("Latency Statistics Tracking (UUID-idx:%d, FID:0x%X) is currently %i.\n", - lt.uuid_index, LATENCY_TRACKING_FID, enabled); + printf("Latency Statistics Tracking (UUID-idx:%d, FID:0x%X) is currently %"PRIu64".\n", + lt.uuid_index, LATENCY_TRACKING_FID, + (uint64_t)enabled); } } else { fprintf(stderr, "Could not read feature id 0xE2.\n"); diff --git a/plugins/solidigm/solidigm-log-page-dir.c b/plugins/solidigm/solidigm-log-page-dir.c index 7590956300..bffd7361fb 100644 --- a/plugins/solidigm/solidigm-log-page-dir.c +++ b/plugins/solidigm/solidigm-log-page-dir.c @@ -52,8 +52,7 @@ static int get_supported_log_pages_log(struct nvme_transport_handle *hdl, int uu cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - return nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); } static struct lid_dir *get_standard_lids(struct nvme_supported_log_pages *supported) diff --git a/plugins/solidigm/solidigm-market-log.c b/plugins/solidigm/solidigm-market-log.c index 38e29acdc2..37173cf4b9 100644 --- a/plugins/solidigm/solidigm-market-log.c +++ b/plugins/solidigm/solidigm-market-log.c @@ -54,8 +54,7 @@ int sldgm_get_market_log(int argc, char **argv, struct command *acmd, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_idx, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err) { nvme_show_status(err); return err; diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index 3edcbbaa27..4b327d9a6e 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -270,8 +270,7 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *acm cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (!err) { if (flags & JSON) vu_smart_log_show_json(&smart_log_payload, diff --git a/plugins/solidigm/solidigm-temp-stats.c b/plugins/solidigm/solidigm-temp-stats.c index d9d4df1d27..dd22af2eaf 100644 --- a/plugins/solidigm/solidigm-temp-stats.c +++ b/plugins/solidigm/solidigm-temp-stats.c @@ -74,8 +74,7 @@ int sldgm_get_temp_stats_log(int argc, char **argv, struct command *acmd, struct cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_idx, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err > 0) { nvme_init_get_log(&cmd, NVME_NSID_ALL, SLDGM_LEGACY_TEMP_STATS_LID, NVME_CSI_NVM, @@ -83,8 +82,7 @@ int sldgm_get_temp_stats_log(int argc, char **argv, struct command *acmd, struct cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_idx, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (!err) { uint64_t *guid = (uint64_t *)&buffer[4080]; diff --git a/plugins/solidigm/solidigm-workload-tracker.c b/plugins/solidigm/solidigm-workload-tracker.c index 3d07f1ec9f..6f16b06974 100644 --- a/plugins/solidigm/solidigm-workload-tracker.c +++ b/plugins/solidigm/solidigm-workload-tracker.c @@ -294,7 +294,7 @@ static int wltracker_show_newer_entries(struct wltracker *wlt) cmd.cdw14 |= NVME_FIELD_ENCODE(wlt->uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - err = nvme_get_log(wlt->hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(wlt->hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (err > 0) { nvme_show_status(err); return err; diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index 6f427333d8..d4b783bbb8 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -51,23 +51,14 @@ enum { static int nvme_sct_op(struct nvme_transport_handle *hdl, __u32 opcode, __u32 cdw10, __u32 cdw11, void *data, __u32 data_len) { - void *metadata = NULL; - const __u32 cdw2 = 0; - const __u32 cdw3 = 0; - const __u32 cdw12 = 0; - const __u32 cdw13 = 0; - const __u32 cdw14 = 0; - const __u32 cdw15 = 0; - const __u32 timeout = 0; - const __u32 metadata_len = 0; - const __u32 namespace_id = 0x0; - const __u32 flags = 0; - const __u32 rsvd = 0; - __u32 result; - - return nvme_admin_passthru(hdl, opcode, flags, rsvd, namespace_id, cdw2, cdw3, cdw10, cdw11, - cdw12, cdw13, cdw14, cdw15, data_len, data, metadata_len, - metadata, timeout, &result); + struct nvme_passthru_cmd cmd = { + .opcode = opcode, + .cdw10 = cdw10, + .cdw11 = cdw11, + .data_len = data_len, + .addr = (__u64)(uintptr_t)data, + }; + return nvme_submit_admin_passthru(hdl, &cmd); } static int nvme_get_sct_status(struct nvme_transport_handle *hdl, __u32 device_mask) @@ -532,7 +523,7 @@ static int clear_correctable_errors(int argc, char **argv, struct command *acmd, const __u32 value = 1; /* Bit0 - reset clear PCIe correctable count */ const __u32 cdw12 = 0; const bool save = false; - __u32 result; + __u64 result; int err; OPT_ARGS(opts) = { diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c index f80be2b659..bd088ed526 100644 --- a/plugins/transcend/transcend-nvme.c +++ b/plugins/transcend/transcend-nvme.c @@ -78,7 +78,7 @@ static int getBadblock(int argc, char **argv, struct command *acmd, struct plugi nvmecmd.addr = (__u64)(uintptr_t)data; nvmecmd.data_len = 0x1; - result = nvme_submit_admin_passthru(hdl, &nvmecmd, NULL); + result = nvme_submit_admin_passthru(hdl, &nvmecmd); if (!result) { int badblock = data[0]; diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index bee6bfdf49..53a23ec0e7 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -2569,7 +2569,7 @@ static bool get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, void * cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: WDC: Unable to get 0x%x Log Page with uuid %d, ret = 0x%x\n", @@ -2596,8 +2596,7 @@ static bool get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, void * cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: WDC: Unable to read 0x%x Log with uuid %d, ret = 0x%x\n", @@ -2654,7 +2653,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: WDC: Unable to get 0x%x Log Page length with uuid %d, ret = 0x%x\n", @@ -2680,8 +2679,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_ix, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (ret) { fprintf(stderr, "ERROR: WDC: Unable to read 0x%x Log Page data with uuid %d, ret = 0x%x\n", @@ -2860,7 +2858,7 @@ static int wdc_get_supported_log_pages(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL); + return nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); } static bool wdc_nvme_check_supported_log_page(struct nvme_global_ctx *ctx, @@ -2995,7 +2993,7 @@ static int wdc_do_clear_dump(struct nvme_transport_handle *hdl, __u8 opcode, __u memset(&admin_cmd, 0, sizeof(struct nvme_passthru_cmd)); admin_cmd.opcode = opcode; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) fprintf(stdout, "ERROR: WDC: Crash dump erase failed\n"); nvme_show_status(ret); @@ -3017,7 +3015,7 @@ static __u32 wdc_dump_length(struct nvme_transport_handle *link, __u32 opcode, _ admin_cmd.cdw10 = cdw10; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(link, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(link, &admin_cmd); if (ret) { l->log_size = 0; ret = -1; @@ -3045,7 +3043,7 @@ static __u32 wdc_dump_length_e6(struct nvme_transport_handle *hdl, __u32 opcode, admin_cmd.cdw10 = cdw10; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading dump length failed\n"); nvme_show_status(ret); @@ -3072,7 +3070,7 @@ static __u32 wdc_dump_dui_data(struct nvme_transport_handle *hdl, __u32 dataLen, admin_cmd.cdw14 = WDC_NVME_CAP_DUI_DISABLE_IO; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading DUI data failed\n"); nvme_show_status(ret); @@ -3103,7 +3101,7 @@ static __u32 wdc_dump_dui_data_v2(struct nvme_transport_handle *hdl, __u32 dataL else admin_cmd.cdw14 = WDC_NVME_CAP_DUI_DISABLE_IO; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading DUI data V2 failed\n"); nvme_show_status(ret); @@ -3141,8 +3139,7 @@ static int wdc_do_dump(struct nvme_transport_handle *hdl, __u32 opcode, __u32 da admin_cmd.cdw13 = curr_data_offset; while (curr_data_offset < data_len) { - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, - NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -3217,7 +3214,7 @@ static int wdc_do_dump_e6(struct nvme_transport_handle *hdl, __u32 opcode, __u32 admin_cmd.cdw10 = xfer_size >> 2; admin_cmd.cdw13 = curr_data_offset >> 2; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -3255,7 +3252,7 @@ static int wdc_do_cap_telemetry_log(struct nvme_global_ctx *ctx, int err = 0, output; __u32 host_gen = 1; int ctrl_init = 0; - __u32 result; + __u64 result; void *buf = NULL; __u8 *data_ptr = NULL; int data_written = 0, data_remaining = 0; @@ -3974,7 +3971,7 @@ static int wdc_do_get_sn730_log_len(struct nvme_transport_handle *hdl, uint32_t admin_cmd.cdw12 = subopcode; admin_cmd.cdw10 = SN730_LOG_CHUNK_SIZE / 4; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) *len_buf = *output; free(output); @@ -4000,7 +3997,7 @@ static int wdc_do_get_sn730_log(struct nvme_transport_handle *hdl, void *log_buf admin_cmd.cdw13 = offset; admin_cmd.cdw10 = SN730_LOG_CHUNK_SIZE / 4; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) memcpy(log_buf, output, SN730_LOG_CHUNK_SIZE); return ret; @@ -4222,7 +4219,7 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir cmd.cdw10 |= NVME_FIELD_ENCODE(NVME_LOG_TELEM_HOST_LSP_CREATE, NVME_LOG_CDW10_LSP_SHIFT, NVME_LOG_CDW10_LSP_MASK); - err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (err < 0) perror("get-telemetry-log"); else if (err > 0) { @@ -4243,7 +4240,7 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_TELEMETRY_HOST, NVME_CSI_NVM, telemetry_log, bs); nvme_init_get_log_lpo(&cmd, offset); - err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL); + err = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (err < 0) { perror("get-telemetry-log"); break; @@ -4664,7 +4661,7 @@ static int wdc_do_drive_log(struct nvme_transport_handle *hdl, const char *file) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_LOG_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_LOG_SIZE_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); if (!ret) ret = wdc_create_log_file(file, drive_log_data, drive_log_length); @@ -4884,8 +4881,7 @@ static int wdc_purge(int argc, char **argv, memset(&admin_cmd, 0, sizeof(admin_cmd)); admin_cmd.opcode = WDC_NVME_PURGE_CMD_OPCODE; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, - NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret > 0) { switch (ret) { case WDC_NVME_PURGE_CMD_SEQ_ERR: @@ -4943,11 +4939,11 @@ static int wdc_purge_monitor(int argc, char **argv, admin_cmd.cdw10 = WDC_NVME_PURGE_MONITOR_CMD_CDW10; admin_cmd.timeout_ms = WDC_NVME_PURGE_MONITOR_TIMEOUT; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, - NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) { mon = (struct wdc_nvme_purge_monitor_data *) output; - printf("Purge state = 0x%0x\n", admin_cmd.result); + printf("Purge state = 0x%0"PRIx64"\n", + (uint64_t)admin_cmd.result); printf("%s\n", wdc_purge_mon_status_to_string(admin_cmd.result)); if (admin_cmd.result == WDC_NVME_PURGE_STATE_BUSY) { progress_percent = @@ -6318,8 +6314,7 @@ static int nvme_get_print_ocp_cloud_smart_log(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (fmt == JSON) nvme_show_status(ret); @@ -6384,8 +6379,7 @@ static int nvme_get_print_c0_eol_log(struct nvme_transport_handle *hdl, cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (fmt == JSON) nvme_show_status(ret); @@ -6421,8 +6415,7 @@ static int nvme_get_ext_smart_cloud_log(struct nvme_transport_handle *hdl, __u8 cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (!ret) { /* Verify GUID matches */ for (i = 0; i < WDC_C0_GUID_LENGTH; i++) { @@ -6469,8 +6462,7 @@ static int nvme_get_hw_rev_log(struct nvme_transport_handle *hdl, __u8 **data, i cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); - ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE); if (!ret) { /* Verify GUID matches */ for (i = 0; i < WDC_NVME_C6_GUID_LENGTH; i++) { @@ -8498,7 +8490,7 @@ static int wdc_cu_smart_log(int argc, char **argv, struct command *acmd, NVME_LOG_CDW14_UUID_SHIFT, NVME_LOG_CDW14_UUID_MASK); ret = nvme_get_log(hdl, &cmd, false, - NVME_LOG_PAGE_PDU_SIZE, NULL); + NVME_LOG_PAGE_PDU_SIZE); if (strcmp(cfg.output_format, "json")) nvme_show_status(ret); @@ -8993,7 +8985,7 @@ static int wdc_do_clear_pcie_correctable_errors(struct nvme_transport_handle *hd admin_cmd.cdw12 = ((WDC_NVME_CLEAR_PCIE_CORR_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_PCIE_CORR_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; } @@ -9006,7 +8998,7 @@ static int wdc_do_clear_pcie_correctable_errors_vuc(struct nvme_transport_handle memset(&admin_cmd, 0, sizeof(admin_cmd)); admin_cmd.opcode = WDC_NVME_CLEAR_PCIE_CORR_OPCODE_VUC; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; } @@ -9014,7 +9006,7 @@ static int wdc_do_clear_pcie_correctable_errors_vuc(struct nvme_transport_handle static int wdc_do_clear_pcie_correctable_errors_fid(struct nvme_transport_handle *hdl) { int ret; - __u32 result; + __u64 result; __u32 value = 1 << 31; /* Bit 31 - clear PCIe correctable count */ ret = nvme_set_features_simple(hdl, 0, WDC_NVME_CLEAR_PCIE_CORR_FEATURE_ID, false, @@ -9260,8 +9252,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *acmd, admin_cmd.cdw12 = ((WDC_NVME_CLEAR_ASSERT_DUMP_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_ASSERT_DUMP_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, - NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); } else fprintf(stderr, "INFO: WDC: No Assert Dump Present\n"); @@ -9511,7 +9502,7 @@ static int wdc_do_clear_fw_activate_history_vuc(struct nvme_transport_handle *hd admin_cmd.cdw12 = ((WDC_NVME_CLEAR_FW_ACT_HIST_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_FW_ACT_HIST_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; @@ -9520,7 +9511,7 @@ static int wdc_do_clear_fw_activate_history_vuc(struct nvme_transport_handle *hd static int wdc_do_clear_fw_activate_history_fid(struct nvme_transport_handle *hdl) { int ret = -1; - __u32 result; + __u64 result; __u32 value = 1 << 31; /* Bit 31 - Clear Firmware Update History Log */ ret = nvme_set_features_simple(hdl, 0, WDC_NVME_CLEAR_FW_ACT_HIST_VU_FID, false, @@ -9578,7 +9569,7 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm __u64 capabilities = 0; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - __u32 result; + __u64 result; int ret = -1; @@ -9724,7 +9715,7 @@ static int wdc_de_VU_read_size(struct nvme_transport_handle *hdl, __u32 fileId, cmd.cdw13 = fileId << 16; cmd.cdw14 = spiDestn; - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret && logSize) *logSize = cmd.result; @@ -9761,7 +9752,7 @@ static int wdc_de_VU_read_buffer(struct nvme_transport_handle *hdl, __u32 fileId cmd.addr = (__u64)(__u64)(uintptr_t)dataBuffer; cmd.data_len = *bufferSize; - ret = nvme_submit_admin_passthru(hdl, &cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &cmd); if (ret != WDC_STATUS_SUCCESS) { fprintf(stderr, "ERROR: WDC: VUReadBuffer() failed, "); @@ -10160,7 +10151,7 @@ static int wdc_do_drive_essentials(struct nvme_global_ctx *ctx, struct nvme_tran __u32 dataBufferSize; __u32 listIdx = 0; __u32 vuLogIdx = 0; - __u32 result; + __u64 result; struct nvme_id_ctrl ctrl; struct nvme_id_ns ns; struct nvme_error_log_page *elogBuffer; @@ -10432,7 +10423,7 @@ static int wdc_do_drive_resize(struct nvme_transport_handle *hdl, uint64_t new_s WDC_NVME_DRIVE_RESIZE_CMD); admin_cmd.cdw13 = new_size; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -10446,7 +10437,7 @@ static int wdc_do_namespace_resize(struct nvme_transport_handle *hdl, __u32 nsid admin_cmd.nsid = nsid; admin_cmd.cdw10 = op_option; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -10460,7 +10451,7 @@ static int wdc_do_drive_info(struct nvme_transport_handle *hdl, __u32 *result) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_INFO_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_INFO_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret && result) *result = admin_cmd.result; @@ -10969,7 +10960,6 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, } else { struct log_page_directory *dir; void *data = NULL; - __u32 result; if (posix_memalign(&data, getpagesize(), 512)) { fprintf(stderr, @@ -10979,12 +10969,15 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, } dir = (struct log_page_directory *)data; - ret = nvme_admin_passthru(hdl, WDC_NVME_ADMIN_VUC_OPCODE_D2, 0, 0, - 0, 0, 0, 8, - 0, WDC_VUC_SUBOPCODE_LOG_PAGE_DIR_D2, 0, 0, 0, - 32, data, 0, NULL, - 0, &result); - + struct nvme_passthru_cmd cmd = { + .opcode = WDC_NVME_ADMIN_VUC_OPCODE_D2, + .cdw10 = 8, + .cdw12 = WDC_VUC_SUBOPCODE_LOG_PAGE_DIR_D2, + .addr = (__u64)(uintptr_t)data, + .data_len = 32, + }; + + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) { switch (fmt) { case BINARY: @@ -11665,7 +11658,7 @@ static int wdc_do_vs_pcie_stats(struct nvme_transport_handle *hdl, admin_cmd.addr = (__u64)(uintptr_t)pcieStatsPtr; admin_cmd.data_len = pcie_stats_size; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -11958,13 +11951,14 @@ static int wdc_vs_drive_info(int argc, char **argv, if (data_len % 4 != 0) num_dwords += 1; - ret = nvme_admin_passthru(hdl, - WDC_NVME_ADMIN_VUC_OPCODE_D2, - 0, 0, 0, 0, 0, num_dwords, 0, - WDC_VUC_SUBOPCODE_VS_DRIVE_INFO_D2, - 0, 0, 0, data_len, &info, 0, - NULL, 0, NULL); - + struct nvme_passthru_cmd cmd = { + .opcode = WDC_NVME_ADMIN_VUC_OPCODE_D2, + .cdw10 = num_dwords, + .cdw12 = WDC_VUC_SUBOPCODE_VS_DRIVE_INFO_D2, + .addr = (__u64)(uintptr_t)&info, + .data_len = data_len, + }; + ret = nvme_submit_admin_passthru(hdl, &cmd); if (!ret) { __u16 hw_rev_major, hw_rev_minor; @@ -12021,7 +12015,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, struct nvme_id_ctrl id_ctrl; nvme_print_flags_t fmt; uint64_t capabilities = 0; - __u32 hctm_tmt; + __u64 hctm_tmt; int temperature, temp_tmt1, temp_tmt2; int ret; @@ -12479,7 +12473,7 @@ static int wdc_enc_submit_move_data(struct nvme_transport_handle *hdl, char *cmd nvme_cmd.timeout_ms, nvme_cmd.result, md, d); #endif nvme_cmd.result = 0; - err = nvme_submit_admin_passthru(hdl, &nvme_cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &nvme_cmd); if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INTERNAL)) { fprintf(stderr, "%s: WARNING : WDC: No log ID:x%x available\n", __func__, log_id); } else if (err) { @@ -12504,8 +12498,7 @@ static int wdc_enc_submit_move_data(struct nvme_transport_handle *hdl, char *cmd nvme_cmd.cdw14 = cdw14; nvme_cmd.cdw15 = cdw15; nvme_cmd.result = 0; /* returned result !=0 indicates more data available */ - err = nvme_submit_admin_passthru(hdl, - &nvme_cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &nvme_cmd); if (err) { more = 0; fprintf(stderr, "%s: ERROR: WDC: NVMe Rcv Mgmt ", __func__); @@ -12565,7 +12558,7 @@ static int wdc_enc_get_nic_log(struct nvme_transport_handle *hdl, __u8 log_id, _ admin_cmd.nsid, admin_cmd.addr, admin_cmd.data_len, admin_cmd.cdw10, admin_cmd.cdw11, admin_cmd.cdw12, admin_cmd.cdw13, admin_cmd.cdw14); #endif - ret = nvme_submit_admin_passthru(hdl, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -12606,7 +12599,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; uint64_t capabilities = 0; - __u32 result; + __u64 result; int ret; const char *active_bucket_timer_threshold = diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index e2848ffd5f..bac0ad4aa4 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -158,7 +158,7 @@ static int id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *p return err; nvme_init_zns_identify_ctrl(&cmd, &ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_zns_id_ctrl(&ctrl, flags); else if (err > 0) @@ -251,7 +251,6 @@ static int zns_mgmt_send(int argc, char **argv, struct command *acmd, struct plu struct nvme_passthru_cmd cmd; int err, zcapc = 0; char *cmdstr; - __u32 result; struct config { __u64 zslba; @@ -288,10 +287,10 @@ static int zns_mgmt_send(int argc, char **argv, struct command *acmd, struct plu nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, zsa, cfg.select_all, 0, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) { if (zsa == NVME_ZNS_ZSA_RESET) - zcapc = result & 0x1; + zcapc = cmd.result & 0x1; printf("%s: Success, action:%d zone:%"PRIx64" all:%d zcapc:%u nsid:%d\n", cmdstr, zsa, (uint64_t)cfg.zslba, (int)cfg.select_all, @@ -437,7 +436,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *acmd, struct pl nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, cfg.zsa, cfg.select_all, cfg.zsaso, 0, buf, cfg.data_len); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zone-mgmt-send: Success, action:%d zone:%"PRIx64" all:%d nsid:%d\n", cfg.zsa, (uint64_t)cfg.zslba, (int)cfg.select_all, cfg.namespace_id); @@ -515,7 +514,7 @@ static int open_zone(int argc, char **argv, struct command *acmd, struct plugin nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, NVME_ZNS_ZSA_OPEN, cfg.select_all, cfg.zrwaa, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zns-open-zone: Success zone slba:%"PRIx64" nsid:%d\n", (uint64_t)cfg.zslba, cfg.namespace_id); @@ -619,7 +618,7 @@ static int set_zone_desc(int argc, char **argv, struct command *acmd, struct plu nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, NVME_ZNS_ZSA_SET_DESC_EXT, 0, cfg.zrwaa, 0, buf, data_len); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("set-zone-desc: Success, zone:%"PRIx64" nsid:%d\n", (uint64_t)cfg.zslba, cfg.namespace_id); @@ -676,7 +675,7 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *acmd, struct p nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.lba, NVME_ZNS_ZSA_ZRWA_FLUSH, 0, 0, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zrwa-flush-zone: Success, lba:%"PRIx64" nsid:%d\n", (uint64_t)cfg.lba, cfg.namespace_id); @@ -759,7 +758,7 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *acmd, struct pl nvme_init_zns_mgmt_recv(&cmd, cfg.namespace_id, cfg.zslba, cfg.zra, cfg.zrasf, cfg.partial, data, cfg.data_len); - err = nvme_submit_admin_passthru(hdl, &cmd, NULL); + err = nvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zone-mgmt-recv: Success, action:%d zone:%"PRIx64" nsid:%d\n", cfg.zra, (uint64_t)cfg.zslba, cfg.namespace_id); @@ -880,7 +879,7 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug nvme_init_zns_report_zones(&cmd, cfg.namespace_id, 0, cfg.state, false, false, buff, log_len); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err > 0) { nvme_show_status(err); goto free_buff; @@ -923,7 +922,7 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug nvme_init_zns_report_zones(&cmd, cfg.namespace_id, offset, cfg.state, cfg.extended, cfg.partial, report, log_len); - err = nvme_submit_io_passthru(hdl, &cmd, NULL); + err = nvme_submit_io_passthru(hdl, &cmd); if (err > 0) { nvme_show_status(err); break; @@ -970,11 +969,10 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi struct timeval start_time, end_time; unsigned int lba_size, meta_size; void *buf = NULL, *mbuf = NULL; - struct nvme_passthru_cmd64 cmd; + struct nvme_passthru_cmd cmd; __u16 nblocks, control = 0; __u16 cev = 0, dspec = 0; __u8 lba_index; - __u64 result; struct nvme_id_ns ns; @@ -1114,14 +1112,15 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi nvme_init_zns_append(&cmd, cfg.namespace_id, cfg.zslba, nblocks, control, cev, dspec, buf, cfg.data_size, mbuf, cfg.metadata_size); - err = nvme_submit_admin_passthru64(hdl, &cmd, &result); + err = nvme_submit_admin_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); if (cfg.latency) printf(" latency: zone append: %llu us\n", elapsed_utime(start_time, end_time)); if (!err) - printf("Success appended data to LBA %"PRIx64"\n", (uint64_t)result); + printf("Success appended data to LBA %"PRIx64"\n", + (uint64_t)cmd.result); else if (err > 0) nvme_show_status(err); else diff --git a/types.h b/types.h index 2b976d046f..e004c00d1a 100644 --- a/types.h +++ b/types.h @@ -34,7 +34,7 @@ struct nvme_get_log_args { __u64 lpo; void *log; __u32 len; - __u32 *result; + __u64 *result; }; #endif