xref: /freebsd/sys/dev/nvme/nvme_linux.h (revision d1bdc2821fcd416ab9b238580386eb605a6128d0)
1 /*-
2  * Copyright (c) 2024, Netflix Inc.
3  * Written by Warner Losh
4  *
5  * SPDX-License-Identifier: BSD-2-Clause
6  */
7 
8 /*
9  * Linux compatible NVME ioctls. So far we just support ID, ADMIN_CMD and
10  * IO_CMD. The rest are not supported.
11  */
12 
13 
14 #include <sys/ioccom.h>
15 #include <sys/_types.h>
16 
17 struct nvme_passthru_cmd {
18 	__uint8_t	opcode;
19 	__uint8_t	flags;
20 	__uint16_t	rsvd1;
21 	__uint32_t	nsid;
22 	__uint32_t	cdw2;
23 	__uint32_t	cdw3;
24 	__uint64_t	metadata;
25 	__uint64_t	addr;
26 	__uint32_t	metadata_len;
27 	__uint32_t	data_len;
28 	__uint32_t	cdw10;
29 	__uint32_t	cdw11;
30 	__uint32_t	cdw12;
31 	__uint32_t	cdw13;
32 	__uint32_t	cdw14;
33 	__uint32_t	cdw15;
34 	__uint32_t	timeout_ms;
35 	__uint32_t	result;
36 };
37 
38 #define nvme_admin_cmd nvme_passthru_cmd
39 
40 /*
41  * Linux nvme ioctls, commented out ones are not supported
42  */
43 #define NVME_IOCTL_ID		_IO('N', 0x40)
44 #define NVME_IOCTL_ADMIN_CMD	_IOWR('N', 0x41, struct nvme_admin_cmd)
45 /* #define NVME_IOCTL_SUBMIT_IO	_IOW('N', 0x42, struct nvme_user_io) */
46 #define NVME_IOCTL_IO_CMD	_IOWR('N', 0x43, struct nvme_passthru_cmd)
47 #define NVME_IOCTL_RESET	_IO('N', 0x44)
48 /* #define NVME_IOCTL_SUBSYS_RESET	_IO('N', 0x45) */
49 /* #define NVME_IOCTL_RESCAN	_IO('N', 0x46) */
50 /* #define NVME_IOCTL_ADMIN64_CMD	_IOWR('N', 0x47, struct nvme_passthru_cmd64) */
51 /* #define NVME_IOCTL_IO64_CMD	_IOWR('N', 0x48, struct nvme_passthru_cmd64) */
52 /* #define NVME_IOCTL_IO64_CMD_VEC	_IOWR('N', 0x49, struct nvme_passthru_cmd64) */
53 
54 /* io_uring async commands: */
55 /* #define NVME_URING_CMD_IO	_IOWR('N', 0x80, struct nvme_uring_cmd) */
56 /* #define NVME_URING_CMD_IO_VEC	_IOWR('N', 0x81, struct nvme_uring_cmd) */
57 /* #define NVME_URING_CMD_ADMIN	_IOWR('N', 0x82, struct nvme_uring_cmd) */
58 /* #define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd) */
59