4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef SPDK_NVMF_SPEC_H
35 #define SPDK_NVMF_SPEC_H
37 #include "spdk/stdinc.h"
39 #include "spdk/assert.h"
40 #include "spdk/nvme_spec.h"
44 * NVMe over Fabrics specification definitions
49 /* Minimum number of admin queue entries defined by NVMe over Fabrics spec */
50 #define SPDK_NVMF_MIN_ADMIN_QUEUE_ENTRIES 32
52 struct spdk_nvmf_capsule_cmd
{
57 uint8_t reserved2
[35];
58 uint8_t fabric_specific
[24];
60 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_capsule_cmd
) == 64, "Incorrect size");
62 /* Fabric Command Set */
63 #define SPDK_NVME_OPC_FABRIC 0x7f
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,
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,
85 * RDMA Queue Pair service types
87 enum spdk_nvmf_rdma_qptype
{
88 /** Reliable connected */
89 SPDK_NVMF_RDMA_QPTYPE_RELIABLE_CONNECTED
= 0x1,
91 /** Reliable datagram */
92 SPDK_NVMF_RDMA_QPTYPE_RELIABLE_DATAGRAM
= 0x2,
98 enum spdk_nvmf_rdma_prtype
{
99 /** No provider specified */
100 SPDK_NVMF_RDMA_PRTYPE_NONE
= 0x1,
103 SPDK_NVMF_RDMA_PRTYPE_IB
= 0x2,
106 SPDK_NVMF_RDMA_PRTYPE_ROCE
= 0x3,
109 SPDK_NVMF_RDMA_PRTYPE_ROCE2
= 0x4,
112 SPDK_NVMF_RDMA_PRTYPE_IWARP
= 0x5,
116 * RDMA connection management service types
118 enum spdk_nvmf_rdma_cms
{
119 /** Sockets based endpoint addressing */
120 SPDK_NVMF_RDMA_CMS_RDMA_CM
= 0x1,
124 * NVMe over Fabrics transport types
126 enum spdk_nvmf_trtype
{
128 SPDK_NVMF_TRTYPE_RDMA
= 0x1,
131 SPDK_NVMF_TRTYPE_FC
= 0x2,
133 /** Intra-host transport (loopback) */
134 SPDK_NVMF_TRTYPE_INTRA_HOST
= 0xfe,
138 * Address family types
140 enum spdk_nvmf_adrfam
{
141 /** IPv4 (AF_INET) */
142 SPDK_NVMF_ADRFAM_IPV4
= 0x1,
144 /** IPv6 (AF_INET6) */
145 SPDK_NVMF_ADRFAM_IPV6
= 0x2,
147 /** InfiniBand (AF_IB) */
148 SPDK_NVMF_ADRFAM_IB
= 0x3,
150 /** Fibre Channel address family */
151 SPDK_NVMF_ADRFAM_FC
= 0x4,
153 /** Intra-host transport (loopback) */
154 SPDK_NVMF_ADRFAM_INTRA_HOST
= 0xfe,
158 * NVM subsystem types
160 enum spdk_nvmf_subtype
{
161 /** Discovery type for NVM subsystem */
162 SPDK_NVMF_SUBTYPE_DISCOVERY
= 0x1,
164 /** NVMe type for NVM subsystem */
165 SPDK_NVMF_SUBTYPE_NVME
= 0x2,
169 * Connections shall be made over a fabric secure channel
171 enum spdk_nvmf_treq_secure_channel
{
173 SPDK_NVMF_TREQ_SECURE_CHANNEL_NOT_SPECIFIED
= 0x0,
176 SPDK_NVMF_TREQ_SECURE_CHANNEL_REQUIRED
= 0x1,
179 SPDK_NVMF_TREQ_SECURE_CHANNEL_NOT_REQUIRED
= 0x2,
182 struct spdk_nvmf_fabric_auth_recv_cmd
{
186 uint8_t fctype
; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV (0x06) */
187 uint8_t reserved2
[19];
188 struct spdk_nvme_sgl_descriptor sgl1
;
194 uint8_t reserved4
[16];
196 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_recv_cmd
) == 64, "Incorrect size");
198 struct spdk_nvmf_fabric_auth_send_cmd
{
202 uint8_t fctype
; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND (0x05) */
203 uint8_t reserved2
[19];
204 struct spdk_nvme_sgl_descriptor sgl1
;
210 uint8_t reserved4
[16];
212 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_send_cmd
) == 64, "Incorrect size");
214 struct spdk_nvmf_fabric_connect_data
{
217 uint8_t reserved5
[238];
219 uint8_t hostnqn
[256];
220 uint8_t reserved6
[256];
222 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_data
) == 1024, "Incorrect size");
224 struct spdk_nvmf_fabric_connect_cmd
{
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 */
236 uint32_t kato
; /* keep alive timeout */
237 uint8_t reserved4
[12];
239 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_cmd
) == 64, "Incorrect size");
241 struct spdk_nvmf_fabric_connect_rsp
{
255 } status_code_specific
;
261 struct spdk_nvme_status status
;
263 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_rsp
) == 16, "Incorrect size");
265 #define SPDK_NVMF_PROP_SIZE_4 0
266 #define SPDK_NVMF_PROP_SIZE_8 1
268 struct spdk_nvmf_fabric_prop_get_cmd
{
273 uint8_t reserved2
[35];
276 uint8_t reserved
: 5;
278 uint8_t reserved3
[3];
280 uint8_t reserved4
[16];
282 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_cmd
) == 64, "Incorrect size");
284 struct spdk_nvmf_fabric_prop_get_rsp
{
296 struct spdk_nvme_status status
;
298 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_rsp
) == 16, "Incorrect size");
300 struct spdk_nvmf_fabric_prop_set_cmd
{
305 uint8_t reserved1
[35];
308 uint8_t reserved
: 5;
310 uint8_t reserved2
[3];
321 uint8_t reserved4
[8];
323 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_set_cmd
) == 64, "Incorrect size");
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"
332 #define SPDK_DOMAIN_LABEL_MAX_LEN 63 /* RFC 1034 max domain label length */
334 #define SPDK_NVMF_TRADDR_MAX_LEN 256
335 #define SPDK_NVMF_TRSVCID_MAX_LEN 32
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) */
342 /** RDMA provider type (\ref spdk_nvmf_rdma_prtype) */
345 /** RDMA connection management service (\ref spdk_nvmf_rdma_cms) */
348 uint8_t reserved0
[5];
350 /** RDMA partition key for AF_IB */
353 uint8_t reserved2
[246];
355 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_transport_specific_address_subtype
) == 256,
358 /** Transport-specific address subtype */
359 union spdk_nvmf_transport_specific_address_subtype
{
363 struct spdk_nvmf_rdma_transport_specific_address_subtype rdma
;
365 SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_transport_specific_address_subtype
) == 256,
369 * Discovery Log Page entry
371 struct spdk_nvmf_discovery_log_page_entry
{
372 /** Transport type (\ref spdk_nvmf_trtype) */
375 /** Address family (\ref spdk_nvmf_adrfam) */
378 /** Subsystem type (\ref spdk_nvmf_subtype) */
381 /** Transport requirements */
383 /** Secure channel requirements (\ref spdk_nvmf_treq_secure_channel) */
384 uint8_t secure_channel
: 2;
386 uint8_t reserved
: 6;
389 /** NVM subsystem port ID */
395 /** Admin max SQ size */
398 uint8_t reserved0
[22];
400 /** Transport service identifier */
401 uint8_t trsvcid
[SPDK_NVMF_TRSVCID_MAX_LEN
];
403 uint8_t reserved1
[192];
405 /** NVM subsystem qualified name */
408 /** Transport address */
409 uint8_t traddr
[SPDK_NVMF_TRADDR_MAX_LEN
];
411 /** Transport-specific address subtype */
412 union spdk_nvmf_transport_specific_address_subtype tsas
;
414 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page_entry
) == 1024, "Incorrect size");
416 struct spdk_nvmf_discovery_log_page
{
420 uint8_t reserved0
[1006];
421 struct spdk_nvmf_discovery_log_page_entry entries
[0];
423 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page
) == 1024, "Incorrect size");
425 /* RDMA Fabric specific definitions below */
427 #define SPDK_NVME_SGL_SUBTYPE_INVALIDATE_KEY 0xF
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];
437 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_request_private_data
) == 32, "Incorrect size");
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];
444 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_accept_private_data
) == 32, "Incorrect size");
446 struct spdk_nvmf_rdma_reject_private_data
{
447 uint16_t recfmt
; /* record format */
448 uint16_t sts
; /* status */
450 SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_reject_private_data
) == 4, "Incorrect size");
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
;
457 SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_rdma_private_data
) == 32, "Incorrect size");
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,
472 #endif /* __NVMF_SPEC_H__ */