2 * nvme structure declarations and helper functions for the
9 #include <linux/nvme_ioctl.h>
13 * If the uapi headers installed on the system lacks nvme uring command
14 * support, use the local version to prevent compilation issues.
16 #ifndef CONFIG_NVME_URING_CMD
17 struct nvme_uring_cmd {
38 #define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd)
39 #define NVME_URING_CMD_IO_VEC _IOWR('N', 0x81, struct nvme_uring_cmd)
40 #endif /* CONFIG_NVME_URING_CMD */
42 #define NVME_DEFAULT_IOCTL_TIMEOUT 0
43 #define NVME_IDENTIFY_DATA_SIZE 4096
44 #define NVME_IDENTIFY_CSI_SHIFT 24
46 #define NVME_ZNS_ZRA_REPORT_ZONES 0
47 #define NVME_ZNS_ZRAS_FEAT_ERZ (1 << 16)
48 #define NVME_ZNS_ZSA_RESET 0x4
49 #define NVME_ZONE_TYPE_SEQWRITE_REQ 0x2
51 #define NVME_ATTRIBUTE_DEALLOCATE (1 << 2)
53 enum nvme_identify_cns {
54 NVME_IDENTIFY_CNS_NS = 0x00,
55 NVME_IDENTIFY_CNS_CSI_NS = 0x05,
56 NVME_IDENTIFY_CNS_CSI_CTRL = 0x06,
65 enum nvme_admin_opcode {
66 nvme_admin_identify = 0x06,
70 nvme_cmd_write = 0x01,
73 nvme_cmd_io_mgmt_recv = 0x12,
74 nvme_zns_cmd_mgmt_send = 0x79,
75 nvme_zns_cmd_mgmt_recv = 0x7a,
79 NVME_ZNS_ZS_EMPTY = 0x1,
80 NVME_ZNS_ZS_IMPL_OPEN = 0x2,
81 NVME_ZNS_ZS_EXPL_OPEN = 0x3,
82 NVME_ZNS_ZS_CLOSED = 0x4,
83 NVME_ZNS_ZS_READ_ONLY = 0xd,
84 NVME_ZNS_ZS_FULL = 0xe,
85 NVME_ZNS_ZS_OFFLINE = 0xf,
138 struct nvme_lbaf lbaf[64];
142 static inline int ilog2(uint32_t i)
153 struct nvme_zns_lbafe {
159 struct nvme_zns_id_ns {
177 struct nvme_zns_lbafe lbafe[64];
181 struct nvme_zns_desc {
193 struct nvme_zone_report {
196 struct nvme_zns_desc entries[];
199 struct nvme_fdp_ruh_status_desc {
207 struct nvme_fdp_ruh_status {
210 struct nvme_fdp_ruh_status_desc ruhss[];
213 struct nvme_dsm_range {
219 int fio_nvme_trim(const struct thread_data *td, struct fio_file *f,
220 unsigned long long offset, unsigned long long len);
222 int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
223 struct nvme_fdp_ruh_status *ruhs, __u32 bytes);
225 int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
226 __u32 *ms, __u64 *nlba);
228 int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
231 int fio_nvme_get_zoned_model(struct thread_data *td, struct fio_file *f,
232 enum zbd_zoned_model *model);
234 int fio_nvme_report_zones(struct thread_data *td, struct fio_file *f,
235 uint64_t offset, struct zbd_zone *zbdz,
236 unsigned int nr_zones);
238 int fio_nvme_reset_wp(struct thread_data *td, struct fio_file *f,
239 uint64_t offset, uint64_t length);
241 int fio_nvme_get_max_open_zones(struct thread_data *td, struct fio_file *f,
242 unsigned int *max_open_zones);