return nvme_submit_io_passthru(args->fd, &cmd, args->result);
}
-int nvme_dsm(int fd, __u32 nsid, __u32 attrs, __u16 nr_ranges,
- struct nvme_dsm_range *dsm, __u32 timeout, __u32 *result)
+int nvme_dsm(struct nvme_dsm_args *args)
{
- __u32 cdw11 = attrs;
-
struct nvme_passthru_cmd cmd = {
.opcode = nvme_cmd_dsm,
- .nsid = nsid,
- .addr = (__u64)(uintptr_t)dsm,
- .data_len = nr_ranges * sizeof(*dsm),
- .cdw10 = nr_ranges - 1,
- .cdw11 = cdw11,
- .timeout_ms = timeout,
+ .nsid = args->nsid,
+ .addr = (__u64)(uintptr_t)args->dsm,
+ .data_len = args->nr_ranges * sizeof(*args->dsm),
+ .cdw10 = args->nr_ranges - 1,
+ .cdw11 = args->attrs,
+ .timeout_ms = args->timeout,
};
- return nvme_submit_io_passthru(fd, &cmd, result);
+ if (args->args_size < sizeof(*args))
+ return -EINVAL;
+ return nvme_submit_io_passthru(args->fd, &cmd, args->result);
}
int nvme_copy(int fd, __u32 nsid, struct nvme_copy_range *copy, __u64 sdlba,
}
/**
- * nvme_dsm() - Send an nvme data set management command
+ * nvme_dsm_args - Arguments for the NVMe Dataset Management command
* @fd: File descriptor of nvme device
* @nsid: Namespace identifier
* @attrs: DSM attributes, see &enum nvme_dsm_attributes
* @dsm: The data set management attributes
* @timeout: Timeout in ms
* @result: The command completion result from CQE dword0
+ */
+struct nvme_dsm_args {
+ int args_size;
+ int fd;
+ __u32 nsid;
+ __u32 attrs;
+ __u16 nr_ranges;
+ struct nvme_dsm_range *dsm;
+ __u32 timeout;
+ __u32 *result;
+};
+
+/**
+ * nvme_dsm() - Send an nvme data set management command
+ * @args: &struct nvme_dsm_args argument structure
*
* The Dataset Management command is used by the host to indicate attributes
* for ranges of logical blocks. This includes attributes like frequency that
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
-int nvme_dsm(int fd, __u32 nsid, __u32 attrs, __u16 nr_ranges,
- struct nvme_dsm_range *dsm, __u32 timeout, __u32 *result);
+int nvme_dsm(struct nvme_dsm_args *args);
/**
* nvme_copy() -