xref: /freebsd/sys/dev/nvmf/nvmf.h (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2022-2024 Chelsio Communications, Inc.
5  * Written by: John Baldwin <jhb@FreeBSD.org>
6  */
7 
8 #ifndef __NVMF_H__
9 #define	__NVMF_H__
10 
11 #include <sys/ioccom.h>
12 #ifndef _KERNEL
13 #include <stdbool.h>
14 #endif
15 
16 /*
17  * Default settings in Fabrics controllers.  These match values used by the
18  * Linux target.
19  */
20 #define	NVMF_MAX_IO_ENTRIES	(1024)
21 #define	NVMF_CC_EN_TIMEOUT	(15)	/* In 500ms units */
22 
23 /* Allows for a 16k data buffer + SQE */
24 #define	NVMF_IOCCSZ		(sizeof(struct nvme_command) + 16 * 1024)
25 #define	NVMF_IORCSZ		(sizeof(struct nvme_completion))
26 
27 #define	NVMF_NN			(1024)
28 
29 /*
30  * (data, size) is the userspace buffer for a packed nvlist.
31  *
32  * For requests that copyout an nvlist, len is the amount of data
33  * copied out to *data.  If size is zero, no data is copied and len is
34  * set to the required buffer size.
35  */
36 struct nvmf_ioc_nv {
37 	void	*data;
38 	size_t	len;
39 	size_t	size;
40 };
41 
42 /*
43  * The fields in a qpair handoff nvlist are:
44  *
45  * Transport independent:
46  *
47  * bool		admin
48  * bool		sq_flow_control
49  * number	qsize
50  * number	sqhd
51  * number	sqtail			host only
52  *
53  * TCP transport:
54  *
55  * number	fd
56  * number	rxpda
57  * number	txpda
58  * bool		header_digests
59  * bool		data_digests
60  * number	maxr2t
61  * number	maxh2cdata
62  * number	max_icd
63  */
64 
65 /*
66  * The fields in the nvlist for NVMF_HANDOFF_HOST and
67  * NVMF_RECONNECT_HOST are:
68  *
69  * number			trtype
70  * number			kato	(optional)
71  * qpair handoff nvlist		admin
72  * qpair handoff nvlist array	io
73  * binary			cdata	struct nvme_controller_data
74  */
75 
76 /*
77  * The fields in the nvlist for NVMF_RECONNECT_PARAMS are:
78  *
79  * number			cntlid
80  * string			subnqn
81  */
82 
83 /*
84  * The fields in the nvlist for handing off a controller qpair are:
85  *
86  * number			trtype
87  * qpair handoff nvlist		params
88  * binary			cmd	struct nvmf_fabric_connect_cmd
89  * binary			data	struct nvmf_fabric_connect_data
90  */
91 
92 /* Operations on /dev/nvmf */
93 #define	NVMF_HANDOFF_HOST	_IOW('n', 200, struct nvmf_ioc_nv)
94 #define	NVMF_DISCONNECT_HOST	_IOW('n', 201, const char *)
95 #define	NVMF_DISCONNECT_ALL	_IO('n', 202)
96 
97 /* Operations on /dev/nvmeX */
98 #define	NVMF_RECONNECT_PARAMS	_IOWR('n', 203, struct nvmf_ioc_nv)
99 #define	NVMF_RECONNECT_HOST	_IOW('n', 204, struct nvmf_ioc_nv)
100 
101 #endif /* !__NVMF_H__ */
102