]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/include/spdk/nvmf_spec.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / include / spdk / nvmf_spec.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef SPDK_NVMF_SPEC_H
35 #define SPDK_NVMF_SPEC_H
36
37 #include "spdk/stdinc.h"
38
39 #include "spdk/assert.h"
40 #include "spdk/nvme_spec.h"
41
42 /**
43 * \file
44 * NVMe over Fabrics specification definitions
45 */
46
47 #pragma pack(push, 1)
48
49 /* Minimum number of admin queue entries defined by NVMe over Fabrics spec */
50 #define SPDK_NVMF_MIN_ADMIN_QUEUE_ENTRIES 32
51
52 struct spdk_nvmf_capsule_cmd {
53 uint8_t opcode;
54 uint8_t reserved1;
55 uint16_t cid;
56 uint8_t fctype;
57 uint8_t reserved2[35];
58 uint8_t fabric_specific[24];
59 };
60 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_capsule_cmd) == 64, "Incorrect size");
61
62 /* Fabric Command Set */
63 #define SPDK_NVME_OPC_FABRIC 0x7f
64
65 enum spdk_nvmf_fabric_cmd_types {
66 SPDK_NVMF_FABRIC_COMMAND_PROPERTY_SET = 0x00,
67 SPDK_NVMF_FABRIC_COMMAND_CONNECT = 0x01,
68 SPDK_NVMF_FABRIC_COMMAND_PROPERTY_GET = 0x04,
69 SPDK_NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND = 0x05,
70 SPDK_NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV = 0x06,
71 SPDK_NVMF_FABRIC_COMMAND_START_VENDOR_SPECIFIC = 0xC0,
72 };
73
74 enum spdk_nvmf_fabric_cmd_status_code {
75 SPDK_NVMF_FABRIC_SC_INCOMPATIBLE_FORMAT = 0x80,
76 SPDK_NVMF_FABRIC_SC_CONTROLLER_BUSY = 0x81,
77 SPDK_NVMF_FABRIC_SC_INVALID_PARAM = 0x82,
78 SPDK_NVMF_FABRIC_SC_RESTART_DISCOVERY = 0x83,
79 SPDK_NVMF_FABRIC_SC_INVALID_HOST = 0x84,
80 SPDK_NVMF_FABRIC_SC_LOG_RESTART_DISCOVERY = 0x90,
81 SPDK_NVMF_FABRIC_SC_AUTH_REQUIRED = 0x91,
82 };
83
84 /**
85 * RDMA Queue Pair service types
86 */
87 enum spdk_nvmf_rdma_qptype {
88 /** Reliable connected */
89 SPDK_NVMF_RDMA_QPTYPE_RELIABLE_CONNECTED = 0x1,
90
91 /** Reliable datagram */
92 SPDK_NVMF_RDMA_QPTYPE_RELIABLE_DATAGRAM = 0x2,
93 };
94
95 /**
96 * RDMA provider types
97 */
98 enum spdk_nvmf_rdma_prtype {
99 /** No provider specified */
100 SPDK_NVMF_RDMA_PRTYPE_NONE = 0x1,
101
102 /** InfiniBand */
103 SPDK_NVMF_RDMA_PRTYPE_IB = 0x2,
104
105 /** RoCE v1 */
106 SPDK_NVMF_RDMA_PRTYPE_ROCE = 0x3,
107
108 /** RoCE v2 */
109 SPDK_NVMF_RDMA_PRTYPE_ROCE2 = 0x4,
110
111 /** iWARP */
112 SPDK_NVMF_RDMA_PRTYPE_IWARP = 0x5,
113 };
114
115 /**
116 * RDMA connection management service types
117 */
118 enum spdk_nvmf_rdma_cms {
119 /** Sockets based endpoint addressing */
120 SPDK_NVMF_RDMA_CMS_RDMA_CM = 0x1,
121 };
122
123 /**
124 * NVMe over Fabrics transport types
125 */
126 enum spdk_nvmf_trtype {
127 /** RDMA */
128 SPDK_NVMF_TRTYPE_RDMA = 0x1,
129
130 /** Fibre Channel */
131 SPDK_NVMF_TRTYPE_FC = 0x2,
132
133 /** Intra-host transport (loopback) */
134 SPDK_NVMF_TRTYPE_INTRA_HOST = 0xfe,
135 };
136
137 /**
138 * Address family types
139 */
140 enum spdk_nvmf_adrfam {
141 /** IPv4 (AF_INET) */
142 SPDK_NVMF_ADRFAM_IPV4 = 0x1,
143
144 /** IPv6 (AF_INET6) */
145 SPDK_NVMF_ADRFAM_IPV6 = 0x2,
146
147 /** InfiniBand (AF_IB) */
148 SPDK_NVMF_ADRFAM_IB = 0x3,
149
150 /** Fibre Channel address family */
151 SPDK_NVMF_ADRFAM_FC = 0x4,
152
153 /** Intra-host transport (loopback) */
154 SPDK_NVMF_ADRFAM_INTRA_HOST = 0xfe,
155 };
156
157 /**
158 * NVM subsystem types
159 */
160 enum spdk_nvmf_subtype {
161 /** Discovery type for NVM subsystem */
162 SPDK_NVMF_SUBTYPE_DISCOVERY = 0x1,
163
164 /** NVMe type for NVM subsystem */
165 SPDK_NVMF_SUBTYPE_NVME = 0x2,
166 };
167
168 /**
169 * Connections shall be made over a fabric secure channel
170 */
171 enum spdk_nvmf_treq_secure_channel {
172 /** Not specified */
173 SPDK_NVMF_TREQ_SECURE_CHANNEL_NOT_SPECIFIED = 0x0,
174
175 /** Required */
176 SPDK_NVMF_TREQ_SECURE_CHANNEL_REQUIRED = 0x1,
177
178 /** Not required */
179 SPDK_NVMF_TREQ_SECURE_CHANNEL_NOT_REQUIRED = 0x2,
180 };
181
182 struct spdk_nvmf_fabric_auth_recv_cmd {
183 uint8_t opcode;
184 uint8_t reserved1;
185 uint16_t cid;
186 uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV (0x06) */
187 uint8_t reserved2[19];
188 struct spdk_nvme_sgl_descriptor sgl1;
189 uint8_t reserved3;
190 uint8_t spsp0;
191 uint8_t spsp1;
192 uint8_t secp;
193 uint32_t al;
194 uint8_t reserved4[16];
195 };
196 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_recv_cmd) == 64, "Incorrect size");
197
198 struct spdk_nvmf_fabric_auth_send_cmd {
199 uint8_t opcode;
200 uint8_t reserved1;
201 uint16_t cid;
202 uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND (0x05) */
203 uint8_t reserved2[19];
204 struct spdk_nvme_sgl_descriptor sgl1;
205 uint8_t reserved3;
206 uint8_t spsp0;
207 uint8_t spsp1;
208 uint8_t secp;
209 uint32_t tl;
210 uint8_t reserved4[16];
211 };
212 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_send_cmd) == 64, "Incorrect size");
213
214 struct spdk_nvmf_fabric_connect_data {
215 uint8_t hostid[16];
216 uint16_t cntlid;
217 uint8_t reserved5[238];
218 uint8_t subnqn[256];
219 uint8_t hostnqn[256];
220 uint8_t reserved6[256];
221 };
222 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_data) == 1024, "Incorrect size");
223
224 struct spdk_nvmf_fabric_connect_cmd {
225 uint8_t opcode;
226 uint8_t reserved1;
227 uint16_t cid;
228 uint8_t fctype;
229 uint8_t reserved2[19];
230 struct spdk_nvme_sgl_descriptor sgl1;
231 uint16_t recfmt; /* Connect Record Format */
232 uint16_t qid; /* Queue Identifier */
233 uint16_t sqsize; /* Submission Queue Size */
234 uint8_t cattr; /* queue attributes */
235 uint8_t reserved3;
236 uint32_t kato; /* keep alive timeout */
237 uint8_t reserved4[12];
238 };
239 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_cmd) == 64, "Incorrect size");
240
241 struct spdk_nvmf_fabric_connect_rsp {
242 union {
243 struct {
244 uint16_t cntlid;
245 uint16_t authreq;
246 } success;
247
248 struct {
249 uint16_t ipo;
250 uint8_t iattr;
251 uint8_t reserved;
252 } invalid;
253
254 uint32_t raw;
255 } status_code_specific;
256
257 uint32_t reserved0;
258 uint16_t sqhd;
259 uint16_t reserved1;
260 uint16_t cid;
261 struct spdk_nvme_status status;
262 };
263 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_rsp) == 16, "Incorrect size");
264
265 #define SPDK_NVMF_PROP_SIZE_4 0
266 #define SPDK_NVMF_PROP_SIZE_8 1
267
268 struct spdk_nvmf_fabric_prop_get_cmd {
269 uint8_t opcode;
270 uint8_t reserved1;
271 uint16_t cid;
272 uint8_t fctype;
273 uint8_t reserved2[35];
274 struct {
275 uint8_t size : 3;
276 uint8_t reserved : 5;
277 } attrib;
278 uint8_t reserved3[3];
279 uint32_t ofst;
280 uint8_t reserved4[16];
281 };
282 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_cmd) == 64, "Incorrect size");
283
284 struct spdk_nvmf_fabric_prop_get_rsp {
285 union {
286 uint64_t u64;
287 struct {
288 uint32_t low;
289 uint32_t high;
290 } u32;
291 } value;
292
293 uint16_t sqhd;
294 uint16_t reserved0;
295 uint16_t cid;
296 struct spdk_nvme_status status;
297 };
298 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_rsp) == 16, "Incorrect size");
299
300 struct spdk_nvmf_fabric_prop_set_cmd {
301 uint8_t opcode;
302 uint8_t reserved0;
303 uint16_t cid;
304 uint8_t fctype;
305 uint8_t reserved1[35];
306 struct {
307 uint8_t size : 3;
308 uint8_t reserved : 5;
309 } attrib;
310 uint8_t reserved2[3];
311 uint32_t ofst;
312
313 union {
314 uint64_t u64;
315 struct {
316 uint32_t low;
317 uint32_t high;
318 } u32;
319 } value;
320
321 uint8_t reserved4[8];
322 };
323 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_set_cmd) == 64, "Incorrect size");
324
325 #define SPDK_NVMF_NQN_MIN_LEN 11 /* The prefix in the spec is 11 characters */
326 #define SPDK_NVMF_NQN_MAX_LEN 223
327 #define SPDK_NVMF_NQN_UUID_PRE_LEN 32
328 #define SPDK_NVMF_UUID_STRING_LEN 36
329 #define SPDK_NVMF_NQN_UUID_PRE "nqn.2014-08.org.nvmexpress:uuid:"
330 #define SPDK_NVMF_DISCOVERY_NQN "nqn.2014-08.org.nvmexpress.discovery"
331
332 #define SPDK_DOMAIN_LABEL_MAX_LEN 63 /* RFC 1034 max domain label length */
333
334 #define SPDK_NVMF_TRADDR_MAX_LEN 256
335 #define SPDK_NVMF_TRSVCID_MAX_LEN 32
336
337 /** RDMA transport-specific address subtype */
338 struct spdk_nvmf_rdma_transport_specific_address_subtype {
339 /** RDMA QP service type (\ref spdk_nvmf_rdma_qptype) */
340 uint8_t rdma_qptype;
341
342 /** RDMA provider type (\ref spdk_nvmf_rdma_prtype) */
343 uint8_t rdma_prtype;
344
345 /** RDMA connection management service (\ref spdk_nvmf_rdma_cms) */
346 uint8_t rdma_cms;
347
348 uint8_t reserved0[5];
349
350 /** RDMA partition key for AF_IB */
351 uint16_t rdma_pkey;
352
353 uint8_t reserved2[246];
354 };
355 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_transport_specific_address_subtype) == 256,
356 "Incorrect size");
357
358 /** Transport-specific address subtype */
359 union spdk_nvmf_transport_specific_address_subtype {
360 uint8_t raw[256];
361
362 /** RDMA */
363 struct spdk_nvmf_rdma_transport_specific_address_subtype rdma;
364 };
365 SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_transport_specific_address_subtype) == 256,
366 "Incorrect size");
367
368 /**
369 * Discovery Log Page entry
370 */
371 struct spdk_nvmf_discovery_log_page_entry {
372 /** Transport type (\ref spdk_nvmf_trtype) */
373 uint8_t trtype;
374
375 /** Address family (\ref spdk_nvmf_adrfam) */
376 uint8_t adrfam;
377
378 /** Subsystem type (\ref spdk_nvmf_subtype) */
379 uint8_t subtype;
380
381 /** Transport requirements */
382 struct {
383 /** Secure channel requirements (\ref spdk_nvmf_treq_secure_channel) */
384 uint8_t secure_channel : 2;
385
386 uint8_t reserved : 6;
387 } treq;
388
389 /** NVM subsystem port ID */
390 uint16_t portid;
391
392 /** Controller ID */
393 uint16_t cntlid;
394
395 /** Admin max SQ size */
396 uint16_t asqsz;
397
398 uint8_t reserved0[22];
399
400 /** Transport service identifier */
401 uint8_t trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN];
402
403 uint8_t reserved1[192];
404
405 /** NVM subsystem qualified name */
406 uint8_t subnqn[256];
407
408 /** Transport address */
409 uint8_t traddr[SPDK_NVMF_TRADDR_MAX_LEN];
410
411 /** Transport-specific address subtype */
412 union spdk_nvmf_transport_specific_address_subtype tsas;
413 };
414 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page_entry) == 1024, "Incorrect size");
415
416 struct spdk_nvmf_discovery_log_page {
417 uint64_t genctr;
418 uint64_t numrec;
419 uint16_t recfmt;
420 uint8_t reserved0[1006];
421 struct spdk_nvmf_discovery_log_page_entry entries[0];
422 };
423 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page) == 1024, "Incorrect size");
424
425 /* RDMA Fabric specific definitions below */
426
427 #define SPDK_NVME_SGL_SUBTYPE_INVALIDATE_KEY 0xF
428
429 struct spdk_nvmf_rdma_request_private_data {
430 uint16_t recfmt; /* record format */
431 uint16_t qid; /* queue id */
432 uint16_t hrqsize; /* host receive queue size */
433 uint16_t hsqsize; /* host send queue size */
434 uint16_t cntlid; /* controller id */
435 uint8_t reserved[22];
436 };
437 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_request_private_data) == 32, "Incorrect size");
438
439 struct spdk_nvmf_rdma_accept_private_data {
440 uint16_t recfmt; /* record format */
441 uint16_t crqsize; /* controller receive queue size */
442 uint8_t reserved[28];
443 };
444 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_accept_private_data) == 32, "Incorrect size");
445
446 struct spdk_nvmf_rdma_reject_private_data {
447 uint16_t recfmt; /* record format */
448 uint16_t sts; /* status */
449 };
450 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_reject_private_data) == 4, "Incorrect size");
451
452 union spdk_nvmf_rdma_private_data {
453 struct spdk_nvmf_rdma_request_private_data pd_request;
454 struct spdk_nvmf_rdma_accept_private_data pd_accept;
455 struct spdk_nvmf_rdma_reject_private_data pd_reject;
456 };
457 SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_rdma_private_data) == 32, "Incorrect size");
458
459 enum spdk_nvmf_rdma_transport_error {
460 SPDK_NVMF_RDMA_ERROR_INVALID_PRIVATE_DATA_LENGTH = 0x1,
461 SPDK_NVMF_RDMA_ERROR_INVALID_RECFMT = 0x2,
462 SPDK_NVMF_RDMA_ERROR_INVALID_QID = 0x3,
463 SPDK_NVMF_RDMA_ERROR_INVALID_HSQSIZE = 0x4,
464 SPDK_NVMF_RDMA_ERROR_INVALID_HRQSIZE = 0x5,
465 SPDK_NVMF_RDMA_ERROR_NO_RESOURCES = 0x6,
466 SPDK_NVMF_RDMA_ERROR_INVALID_IRD = 0x7,
467 SPDK_NVMF_RDMA_ERROR_INVALID_ORD = 0x8,
468 };
469
470 #pragma pack(pop)
471
472 #endif /* __NVMF_SPEC_H__ */