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