xref: /freebsd/sys/dev/nvmf/nvmf.h (revision d86edc181ab2c14df7f1411dd15f7ee7accbd027)
1*d86edc18SJohn Baldwin /*-
2*d86edc18SJohn Baldwin  * SPDX-License-Identifier: BSD-2-Clause
3*d86edc18SJohn Baldwin  *
4*d86edc18SJohn Baldwin  * Copyright (c) 2022-2024 Chelsio Communications, Inc.
5*d86edc18SJohn Baldwin  * Written by: John Baldwin <jhb@FreeBSD.org>
6*d86edc18SJohn Baldwin  */
7*d86edc18SJohn Baldwin 
8*d86edc18SJohn Baldwin #ifndef __NVMF_H__
9*d86edc18SJohn Baldwin #define	__NVMF_H__
10*d86edc18SJohn Baldwin 
11*d86edc18SJohn Baldwin #include <sys/ioccom.h>
12*d86edc18SJohn Baldwin #ifndef _KERNEL
13*d86edc18SJohn Baldwin #include <stdbool.h>
14*d86edc18SJohn Baldwin #endif
15*d86edc18SJohn Baldwin 
16*d86edc18SJohn Baldwin /*
17*d86edc18SJohn Baldwin  * Default settings in Fabrics controllers.  These match values used by the
18*d86edc18SJohn Baldwin  * Linux target.
19*d86edc18SJohn Baldwin  */
20*d86edc18SJohn Baldwin #define	NVMF_MAX_IO_ENTRIES	(1024)
21*d86edc18SJohn Baldwin #define	NVMF_CC_EN_TIMEOUT	(15)	/* In 500ms units */
22*d86edc18SJohn Baldwin 
23*d86edc18SJohn Baldwin /* Allows for a 16k data buffer + SQE */
24*d86edc18SJohn Baldwin #define	NVMF_IOCCSZ		(sizeof(struct nvme_command) + 16 * 1024)
25*d86edc18SJohn Baldwin #define	NVMF_IORCSZ		(sizeof(struct nvme_completion))
26*d86edc18SJohn Baldwin 
27*d86edc18SJohn Baldwin #define	NVMF_NN			(1024)
28*d86edc18SJohn Baldwin 
29*d86edc18SJohn Baldwin struct nvmf_handoff_qpair_params {
30*d86edc18SJohn Baldwin 	bool	admin;
31*d86edc18SJohn Baldwin 	bool	sq_flow_control;
32*d86edc18SJohn Baldwin 	u_int	qsize;
33*d86edc18SJohn Baldwin 	uint16_t sqhd;
34*d86edc18SJohn Baldwin 	uint16_t sqtail;	/* host only */
35*d86edc18SJohn Baldwin 	union {
36*d86edc18SJohn Baldwin 		struct {
37*d86edc18SJohn Baldwin 			int	fd;
38*d86edc18SJohn Baldwin 			uint8_t	rxpda;
39*d86edc18SJohn Baldwin 			uint8_t txpda;
40*d86edc18SJohn Baldwin 			bool	header_digests;
41*d86edc18SJohn Baldwin 			bool	data_digests;
42*d86edc18SJohn Baldwin 			uint32_t maxr2t;
43*d86edc18SJohn Baldwin 			uint32_t maxh2cdata;
44*d86edc18SJohn Baldwin 			uint32_t max_icd;
45*d86edc18SJohn Baldwin 		} tcp;
46*d86edc18SJohn Baldwin 	};
47*d86edc18SJohn Baldwin };
48*d86edc18SJohn Baldwin 
49*d86edc18SJohn Baldwin struct nvmf_handoff_host {
50*d86edc18SJohn Baldwin 	u_int	trtype;
51*d86edc18SJohn Baldwin 	u_int	num_io_queues;
52*d86edc18SJohn Baldwin 	u_int	kato;
53*d86edc18SJohn Baldwin 	struct nvmf_handoff_qpair_params admin;
54*d86edc18SJohn Baldwin 	struct nvmf_handoff_qpair_params *io;
55*d86edc18SJohn Baldwin 	const struct nvme_controller_data *cdata;
56*d86edc18SJohn Baldwin };
57*d86edc18SJohn Baldwin 
58*d86edc18SJohn Baldwin struct nvmf_reconnect_params {
59*d86edc18SJohn Baldwin 	uint16_t cntlid;
60*d86edc18SJohn Baldwin 	char	subnqn[256];
61*d86edc18SJohn Baldwin };
62*d86edc18SJohn Baldwin 
63*d86edc18SJohn Baldwin struct nvmf_handoff_controller_qpair {
64*d86edc18SJohn Baldwin 	u_int	trtype;
65*d86edc18SJohn Baldwin 	struct nvmf_handoff_qpair_params params;
66*d86edc18SJohn Baldwin 	const struct nvmf_fabric_connect_cmd *cmd;
67*d86edc18SJohn Baldwin 	const struct nvmf_fabric_connect_data *data;
68*d86edc18SJohn Baldwin };
69*d86edc18SJohn Baldwin 
70*d86edc18SJohn Baldwin /* Operations on /dev/nvmf */
71*d86edc18SJohn Baldwin #define	NVMF_HANDOFF_HOST	_IOW('n', 200, struct nvmf_handoff_host)
72*d86edc18SJohn Baldwin #define	NVMF_DISCONNECT_HOST	_IOW('n', 201, const char *)
73*d86edc18SJohn Baldwin #define	NVMF_DISCONNECT_ALL	_IO('n', 202)
74*d86edc18SJohn Baldwin 
75*d86edc18SJohn Baldwin /* Operations on /dev/nvmeX */
76*d86edc18SJohn Baldwin #define	NVMF_RECONNECT_PARAMS	_IOR('n', 203, struct nvmf_reconnect_params)
77*d86edc18SJohn Baldwin #define	NVMF_RECONNECT_HOST	_IOW('n', 204, struct nvmf_handoff_host)
78*d86edc18SJohn Baldwin 
79*d86edc18SJohn Baldwin #endif /* !__NVMF_H__ */
80