Skip to content

Commit 2bfe3d2

Browse files
hreineckedwsuse
authored andcommitted
Use argument structure for nvme_dev_self_test()
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 <[email protected]>
1 parent 00b1ea9 commit 2bfe3d2

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/nvme/ioctl.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,17 +1474,20 @@ int nvme_sanitize_nvm(struct nvme_sanitize_nvm_args *args)
14741474
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
14751475
}
14761476

1477-
int nvme_dev_self_test(int fd, __u32 nsid, enum nvme_dst_stc stc)
1477+
int nvme_dev_self_test(struct nvme_dev_self_test_args *args)
14781478
{
1479-
__u32 cdw10 = NVME_SET(stc, DEVICE_SELF_TEST_CDW10_STC);
1479+
__u32 cdw10 = NVME_SET(args->stc, DEVICE_SELF_TEST_CDW10_STC);
14801480

14811481
struct nvme_passthru_cmd cmd = {
1482-
.opcode = nvme_admin_dev_self_test,
1483-
.nsid = nsid,
1484-
.cdw10 = cdw10,
1482+
.opcode = nvme_admin_dev_self_test,
1483+
.nsid = args->nsid,
1484+
.cdw10 = cdw10,
1485+
.timeout_ms = args->timeout,
14851486
};
14861487

1487-
return nvme_submit_admin_passthru(fd, &cmd, NULL);
1488+
if (args->args_size < sizeof(*args))
1489+
return -EINVAL;
1490+
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
14881491
}
14891492

14901493
int nvme_virtual_mgmt(int fd, enum nvme_virt_mgmt_act act,

src/nvme/ioctl.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,10 +3481,25 @@ struct nvme_sanitize_nvm_args {
34813481
int nvme_sanitize_nvm(struct nvme_sanitize_nvm_args *args);
34823482

34833483
/**
3484-
* nvme_dev_self_test() - Start or abort a self test
3484+
* nvme_dev_self_test_args - Arguments for the NVMe Device Self Test command
34853485
* @fd: File descriptor of nvme device
34863486
* @nsid: Namespace ID to test
34873487
* @stc: Self test code, see &enum nvme_dst_stc
3488+
* @timeout: Timeout in ms
3489+
* @result: The command completion result from CQE dword0
3490+
*/
3491+
struct nvme_dev_self_test_args {
3492+
int args_size;
3493+
int fd;
3494+
__u32 nsid;
3495+
enum nvme_dst_stc stc;
3496+
__u32 timeout;
3497+
__u32 *result;
3498+
};
3499+
3500+
/**
3501+
* nvme_dev_self_test() - Start or abort a self test
3502+
* @args: &struct nvme_dev_self_test argument structure
34883503
*
34893504
* The Device Self-test command starts a device self-test operation or abort a
34903505
* device self-test operation. A device self-test operation is a diagnostic
@@ -3500,7 +3515,7 @@ int nvme_sanitize_nvm(struct nvme_sanitize_nvm_args *args);
35003515
* Return: The nvme command status if a response was received (see
35013516
* &enum nvme_status_field) or -1 with errno set otherwise.
35023517
*/
3503-
int nvme_dev_self_test(int fd, __u32 nsid, enum nvme_dst_stc stc);
3518+
int nvme_dev_self_test(struct nvme_dev_self_test_args *args);
35043519

35053520
/**
35063521
* nvme_virtual_mgmt() - Virtualization resource management

0 commit comments

Comments
 (0)