xref: /qemu/linux-headers/linux/nvme_ioctl.h (revision 83ecdb18)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Definitions for the NVM Express ioctl interface
4  * Copyright (c) 2011-2014, Intel Corporation.
5  */
6 
7 #ifndef _LINUX_NVME_IOCTL_H
8 #define _LINUX_NVME_IOCTL_H
9 
10 #include <linux/types.h>
11 
12 struct nvme_user_io {
13 	__u8	opcode;
14 	__u8	flags;
15 	__u16	control;
16 	__u16	nblocks;
17 	__u16	rsvd;
18 	__u64	metadata;
19 	__u64	addr;
20 	__u64	slba;
21 	__u32	dsmgmt;
22 	__u32	reftag;
23 	__u16	apptag;
24 	__u16	appmask;
25 };
26 
27 struct nvme_passthru_cmd {
28 	__u8	opcode;
29 	__u8	flags;
30 	__u16	rsvd1;
31 	__u32	nsid;
32 	__u32	cdw2;
33 	__u32	cdw3;
34 	__u64	metadata;
35 	__u64	addr;
36 	__u32	metadata_len;
37 	__u32	data_len;
38 	__u32	cdw10;
39 	__u32	cdw11;
40 	__u32	cdw12;
41 	__u32	cdw13;
42 	__u32	cdw14;
43 	__u32	cdw15;
44 	__u32	timeout_ms;
45 	__u32	result;
46 };
47 
48 struct nvme_passthru_cmd64 {
49 	__u8	opcode;
50 	__u8	flags;
51 	__u16	rsvd1;
52 	__u32	nsid;
53 	__u32	cdw2;
54 	__u32	cdw3;
55 	__u64	metadata;
56 	__u64	addr;
57 	__u32	metadata_len;
58 	union {
59 		__u32	data_len; /* for non-vectored io */
60 		__u32	vec_cnt; /* for vectored io */
61 	};
62 	__u32	cdw10;
63 	__u32	cdw11;
64 	__u32	cdw12;
65 	__u32	cdw13;
66 	__u32	cdw14;
67 	__u32	cdw15;
68 	__u32	timeout_ms;
69 	__u32   rsvd2;
70 	__u64	result;
71 };
72 
73 /* same as struct nvme_passthru_cmd64, minus the 8b result field */
74 struct nvme_uring_cmd {
75 	__u8	opcode;
76 	__u8	flags;
77 	__u16	rsvd1;
78 	__u32	nsid;
79 	__u32	cdw2;
80 	__u32	cdw3;
81 	__u64	metadata;
82 	__u64	addr;
83 	__u32	metadata_len;
84 	__u32	data_len;
85 	__u32	cdw10;
86 	__u32	cdw11;
87 	__u32	cdw12;
88 	__u32	cdw13;
89 	__u32	cdw14;
90 	__u32	cdw15;
91 	__u32	timeout_ms;
92 	__u32   rsvd2;
93 };
94 
95 #define nvme_admin_cmd nvme_passthru_cmd
96 
97 #define NVME_IOCTL_ID		_IO('N', 0x40)
98 #define NVME_IOCTL_ADMIN_CMD	_IOWR('N', 0x41, struct nvme_admin_cmd)
99 #define NVME_IOCTL_SUBMIT_IO	_IOW('N', 0x42, struct nvme_user_io)
100 #define NVME_IOCTL_IO_CMD	_IOWR('N', 0x43, struct nvme_passthru_cmd)
101 #define NVME_IOCTL_RESET	_IO('N', 0x44)
102 #define NVME_IOCTL_SUBSYS_RESET	_IO('N', 0x45)
103 #define NVME_IOCTL_RESCAN	_IO('N', 0x46)
104 #define NVME_IOCTL_ADMIN64_CMD	_IOWR('N', 0x47, struct nvme_passthru_cmd64)
105 #define NVME_IOCTL_IO64_CMD	_IOWR('N', 0x48, struct nvme_passthru_cmd64)
106 #define NVME_IOCTL_IO64_CMD_VEC	_IOWR('N', 0x49, struct nvme_passthru_cmd64)
107 
108 /* io_uring async commands: */
109 #define NVME_URING_CMD_IO	_IOWR('N', 0x80, struct nvme_uring_cmd)
110 #define NVME_URING_CMD_IO_VEC	_IOWR('N', 0x81, struct nvme_uring_cmd)
111 #define NVME_URING_CMD_ADMIN	_IOWR('N', 0x82, struct nvme_uring_cmd)
112 #define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd)
113 
114 #endif /* _LINUX_NVME_IOCTL_H */
115