]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/include/spdk/nvmf_spec.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / spdk / include / spdk / nvmf_spec.h
CommitLineData
7c673cae
FG
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 <stdint.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
52struct 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};
60SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_capsule_cmd) == 64, "Incorrect size");
61
62/* Fabric Command Set */
63#define SPDK_NVME_OPC_FABRIC 0x7f
64
65enum 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
74enum 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 */
87enum 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 */
98enum 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 */
118enum 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 */
126enum 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 */
140enum 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 */
160enum 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 */
171enum 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
182struct 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};
196SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_recv_cmd) == 64, "Incorrect size");
197
198struct 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};
212SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_auth_send_cmd) == 64, "Incorrect size");
213
214struct 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};
222SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_data) == 1024, "Incorrect size");
223
224struct 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};
239SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_connect_cmd) == 64, "Incorrect size");
240
241struct 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};
263SPDK_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
268struct 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 : 2;
276 uint8_t reserved : 6;
277 } attrib;
278 uint8_t reserved3[3];
279 uint32_t ofst;
280 uint8_t reserved4[16];
281};
282SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_cmd) == 64, "Incorrect size");
283
284struct 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};
298SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_get_rsp) == 16, "Incorrect size");
299
300struct 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 : 2;
308 uint8_t reserved : 6;
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};
323SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_fabric_prop_set_cmd) == 64, "Incorrect size");
324
325#define SPDK_NVMF_NQN_MAX_LEN 223
326#define SPDK_NVMF_DISCOVERY_NQN "nqn.2014-08.org.nvmexpress.discovery"
327
328#define SPDK_NVMF_TRADDR_MAX_LEN 256
329#define SPDK_NVMF_TRSVCID_MAX_LEN 32
330
331/** RDMA transport-specific address subtype */
332struct spdk_nvmf_rdma_transport_specific_address_subtype {
333 /** RDMA QP service type (\ref spdk_nvmf_rdma_qptype) */
334 uint8_t rdma_qptype;
335
336 /** RDMA provider type (\ref spdk_nvmf_rdma_prtype) */
337 uint8_t rdma_prtype;
338
339 /** RDMA connection management service (\ref spdk_nvmf_rdma_cms) */
340 uint8_t rdma_cms;
341
342 uint8_t reserved0[5];
343
344 /** RDMA partition key for AF_IB */
345 uint16_t rdma_pkey;
346
347 uint8_t reserved2[246];
348};
349SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_transport_specific_address_subtype) == 256,
350 "Incorrect size");
351
352/** Transport-specific address subtype */
353union spdk_nvmf_transport_specific_address_subtype {
354 uint8_t raw[256];
355
356 /** RDMA */
357 struct spdk_nvmf_rdma_transport_specific_address_subtype rdma;
358};
359SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_transport_specific_address_subtype) == 256,
360 "Incorrect size");
361
362/**
363 * Discovery Log Page entry
364 */
365struct spdk_nvmf_discovery_log_page_entry {
366 /** Transport type (\ref spdk_nvmf_trtype) */
367 uint8_t trtype;
368
369 /** Address family (\ref spdk_nvmf_adrfam) */
370 uint8_t adrfam;
371
372 /** Subsystem type (\ref spdk_nvmf_subtype) */
373 uint8_t subtype;
374
375 /** Transport requirements */
376 struct {
377 /** Secure channel requirements (\ref spdk_nvmf_treq_secure_channel) */
378 uint8_t secure_channel : 2;
379
380 uint8_t reserved : 6;
381 } treq;
382
383 /** NVM subsystem port ID */
384 uint16_t portid;
385
386 /** Controller ID */
387 uint16_t cntlid;
388
389 /** Admin max SQ size */
390 uint16_t asqsz;
391
392 uint8_t reserved0[22];
393
394 /** Transport service identifier */
395 uint8_t trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN];
396
397 uint8_t reserved1[192];
398
399 /** NVM subsystem qualified name */
400 uint8_t subnqn[256];
401
402 /** Transport address */
403 uint8_t traddr[SPDK_NVMF_TRADDR_MAX_LEN];
404
405 /** Transport-specific address subtype */
406 union spdk_nvmf_transport_specific_address_subtype tsas;
407};
408SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page_entry) == 1024, "Incorrect size");
409
410struct spdk_nvmf_discovery_log_page {
411 uint64_t genctr;
412 uint64_t numrec;
413 uint16_t recfmt;
414 uint8_t reserved0[1006];
415 struct spdk_nvmf_discovery_log_page_entry entries[0];
416};
417SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page) == 1024, "Incorrect size");
418
419/* RDMA Fabric specific definitions below */
420
421#define SPDK_NVME_SGL_SUBTYPE_INVALIDATE_KEY 0xF
422
423struct spdk_nvmf_rdma_request_private_data {
424 uint16_t recfmt; /* record format */
425 uint16_t qid; /* queue id */
426 uint16_t hrqsize; /* host receive queue size */
427 uint16_t hsqsize; /* host send queue size */
428 uint16_t cntlid; /* controller id */
429 uint8_t reserved[22];
430};
431SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_request_private_data) == 32, "Incorrect size");
432
433struct spdk_nvmf_rdma_accept_private_data {
434 uint16_t recfmt; /* record format */
435 uint16_t crqsize; /* controller receive queue size */
436 uint8_t reserved[28];
437};
438SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_accept_private_data) == 32, "Incorrect size");
439
440struct spdk_nvmf_rdma_reject_private_data {
441 uint16_t recfmt; /* record format */
442 struct spdk_nvme_status status;
443};
444SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_reject_private_data) == 4, "Incorrect size");
445
446union spdk_nvmf_rdma_private_data {
447 struct spdk_nvmf_rdma_request_private_data pd_request;
448 struct spdk_nvmf_rdma_accept_private_data pd_accept;
449 struct spdk_nvmf_rdma_reject_private_data pd_reject;
450};
451SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_rdma_private_data) == 32, "Incorrect size");
452
453enum spdk_nvmf_rdma_transport_errors {
454 SPDK_NVMF_RDMA_ERROR_INVALID_PRIVATE_DATA_LENGTH = 0x1,
455 SPDK_NVMF_RDMA_ERROR_INVALID_RECFMT = 0x2,
456 SPDK_NVMF_RDMA_ERROR_INVALID_QID = 0x3,
457 SPDK_NVMF_RDMA_ERROR_INVALID_HSQSIZE = 0x4,
458 SPDK_NVMF_RDMA_ERROR_INVALID_HRQSIZE = 0x5,
459 SPDK_NVMF_RDMA_ERROR_NO_RESOURCES = 0x6,
460 SPDK_NVMF_RDMA_ERROR_INVALID_IRD = 0x7,
461 SPDK_NVMF_RDMA_ERROR_INVALID_ORD = 0x8,
462 SPDK_NVMF_RDMA_ERROR_INVALID_CNTLID = 0x9,
463};
464
465#pragma pack(pop)
466
467#endif /* __NVMF_SPEC_H__ */