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 enum nvme_identify_cns {
52 NVME_IDENTIFY_CNS_NS = 0x00,
53 NVME_IDENTIFY_CNS_CSI_NS = 0x05,
54 NVME_IDENTIFY_CNS_CSI_CTRL = 0x06,
63 enum nvme_admin_opcode {
64 nvme_admin_identify = 0x06,
68 nvme_cmd_write = 0x01,
70 nvme_cmd_io_mgmt_recv = 0x12,
71 nvme_zns_cmd_mgmt_send = 0x79,
72 nvme_zns_cmd_mgmt_recv = 0x7a,
76 NVME_ZNS_ZS_EMPTY = 0x1,
77 NVME_ZNS_ZS_IMPL_OPEN = 0x2,
78 NVME_ZNS_ZS_EXPL_OPEN = 0x3,
79 NVME_ZNS_ZS_CLOSED = 0x4,
80 NVME_ZNS_ZS_READ_ONLY = 0xd,
81 NVME_ZNS_ZS_FULL = 0xe,
82 NVME_ZNS_ZS_OFFLINE = 0xf,
134 struct nvme_lbaf lbaf[16];
139 static inline int ilog2(uint32_t i)
150 struct nvme_zns_lbafe {
156 struct nvme_zns_id_ns {
174 struct nvme_zns_lbafe lbafe[64];
178 struct nvme_zns_desc {
190 struct nvme_zone_report {
193 struct nvme_zns_desc entries[];
196 struct nvme_fdp_ruh_status_desc {
204 struct nvme_fdp_ruh_status {
207 struct nvme_fdp_ruh_status_desc ruhss[];
210 int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
211 struct nvme_fdp_ruh_status *ruhs, __u32 bytes);
213 int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
216 int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
219 int fio_nvme_get_zoned_model(struct thread_data *td, struct fio_file *f,
220 enum zbd_zoned_model *model);
222 int fio_nvme_report_zones(struct thread_data *td, struct fio_file *f,
223 uint64_t offset, struct zbd_zone *zbdz,
224 unsigned int nr_zones);
226 int fio_nvme_reset_wp(struct thread_data *td, struct fio_file *f,
227 uint64_t offset, uint64_t length);
229 int fio_nvme_get_max_open_zones(struct thread_data *td, struct fio_file *f,
230 unsigned int *max_open_zones);