summaryrefslogtreecommitdiff
path: root/sys/dev/nvmf/nvmf.h
blob: 9b2b4c1dea4094d64ee03da5c33162130d7e3de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*-
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2022-2024 Chelsio Communications, Inc.
 * Written by: John Baldwin <jhb@FreeBSD.org>
 */

#ifndef __NVMF_H__
#define	__NVMF_H__

#include <sys/ioccom.h>
#ifndef _KERNEL
#include <stdbool.h>
#endif

/*
 * Default settings in Fabrics controllers.  These match values used by the
 * Linux target.
 */
#define	NVMF_MAX_IO_ENTRIES	(1024)
#define	NVMF_CC_EN_TIMEOUT	(15)	/* In 500ms units */

/* Allows for a 16k data buffer + SQE */
#define	NVMF_IOCCSZ		(sizeof(struct nvme_command) + 16 * 1024)
#define	NVMF_IORCSZ		(sizeof(struct nvme_completion))

#define	NVMF_NN			(1024)

/*
 * Default timeouts for Fabrics hosts.  These match values used by
 * Linux.
 */
#define	NVMF_DEFAULT_RECONNECT_DELAY	10
#define	NVMF_DEFAULT_CONTROLLER_LOSS	600

/*
 * (data, size) is the userspace buffer for a packed nvlist.
 *
 * For requests that copyout an nvlist, len is the amount of data
 * copied out to *data.  If size is zero, no data is copied and len is
 * set to the required buffer size.
 */
struct nvmf_ioc_nv {
	void	*data;
	size_t	len;
	size_t	size;
};

/*
 * The fields in a qpair handoff nvlist are:
 *
 * Transport independent:
 *
 * bool		admin
 * bool		sq_flow_control
 * number	qsize
 * number	sqhd
 * number	sqtail			host only
 *
 * TCP transport:
 *
 * number	fd
 * number	rxpda
 * number	txpda
 * bool		header_digests
 * bool		data_digests
 * number	maxr2t
 * number	maxh2cdata
 * number	max_icd
 */

/*
 * The fields in the nvlist for NVMF_HANDOFF_HOST and
 * NVMF_RECONNECT_HOST are:
 *
 * number			trtype
 * number			kato	(optional)
 * number                       reconnect_delay (optional)
 * number                       controller_loss_timeout (optional)
 * qpair handoff nvlist		admin
 * qpair handoff nvlist array	io
 * binary			cdata	struct nvme_controller_data
 * NVMF_RECONNECT_PARAMS nvlist	rparams
 */

/*
 * The fields in the nvlist for NVMF_RECONNECT_PARAMS are:
 *
 * binary			dle	struct nvme_discovery_log_entry
 * string			hostnqn
 * number			num_io_queues
 * number			kato	(optional)
 * number                       reconnect_delay (optional)
 * number                       controller_loss_timeout (optional)
 * number			io_qsize
 * bool				sq_flow_control
 *
 * TCP transport:
 *
 * bool				header_digests
 * bool				data_digests
 */

/*
 * The fields in the nvlist for NVMF_CONNECTION_STATUS are:
 *
 * bool				connected
 * timespec nvlist		last_disconnect
 *  number			tv_sec
 *  number			tv_nsec
 */

/*
 * The fields in the nvlist for handing off a controller qpair are:
 *
 * number			trtype
 * qpair handoff nvlist		params
 * binary			cmd	struct nvmf_fabric_connect_cmd
 * binary			data	struct nvmf_fabric_connect_data
 */

/* Operations on /dev/nvmf */
#define	NVMF_HANDOFF_HOST	_IOW('n', 200, struct nvmf_ioc_nv)
#define	NVMF_DISCONNECT_HOST	_IOW('n', 201, const char *)
#define	NVMF_DISCONNECT_ALL	_IO('n', 202)

/* Operations on /dev/nvmeX */
#define	NVMF_RECONNECT_PARAMS	_IOWR('n', 203, struct nvmf_ioc_nv)
#define	NVMF_RECONNECT_HOST	_IOW('n', 204, struct nvmf_ioc_nv)
#define	NVMF_CONNECTION_STATUS	_IOWR('n', 205, struct nvmf_ioc_nv)

#endif /* !__NVMF_H__ */