From: Hannes Reinecke Date: Fri, 17 Dec 2021 07:03:42 +0000 (+0100) Subject: Use argument structure for nvme_virtual_mgmt() X-Git-Tag: v1.0-rc0~6^2~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=db91866c6a3b6f86d567bb8b47b68c925920f8cb;p=users%2Fsagi%2Flibnvme.git Use argument structure for nvme_virtual_mgmt() Use an argument structure instead of passing all arguments one by one. This allows for a future expansion of the argument list without having to change the library ABI. Signed-off-by: Hannes Reinecke --- diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index 6a624b8b..f1ef3efa 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -1490,22 +1490,23 @@ int nvme_dev_self_test(struct nvme_dev_self_test_args *args) return nvme_submit_admin_passthru(args->fd, &cmd, args->result); } -int nvme_virtual_mgmt(int fd, enum nvme_virt_mgmt_act act, - enum nvme_virt_mgmt_rt rt, __u16 cntlid, __u16 nr, - __u32 *result) +int nvme_virtual_mgmt(struct nvme_virtual_mgmt_args *args) { - __u32 cdw10 = NVME_SET(act, VIRT_MGMT_CDW10_ACT) | - NVME_SET(rt, VIRT_MGMT_CDW10_RT) | - NVME_SET(cntlid, VIRT_MGMT_CDW10_CNTLID); - __u32 cdw11 = NVME_SET(nr, VIRT_MGMT_CDW11_NR); + __u32 cdw10 = NVME_SET(args->act, VIRT_MGMT_CDW10_ACT) | + NVME_SET(args->rt, VIRT_MGMT_CDW10_RT) | + NVME_SET(args->cntlid, VIRT_MGMT_CDW10_CNTLID); + __u32 cdw11 = NVME_SET(args->nr, VIRT_MGMT_CDW11_NR); struct nvme_passthru_cmd cmd = { - .opcode = nvme_admin_virtual_mgmt, - .cdw10 = cdw10, - .cdw11 = cdw11, + .opcode = nvme_admin_virtual_mgmt, + .cdw10 = cdw10, + .cdw11 = cdw11, + .timeout_ms = args->timeout, }; - return nvme_submit_admin_passthru(fd, &cmd, result); + if (args->args_size < sizeof(*args)) + return -EINVAL; + return nvme_submit_admin_passthru(args->fd, &cmd, args->result); } int nvme_submit_io_passthru64(int fd, struct nvme_passthru_cmd64 *cmd, diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 55f09704..f35c7aa8 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -3518,13 +3518,30 @@ struct nvme_dev_self_test_args { int nvme_dev_self_test(struct nvme_dev_self_test_args *args); /** - * nvme_virtual_mgmt() - Virtualization resource management + * nvme_virtual_mgmt_args - Arguments for the NVMe Virtualization + * resource management command * @fd: File descriptor of nvme device * @act: Virtual resource action, see &enum nvme_virt_mgmt_act * @rt: Resource type to modify, see &enum nvme_virt_mgmt_rt * @cntlid: Controller id for which resources are bing modified * @nr: Number of resources being allocated or assigned + * @timeout: Timeout in ms * @result: If successful, the CQE dword0 + */ +struct nvme_virtual_mgmt_args { + int args_size; + int fd; + enum nvme_virt_mgmt_act act; + enum nvme_virt_mgmt_rt rt; + __u16 cntlid; + __u16 nr; + __u32 timeout; + __u32 *result; +}; + +/** + * nvme_virtual_mgmt() - Virtualization resource management + * @args: &struct nvme_virtual_mgmt_args argument structure * * The Virtualization Management command is supported by primary controllers * that support the Virtualization Enhancements capability. This command is @@ -3537,9 +3554,7 @@ int nvme_dev_self_test(struct nvme_dev_self_test_args *args); * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise. */ -int nvme_virtual_mgmt(int fd, enum nvme_virt_mgmt_act act, - enum nvme_virt_mgmt_rt rt, __u16 cntlid, __u16 nr, - __u32 *result); +int nvme_virtual_mgmt(struct nvme_virtual_mgmt_args *args); /** * nvme_flush() - Send an nvme flush command