Line data Source code
1 : /* SPDX-License-Identifier: BSD-3-Clause
2 : * Copyright (C) 2015 Intel Corporation. All rights reserved.
3 : * Copyright (c) 2019-2021 Mellanox Technologies LTD. All rights reserved.
4 : * Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
5 : * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
6 : */
7 :
8 : /** \file
9 : * NVMe driver public API
10 : */
11 :
12 : #ifndef SPDK_NVME_H
13 : #define SPDK_NVME_H
14 :
15 : #include "spdk/stdinc.h"
16 :
17 : #ifdef __cplusplus
18 : extern "C" {
19 : #endif
20 :
21 : #include "spdk/dma.h"
22 : #include "spdk/env.h"
23 : #include "spdk/keyring.h"
24 : #include "spdk/nvme_spec.h"
25 : #include "spdk/nvmf_spec.h"
26 :
27 : #define SPDK_NVME_TRANSPORT_NAME_FC "FC"
28 : #define SPDK_NVME_TRANSPORT_NAME_PCIE "PCIE"
29 : #define SPDK_NVME_TRANSPORT_NAME_RDMA "RDMA"
30 : #define SPDK_NVME_TRANSPORT_NAME_TCP "TCP"
31 : #define SPDK_NVME_TRANSPORT_NAME_VFIOUSER "VFIOUSER"
32 : #define SPDK_NVME_TRANSPORT_NAME_CUSTOM "CUSTOM"
33 :
34 : #define SPDK_NVMF_PRIORITY_MAX_LEN 4
35 :
36 : /**
37 : * Opaque handle to a controller. Returned by spdk_nvme_probe()'s attach_cb.
38 : */
39 : struct spdk_nvme_ctrlr;
40 :
41 : /**
42 : * NVMe controller initialization options.
43 : *
44 : * A pointer to this structure will be provided for each probe callback from spdk_nvme_probe() to
45 : * allow the user to request non-default options, and the actual options enabled on the controller
46 : * will be provided during the attach callback.
47 : */
48 : struct spdk_nvme_ctrlr_opts {
49 : /**
50 : * Number of I/O queues to request (used to set Number of Queues feature)
51 : */
52 : uint32_t num_io_queues;
53 :
54 : /**
55 : * Enable submission queue in controller memory buffer
56 : */
57 : bool use_cmb_sqs;
58 :
59 : /**
60 : * Don't initiate shutdown processing
61 : */
62 : bool no_shn_notification;
63 :
64 : /* Hole at bytes 6-7. */
65 : uint8_t reserved6[2];
66 :
67 : /**
68 : * Type of arbitration mechanism
69 : */
70 : enum spdk_nvme_cc_ams arb_mechanism;
71 :
72 : /**
73 : * Maximum number of commands that the controller may launch at one time. The
74 : * value is expressed as a power of two, valid values are from 0-7, and 7 means
75 : * unlimited.
76 : */
77 : uint8_t arbitration_burst;
78 :
79 : /**
80 : * Number of commands that may be executed from the low priority queue in each
81 : * arbitration round. This field is only valid when arb_mechanism is set to
82 : * SPDK_NVME_CC_AMS_WRR (weighted round robin).
83 : */
84 : uint8_t low_priority_weight;
85 :
86 : /**
87 : * Number of commands that may be executed from the medium priority queue in each
88 : * arbitration round. This field is only valid when arb_mechanism is set to
89 : * SPDK_NVME_CC_AMS_WRR (weighted round robin).
90 : */
91 : uint8_t medium_priority_weight;
92 :
93 : /**
94 : * Number of commands that may be executed from the high priority queue in each
95 : * arbitration round. This field is only valid when arb_mechanism is set to
96 : * SPDK_NVME_CC_AMS_WRR (weighted round robin).
97 : */
98 : uint8_t high_priority_weight;
99 :
100 : /**
101 : * Keep alive timeout in milliseconds (0 = disabled).
102 : *
103 : * The NVMe library will set the Keep Alive Timer feature to this value and automatically
104 : * send Keep Alive commands as needed. The library user must call
105 : * spdk_nvme_ctrlr_process_admin_completions() periodically to ensure Keep Alive commands
106 : * are sent.
107 : */
108 : uint32_t keep_alive_timeout_ms;
109 :
110 : /**
111 : * Specify the retry number when there is issue with the transport
112 : */
113 : uint8_t transport_retry_count;
114 :
115 : /* Hole at bytes 21-23. */
116 : uint8_t reserved21[3];
117 :
118 : /**
119 : * The queue depth of each NVMe I/O queue.
120 : */
121 : uint32_t io_queue_size;
122 :
123 : /**
124 : * The host NQN to use when connecting to NVMe over Fabrics controllers.
125 : *
126 : * If empty, a default value will be used.
127 : */
128 : char hostnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
129 :
130 : /**
131 : * The number of requests to allocate for each NVMe I/O queue.
132 : *
133 : * This should be at least as large as io_queue_size.
134 : *
135 : * A single I/O may allocate more than one request, since splitting may be necessary to
136 : * conform to the device's maximum transfer size, PRP list compatibility requirements,
137 : * or driver-assisted striping.
138 : */
139 : uint32_t io_queue_requests;
140 :
141 : /**
142 : * Source address for NVMe-oF connections.
143 : * Set src_addr and src_svcid to empty strings if no source address should be
144 : * specified.
145 : */
146 : char src_addr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
147 :
148 : /**
149 : * Source service ID (port) for NVMe-oF connections.
150 : * Set src_addr and src_svcid to empty strings if no source address should be
151 : * specified.
152 : */
153 : char src_svcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
154 :
155 : /**
156 : * The host identifier to use when connecting to controllers with 64-bit host ID support.
157 : *
158 : * Set to all zeroes to specify that no host ID should be provided to the controller.
159 : */
160 : uint8_t host_id[8];
161 :
162 : /**
163 : * The host identifier to use when connecting to controllers with extended (128-bit) host ID support.
164 : *
165 : * Set to all zeroes to specify that no host ID should be provided to the controller.
166 : */
167 : uint8_t extended_host_id[16];
168 :
169 : /* Hole at bytes 570-571. */
170 : uint8_t reserved570[2];
171 :
172 : /**
173 : * The I/O command set to select.
174 : *
175 : * If the requested command set is not supported, the controller
176 : * initialization process will not proceed. By default, the NVM
177 : * command set is used.
178 : */
179 : enum spdk_nvme_cc_css command_set;
180 :
181 : /**
182 : * Admin commands timeout in milliseconds (0 = no timeout).
183 : *
184 : * The timeout value is used for admin commands submitted internally
185 : * by the nvme driver during initialization, before the user is able
186 : * to call spdk_nvme_ctrlr_register_timeout_callback(). By default,
187 : * this is set to 120 seconds, users can change it in the probing
188 : * callback.
189 : */
190 : uint32_t admin_timeout_ms;
191 :
192 : /**
193 : * It is used for TCP transport.
194 : *
195 : * Set to true, means having header digest for the header in the NVMe/TCP PDU
196 : */
197 : bool header_digest;
198 :
199 : /**
200 : * It is used for TCP transport.
201 : *
202 : * Set to true, means having data digest for the data in the NVMe/TCP PDU
203 : */
204 : bool data_digest;
205 :
206 : /**
207 : * Disable logging of requests that are completed with error status.
208 : *
209 : * Defaults to 'false' (errors are logged).
210 : */
211 : bool disable_error_logging;
212 :
213 : /**
214 : * It is used for both RDMA & TCP transport
215 : * Specify the transport ACK timeout. The value should be in range 0-31 where 0 means
216 : * use driver-specific default value.
217 : * RDMA: The value is applied to each qpair
218 : * and affects the time that qpair waits for transport layer acknowledgement
219 : * until it retransmits a packet. The value should be chosen empirically
220 : * to meet the needs of a particular application. A low value means less time
221 : * the qpair waits for ACK which can increase the number of retransmissions.
222 : * A large value can increase the time the connection is closed.
223 : * The value of ACK timeout is calculated according to the formula
224 : * 4.096 * 2^(transport_ack_timeout) usec.
225 : * TCP: The value is applied to each qpair
226 : * and affects the time that qpair waits for transport layer acknowledgement
227 : * until connection is closed forcefully.
228 : * The value of ACK timeout is calculated according to the formula
229 : * 2^(transport_ack_timeout) msec.
230 : */
231 : uint8_t transport_ack_timeout;
232 :
233 : /**
234 : * The queue depth of NVMe Admin queue.
235 : */
236 : uint16_t admin_queue_size;
237 :
238 : /* Hole at bytes 586-591. */
239 : uint8_t reserved586[6];
240 :
241 : /**
242 : * The size of spdk_nvme_ctrlr_opts according to the caller of this library is used for ABI
243 : * compatibility. The library uses this field to know how many fields in this
244 : * structure are valid. And the library will populate any remaining fields with default values.
245 : */
246 : size_t opts_size;
247 :
248 : /**
249 : * The amount of time to spend before timing out during fabric connect on qpairs associated with
250 : * this controller in microseconds.
251 : */
252 : uint64_t fabrics_connect_timeout_us;
253 :
254 : /**
255 : * Disable reading ANA log page. The upper layer should reading ANA log page instead
256 : * if set to true.
257 : *
258 : * Default is `false` (ANA log page is read).
259 : */
260 : bool disable_read_ana_log_page;
261 :
262 : /* Hole at bytes 610-616. */
263 : uint8_t reserved610[7];
264 :
265 : /**
266 : * Disable reading CHANGED_NS_LIST log page in response to an NS_ATTR_CHANGED AEN
267 : * The upper layer should reading CHANGED_NS_LIST log page instead if set to true.
268 : *
269 : * Default is `false` (CHANGED_NS_LIST log page is read).
270 : */
271 : uint8_t disable_read_changed_ns_list_log_page;
272 :
273 : /* Hole at bytes 617-816. */
274 : uint8_t reserved617[200];
275 :
276 : /**
277 : * It is used for RDMA transport.
278 : *
279 : * Set the IP protocol type of service value for RDMA transport. Default is 0, which means that the TOS will not be set.
280 : */
281 : uint8_t transport_tos;
282 :
283 : /**
284 : * Pre-shared key for NVMe/TCP's TLS connection.
285 : */
286 : struct spdk_key *tls_psk;
287 :
288 : /**
289 : * In-band authentication DH-HMAC-CHAP host key.
290 : */
291 : struct spdk_key *dhchap_key;
292 :
293 : /**
294 : * In-band authentication DH-HMAC-CHAP controller key.
295 : */
296 : struct spdk_key *dhchap_ctrlr_key;
297 :
298 : /**
299 : * Allowed digests in in-band authentication. Each bit corresponds to one of the
300 : * spdk_nvmf_dhchap_hash values.
301 : */
302 : uint32_t dhchap_digests;
303 :
304 : /**
305 : * Allowed Diffie-Hellman groups in in-band authentication. Each bit corresponds to one of
306 : * the spdk_nvmf_dhchap_dhgroup values.
307 : */
308 : uint32_t dhchap_dhgroups;
309 : };
310 : SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ctrlr_opts) == 856, "Incorrect size");
311 :
312 : /**
313 : * NVMe acceleration operation callback.
314 : *
315 : * \param cb_arg The user provided arg which is passed to the corresponding accelerated function call
316 : * defined in struct spdk_nvme_accel_fn_table.
317 : * \param status 0 if it completed successfully, or negative errno if it failed.
318 : */
319 : typedef void (*spdk_nvme_accel_completion_cb)(void *cb_arg, int status);
320 :
321 : /**
322 : * Completion callback for a single operation in a sequence.
323 : *
324 : * \param cb_arg Argument provided by the user when appending an operation to a sequence.
325 : */
326 : typedef void (*spdk_nvme_accel_step_cb)(void *cb_arg);
327 :
328 : /**
329 : * Function table for the NVMe accelerator device.
330 : *
331 : * This table provides a set of APIs to allow user to leverage
332 : * accelerator functions.
333 : */
334 : struct spdk_nvme_accel_fn_table {
335 : /**
336 : * The size of spdk_nvme_accel_fun_table according to the caller of
337 : * this library is used for ABI compatibility. The library uses this
338 : * field to know how many fields in this structure are valid.
339 : * And the library will populate any remaining fields with default values.
340 : * Newly added fields should be put at the end of the struct.
341 : */
342 : size_t table_size;
343 :
344 : /* Hole at bytes 8-15. */
345 : uint8_t reserved8[8];
346 :
347 : /** Finish an accel sequence */
348 : void (*finish_sequence)(void *seq, spdk_nvme_accel_completion_cb cb_fn, void *cb_arg);
349 :
350 : /** Reverse an accel sequence */
351 : void (*reverse_sequence)(void *seq);
352 :
353 : /** Abort an accel sequence */
354 : void (*abort_sequence)(void *seq);
355 :
356 : /** Append a crc32c operation to a sequence */
357 : int (*append_crc32c)(void *ctx, void **seq, uint32_t *dst, struct iovec *iovs, uint32_t iovcnt,
358 : struct spdk_memory_domain *memory_domain, void *domain_ctx,
359 : uint32_t seed, spdk_nvme_accel_step_cb cb_fn, void *cb_arg);
360 :
361 : /** Append a copy operation to a sequence */
362 : int (*append_copy)(void *ctx, void **seq, struct iovec *dst_iovs, uint32_t dst_iovcnt,
363 : struct spdk_memory_domain *dst_domain, void *dst_domain_ctx,
364 : struct iovec *src_iovs, uint32_t src_iovcnt,
365 : struct spdk_memory_domain *src_domain, void *src_domain_ctx,
366 : spdk_nvme_accel_step_cb cb_fn, void *cb_arg);
367 : };
368 :
369 : /**
370 : * Indicate whether a ctrlr handle is associated with a Discovery controller.
371 : *
372 : * \param ctrlr Opaque handle to NVMe controller.
373 : *
374 : * \return true if a discovery controller, else false.
375 : */
376 : bool spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr);
377 :
378 : /**
379 : * Indicate whether a ctrlr handle is associated with a fabrics controller.
380 : *
381 : * \param ctrlr Opaque handle to NVMe controller.
382 : *
383 : * \return true if a fabrics controller, else false.
384 : */
385 : bool spdk_nvme_ctrlr_is_fabrics(struct spdk_nvme_ctrlr *ctrlr);
386 :
387 : /**
388 : * Get the default options for the creation of a specific NVMe controller.
389 : *
390 : * \param[out] opts Will be filled with the default option.
391 : * \param opts_size Must be set to sizeof(struct spdk_nvme_ctrlr_opts).
392 : */
393 : void spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts,
394 : size_t opts_size);
395 :
396 : /*
397 : * Get the options in use for a given controller.
398 : *
399 : * \param ctrlr Opaque handle to NVMe controller.
400 : */
401 : const struct spdk_nvme_ctrlr_opts *spdk_nvme_ctrlr_get_opts(struct spdk_nvme_ctrlr *ctrlr);
402 :
403 : /**
404 : * Reason for qpair disconnect at the transport layer.
405 : *
406 : * NONE implies that the qpair is still connected while UNKNOWN means that the
407 : * qpair is disconnected, but the cause was not apparent.
408 : */
409 : enum spdk_nvme_qp_failure_reason {
410 : SPDK_NVME_QPAIR_FAILURE_NONE = 0,
411 : SPDK_NVME_QPAIR_FAILURE_LOCAL,
412 : SPDK_NVME_QPAIR_FAILURE_REMOTE,
413 : SPDK_NVME_QPAIR_FAILURE_UNKNOWN,
414 : SPDK_NVME_QPAIR_FAILURE_RESET,
415 : };
416 :
417 : typedef enum spdk_nvme_qp_failure_reason spdk_nvme_qp_failure_reason;
418 :
419 : /**
420 : * NVMe library transports
421 : *
422 : * NOTE: These are mapped directly to the NVMe over Fabrics TRTYPE values, except for PCIe,
423 : * which is a special case since NVMe over Fabrics does not define a TRTYPE for local PCIe.
424 : *
425 : * Currently, this uses 256 for PCIe which is intentionally outside of the 8-bit range of TRTYPE.
426 : * If the NVMe-oF specification ever defines a PCIe TRTYPE, this should be updated.
427 : */
428 : enum spdk_nvme_transport_type {
429 : /**
430 : * PCIe Transport (locally attached devices)
431 : */
432 : SPDK_NVME_TRANSPORT_PCIE = 256,
433 :
434 : /**
435 : * RDMA Transport (RoCE, iWARP, etc.)
436 : */
437 : SPDK_NVME_TRANSPORT_RDMA = SPDK_NVMF_TRTYPE_RDMA,
438 :
439 : /**
440 : * Fibre Channel (FC) Transport
441 : */
442 : SPDK_NVME_TRANSPORT_FC = SPDK_NVMF_TRTYPE_FC,
443 :
444 : /**
445 : * TCP Transport
446 : */
447 : SPDK_NVME_TRANSPORT_TCP = SPDK_NVMF_TRTYPE_TCP,
448 :
449 : /**
450 : * Custom VFIO User Transport (Not spec defined)
451 : */
452 : SPDK_NVME_TRANSPORT_VFIOUSER = 1024,
453 :
454 : /**
455 : * Custom Transport (Not spec defined)
456 : */
457 : SPDK_NVME_TRANSPORT_CUSTOM = 4096,
458 :
459 : /**
460 : * Custom Fabric Transport (Not spec defined)
461 : */
462 : SPDK_NVME_TRANSPORT_CUSTOM_FABRICS = 4097,
463 : };
464 :
465 287 : static inline bool spdk_nvme_trtype_is_fabrics(enum spdk_nvme_transport_type trtype)
466 : {
467 : /* We always define non-fabrics trtypes outside of the 8-bit range
468 : * of NVMe-oF trtype.
469 : */
470 287 : return trtype <= UINT8_MAX || trtype == SPDK_NVME_TRANSPORT_CUSTOM_FABRICS;
471 : }
472 :
473 : /* typedef added for coding style reasons */
474 : typedef enum spdk_nvme_transport_type spdk_nvme_transport_type_t;
475 :
476 : /**
477 : * NVMe transport identifier.
478 : *
479 : * This identifies a unique endpoint on an NVMe fabric.
480 : *
481 : * A string representation of a transport ID may be converted to this type using
482 : * spdk_nvme_transport_id_parse().
483 : */
484 : struct spdk_nvme_transport_id {
485 : /**
486 : * NVMe transport string.
487 : */
488 : char trstring[SPDK_NVMF_TRSTRING_MAX_LEN + 1];
489 :
490 : /**
491 : * NVMe transport type.
492 : */
493 : enum spdk_nvme_transport_type trtype;
494 :
495 : /**
496 : * Address family of the transport address.
497 : *
498 : * For PCIe, this value is ignored.
499 : */
500 : enum spdk_nvmf_adrfam adrfam;
501 :
502 : /**
503 : * Transport address of the NVMe-oF endpoint. For transports which use IP
504 : * addressing (e.g. RDMA), this should be an IP address. For PCIe, this
505 : * can either be a zero length string (the whole bus) or a PCI address
506 : * in the format DDDD:BB:DD.FF or DDDD.BB.DD.FF. For FC the string is
507 : * formatted as: nn-0xWWNN:pn-0xWWPN” where WWNN is the Node_Name of the
508 : * target NVMe_Port and WWPN is the N_Port_Name of the target NVMe_Port.
509 : */
510 : char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
511 :
512 : /**
513 : * Transport service id of the NVMe-oF endpoint. For transports which use
514 : * IP addressing (e.g. RDMA), this field should be the port number. For PCIe,
515 : * and FC this is always a zero length string.
516 : */
517 : char trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
518 :
519 : /**
520 : * Subsystem NQN of the NVMe over Fabrics endpoint. May be a zero length string.
521 : */
522 : char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
523 :
524 : /**
525 : * The Transport connection priority of the NVMe-oF endpoint. Currently this is
526 : * only supported by posix based sock implementation on Kernel TCP stack. More
527 : * information of this field can be found from the socket(7) man page.
528 : */
529 : int priority;
530 : };
531 :
532 : /**
533 : * NVMe host identifier
534 : *
535 : * Used for defining the host identity for an NVMe-oF connection.
536 : *
537 : * In terms of configuration, this object can be considered a subtype of TransportID
538 : * Please see etc/spdk/nvmf.conf.in for more details.
539 : *
540 : * A string representation of this type may be converted to this type using
541 : * spdk_nvme_host_id_parse().
542 : */
543 : struct spdk_nvme_host_id {
544 : /**
545 : * Transport address to be used by the host when connecting to the NVMe-oF endpoint.
546 : * May be an IP address or a zero length string for transports which
547 : * use IP addressing (e.g. RDMA).
548 : * For PCIe and FC this is always a zero length string.
549 : */
550 : char hostaddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
551 :
552 : /**
553 : * Transport service ID used by the host when connecting to the NVMe.
554 : * May be a port number or a zero length string for transports which
555 : * use IP addressing (e.g. RDMA).
556 : * For PCIe and FC this is always a zero length string.
557 : */
558 : char hostsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
559 : };
560 :
561 : struct spdk_nvme_rdma_device_stat {
562 : const char *name;
563 : uint64_t polls;
564 : uint64_t idle_polls;
565 : uint64_t completions;
566 : uint64_t queued_requests;
567 : uint64_t total_send_wrs;
568 : uint64_t send_doorbell_updates;
569 : uint64_t total_recv_wrs;
570 : uint64_t recv_doorbell_updates;
571 : };
572 :
573 : struct spdk_nvme_pcie_stat {
574 : uint64_t polls;
575 : uint64_t idle_polls;
576 : uint64_t completions;
577 : uint64_t cq_mmio_doorbell_updates;
578 : uint64_t cq_shadow_doorbell_updates;
579 : uint64_t submitted_requests;
580 : uint64_t queued_requests;
581 : uint64_t sq_mmio_doorbell_updates;
582 : uint64_t sq_shadow_doorbell_updates;
583 : };
584 :
585 : struct spdk_nvme_tcp_stat {
586 : uint64_t polls;
587 : uint64_t idle_polls;
588 : uint64_t socket_completions;
589 : uint64_t nvme_completions;
590 : uint64_t submitted_requests;
591 : uint64_t queued_requests;
592 : };
593 :
594 : struct spdk_nvme_transport_poll_group_stat {
595 : spdk_nvme_transport_type_t trtype;
596 : union {
597 : struct {
598 : uint32_t num_devices;
599 : struct spdk_nvme_rdma_device_stat *device_stats;
600 : } rdma;
601 : struct spdk_nvme_pcie_stat pcie;
602 : struct spdk_nvme_tcp_stat tcp;
603 : };
604 : };
605 :
606 : struct spdk_nvme_poll_group_stat {
607 : uint32_t num_transports;
608 : struct spdk_nvme_transport_poll_group_stat **transport_stat;
609 : };
610 :
611 : /*
612 : * Controller support flags
613 : *
614 : * Used for identifying if the controller supports these flags.
615 : */
616 : enum spdk_nvme_ctrlr_flags {
617 : SPDK_NVME_CTRLR_SGL_SUPPORTED = 1 << 0, /**< SGL is supported */
618 : SPDK_NVME_CTRLR_SECURITY_SEND_RECV_SUPPORTED = 1 << 1, /**< security send/receive is supported */
619 : SPDK_NVME_CTRLR_WRR_SUPPORTED = 1 << 2, /**< Weighted Round Robin is supported */
620 : SPDK_NVME_CTRLR_COMPARE_AND_WRITE_SUPPORTED = 1 << 3, /**< Compare and write fused operations supported */
621 : SPDK_NVME_CTRLR_SGL_REQUIRES_DWORD_ALIGNMENT = 1 << 4, /**< Dword alignment is required for SGL */
622 : SPDK_NVME_CTRLR_ZONE_APPEND_SUPPORTED = 1 << 5, /**< Zone Append is supported (within Zoned Namespaces) */
623 : SPDK_NVME_CTRLR_DIRECTIVES_SUPPORTED = 1 << 6, /**< The Directives is supported */
624 : SPDK_NVME_CTRLR_MPTR_SGL_SUPPORTED = 1 << 7, /**< MPTR containing SGL descriptor is supported */
625 : SPDK_NVME_CTRLR_ACCEL_SEQUENCE_SUPPORTED = 1 << 8, /**< Support for sending I/O requests with accel sequence */
626 : };
627 :
628 : /**
629 : * Structure with optional IO request parameters
630 : */
631 : struct spdk_nvme_ns_cmd_ext_io_opts {
632 : /** size of this structure in bytes, use SPDK_SIZEOF(opts, last_member) to obtain it */
633 : size_t size;
634 : /** Memory domain which describes data payload in IO request. The controller must support
635 : * the corresponding memory domain type, refer to \ref spdk_nvme_ctrlr_get_memory_domains */
636 : struct spdk_memory_domain *memory_domain;
637 : /** User context to be passed to memory domain operations */
638 : void *memory_domain_ctx;
639 : /** Flags for this IO, defined in nvme_spec.h */
640 : uint32_t io_flags;
641 : /* Hole at bytes 28-31. */
642 : uint8_t reserved28[4];
643 : /** Virtual address pointer to the metadata payload, the length of metadata is specified by \ref spdk_nvme_ns_get_md_size */
644 : void *metadata;
645 : /** Application tag mask to use end-to-end protection information. */
646 : uint16_t apptag_mask;
647 : /** Application tag to use end-to-end protection information. */
648 : uint16_t apptag;
649 : /** Command dword 13 specific field. */
650 : uint32_t cdw13;
651 : /** Accel sequence (only valid if SPDK_NVME_CTRLR_ACCEL_SEQUENCE_SUPPORTED is set and the
652 : * qpair is part of a poll group).
653 : */
654 : void *accel_sequence;
655 : };
656 : SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ns_cmd_ext_io_opts) == 56, "Incorrect size");
657 :
658 : /**
659 : * Parse the string representation of a transport ID.
660 : *
661 : * \param trid Output transport ID structure (must be allocated and initialized by caller).
662 : * \param str Input string representation of a transport ID to parse.
663 : *
664 : * str must be a zero-terminated C string containing one or more key:value pairs
665 : * separated by whitespace.
666 : *
667 : * Key | Value
668 : * ------------ | -----
669 : * trtype | Transport type (e.g. PCIe, RDMA)
670 : * adrfam | Address family (e.g. IPv4, IPv6)
671 : * traddr | Transport address (e.g. 0000:04:00.0 for PCIe, 192.168.100.8 for RDMA, or WWN for FC)
672 : * trsvcid | Transport service identifier (e.g. 4420)
673 : * subnqn | Subsystem NQN
674 : *
675 : * Unspecified fields of trid are left unmodified, so the caller must initialize
676 : * trid (for example, memset() to 0) before calling this function.
677 : *
678 : * \return 0 if parsing was successful and trid is filled out, or negated errno
679 : * values on failure.
680 : */
681 : int spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *str);
682 :
683 :
684 : /**
685 : * Fill in the trtype and trstring fields of this trid based on a known transport type.
686 : *
687 : * \param trid The trid to fill out.
688 : * \param trtype The transport type to use for filling the trid fields. Only valid for
689 : * transport types referenced in the NVMe-oF spec.
690 : */
691 : void spdk_nvme_trid_populate_transport(struct spdk_nvme_transport_id *trid,
692 : enum spdk_nvme_transport_type trtype);
693 :
694 : /**
695 : * Parse the string representation of a host ID.
696 : *
697 : * \param hostid Output host ID structure (must be allocated and initialized by caller).
698 : * \param str Input string representation of a transport ID to parse (hostid is a sub-configuration).
699 : *
700 : * str must be a zero-terminated C string containing one or more key:value pairs
701 : * separated by whitespace.
702 : *
703 : * Key | Value
704 : * -------------- | -----
705 : * hostaddr | Transport address (e.g. 192.168.100.8 for RDMA)
706 : * hostsvcid | Transport service identifier (e.g. 4420)
707 : *
708 : * Unspecified fields of trid are left unmodified, so the caller must initialize
709 : * hostid (for example, memset() to 0) before calling this function.
710 : *
711 : * This function should not be used with Fiber Channel or PCIe as these transports
712 : * do not require host information for connections.
713 : *
714 : * \return 0 if parsing was successful and hostid is filled out, or negated errno
715 : * values on failure.
716 : */
717 : int spdk_nvme_host_id_parse(struct spdk_nvme_host_id *hostid, const char *str);
718 :
719 : /**
720 : * Parse the string representation of a transport ID transport type into the trid struct.
721 : *
722 : * \param trid The trid to write to
723 : * \param trstring Input string representation of transport type (e.g. "PCIe", "RDMA").
724 : *
725 : * \return 0 if parsing was successful and trtype is filled out, or negated errno
726 : * values if the provided string was an invalid transport string.
727 : */
728 : int spdk_nvme_transport_id_populate_trstring(struct spdk_nvme_transport_id *trid,
729 : const char *trstring);
730 :
731 : /**
732 : * Parse the string representation of a transport ID transport type.
733 : *
734 : * \param trtype Output transport type (allocated by caller).
735 : * \param str Input string representation of transport type (e.g. "PCIe", "RDMA").
736 : *
737 : * \return 0 if parsing was successful and trtype is filled out, or negated errno
738 : * values on failure.
739 : */
740 : int spdk_nvme_transport_id_parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str);
741 :
742 : /**
743 : * Look up the string representation of a transport ID transport type.
744 : *
745 : * \param trtype Transport type to convert.
746 : *
747 : * \return static string constant describing trtype, or NULL if trtype not found.
748 : */
749 : const char *spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype);
750 :
751 : /**
752 : * Look up the string representation of a transport ID address family.
753 : *
754 : * \param adrfam Address family to convert.
755 : *
756 : * \return static string constant describing adrfam, or NULL if adrfam not found.
757 : */
758 : const char *spdk_nvme_transport_id_adrfam_str(enum spdk_nvmf_adrfam adrfam);
759 :
760 : /**
761 : * Parse the string representation of a transport ID address family.
762 : *
763 : * \param adrfam Output address family (allocated by caller).
764 : * \param str Input string representation of address family (e.g. "IPv4", "IPv6").
765 : *
766 : * \return 0 if parsing was successful and adrfam is filled out, or negated errno
767 : * values on failure.
768 : */
769 : int spdk_nvme_transport_id_parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const char *str);
770 :
771 : /**
772 : * Compare two transport IDs.
773 : *
774 : * The result of this function may be used to sort transport IDs in a consistent
775 : * order; however, the comparison result is not guaranteed to be consistent across
776 : * library versions.
777 : *
778 : * This function uses a case-insensitive comparison for string fields, but it does
779 : * not otherwise normalize the transport ID. It is the caller's responsibility to
780 : * provide the transport IDs in a consistent format.
781 : *
782 : * \param trid1 First transport ID to compare.
783 : * \param trid2 Second transport ID to compare.
784 : *
785 : * \return 0 if trid1 == trid2, less than 0 if trid1 < trid2, greater than 0 if
786 : * trid1 > trid2.
787 : */
788 : int spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
789 : const struct spdk_nvme_transport_id *trid2);
790 :
791 : /**
792 : * Parse the string representation of PI check settings (prchk:guard|reftag)
793 : *
794 : * \param prchk_flags Output PI check flags.
795 : * \param str Input string representation of PI check settings.
796 : *
797 : * \return 0 if parsing was successful and prchk_flags is set, or negated errno
798 : * values on failure.
799 : */
800 : int spdk_nvme_prchk_flags_parse(uint32_t *prchk_flags, const char *str);
801 :
802 : /**
803 : * Look up the string representation of PI check settings (prchk:guard|reftag)
804 : *
805 : * \param prchk_flags PI check flags to convert.
806 : *
807 : * \return static string constant describing PI check settings. If prchk_flags is 0,
808 : * NULL is returned.
809 : */
810 : const char *spdk_nvme_prchk_flags_str(uint32_t prchk_flags);
811 :
812 : /**
813 : * Determine whether the NVMe library can handle a specific NVMe over Fabrics
814 : * transport type.
815 : *
816 : * \param trtype NVMe over Fabrics transport type to check.
817 : *
818 : * \return true if trtype is supported or false if it is not supported or if
819 : * SPDK_NVME_TRANSPORT_CUSTOM is supplied as trtype since it can represent multiple
820 : * transports.
821 : */
822 : bool spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype);
823 :
824 : /**
825 : * Determine whether the NVMe library can handle a specific NVMe over Fabrics
826 : * transport type.
827 : *
828 : * \param transport_name Name of the NVMe over Fabrics transport type to check.
829 : *
830 : * \return true if transport_name is supported or false if it is not supported.
831 : */
832 : bool spdk_nvme_transport_available_by_name(const char *transport_name);
833 :
834 : /**
835 : * Callback for spdk_nvme_probe() enumeration.
836 : *
837 : * \param cb_ctx Opaque value passed to spdk_nvme_probe().
838 : * \param trid NVMe transport identifier.
839 : * \param opts NVMe controller initialization options. This structure will be
840 : * populated with the default values on entry, and the user callback may update
841 : * any options to request a different value. The controller may not support all
842 : * requested parameters, so the final values will be provided during the attach
843 : * callback.
844 : *
845 : * \return true to attach to this device.
846 : */
847 : typedef bool (*spdk_nvme_probe_cb)(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
848 : struct spdk_nvme_ctrlr_opts *opts);
849 :
850 : /**
851 : * Callback for spdk_nvme_attach() to report a device that has been attached to
852 : * the userspace NVMe driver.
853 : *
854 : * \param cb_ctx Opaque value passed to spdk_nvme_attach_cb().
855 : * \param trid NVMe transport identifier.
856 : * \param ctrlr Opaque handle to NVMe controller.
857 : * \param opts NVMe controller initialization options that were actually used.
858 : * Options may differ from the requested options from the attach call depending
859 : * on what the controller supports.
860 : */
861 : typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
862 : struct spdk_nvme_ctrlr *ctrlr,
863 : const struct spdk_nvme_ctrlr_opts *opts);
864 :
865 : /**
866 : * Callback for spdk_nvme_probe*_ext() to report a device that has been probed but
867 : * unable to attach to the userspace NVMe driver.
868 : *
869 : * \param cb_ctx Opaque value passed to spdk_nvme_probe*_ext().
870 : * \param trid NVMe transport identifier.
871 : * \param rc Negative error code that provides information about the failure.
872 : */
873 : typedef void (*spdk_nvme_attach_fail_cb)(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
874 : int rc);
875 :
876 : /**
877 : * Callback for spdk_nvme_remove() to report that a device attached to the userspace
878 : * NVMe driver has been removed from the system.
879 : *
880 : * The controller will remain in a failed state (any new I/O submitted will fail).
881 : *
882 : * The controller must be detached from the userspace driver by calling spdk_nvme_detach()
883 : * once the controller is no longer in use. It is up to the library user to ensure
884 : * that no other threads are using the controller before calling spdk_nvme_detach().
885 : *
886 : * \param cb_ctx Opaque value passed to spdk_nvme_remove_cb().
887 : * \param ctrlr NVMe controller instance that was removed.
888 : */
889 : typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr);
890 :
891 : typedef bool (*spdk_nvme_pcie_hotplug_filter_cb)(const struct spdk_pci_addr *addr);
892 :
893 : /**
894 : * Register the associated function to allow filtering of hot-inserted PCIe SSDs.
895 : *
896 : * If an application is using spdk_nvme_probe() to detect hot-inserted SSDs,
897 : * this function may be used to register a function to filter those SSDs.
898 : * If the filter function returns true, the nvme library will notify the SPDK
899 : * env layer to allow probing of the device.
900 : *
901 : * Registering a filter function is optional. If none is registered, the nvme
902 : * library will allow probing of all hot-inserted SSDs.
903 : *
904 : * \param filter_cb Filter function callback routine
905 : */
906 : void
907 : spdk_nvme_pcie_set_hotplug_filter(spdk_nvme_pcie_hotplug_filter_cb filter_cb);
908 :
909 : /**
910 : * Enumerate the bus indicated by the transport ID and attach the userspace NVMe
911 : * driver to each device found if desired.
912 : *
913 : * This function is not thread safe and should only be called from one thread at
914 : * a time while no other threads are actively using any NVMe devices.
915 : *
916 : * If called from a secondary process, only devices that have been attached to
917 : * the userspace driver in the primary process will be probed.
918 : *
919 : * If called more than once, only devices that are not already attached to the
920 : * SPDK NVMe driver will be reported.
921 : *
922 : * To stop using the the controller and release its associated resources,
923 : * call spdk_nvme_detach() with the spdk_nvme_ctrlr instance from the attach_cb()
924 : * function.
925 : *
926 : * \param trid The transport ID indicating which bus to enumerate. If the trtype
927 : * is PCIe or trid is NULL, this will scan the local PCIe bus. If the trtype is
928 : * fabrics (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an
929 : * NVMe-oF discovery service.
930 : * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of
931 : * the callbacks.
932 : * \param probe_cb will be called once per NVMe device found in the system.
933 : * \param attach_cb will be called for devices for which probe_cb returned true
934 : * once that NVMe controller has been attached to the userspace driver.
935 : * \param remove_cb will be called for devices that were attached in a previous
936 : * spdk_nvme_probe() call but are no longer attached to the system. Optional;
937 : * specify NULL if removal notices are not desired.
938 : *
939 : * \return 0 on success, -1 on failure.
940 : */
941 : int spdk_nvme_probe(const struct spdk_nvme_transport_id *trid,
942 : void *cb_ctx,
943 : spdk_nvme_probe_cb probe_cb,
944 : spdk_nvme_attach_cb attach_cb,
945 : spdk_nvme_remove_cb remove_cb);
946 :
947 : /**
948 : * Enumerate the bus indicated by the transport ID and attach the userspace NVMe
949 : * driver to each device found if desired.
950 : *
951 : * This works just the same as spdk_nvme_probe(), except that it calls attach_fail_cb
952 : * for devices that are probed but unabled to attach.
953 : *
954 : * \param trid The transport ID indicating which bus to enumerate. If the trtype
955 : * is PCIe or trid is NULL, this will scan the local PCIe bus. If the trtype is
956 : * fabrics (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an
957 : * NVMe-oF discovery service.
958 : * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of
959 : * the callbacks.
960 : * \param probe_cb will be called once per NVMe device found in the system.
961 : * \param attach_cb will be called for devices for which probe_cb returned true
962 : * once that NVMe controller has been attached to the userspace driver.
963 : * \param attach_fail_cb will be called for devices which probe_cb returned true
964 : * but failed to attach to the userspace driver.
965 : * \param remove_cb will be called for devices that were attached in a previous
966 : * spdk_nvme_probe() call but are no longer attached to the system. Optional;
967 : * specify NULL if removal notices are not desired.
968 : *
969 : * \return 0 on success, -1 on failure.
970 : */
971 : int spdk_nvme_probe_ext(const struct spdk_nvme_transport_id *trid,
972 : void *cb_ctx,
973 : spdk_nvme_probe_cb probe_cb,
974 : spdk_nvme_attach_cb attach_cb,
975 : spdk_nvme_attach_fail_cb attach_fail_cb,
976 : spdk_nvme_remove_cb remove_cb);
977 :
978 : /**
979 : * Connect the NVMe driver to the device located at the given transport ID.
980 : *
981 : * This function is not thread safe and should only be called from one thread at
982 : * a time while no other threads are actively using this NVMe device.
983 : *
984 : * If called from a secondary process, only the device that has been attached to
985 : * the userspace driver in the primary process will be connected.
986 : *
987 : * If connecting to multiple controllers, it is suggested to use spdk_nvme_probe()
988 : * and filter the requested controllers with the probe callback. For PCIe controllers,
989 : * spdk_nvme_probe() will be more efficient since the controller resets will happen
990 : * in parallel.
991 : *
992 : * To stop using the the controller and release its associated resources, call
993 : * spdk_nvme_detach() with the spdk_nvme_ctrlr instance returned by this function.
994 : *
995 : * \param trid The transport ID indicating which device to connect. If the trtype
996 : * is PCIe, this will connect the local PCIe bus. If the trtype is fabrics
997 : * (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an NVMe-oF
998 : * service.
999 : * \param opts NVMe controller initialization options. Default values will be used
1000 : * if the user does not specify the options. The controller may not support all
1001 : * requested parameters.
1002 : * \param opts_size Must be set to sizeof(struct spdk_nvme_ctrlr_opts), or 0 if
1003 : * opts is NULL.
1004 : *
1005 : * \return pointer to the connected NVMe controller or NULL if there is any failure.
1006 : *
1007 : */
1008 : struct spdk_nvme_ctrlr *spdk_nvme_connect(const struct spdk_nvme_transport_id *trid,
1009 : const struct spdk_nvme_ctrlr_opts *opts,
1010 : size_t opts_size);
1011 :
1012 : struct spdk_nvme_probe_ctx;
1013 :
1014 : /**
1015 : * Connect the NVMe driver to the device located at the given transport ID.
1016 : *
1017 : * The function will return a probe context on success, controller associates with
1018 : * the context is not ready for use, user must call spdk_nvme_probe_poll_async()
1019 : * until spdk_nvme_probe_poll_async() returns 0.
1020 : *
1021 : * \param trid The transport ID indicating which device to connect. If the trtype
1022 : * is PCIe, this will connect the local PCIe bus. If the trtype is fabrics
1023 : * (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an NVMe-oF
1024 : * service.
1025 : * \param opts NVMe controller initialization options. Default values will be used
1026 : * if the user does not specify the options. The controller may not support all
1027 : * requested parameters.
1028 : * \param attach_cb will be called once the NVMe controller has been attached
1029 : * to the userspace driver.
1030 : *
1031 : * \return probe context on success, NULL on failure.
1032 : *
1033 : */
1034 : struct spdk_nvme_probe_ctx *spdk_nvme_connect_async(const struct spdk_nvme_transport_id *trid,
1035 : const struct spdk_nvme_ctrlr_opts *opts,
1036 : spdk_nvme_attach_cb attach_cb);
1037 :
1038 : /**
1039 : * Probe and add controllers to the probe context list.
1040 : *
1041 : * Users must call spdk_nvme_probe_poll_async() to initialize
1042 : * controllers in the probe context list to the READY state.
1043 : *
1044 : * \param trid The transport ID indicating which bus to enumerate. If the trtype
1045 : * is PCIe or trid is NULL, this will scan the local PCIe bus. If the trtype is
1046 : * fabrics (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an
1047 : * NVMe-oF discovery service.
1048 : * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of
1049 : * the callbacks.
1050 : * \param probe_cb will be called once per NVMe device found in the system.
1051 : * \param attach_cb will be called for devices for which probe_cb returned true
1052 : * once that NVMe controller has been attached to the userspace driver.
1053 : * \param remove_cb will be called for devices that were attached in a previous
1054 : * spdk_nvme_probe() call but are no longer attached to the system. Optional;
1055 : * specify NULL if removal notices are not desired.
1056 : *
1057 : * \return probe context on success, NULL on failure.
1058 : */
1059 : struct spdk_nvme_probe_ctx *spdk_nvme_probe_async(const struct spdk_nvme_transport_id *trid,
1060 : void *cb_ctx,
1061 : spdk_nvme_probe_cb probe_cb,
1062 : spdk_nvme_attach_cb attach_cb,
1063 : spdk_nvme_remove_cb remove_cb);
1064 :
1065 : /**
1066 : * Probe and add controllers to the probe context list.
1067 : *
1068 : * Users must call spdk_nvme_probe_poll_async() to initialize
1069 : * controllers in the probe context list to the READY state.
1070 : *
1071 : * This works just the same as spdk_nvme_probe_async(), except that it calls
1072 : * attach_fail_cb for devices that are probed but unabled to attach.
1073 : *
1074 : * \param trid The transport ID indicating which bus to enumerate. If the trtype
1075 : * is PCIe or trid is NULL, this will scan the local PCIe bus. If the trtype is
1076 : * fabrics (e.g. RDMA, TCP), the traddr and trsvcid must point at the location of an
1077 : * NVMe-oF discovery service.
1078 : * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of
1079 : * the callbacks.
1080 : * \param probe_cb will be called once per NVMe device found in the system.
1081 : * \param attach_cb will be called for devices for which probe_cb returned true
1082 : * once that NVMe controller has been attached to the userspace driver.
1083 : * \param attach_fail_cb will be called for devices which probe_cb returned true
1084 : * but failed to attach to the userspace driver.
1085 : * \param remove_cb will be called for devices that were attached in a previous
1086 : * spdk_nvme_probe() call but are no longer attached to the system. Optional;
1087 : * specify NULL if removal notices are not desired.
1088 : *
1089 : * \return probe context on success, NULL on failure.
1090 : */
1091 : struct spdk_nvme_probe_ctx *spdk_nvme_probe_async_ext(const struct spdk_nvme_transport_id *trid,
1092 : void *cb_ctx,
1093 : spdk_nvme_probe_cb probe_cb,
1094 : spdk_nvme_attach_cb attach_cb,
1095 : spdk_nvme_attach_fail_cb attach_fail_cb,
1096 : spdk_nvme_remove_cb remove_cb);
1097 :
1098 : /**
1099 : * Proceed with attaching controllers associated with the probe context.
1100 : *
1101 : * The probe context is one returned from a previous call to
1102 : * spdk_nvme_probe_async(). Users must call this function on the
1103 : * probe context until it returns 0.
1104 : *
1105 : * If any controllers fail to attach, there is no explicit notification.
1106 : * Users can detect attachment failure by comparing attach_cb invocations
1107 : * with the number of times where the user returned true for the
1108 : * probe_cb.
1109 : *
1110 : * \param probe_ctx Context used to track probe actions.
1111 : *
1112 : * \return 0 if all probe operations are complete; the probe_ctx
1113 : * is also freed and no longer valid.
1114 : * \return -EAGAIN if there are still pending probe operations; user must call
1115 : * spdk_nvme_probe_poll_async again to continue progress.
1116 : */
1117 : int spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx);
1118 :
1119 : /**
1120 : * Detach specified device returned by spdk_nvme_probe()'s attach_cb from the
1121 : * NVMe driver.
1122 : *
1123 : * On success, the spdk_nvme_ctrlr handle is no longer valid.
1124 : *
1125 : * This function should be called from a single thread while no other threads
1126 : * are actively using the NVMe device.
1127 : *
1128 : * \param ctrlr Opaque handle to NVMe controller.
1129 : *
1130 : * \return 0 on success, -1 on failure.
1131 : */
1132 : int spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr);
1133 :
1134 : struct spdk_nvme_detach_ctx;
1135 :
1136 : /**
1137 : * Allocate a context to track detachment of multiple controllers if this call is the
1138 : * first successful start of detachment in a sequence, or use the passed context otherwise.
1139 : *
1140 : * Then, start detaching the specified device returned by spdk_nvme_probe()'s attach_cb
1141 : * from the NVMe driver, and append this detachment to the context.
1142 : *
1143 : * User must call spdk_nvme_detach_poll_async() to complete the detachment.
1144 : *
1145 : * If the context is not allocated before this call, and if the specified device is detached
1146 : * locally from the caller process but any other process still attaches it or failed to be
1147 : * detached, context is not allocated.
1148 : *
1149 : * This function should be called from a single thread while no other threads are
1150 : * actively using the NVMe device.
1151 : *
1152 : * \param ctrlr Opaque handle to NVMe controller.
1153 : * \param detach_ctx Reference to the context in a sequence. An new context is allocated
1154 : * if this call is the first successful start of detachment in a sequence, or use the
1155 : * passed context.
1156 : */
1157 : int spdk_nvme_detach_async(struct spdk_nvme_ctrlr *ctrlr,
1158 : struct spdk_nvme_detach_ctx **detach_ctx);
1159 :
1160 : /**
1161 : * Poll detachment of multiple controllers until they complete.
1162 : *
1163 : * User must call this function until it returns 0.
1164 : *
1165 : * \param detach_ctx Context to track the detachment.
1166 : *
1167 : * \return 0 if all detachments complete; the context is also freed and no longer valid.
1168 : * \return -EAGAIN if any detachment is still in progress; users must call
1169 : * spdk_nvme_detach_poll_async() again to continue progress.
1170 : */
1171 : int spdk_nvme_detach_poll_async(struct spdk_nvme_detach_ctx *detach_ctx);
1172 :
1173 : /**
1174 : * Continue calling spdk_nvme_detach_poll_async() internally until it returns 0.
1175 : *
1176 : * \param detach_ctx Context to track the detachment.
1177 : */
1178 : void spdk_nvme_detach_poll(struct spdk_nvme_detach_ctx *detach_ctx);
1179 :
1180 : /**
1181 : * Scan attached controllers for events.
1182 : *
1183 : * This function lets user act on events such as hot-remove without a need to
1184 : * enable hotplug explicitly. Only attached devices will be checked.
1185 : *
1186 : * \param trid Transport ID.
1187 : *
1188 : * \returns 0 on success, negative on failure.
1189 : */
1190 : int spdk_nvme_scan_attached(const struct spdk_nvme_transport_id *trid);
1191 :
1192 : /**
1193 : * Update the transport ID for a given controller.
1194 : *
1195 : * This function allows the user to set a new trid for a controller only if the
1196 : * controller is failed. The controller's failed state can be obtained from
1197 : * spdk_nvme_ctrlr_is_failed(). The controller can also be forced to the failed
1198 : * state using spdk_nvme_ctrlr_fail().
1199 : *
1200 : * This function also requires that the transport type and subnqn of the new trid
1201 : * be the same as the old trid.
1202 : *
1203 : * \param ctrlr Opaque handle to an NVMe controller.
1204 : * \param trid The new transport ID.
1205 : *
1206 : * \return 0 on success, -EINVAL if the trid is invalid,
1207 : * -EPERM if the ctrlr is not failed.
1208 : */
1209 : int spdk_nvme_ctrlr_set_trid(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_transport_id *trid);
1210 :
1211 : /**
1212 : * Set the remove callback and context to be invoked if the controller is removed.
1213 : *
1214 : * This will override any remove_cb and/or ctx specified when the controller was
1215 : * probed.
1216 : *
1217 : * This function may only be called from the primary process. This function has
1218 : * no effect if called from a secondary process.
1219 : *
1220 : * \param ctrlr Opaque handle to an NVMe controller.
1221 : * \param remove_cb remove callback
1222 : * \param remove_ctx remove callback context
1223 : */
1224 : void spdk_nvme_ctrlr_set_remove_cb(struct spdk_nvme_ctrlr *ctrlr,
1225 : spdk_nvme_remove_cb remove_cb, void *remove_ctx);
1226 :
1227 : struct spdk_nvme_ctrlr_key_opts {
1228 : /** Size of this structure */
1229 : size_t size;
1230 : /** DH-HMAC-CHAP host key */
1231 : struct spdk_key *dhchap_key;
1232 : /** DH-HMAC-CHAP controller key */
1233 : struct spdk_key *dhchap_ctrlr_key;
1234 : };
1235 :
1236 : /**
1237 : * Set keys for a given NVMe controller. These keys will override the keys specified in
1238 : * `spdk_nvme_ctrlr_opts` when attaching the controller and will be used from now on to authenticate
1239 : * all qpairs associated with this controller.
1240 : *
1241 : * This function only sets the keys, it doesn't force existing qpairs to use them. To do that,
1242 : * users need to call `spdk_nvme_ctrlr_authenticate()` to authenticate the admin queue and
1243 : * `spdk_nvme_qpair_authenticate()` to authenticate IO queues.
1244 : *
1245 : * \param ctrlr NVMe controller.
1246 : * \param opts Key options.
1247 : *
1248 : * \return 0 on success, negative errno on failure.
1249 : */
1250 : int spdk_nvme_ctrlr_set_keys(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ctrlr_key_opts *opts);
1251 :
1252 : /**
1253 : * Perform a full hardware reset of the NVMe controller.
1254 : *
1255 : * This function should be called from a single thread while no other threads
1256 : * are actively using the NVMe device.
1257 : *
1258 : * Any pointers returned from spdk_nvme_ctrlr_get_ns(), spdk_nvme_ns_get_data(),
1259 : * spdk_nvme_zns_ns_get_data(), and spdk_nvme_zns_ctrlr_get_data()
1260 : * may be invalidated by calling this function. The number of namespaces as returned
1261 : * by spdk_nvme_ctrlr_get_num_ns() may also change.
1262 : *
1263 : * \param ctrlr Opaque handle to NVMe controller.
1264 : *
1265 : * \return 0 on success, -1 on failure.
1266 : */
1267 : int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr);
1268 :
1269 : /**
1270 : * Disconnect the given NVMe controller.
1271 : *
1272 : * This function is used as the first operation of a full reset sequence of the given NVMe
1273 : * controller. The NVMe controller is ready to reconnect after completing this function.
1274 : *
1275 : * \param ctrlr Opaque handle to NVMe controller.
1276 : *
1277 : * \return 0 on success, -EBUSY if controller is already resetting, or -ENXIO if controller
1278 : * has been removed.
1279 : */
1280 : int spdk_nvme_ctrlr_disconnect(struct spdk_nvme_ctrlr *ctrlr);
1281 :
1282 : /**
1283 : * Start re-enabling the given NVMe controller in a full reset sequence
1284 : *
1285 : * \param ctrlr Opaque handle to NVMe controller.
1286 : */
1287 : void spdk_nvme_ctrlr_reconnect_async(struct spdk_nvme_ctrlr *ctrlr);
1288 :
1289 : /**
1290 : * Proceed with re-enabling the given NVMe controller.
1291 : *
1292 : * Users must call this function in a full reset sequence until it returns a value other
1293 : * than -EAGAIN.
1294 : *
1295 : * \return 0 if the given NVMe controller is enabled, or -EBUSY if there are still
1296 : * pending operations to enable it.
1297 : */
1298 : int spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr);
1299 :
1300 : /**
1301 : * Perform a NVMe subsystem reset.
1302 : *
1303 : * This function should be called from a single thread while no other threads
1304 : * are actively using the NVMe device.
1305 : * A subsystem reset is typically seen by the OS as a hot remove, followed by a
1306 : * hot add event.
1307 : *
1308 : * Any pointers returned from spdk_nvme_ctrlr_get_ns(), spdk_nvme_ns_get_data(),
1309 : * spdk_nvme_zns_ns_get_data(), and spdk_nvme_zns_ctrlr_get_data()
1310 : * may be invalidated by calling this function. The number of namespaces as returned
1311 : * by spdk_nvme_ctrlr_get_num_ns() may also change.
1312 : *
1313 : * \param ctrlr Opaque handle to NVMe controller.
1314 : *
1315 : * \return 0 on success, -1 on failure, -ENOTSUP if subsystem reset is not supported.
1316 : */
1317 : int spdk_nvme_ctrlr_reset_subsystem(struct spdk_nvme_ctrlr *ctrlr);
1318 :
1319 : /**
1320 : * Fail the given NVMe controller.
1321 : *
1322 : * This function gives the application the opportunity to fail a controller
1323 : * at will. When a controller is failed, any calls to process completions or
1324 : * submit I/O on qpairs associated with that controller will fail with an error
1325 : * code of -ENXIO.
1326 : * The controller can only be taken from the failed state by
1327 : * calling spdk_nvme_ctrlr_reset. After the controller has been successfully
1328 : * reset, any I/O pending when the controller was moved to failed will be
1329 : * aborted back to the application and can be resubmitted. I/O can then resume.
1330 : *
1331 : * \param ctrlr Opaque handle to an NVMe controller.
1332 : */
1333 : void spdk_nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr);
1334 :
1335 : /**
1336 : * This function returns the failed status of a given controller.
1337 : *
1338 : * \param ctrlr Opaque handle to an NVMe controller.
1339 : *
1340 : * \return True if the controller is failed, false otherwise.
1341 : */
1342 : bool spdk_nvme_ctrlr_is_failed(struct spdk_nvme_ctrlr *ctrlr);
1343 :
1344 : /**
1345 : * Get the identify controller data as defined by the NVMe specification.
1346 : *
1347 : * This function is thread safe and can be called at any point while the controller
1348 : * is attached to the SPDK NVMe driver.
1349 : *
1350 : * \param ctrlr Opaque handle to NVMe controller.
1351 : *
1352 : * \return pointer to the identify controller data.
1353 : */
1354 : const struct spdk_nvme_ctrlr_data *spdk_nvme_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr);
1355 :
1356 : /**
1357 : * Get the NVMe controller CSTS (Status) register.
1358 : *
1359 : * \param ctrlr Opaque handle to NVMe controller.
1360 : *
1361 : * \return the NVMe controller CSTS (Status) register.
1362 : */
1363 : union spdk_nvme_csts_register spdk_nvme_ctrlr_get_regs_csts(struct spdk_nvme_ctrlr *ctrlr);
1364 :
1365 : /**
1366 : * Get the NVMe controller CC (Configuration) register.
1367 : *
1368 : * \param ctrlr Opaque handle to NVMe controller.
1369 : *
1370 : * \return the NVMe controller CC (Configuration) register.
1371 : */
1372 : union spdk_nvme_cc_register spdk_nvme_ctrlr_get_regs_cc(struct spdk_nvme_ctrlr *ctrlr);
1373 :
1374 : /**
1375 : * Get the NVMe controller CAP (Capabilities) register.
1376 : *
1377 : * \param ctrlr Opaque handle to NVMe controller.
1378 : *
1379 : * \return the NVMe controller CAP (Capabilities) register.
1380 : */
1381 : union spdk_nvme_cap_register spdk_nvme_ctrlr_get_regs_cap(struct spdk_nvme_ctrlr *ctrlr);
1382 :
1383 : /**
1384 : * Get the NVMe controller VS (Version) register.
1385 : *
1386 : * \param ctrlr Opaque handle to NVMe controller.
1387 : *
1388 : * \return the NVMe controller VS (Version) register.
1389 : */
1390 : union spdk_nvme_vs_register spdk_nvme_ctrlr_get_regs_vs(struct spdk_nvme_ctrlr *ctrlr);
1391 :
1392 : /**
1393 : * Get the NVMe controller CMBSZ (Controller Memory Buffer Size) register
1394 : *
1395 : * \param ctrlr Opaque handle to NVMe controller.
1396 : *
1397 : * \return the NVMe controller CMBSZ (Controller Memory Buffer Size) register.
1398 : */
1399 : union spdk_nvme_cmbsz_register spdk_nvme_ctrlr_get_regs_cmbsz(struct spdk_nvme_ctrlr *ctrlr);
1400 :
1401 : /**
1402 : * Get the NVMe controller PMRCAP (Persistent Memory Region Capabilities) register.
1403 : *
1404 : * \param ctrlr Opaque handle to NVMe controller.
1405 : *
1406 : * \return the NVMe controller PMRCAP (Persistent Memory Region Capabilities) register.
1407 : */
1408 : union spdk_nvme_pmrcap_register spdk_nvme_ctrlr_get_regs_pmrcap(struct spdk_nvme_ctrlr *ctrlr);
1409 :
1410 : /**
1411 : * Get the NVMe controller BPINFO (Boot Partition Information) register.
1412 : *
1413 : * \param ctrlr Opaque handle to NVMe controller.
1414 : *
1415 : * \return the NVMe controller BPINFO (Boot Partition Information) register.
1416 : */
1417 : union spdk_nvme_bpinfo_register spdk_nvme_ctrlr_get_regs_bpinfo(struct spdk_nvme_ctrlr *ctrlr);
1418 :
1419 : /**
1420 : * Get the NVMe controller PMR size.
1421 : *
1422 : * \param ctrlr Opaque handle to NVMe controller.
1423 : *
1424 : * \return the NVMe controller PMR size or 0 if PMR is not supported.
1425 : */
1426 : uint64_t spdk_nvme_ctrlr_get_pmrsz(struct spdk_nvme_ctrlr *ctrlr);
1427 :
1428 : /**
1429 : * Get the maximum NSID value that will ever be used for the given controller
1430 : *
1431 : * This function is thread safe and can be called at any point while the
1432 : * controller is attached to the SPDK NVMe driver.
1433 : *
1434 : * This is equivalent to calling spdk_nvme_ctrlr_get_data() to get the
1435 : * spdk_nvme_ctrlr_data and then reading the nn field.
1436 : *
1437 : * The NN field in the NVMe specification represents the maximum value that a
1438 : * namespace ID can ever have. Prior to NVMe 1.2, this was also the number of
1439 : * active namespaces, but from 1.2 onward the list of namespaces may be
1440 : * sparsely populated. Unfortunately, the meaning of this field is often
1441 : * misinterpreted by drive manufacturers and NVMe-oF implementers so it is
1442 : * not considered reliable. AVOID USING THIS FUNCTION WHENEVER POSSIBLE.
1443 : *
1444 : * \param ctrlr Opaque handle to NVMe controller.
1445 : *
1446 : * \return the number of namespaces.
1447 : */
1448 : uint32_t spdk_nvme_ctrlr_get_num_ns(struct spdk_nvme_ctrlr *ctrlr);
1449 :
1450 : /**
1451 : * Get the PCI device of a given NVMe controller.
1452 : *
1453 : * This only works for local (PCIe-attached) NVMe controllers; other transports
1454 : * will return NULL.
1455 : *
1456 : * \param ctrlr Opaque handle to NVMe controller.
1457 : *
1458 : * \return PCI device of the NVMe controller, or NULL if not available.
1459 : */
1460 : struct spdk_pci_device *spdk_nvme_ctrlr_get_pci_device(struct spdk_nvme_ctrlr *ctrlr);
1461 :
1462 : /**
1463 : * Get the NUMA ID for the given NVMe controller.
1464 : *
1465 : * For network-based transports, the NUMA ID will be correlated to the
1466 : * network interface.
1467 : *
1468 : * \param ctrlr Opaque handle to NVMe controller
1469 : *
1470 : * \return NUMA ID of the NVMe controller, or SPDK_ENV_NUMA_ID_ANY if
1471 : * the NUMA ID is unknown
1472 : */
1473 : int32_t spdk_nvme_ctrlr_get_numa_id(struct spdk_nvme_ctrlr *ctrlr);
1474 :
1475 : /**
1476 : * Get the NVMe controller ID for the given controller.
1477 : *
1478 : * \param ctrlr Opaque handle to NVMe controller.
1479 : *
1480 : * \return ID of the NVMe controller.
1481 : */
1482 : uint16_t spdk_nvme_ctrlr_get_id(struct spdk_nvme_ctrlr *ctrlr);
1483 :
1484 : /**
1485 : * Get the maximum data transfer size of a given NVMe controller.
1486 : *
1487 : * \param ctrlr Opaque handle to NVMe controller.
1488 : *
1489 : * \return Maximum data transfer size of the NVMe controller in bytes.
1490 : *
1491 : * The I/O command helper functions, such as spdk_nvme_ns_cmd_read(), will split
1492 : * large I/Os automatically; however, it is up to the user to obey this limit for
1493 : * commands submitted with the raw command functions, such as spdk_nvme_ctrlr_cmd_io_raw().
1494 : */
1495 : uint32_t spdk_nvme_ctrlr_get_max_xfer_size(const struct spdk_nvme_ctrlr *ctrlr);
1496 :
1497 : /**
1498 : * Get the maximum number of SGEs per request for the given NVMe controller.
1499 : *
1500 : * Controllers that do not support SGL will return UINT16_MAX.
1501 : *
1502 : * \param ctrlr Opaque handle to NVMe controller.
1503 : *
1504 : * \return Maximum number of SGEs per request
1505 : */
1506 : uint16_t spdk_nvme_ctrlr_get_max_sges(const struct spdk_nvme_ctrlr *ctrlr);
1507 :
1508 : /**
1509 : * Check whether the nsid is an active nv for the given NVMe controller.
1510 : *
1511 : * This function is thread safe and can be called at any point while the controller
1512 : * is attached to the SPDK NVMe driver.
1513 : *
1514 : * \param ctrlr Opaque handle to NVMe controller.
1515 : * \param nsid Namespace id.
1516 : *
1517 : * \return true if nsid is an active ns, or false otherwise.
1518 : */
1519 : bool spdk_nvme_ctrlr_is_active_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid);
1520 :
1521 : /**
1522 : * Get the nsid of the first active namespace.
1523 : *
1524 : * This function is thread safe and can be called at any point while the controller
1525 : * is attached to the SPDK NVMe driver.
1526 : *
1527 : * \param ctrlr Opaque handle to NVMe controller.
1528 : *
1529 : * \return the nsid of the first active namespace, 0 if there are no active namespaces.
1530 : */
1531 : uint32_t spdk_nvme_ctrlr_get_first_active_ns(struct spdk_nvme_ctrlr *ctrlr);
1532 :
1533 : /**
1534 : * Get next active namespace given the previous nsid.
1535 : *
1536 : * This function is thread safe and can be called at any point while the controller
1537 : * is attached to the SPDK NVMe driver.
1538 : *
1539 : * \param ctrlr Opaque handle to NVMe controller.
1540 : * \param prev_nsid Namespace id.
1541 : *
1542 : * \return a next active namespace given the previous nsid, 0 when there are no
1543 : * more active namespaces.
1544 : */
1545 : uint32_t spdk_nvme_ctrlr_get_next_active_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t prev_nsid);
1546 :
1547 : /**
1548 : * Determine if a particular log page is supported by the given NVMe controller.
1549 : *
1550 : * This function is thread safe and can be called at any point while the controller
1551 : * is attached to the SPDK NVMe driver.
1552 : *
1553 : * \sa spdk_nvme_ctrlr_cmd_get_log_page().
1554 : *
1555 : * \param ctrlr Opaque handle to NVMe controller.
1556 : * \param log_page Log page to query.
1557 : *
1558 : * \return true if supported, or false otherwise.
1559 : */
1560 : bool spdk_nvme_ctrlr_is_log_page_supported(struct spdk_nvme_ctrlr *ctrlr, uint8_t log_page);
1561 :
1562 : /**
1563 : * Determine if a particular feature is supported by the given NVMe controller.
1564 : *
1565 : * This function is thread safe and can be called at any point while the controller
1566 : * is attached to the SPDK NVMe driver.
1567 : *
1568 : * \sa spdk_nvme_ctrlr_cmd_get_feature().
1569 : *
1570 : * \param ctrlr Opaque handle to NVMe controller.
1571 : * \param feature_code Feature to query.
1572 : *
1573 : * \return true if supported, or false otherwise.
1574 : */
1575 : bool spdk_nvme_ctrlr_is_feature_supported(struct spdk_nvme_ctrlr *ctrlr, uint8_t feature_code);
1576 :
1577 : /**
1578 : * Signature for callback function invoked when a command is completed.
1579 : *
1580 : * \param ctx Callback context provided when the command was submitted.
1581 : * \param cpl Completion queue entry that contains the completion status.
1582 : */
1583 : typedef void (*spdk_nvme_cmd_cb)(void *ctx, const struct spdk_nvme_cpl *cpl);
1584 :
1585 : /**
1586 : * Signature for callback function invoked when an asynchronous event request
1587 : * command is completed.
1588 : *
1589 : * \param aer_cb_arg Context specified by spdk_nvme_register_aer_callback().
1590 : * \param cpl Completion queue entry that contains the completion status
1591 : * of the asynchronous event request that was completed.
1592 : */
1593 : typedef void (*spdk_nvme_aer_cb)(void *aer_cb_arg,
1594 : const struct spdk_nvme_cpl *cpl);
1595 :
1596 : /**
1597 : * Register callback function invoked when an AER command is completed for the
1598 : * given NVMe controller.
1599 : *
1600 : * \param ctrlr Opaque handle to NVMe controller.
1601 : * \param aer_cb_fn Callback function invoked when an asynchronous event request
1602 : * command is completed.
1603 : * \param aer_cb_arg Argument passed to callback function.
1604 : */
1605 : void spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
1606 : spdk_nvme_aer_cb aer_cb_fn,
1607 : void *aer_cb_arg);
1608 :
1609 : /**
1610 : * Disable reading the CHANGED_NS_LIST log page for the specified controller.
1611 : *
1612 : * Applications that register an AER callback may wish to read the CHANGED_NS_LIST
1613 : * log page itself, rather than relying on the driver to do it. Calling this
1614 : * function will ensure that the driver does not read this log page if the
1615 : * controller returns a NS_ATTR_CHANGED AEN.
1616 : *
1617 : * Reading of this log page can alternatively be disabled by setting the
1618 : * disable_read_changed_ns_list_log_page flag in the spdk_nvme_ctrlr_opts
1619 : * when attaching the controller.
1620 : *
1621 : * \param ctrlr NVMe controller on which to disable the log page read.
1622 : */
1623 : void spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page(struct spdk_nvme_ctrlr *ctrlr);
1624 :
1625 : /**
1626 : * Opaque handle to a queue pair.
1627 : *
1628 : * I/O queue pairs may be allocated using spdk_nvme_ctrlr_alloc_io_qpair().
1629 : */
1630 : struct spdk_nvme_qpair;
1631 :
1632 : /**
1633 : * Signature for the callback function invoked when a timeout is detected on a
1634 : * request.
1635 : *
1636 : * For timeouts detected on the admin queue pair, the qpair returned here will
1637 : * be NULL. If the controller has a serious error condition and is unable to
1638 : * communicate with driver via completion queue, the controller can set Controller
1639 : * Fatal Status field to 1, then reset is required to recover from such error.
1640 : * Users may detect Controller Fatal Status when timeout happens.
1641 : *
1642 : * \param cb_arg Argument passed to callback function.
1643 : * \param ctrlr Opaque handle to NVMe controller.
1644 : * \param qpair Opaque handle to a queue pair.
1645 : * \param cid Command ID.
1646 : */
1647 : typedef void (*spdk_nvme_timeout_cb)(void *cb_arg,
1648 : struct spdk_nvme_ctrlr *ctrlr,
1649 : struct spdk_nvme_qpair *qpair,
1650 : uint16_t cid);
1651 :
1652 : /**
1653 : * Register for timeout callback on a controller.
1654 : *
1655 : * The application can choose to register for timeout callback or not register
1656 : * for timeout callback.
1657 : *
1658 : * \param ctrlr NVMe controller on which to monitor for timeout.
1659 : * \param timeout_io_us Timeout value in microseconds for io commands.
1660 : * \param timeout_admin_us Timeout value in microseconds for admin commands.
1661 : * \param cb_fn A function pointer that points to the callback function.
1662 : * \param cb_arg Argument to the callback function.
1663 : */
1664 : void spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
1665 : uint64_t timeout_io_us, uint64_t timeout_admin_us,
1666 : spdk_nvme_timeout_cb cb_fn, void *cb_arg);
1667 :
1668 : /**
1669 : * Signature for the callback function when a
1670 : * \ref spdk_nvme_ctrlr_get_discovery_log_page operation is completed.
1671 : *
1672 : * \param cb_arg Argument passed to callback function.
1673 : * \param rc Status of operation. 0 means success, and that the cpl argument is valid.
1674 : * Failure indicated by negative errno value.
1675 : * \param cpl NVMe completion status of the operation. NULL if rc != 0. If multiple
1676 : * completions with error status occurred during the operation, the cpl
1677 : * value for the first error will be used here.
1678 : * \param log_page Pointer to the full discovery log page. The application is
1679 : * responsible for freeing this buffer using free().
1680 : */
1681 : typedef void (*spdk_nvme_discovery_cb)(void *cb_arg, int rc,
1682 : const struct spdk_nvme_cpl *cpl,
1683 : struct spdk_nvmf_discovery_log_page *log_page);
1684 :
1685 : /**
1686 : * Get a full discovery log page from the specified controller.
1687 : *
1688 : * This function will first read the discovery log header to determine the
1689 : * total number of valid entries in the discovery log, then it will allocate
1690 : * a buffer to hold the entire log and issue multiple GET_LOG_PAGE commands to
1691 : * get all of the entries.
1692 : *
1693 : * The application is responsible for calling
1694 : * \ref spdk_nvme_ctrlr_process_admin_completions to trigger processing of
1695 : * completions submitted by this function.
1696 : *
1697 : * \param ctrlr Pointer to the discovery controller.
1698 : * \param cb_fn Function to call when the operation is complete.
1699 : * \param cb_arg Argument to pass to cb_fn.
1700 : */
1701 : int spdk_nvme_ctrlr_get_discovery_log_page(struct spdk_nvme_ctrlr *ctrlr,
1702 : spdk_nvme_discovery_cb cb_fn, void *cb_arg);
1703 :
1704 : /**
1705 : * NVMe I/O queue pair initialization options.
1706 : *
1707 : * These options may be passed to spdk_nvme_ctrlr_alloc_io_qpair() to configure queue pair
1708 : * options at queue creation time.
1709 : *
1710 : * The user may retrieve the default I/O queue pair creation options for a controller using
1711 : * spdk_nvme_ctrlr_get_default_io_qpair_opts().
1712 : */
1713 : struct spdk_nvme_io_qpair_opts {
1714 : /**
1715 : * Queue priority for weighted round robin arbitration. If a different arbitration
1716 : * method is in use, pass 0.
1717 : */
1718 : enum spdk_nvme_qprio qprio;
1719 :
1720 : /**
1721 : * The queue depth of this NVMe I/O queue. Overrides spdk_nvme_ctrlr_opts::io_queue_size.
1722 : */
1723 : uint32_t io_queue_size;
1724 :
1725 : /**
1726 : * The number of requests to allocate for this NVMe I/O queue.
1727 : *
1728 : * Overrides spdk_nvme_ctrlr_opts::io_queue_requests.
1729 : *
1730 : * This should be at least as large as io_queue_size.
1731 : *
1732 : * A single I/O may allocate more than one request, since splitting may be
1733 : * necessary to conform to the device's maximum transfer size, PRP list
1734 : * compatibility requirements, or driver-assisted striping.
1735 : */
1736 : uint32_t io_queue_requests;
1737 :
1738 : /**
1739 : * When submitting I/O via spdk_nvme_ns_read/write and similar functions,
1740 : * don't immediately submit it to hardware. Instead, queue up new commands
1741 : * and submit them to the hardware inside spdk_nvme_qpair_process_completions().
1742 : *
1743 : * This results in better batching of I/O commands. Often, it is more efficient
1744 : * to submit batches of commands to the underlying hardware than each command
1745 : * individually.
1746 : *
1747 : * This only applies to PCIe and RDMA transports.
1748 : *
1749 : * The flag was originally named delay_pcie_doorbell. To allow backward compatibility
1750 : * both names are kept in unnamed union.
1751 : */
1752 : union {
1753 : bool delay_cmd_submit;
1754 : bool delay_pcie_doorbell;
1755 : };
1756 :
1757 : /* Hole at bytes 13-15. */
1758 : uint8_t reserved13[3];
1759 :
1760 : /**
1761 : * These fields allow specifying the memory buffers for the submission and/or
1762 : * completion queues.
1763 : * By default, vaddr is set to NULL meaning SPDK will allocate the memory to be used.
1764 : * If vaddr is NULL then paddr must be set to 0.
1765 : * If vaddr is non-NULL, and paddr is zero, SPDK derives the physical
1766 : * address for the NVMe device, in this case the memory must be registered.
1767 : * If a paddr value is non-zero, SPDK uses the vaddr and paddr as passed
1768 : * SPDK assumes that the memory passed is both virtually and physically
1769 : * contiguous.
1770 : * If these fields are used, SPDK will NOT impose any restriction
1771 : * on the number of elements in the queues.
1772 : * The buffer sizes are in number of bytes, and are used to confirm
1773 : * that the buffers are large enough to contain the appropriate queue.
1774 : * These fields are only used by PCIe attached NVMe devices. They
1775 : * are presently ignored for other transports.
1776 : */
1777 : struct {
1778 : struct spdk_nvme_cmd *vaddr;
1779 : uint64_t paddr;
1780 : uint64_t buffer_size;
1781 : } sq;
1782 : struct {
1783 : struct spdk_nvme_cpl *vaddr;
1784 : uint64_t paddr;
1785 : uint64_t buffer_size;
1786 : } cq;
1787 :
1788 : /**
1789 : * This flag indicates to the alloc_io_qpair function that it should not perform
1790 : * the connect portion on this qpair. This allows the user to add the qpair to a
1791 : * poll group and then connect it later.
1792 : */
1793 : bool create_only;
1794 :
1795 : /**
1796 : * This flag if set to true enables the creation of submission and completion queue
1797 : * asynchronously. Default mode is set to false to create io qpair synchronously.
1798 : */
1799 : bool async_mode;
1800 :
1801 : /**
1802 : * This flag if set to true disables the merging of physically
1803 : * contiguous SGL elements. Default mode is set to false to allow
1804 : * merging of physically contiguous SGL elements.
1805 : */
1806 : bool disable_pcie_sgl_merge;
1807 :
1808 : /* Hole at bytes 67-71. */
1809 : uint8_t reserved67[5];
1810 : };
1811 : SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_io_qpair_opts) == 72, "Incorrect size");
1812 :
1813 : /**
1814 : * Get the default options for I/O qpair creation for a specific NVMe controller.
1815 : *
1816 : * \param ctrlr NVMe controller to retrieve the defaults from.
1817 : * \param[out] opts Will be filled with the default options for
1818 : * spdk_nvme_ctrlr_alloc_io_qpair().
1819 : * \param opts_size Must be set to sizeof(struct spdk_nvme_io_qpair_opts).
1820 : */
1821 : void spdk_nvme_ctrlr_get_default_io_qpair_opts(struct spdk_nvme_ctrlr *ctrlr,
1822 : struct spdk_nvme_io_qpair_opts *opts,
1823 : size_t opts_size);
1824 :
1825 : /**
1826 : * Allocate an I/O queue pair (submission and completion queue).
1827 : *
1828 : * This function by default also performs any connection activities required for
1829 : * a newly created qpair. To avoid that behavior, the user should set the create_only
1830 : * flag in the opts structure to true.
1831 : *
1832 : * Each queue pair should only be used from a single thread at a time (mutual
1833 : * exclusion must be enforced by the user).
1834 : *
1835 : * \param ctrlr NVMe controller for which to allocate the I/O queue pair.
1836 : * \param opts I/O qpair creation options, or NULL to use the defaults as returned
1837 : * by spdk_nvme_ctrlr_get_default_io_qpair_opts().
1838 : * \param opts_size Must be set to sizeof(struct spdk_nvme_io_qpair_opts), or 0
1839 : * if opts is NULL.
1840 : *
1841 : * \return a pointer to the allocated I/O queue pair.
1842 : */
1843 : struct spdk_nvme_qpair *spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
1844 : const struct spdk_nvme_io_qpair_opts *opts,
1845 : size_t opts_size);
1846 :
1847 : /**
1848 : * Connect a newly created I/O qpair.
1849 : *
1850 : * This function does any connection activities required for a newly created qpair.
1851 : * It should be called after spdk_nvme_ctrlr_alloc_io_qpair has been called with the
1852 : * create_only flag set to true in the spdk_nvme_io_qpair_opts structure.
1853 : *
1854 : * This call will fail if performed on a qpair that is already connected.
1855 : * For reconnecting qpairs, see spdk_nvme_ctrlr_reconnect_io_qpair.
1856 : *
1857 : * For fabrics like TCP and RDMA, this function actually sends the commands over the wire
1858 : * that connect the qpair. For PCIe, this function performs some internal state machine operations.
1859 : *
1860 : * \param ctrlr NVMe controller for which to allocate the I/O queue pair.
1861 : * \param qpair Opaque handle to the qpair to connect.
1862 : *
1863 : * return 0 on success or negated errno on failure. Specifically -EISCONN if the qpair is already connected.
1864 : *
1865 : */
1866 : int spdk_nvme_ctrlr_connect_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);
1867 :
1868 : /**
1869 : * Disconnect the given I/O qpair.
1870 : *
1871 : * This function must be called from the same thread as spdk_nvme_qpair_process_completions
1872 : * and the spdk_nvme_ns_cmd_* functions.
1873 : *
1874 : * After disconnect, calling spdk_nvme_qpair_process_completions or one of the
1875 : * spdk_nvme_ns_cmd* on a qpair will result in a return value of -ENXIO. A
1876 : * disconnected qpair may be reconnected with either the spdk_nvme_ctrlr_connect_io_qpair
1877 : * or spdk_nvme_ctrlr_reconnect_io_qpair APIs.
1878 : *
1879 : * \param qpair The qpair to disconnect.
1880 : */
1881 : void spdk_nvme_ctrlr_disconnect_io_qpair(struct spdk_nvme_qpair *qpair);
1882 :
1883 : /**
1884 : * Attempt to reconnect the given qpair.
1885 : *
1886 : * This function is intended to be called on qpairs that have already been connected,
1887 : * but have since entered a failed state as indicated by a return value of -ENXIO from
1888 : * either spdk_nvme_qpair_process_completions or one of the spdk_nvme_ns_cmd_* functions.
1889 : * This function must be called from the same thread as spdk_nvme_qpair_process_completions
1890 : * and the spdk_nvme_ns_cmd_* functions.
1891 : *
1892 : * Calling this function has the same effect as calling spdk_nvme_ctrlr_disconnect_io_qpair
1893 : * followed by spdk_nvme_ctrlr_connect_io_qpair.
1894 : *
1895 : * This function may be called on newly created qpairs, but it does extra checks and attempts
1896 : * to disconnect the qpair before connecting it. The recommended API for newly created qpairs
1897 : * is spdk_nvme_ctrlr_connect_io_qpair.
1898 : *
1899 : * \param qpair The qpair to reconnect.
1900 : *
1901 : * \return 0 on success, or if the qpair was already connected.
1902 : * -EAGAIN if the driver was unable to reconnect during this call,
1903 : * but the controller is still connected and is either resetting or enabled.
1904 : * -ENODEV if the controller is removed. In this case, the controller cannot be recovered
1905 : * and the application will have to destroy it and the associated qpairs.
1906 : * -ENXIO if the controller is in a failed state but is not yet resetting. In this case,
1907 : * the application should call spdk_nvme_ctrlr_reset to reset the entire controller.
1908 : */
1909 : int spdk_nvme_ctrlr_reconnect_io_qpair(struct spdk_nvme_qpair *qpair);
1910 :
1911 : /**
1912 : * Returns the reason the admin qpair for a given controller is disconnected.
1913 : *
1914 : * \param ctrlr The controller to check.
1915 : *
1916 : * \return a valid spdk_nvme_qp_failure_reason.
1917 : */
1918 : spdk_nvme_qp_failure_reason spdk_nvme_ctrlr_get_admin_qp_failure_reason(
1919 : struct spdk_nvme_ctrlr *ctrlr);
1920 :
1921 : /**
1922 : * Free an I/O queue pair that was allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1923 : *
1924 : * The qpair must not be accessed after calling this function.
1925 : *
1926 : * \param qpair I/O queue pair to free.
1927 : *
1928 : * \return 0 on success. This function will never return any value other than 0.
1929 : */
1930 : int spdk_nvme_ctrlr_free_io_qpair(struct spdk_nvme_qpair *qpair);
1931 :
1932 : /**
1933 : * Send the given NVM I/O command, I/O buffers, lists and all to the NVMe controller.
1934 : *
1935 : * This is a low level interface for submitting I/O commands directly.
1936 : *
1937 : * This function allows a caller to submit an I/O request that is
1938 : * COMPLETELY pre-defined, right down to the "physical" memory buffers.
1939 : * It is intended for testing hardware, specifying exact buffer location,
1940 : * alignment, and offset. It also allows for specific choice of PRP
1941 : * and SGLs.
1942 : *
1943 : * The driver sets the CID. EVERYTHING else is assumed set by the caller.
1944 : * Needless to say, this is potentially extremely dangerous for both the host
1945 : * (accidental/malicious storage usage/corruption), and the device.
1946 : * Thus its intent is for very specific hardware testing and environment
1947 : * reproduction.
1948 : *
1949 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1950 : * The user must ensure that only one thread submits I/O on a given qpair at any
1951 : * given time.
1952 : *
1953 : * This function can only be used on PCIe controllers and qpairs.
1954 : *
1955 : * \param ctrlr Opaque handle to NVMe controller.
1956 : * \param qpair I/O qpair to submit command.
1957 : * \param cmd NVM I/O command to submit.
1958 : * \param cb_fn Callback function invoked when the I/O command completes.
1959 : * \param cb_arg Argument passed to callback function.
1960 : *
1961 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
1962 : * -ENOMEM: The request cannot be allocated.
1963 : * -ENXIO: The qpair is failed at the transport level.
1964 : */
1965 :
1966 : int spdk_nvme_ctrlr_io_cmd_raw_no_payload_build(struct spdk_nvme_ctrlr *ctrlr,
1967 : struct spdk_nvme_qpair *qpair,
1968 : struct spdk_nvme_cmd *cmd,
1969 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1970 :
1971 : /**
1972 : * Send the given NVM I/O command to the NVMe controller.
1973 : *
1974 : * This is a low level interface for submitting I/O commands directly. Prefer
1975 : * the spdk_nvme_ns_cmd_* functions instead. The validity of the command will
1976 : * not be checked!
1977 : *
1978 : * When constructing the nvme_command it is not necessary to fill out the PRP
1979 : * list/SGL or the CID. The driver will handle both of those for you.
1980 : *
1981 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1982 : * The user must ensure that only one thread submits I/O on a given qpair at any
1983 : * given time.
1984 : *
1985 : * \param ctrlr Opaque handle to NVMe controller.
1986 : * \param qpair I/O qpair to submit command.
1987 : * \param cmd NVM I/O command to submit.
1988 : * \param buf Virtual memory address of a single physically contiguous buffer.
1989 : * \param len Size of buffer.
1990 : * \param cb_fn Callback function invoked when the I/O command completes.
1991 : * \param cb_arg Argument passed to callback function.
1992 : *
1993 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
1994 : * -ENOMEM: The request cannot be allocated.
1995 : * -ENXIO: The qpair is failed at the transport level.
1996 : */
1997 : int spdk_nvme_ctrlr_cmd_io_raw(struct spdk_nvme_ctrlr *ctrlr,
1998 : struct spdk_nvme_qpair *qpair,
1999 : struct spdk_nvme_cmd *cmd,
2000 : void *buf, uint32_t len,
2001 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2002 :
2003 : /**
2004 : * Send the given NVM I/O command with metadata to the NVMe controller.
2005 : *
2006 : * This is a low level interface for submitting I/O commands directly. Prefer
2007 : * the spdk_nvme_ns_cmd_* functions instead. The validity of the command will
2008 : * not be checked!
2009 : *
2010 : * When constructing the nvme_command it is not necessary to fill out the PRP
2011 : * list/SGL or the CID. The driver will handle both of those for you.
2012 : *
2013 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
2014 : * The user must ensure that only one thread submits I/O on a given qpair at any
2015 : * given time.
2016 : *
2017 : * \param ctrlr Opaque handle to NVMe controller.
2018 : * \param qpair I/O qpair to submit command.
2019 : * \param cmd NVM I/O command to submit.
2020 : * \param buf Virtual memory address of a single physically contiguous buffer.
2021 : * \param len Size of buffer.
2022 : * \param md_buf Virtual memory address of a single physically contiguous metadata
2023 : * buffer.
2024 : * \param cb_fn Callback function invoked when the I/O command completes.
2025 : * \param cb_arg Argument passed to callback function.
2026 : *
2027 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
2028 : * -ENOMEM: The request cannot be allocated.
2029 : * -ENXIO: The qpair is failed at the transport level.
2030 : */
2031 : int spdk_nvme_ctrlr_cmd_io_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
2032 : struct spdk_nvme_qpair *qpair,
2033 : struct spdk_nvme_cmd *cmd,
2034 : void *buf, uint32_t len, void *md_buf,
2035 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2036 :
2037 : /**
2038 : * Restart the SGL walk to the specified offset when the command has scattered
2039 : * payloads.
2040 : *
2041 : * \param cb_arg Argument passed to readv/writev.
2042 : * \param offset Offset for SGL.
2043 : */
2044 : typedef void (*spdk_nvme_req_reset_sgl_cb)(void *cb_arg, uint32_t offset);
2045 :
2046 : /**
2047 : * Fill out *address and *length with the current SGL entry and advance to the
2048 : * next entry for the next time the callback is invoked.
2049 : *
2050 : * The described segment must be physically contiguous.
2051 : *
2052 : * \param cb_arg Argument passed to readv/writev.
2053 : * \param address Virtual address of this segment, a value of UINT64_MAX
2054 : * means the segment should be described via Bit Bucket SGL.
2055 : * \param length Length of this physical segment.
2056 : */
2057 : typedef int (*spdk_nvme_req_next_sge_cb)(void *cb_arg, void **address,
2058 : uint32_t *length);
2059 :
2060 : /**
2061 : * Send the given NVM I/O command with metadata to the NVMe controller.
2062 : *
2063 : * This is a low level interface for submitting I/O commands directly. Prefer
2064 : * the spdk_nvme_ns_cmd_* functions instead. The validity of the command will
2065 : * not be checked!
2066 : *
2067 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
2068 : * The user must ensure that only one thread submits I/O on a given qpair at any
2069 : * given time.
2070 : *
2071 : * \param ctrlr Opaque handle to NVMe controller.
2072 : * \param qpair I/O qpair to submit command.
2073 : * \param cmd NVM I/O command to submit.
2074 : * \param len Size of buffer.
2075 : * \param md_buf Virtual memory address of a single physically contiguous metadata buffer.
2076 : * \param cb_fn Callback function invoked when the I/O command completes.
2077 : * \param cb_arg Argument passed to callback function.
2078 : * \param reset_sgl_fn Callback function to reset scattered payload.
2079 : * \param next_sge_fn Callback function to iterate each scattered payload memory segment.
2080 : *
2081 : * \return 0 if successfully submitted, negated errnos on the following error
2082 : conditions:
2083 : * -ENOMEM: The request cannot be allocated.
2084 : * -ENXIO: The qpair is failed at the transport level.
2085 : */
2086 : int spdk_nvme_ctrlr_cmd_iov_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
2087 : struct spdk_nvme_qpair *qpair,
2088 : struct spdk_nvme_cmd *cmd, uint32_t len,
2089 : void *md_buf, spdk_nvme_cmd_cb cb_fn,
2090 : void *cb_arg,
2091 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
2092 : spdk_nvme_req_next_sge_cb next_sge_fn);
2093 :
2094 : /**
2095 : * Process any outstanding completions for I/O submitted on a queue pair.
2096 : *
2097 : * This call is non-blocking, i.e. it only processes completions that are ready
2098 : * at the time of this function call. It does not wait for outstanding commands
2099 : * to finish.
2100 : *
2101 : * For each completed command, the request's callback function will be called if
2102 : * specified as non-NULL when the request was submitted.
2103 : *
2104 : * The caller must ensure that each queue pair is only used from one thread at a
2105 : * time.
2106 : *
2107 : * This function may be called at any point while the controller is attached to
2108 : * the SPDK NVMe driver.
2109 : *
2110 : * \sa spdk_nvme_cmd_cb
2111 : *
2112 : * \param qpair Queue pair to check for completions.
2113 : * \param max_completions Limit the number of completions to be processed in one
2114 : * call, or 0 for unlimited.
2115 : *
2116 : * \return number of completions processed (may be 0) or negated on error. -ENXIO
2117 : * in the special case that the qpair is failed at the transport layer.
2118 : */
2119 : int32_t spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair,
2120 : uint32_t max_completions);
2121 :
2122 : /**
2123 : * Returns the reason the qpair is disconnected.
2124 : *
2125 : * \param qpair The qpair to check.
2126 : *
2127 : * \return a valid spdk_nvme_qp_failure_reason.
2128 : */
2129 : spdk_nvme_qp_failure_reason spdk_nvme_qpair_get_failure_reason(struct spdk_nvme_qpair *qpair);
2130 :
2131 : /**
2132 : * Control if DNR is set or not for aborted commands.
2133 : *
2134 : * The default value is false.
2135 : *
2136 : * \param qpair The qpair to set.
2137 : * \param dnr Set the DNR bit to 1 if true or 0 if false for aborted commands.
2138 : */
2139 : void spdk_nvme_qpair_set_abort_dnr(struct spdk_nvme_qpair *qpair, bool dnr);
2140 :
2141 : /**
2142 : * Return the connection status of a given qpair.
2143 : *
2144 : * \param qpair The qpair to check.
2145 : *
2146 : * \return true if the qpair is connected, or false otherwise.
2147 : */
2148 : bool spdk_nvme_qpair_is_connected(struct spdk_nvme_qpair *qpair);
2149 :
2150 : typedef void (*spdk_nvme_authenticate_cb)(void *ctx, int status);
2151 :
2152 : /**
2153 : * Force a qpair to authenticate. As part of initialization, qpairs are authenticated automatically
2154 : * if the controller is configured with DH-HMAC-CHAP keys. However, this function can be used to
2155 : * force authentication after a connection has already been established.
2156 : *
2157 : * This function doesn't disconnect the qpair if the authentication is successful.
2158 : *
2159 : * \param qpair The qpair to authenticate.
2160 : * \param cb_fn Callback to be executed after the authentication is done.
2161 : * \param cb_ctx Context passed to `cb_fn`.
2162 : *
2163 : * \return 0 on success, negative errno on failure.
2164 : */
2165 : int spdk_nvme_qpair_authenticate(struct spdk_nvme_qpair *qpair,
2166 : spdk_nvme_authenticate_cb cb_fn, void *cb_ctx);
2167 :
2168 : /**
2169 : * Force authentication on the admin qpair of a controller. As part of initialization, the admin
2170 : * qpair is authenticated automatically if the controller is configured with DH-HMAC-CHAP keys.
2171 : * However, this function can be used to force authentication after a connection has already been
2172 : * established.
2173 : *
2174 : * This function doesn't disconnect the admin qpair if the authentication is successful.
2175 : *
2176 : * \param ctrlr Controller to authenticate.
2177 : * \param cb_fn Callback to be executed after the authentication is done.
2178 : * \param cb_ctx Context passed to `cb_fn`.
2179 : *
2180 : * \return 0 on success, negative errno on failure.
2181 : */
2182 : int spdk_nvme_ctrlr_authenticate(struct spdk_nvme_ctrlr *ctrlr,
2183 : spdk_nvme_authenticate_cb cb_fn, void *cb_ctx);
2184 :
2185 : /**
2186 : * Send the given admin command to the NVMe controller.
2187 : *
2188 : * This is a low level interface for submitting admin commands directly. Prefer
2189 : * the spdk_nvme_ctrlr_cmd_* functions instead. The validity of the command will
2190 : * not be checked!
2191 : *
2192 : * When constructing the nvme_command it is not necessary to fill out the PRP
2193 : * list/SGL or the CID. The driver will handle both of those for you.
2194 : *
2195 : * This function is thread safe and can be called at any point while the controller
2196 : * is attached to the SPDK NVMe driver.
2197 : *
2198 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion
2199 : * of commands submitted through this function.
2200 : *
2201 : * \param ctrlr Opaque handle to NVMe controller.
2202 : * \param cmd NVM admin command to submit.
2203 : * \param buf Virtual memory address of a single physically contiguous buffer.
2204 : * \param len Size of buffer.
2205 : * \param cb_fn Callback function invoked when the admin command completes.
2206 : * \param cb_arg Argument passed to callback function.
2207 : *
2208 : * \return 0 if successfully submitted, negated errno if resources could not be
2209 : * allocated for this request, -ENXIO if the admin qpair is failed at the transport layer.
2210 : */
2211 : int spdk_nvme_ctrlr_cmd_admin_raw(struct spdk_nvme_ctrlr *ctrlr,
2212 : struct spdk_nvme_cmd *cmd,
2213 : void *buf, uint32_t len,
2214 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2215 :
2216 : /**
2217 : * Process any outstanding completions for admin commands.
2218 : *
2219 : * This will process completions for admin commands submitted on any thread.
2220 : *
2221 : * This call is non-blocking, i.e. it only processes completions that are ready
2222 : * at the time of this function call. It does not wait for outstanding commands
2223 : * to finish.
2224 : *
2225 : * This function is thread safe and can be called at any point while the controller
2226 : * is attached to the SPDK NVMe driver.
2227 : *
2228 : * \param ctrlr Opaque handle to NVMe controller.
2229 : *
2230 : * \return number of completions processed (may be 0) or negated on error. -ENXIO
2231 : * in the special case that the qpair is failed at the transport layer.
2232 : */
2233 : int32_t spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr);
2234 :
2235 :
2236 : /**
2237 : * Opaque handle to a namespace. Obtained by calling spdk_nvme_ctrlr_get_ns().
2238 : */
2239 : struct spdk_nvme_ns;
2240 :
2241 : /**
2242 : * Get a handle to a namespace for the given controller.
2243 : *
2244 : * Namespaces are numbered from 1 to the total number of namespaces. There will
2245 : * never be any gaps in the numbering. The number of namespaces is obtained by
2246 : * calling spdk_nvme_ctrlr_get_num_ns().
2247 : *
2248 : * This function is thread safe and can be called at any point while the controller
2249 : * is attached to the SPDK NVMe driver.
2250 : *
2251 : * \param ctrlr Opaque handle to NVMe controller.
2252 : * \param ns_id Namespace id.
2253 : *
2254 : * \return a pointer to the namespace.
2255 : */
2256 : struct spdk_nvme_ns *spdk_nvme_ctrlr_get_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t ns_id);
2257 :
2258 : /**
2259 : * Get a specific log page from the NVMe controller.
2260 : *
2261 : * This function is thread safe and can be called at any point while the controller
2262 : * is attached to the SPDK NVMe driver.
2263 : *
2264 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2265 : * commands submitted through this function.
2266 : *
2267 : * \sa spdk_nvme_ctrlr_is_log_page_supported()
2268 : *
2269 : * \param ctrlr Opaque handle to NVMe controller.
2270 : * \param log_page The log page identifier.
2271 : * \param nsid Depending on the log page, this may be 0, a namespace identifier,
2272 : * or SPDK_NVME_GLOBAL_NS_TAG.
2273 : * \param payload The pointer to the payload buffer.
2274 : * \param payload_size The size of payload buffer.
2275 : * \param offset Offset in bytes within the log page to start retrieving log page
2276 : * data. May only be non-zero if the controller supports extended data for Get Log
2277 : * Page as reported in the controller data log page attributes.
2278 : * \param cb_fn Callback function to invoke when the log page has been retrieved.
2279 : * \param cb_arg Argument to pass to the callback function.
2280 : *
2281 : * \return 0 if successfully submitted, negated errno if resources could not be
2282 : * allocated for this request, -ENXIO if the admin qpair is failed at the transport layer.
2283 : */
2284 : int spdk_nvme_ctrlr_cmd_get_log_page(struct spdk_nvme_ctrlr *ctrlr,
2285 : uint8_t log_page, uint32_t nsid,
2286 : void *payload, uint32_t payload_size,
2287 : uint64_t offset,
2288 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2289 :
2290 : /**
2291 : * Get a specific log page from the NVMe controller.
2292 : *
2293 : * This function is thread safe and can be called at any point while the controller
2294 : * is attached to the SPDK NVMe driver.
2295 : *
2296 : * This function allows specifying extra fields in cdw10 and cdw11 such as
2297 : * Retain Asynchronous Event and Log Specific Field.
2298 : *
2299 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2300 : * commands submitted through this function.
2301 : *
2302 : * \sa spdk_nvme_ctrlr_is_log_page_supported()
2303 : *
2304 : * \param ctrlr Opaque handle to NVMe controller.
2305 : * \param log_page The log page identifier.
2306 : * \param nsid Depending on the log page, this may be 0, a namespace identifier,
2307 : * or SPDK_NVME_GLOBAL_NS_TAG.
2308 : * \param payload The pointer to the payload buffer.
2309 : * \param payload_size The size of payload buffer.
2310 : * \param offset Offset in bytes within the log page to start retrieving log page
2311 : * data. May only be non-zero if the controller supports extended data for Get Log
2312 : * Page as reported in the controller data log page attributes.
2313 : * \param cdw10 Value to specify for cdw10. Specify 0 for numdl - it will be
2314 : * set by this function based on the payload_size parameter. Specify 0 for lid -
2315 : * it will be set by this function based on the log_page parameter.
2316 : * \param cdw11 Value to specify for cdw11. Specify 0 for numdu - it will be
2317 : * set by this function based on the payload_size.
2318 : * \param cdw14 Value to specify for cdw14.
2319 : * \param cb_fn Callback function to invoke when the log page has been retrieved.
2320 : * \param cb_arg Argument to pass to the callback function.
2321 : *
2322 : * \return 0 if successfully submitted, negated errno if resources could not be
2323 : * allocated for this request, -ENXIO if the admin qpair is failed at the transport layer.
2324 : */
2325 : int spdk_nvme_ctrlr_cmd_get_log_page_ext(struct spdk_nvme_ctrlr *ctrlr, uint8_t log_page,
2326 : uint32_t nsid, void *payload, uint32_t payload_size,
2327 : uint64_t offset, uint32_t cdw10, uint32_t cdw11,
2328 : uint32_t cdw14, spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2329 :
2330 : /**
2331 : * Abort a specific previously-submitted NVMe command.
2332 : *
2333 : * \sa spdk_nvme_ctrlr_register_timeout_callback()
2334 : *
2335 : * \param ctrlr NVMe controller to which the command was submitted.
2336 : * \param qpair NVMe queue pair to which the command was submitted. For admin
2337 : * commands, pass NULL for the qpair.
2338 : * \param cid Command ID of the command to abort.
2339 : * \param cb_fn Callback function to invoke when the abort has completed.
2340 : * \param cb_arg Argument to pass to the callback function.
2341 : *
2342 : * \return 0 if successfully submitted, negated errno if resources could not be
2343 : * allocated for this request, -ENXIO if the admin qpair is failed at the transport layer.
2344 : */
2345 : int spdk_nvme_ctrlr_cmd_abort(struct spdk_nvme_ctrlr *ctrlr,
2346 : struct spdk_nvme_qpair *qpair,
2347 : uint16_t cid,
2348 : spdk_nvme_cmd_cb cb_fn,
2349 : void *cb_arg);
2350 :
2351 : /**
2352 : * Abort previously submitted commands which have cmd_cb_arg as its callback argument.
2353 : *
2354 : * \param ctrlr NVMe controller to which the commands were submitted.
2355 : * \param qpair NVMe queue pair to which the commands were submitted. For admin
2356 : * commands, pass NULL for the qpair.
2357 : * \param cmd_cb_arg Callback argument for the NVMe commands which this function
2358 : * attempts to abort.
2359 : * \param cb_fn Callback function to invoke when this function has completed.
2360 : * \param cb_arg Argument to pass to the callback function.
2361 : *
2362 : * \return 0 if successfully submitted, negated errno otherwise.
2363 : */
2364 : int spdk_nvme_ctrlr_cmd_abort_ext(struct spdk_nvme_ctrlr *ctrlr,
2365 : struct spdk_nvme_qpair *qpair,
2366 : void *cmd_cb_arg,
2367 : spdk_nvme_cmd_cb cb_fn,
2368 : void *cb_arg);
2369 :
2370 : /**
2371 : * Set specific feature for the given NVMe controller.
2372 : *
2373 : * This function is thread safe and can be called at any point while the controller
2374 : * is attached to the SPDK NVMe driver.
2375 : *
2376 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2377 : * commands submitted through this function.
2378 : *
2379 : * \sa spdk_nvme_ctrlr_cmd_get_feature().
2380 : *
2381 : * \param ctrlr NVMe controller to manipulate.
2382 : * \param feature The feature identifier.
2383 : * \param cdw11 as defined by the specification for this command.
2384 : * \param cdw12 as defined by the specification for this command.
2385 : * \param payload The pointer to the payload buffer.
2386 : * \param payload_size The size of payload buffer.
2387 : * \param cb_fn Callback function to invoke when the feature has been set.
2388 : * \param cb_arg Argument to pass to the callback function.
2389 : *
2390 : * \return 0 if successfully submitted, negated errno if resources could not be
2391 : * allocated for this request, -ENXIO if the admin qpair is failed at the transport layer.
2392 : */
2393 : int spdk_nvme_ctrlr_cmd_set_feature(struct spdk_nvme_ctrlr *ctrlr,
2394 : uint8_t feature, uint32_t cdw11, uint32_t cdw12,
2395 : void *payload, uint32_t payload_size,
2396 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2397 :
2398 : /**
2399 : * Get specific feature from given NVMe controller.
2400 : *
2401 : * This function is thread safe and can be called at any point while the controller
2402 : * is attached to the SPDK NVMe driver.
2403 : *
2404 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2405 : * commands submitted through this function.
2406 : *
2407 : * \sa spdk_nvme_ctrlr_cmd_set_feature()
2408 : *
2409 : * \param ctrlr NVMe controller to query.
2410 : * \param feature The feature identifier.
2411 : * \param cdw11 as defined by the specification for this command.
2412 : * \param payload The pointer to the payload buffer.
2413 : * \param payload_size The size of payload buffer.
2414 : * \param cb_fn Callback function to invoke when the feature has been retrieved.
2415 : * \param cb_arg Argument to pass to the callback function.
2416 : *
2417 : * \return 0 if successfully submitted, -ENOMEM if resources could not be allocated
2418 : * for this request, -ENXIO if the admin qpair is failed at the transport layer.
2419 : */
2420 : int spdk_nvme_ctrlr_cmd_get_feature(struct spdk_nvme_ctrlr *ctrlr,
2421 : uint8_t feature, uint32_t cdw11,
2422 : void *payload, uint32_t payload_size,
2423 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2424 :
2425 : /**
2426 : * Get specific feature from given NVMe controller.
2427 : *
2428 : * \param ctrlr NVMe controller to query.
2429 : * \param feature The feature identifier.
2430 : * \param cdw11 as defined by the specification for this command.
2431 : * \param payload The pointer to the payload buffer.
2432 : * \param payload_size The size of payload buffer.
2433 : * \param cb_fn Callback function to invoke when the feature has been retrieved.
2434 : * \param cb_arg Argument to pass to the callback function.
2435 : * \param ns_id The namespace identifier.
2436 : *
2437 : * \return 0 if successfully submitted, -ENOMEM if resources could not be allocated
2438 : * for this request, -ENXIO if the admin qpair is failed at the transport layer.
2439 : *
2440 : * This function is thread safe and can be called at any point while the controller
2441 : * is attached to the SPDK NVMe driver.
2442 : *
2443 : * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
2444 : * of commands submitted through this function.
2445 : *
2446 : * \sa spdk_nvme_ctrlr_cmd_set_feature_ns()
2447 : */
2448 : int spdk_nvme_ctrlr_cmd_get_feature_ns(struct spdk_nvme_ctrlr *ctrlr, uint8_t feature,
2449 : uint32_t cdw11, void *payload, uint32_t payload_size,
2450 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t ns_id);
2451 :
2452 : /**
2453 : * Set specific feature for the given NVMe controller and namespace ID.
2454 : *
2455 : * \param ctrlr NVMe controller to manipulate.
2456 : * \param feature The feature identifier.
2457 : * \param cdw11 as defined by the specification for this command.
2458 : * \param cdw12 as defined by the specification for this command.
2459 : * \param payload The pointer to the payload buffer.
2460 : * \param payload_size The size of payload buffer.
2461 : * \param cb_fn Callback function to invoke when the feature has been set.
2462 : * \param cb_arg Argument to pass to the callback function.
2463 : * \param ns_id The namespace identifier.
2464 : *
2465 : * \return 0 if successfully submitted, -ENOMEM if resources could not be allocated
2466 : * for this request, -ENXIO if the admin qpair is failed at the transport layer.
2467 : *
2468 : * This function is thread safe and can be called at any point while the controller
2469 : * is attached to the SPDK NVMe driver.
2470 : *
2471 : * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
2472 : * of commands submitted through this function.
2473 : *
2474 : * \sa spdk_nvme_ctrlr_cmd_get_feature_ns()
2475 : */
2476 : int spdk_nvme_ctrlr_cmd_set_feature_ns(struct spdk_nvme_ctrlr *ctrlr, uint8_t feature,
2477 : uint32_t cdw11, uint32_t cdw12, void *payload,
2478 : uint32_t payload_size, spdk_nvme_cmd_cb cb_fn,
2479 : void *cb_arg, uint32_t ns_id);
2480 :
2481 : /**
2482 : * Receive security protocol data from controller.
2483 : *
2484 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2485 : *
2486 : * \param ctrlr NVMe controller to use for security receive command submission.
2487 : * \param secp Security Protocol that is used.
2488 : * \param spsp Security Protocol Specific field.
2489 : * \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
2490 : * Protocol EAh.
2491 : * \param payload The pointer to the payload buffer.
2492 : * \param payload_size The size of payload buffer.
2493 : * \param cb_fn Callback function to invoke when the command has been completed.
2494 : * \param cb_arg Argument to pass to the callback function.
2495 : *
2496 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2497 : * for this request.
2498 : */
2499 : int spdk_nvme_ctrlr_cmd_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
2500 : uint16_t spsp, uint8_t nssf, void *payload,
2501 : uint32_t payload_size,
2502 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2503 :
2504 : /**
2505 : * Send security protocol data to controller.
2506 : *
2507 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2508 : *
2509 : * \param ctrlr NVMe controller to use for security send command submission.
2510 : * \param secp Security Protocol that is used.
2511 : * \param spsp Security Protocol Specific field.
2512 : * \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
2513 : * Protocol EAh.
2514 : * \param payload The pointer to the payload buffer.
2515 : * \param payload_size The size of payload buffer.
2516 : * \param cb_fn Callback function to invoke when the command has been completed.
2517 : * \param cb_arg Argument to pass to the callback function.
2518 : *
2519 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2520 : * for this request.
2521 : */
2522 : int spdk_nvme_ctrlr_cmd_security_send(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
2523 : uint16_t spsp, uint8_t nssf, void *payload,
2524 : uint32_t payload_size, spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2525 :
2526 : /**
2527 : * Receive security protocol data from controller.
2528 : *
2529 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2530 : *
2531 : * \param ctrlr NVMe controller to use for security receive command submission.
2532 : * \param secp Security Protocol that is used.
2533 : * \param spsp Security Protocol Specific field.
2534 : * \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
2535 : * Protocol EAh.
2536 : * \param payload The pointer to the payload buffer.
2537 : * \param size The size of payload buffer.
2538 : *
2539 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2540 : * for this request.
2541 : */
2542 : int spdk_nvme_ctrlr_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
2543 : uint16_t spsp, uint8_t nssf, void *payload, size_t size);
2544 :
2545 : /**
2546 : * Send security protocol data to controller.
2547 : *
2548 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2549 : *
2550 : * \param ctrlr NVMe controller to use for security send command submission.
2551 : * \param secp Security Protocol that is used.
2552 : * \param spsp Security Protocol Specific field.
2553 : * \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
2554 : * Protocol EAh.
2555 : * \param payload The pointer to the payload buffer.
2556 : * \param size The size of payload buffer.
2557 : *
2558 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2559 : * for this request.
2560 : */
2561 : int spdk_nvme_ctrlr_security_send(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
2562 : uint16_t spsp, uint8_t nssf, void *payload, size_t size);
2563 :
2564 : /**
2565 : * Receive data related to a specific Directive Type from the controller.
2566 : *
2567 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2568 : *
2569 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2570 : * commands submitted through this function.
2571 : *
2572 : * \param ctrlr NVMe controller to use for directive receive command submission.
2573 : * \param nsid Specific Namespace Identifier.
2574 : * \param doper Directive Operation defined in nvme_spec.h.
2575 : * \param dtype Directive Type defined in nvme_spec.h.
2576 : * \param dspec Directive Specific defined in nvme_spec.h.
2577 : * \param payload The pointer to the payload buffer.
2578 : * \param payload_size The size of payload buffer.
2579 : * \param cdw12 Command dword 12.
2580 : * \param cdw13 Command dword 13.
2581 : * \param cb_fn Callback function to invoke when the command has been completed.
2582 : * \param cb_arg Argument to pass to the callback function.
2583 : *
2584 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2585 : * for this request.
2586 : */
2587 : int spdk_nvme_ctrlr_cmd_directive_receive(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
2588 : uint32_t doper, uint32_t dtype, uint32_t dspec,
2589 : void *payload, uint32_t payload_size, uint32_t cdw12,
2590 : uint32_t cdw13, spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2591 :
2592 : /**
2593 : * Send data related to a specific Directive Type to the controller.
2594 : *
2595 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2596 : *
2597 : * Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
2598 : * commands submitted through this function.
2599 : *
2600 : * \param ctrlr NVMe controller to use for directive send command submission.
2601 : * \param nsid Specific Namespace Identifier.
2602 : * \param doper Directive Operation defined in nvme_spec.h.
2603 : * \param dtype Directive Type defined in nvme_spec.h.
2604 : * \param dspec Directive Specific defined in nvme_spec.h.
2605 : * \param payload The pointer to the payload buffer.
2606 : * \param payload_size The size of payload buffer.
2607 : * \param cdw12 Command dword 12.
2608 : * \param cdw13 Command dword 13.
2609 : * \param cb_fn Callback function to invoke when the command has been completed.
2610 : * \param cb_arg Argument to pass to the callback function.
2611 : *
2612 : * \return 0 if successfully submitted, negated errno if resources could not be allocated
2613 : * for this request.
2614 : */
2615 : int spdk_nvme_ctrlr_cmd_directive_send(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
2616 : uint32_t doper, uint32_t dtype, uint32_t dspec,
2617 : void *payload, uint32_t payload_size, uint32_t cdw12,
2618 : uint32_t cdw13, spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2619 :
2620 : /**
2621 : * Get supported flags of the controller.
2622 : *
2623 : * \param ctrlr NVMe controller to get flags.
2624 : *
2625 : * \return supported flags of this controller.
2626 : */
2627 : uint64_t spdk_nvme_ctrlr_get_flags(struct spdk_nvme_ctrlr *ctrlr);
2628 :
2629 : /**
2630 : * Attach the specified namespace to controllers.
2631 : *
2632 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2633 : *
2634 : * \param ctrlr NVMe controller to use for command submission.
2635 : * \param nsid Namespace identifier for namespace to attach.
2636 : * \param payload The pointer to the controller list.
2637 : *
2638 : * \return 0 if successfully submitted, ENOMEM if resources could not be allocated
2639 : * for this request.
2640 : */
2641 : int spdk_nvme_ctrlr_attach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
2642 : struct spdk_nvme_ctrlr_list *payload);
2643 :
2644 : /**
2645 : * Detach the specified namespace from controllers.
2646 : *
2647 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2648 : *
2649 : * \param ctrlr NVMe controller to use for command submission.
2650 : * \param nsid Namespace ID to detach.
2651 : * \param payload The pointer to the controller list.
2652 : *
2653 : * \return 0 if successfully submitted, ENOMEM if resources could not be allocated
2654 : * for this request
2655 : */
2656 : int spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
2657 : struct spdk_nvme_ctrlr_list *payload);
2658 :
2659 : /**
2660 : * Create a namespace.
2661 : *
2662 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2663 : *
2664 : * \param ctrlr NVMe controller to create namespace on.
2665 : * \param payload The pointer to the NVMe namespace data.
2666 : *
2667 : * \return Namespace ID (>= 1) if successfully created, or 0 if the request failed.
2668 : */
2669 : uint32_t spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr,
2670 : struct spdk_nvme_ns_data *payload);
2671 :
2672 : /**
2673 : * Delete a namespace.
2674 : *
2675 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2676 : *
2677 : * \param ctrlr NVMe controller to delete namespace from.
2678 : * \param nsid The namespace identifier.
2679 : *
2680 : * \return 0 if successfully submitted, negated errno if resources could not be
2681 : * allocated
2682 : * for this request
2683 : */
2684 : int spdk_nvme_ctrlr_delete_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid);
2685 :
2686 : /**
2687 : * Format NVM.
2688 : *
2689 : * This function requests a low-level format of the media.
2690 : *
2691 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2692 : *
2693 : * \param ctrlr NVMe controller to format.
2694 : * \param nsid The namespace identifier. May be SPDK_NVME_GLOBAL_NS_TAG to format
2695 : * all namespaces.
2696 : * \param format The format information for the command.
2697 : *
2698 : * \return 0 if successfully submitted, negated errno if resources could not be
2699 : * allocated for this request
2700 : */
2701 : int spdk_nvme_ctrlr_format(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
2702 : struct spdk_nvme_format *format);
2703 :
2704 : /**
2705 : * Download a new firmware image.
2706 : *
2707 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2708 : *
2709 : * \param ctrlr NVMe controller to perform firmware operation on.
2710 : * \param payload The data buffer for the firmware image.
2711 : * \param size The data size will be downloaded.
2712 : * \param slot The slot that the firmware image will be committed to.
2713 : * \param commit_action The action to perform when firmware is committed.
2714 : * \param completion_status output parameter. Contains the completion status of
2715 : * the firmware commit operation.
2716 : *
2717 : * \return 0 if successfully submitted, ENOMEM if resources could not be allocated
2718 : * for this request, -1 if the size is not multiple of 4.
2719 : */
2720 : int spdk_nvme_ctrlr_update_firmware(struct spdk_nvme_ctrlr *ctrlr, void *payload, uint32_t size,
2721 : int slot, enum spdk_nvme_fw_commit_action commit_action,
2722 : struct spdk_nvme_status *completion_status);
2723 :
2724 : /**
2725 : * Start the Read from a Boot Partition.
2726 : *
2727 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2728 : *
2729 : * \param ctrlr NVMe controller to perform the Boot Partition read.
2730 : * \param payload The data buffer for Boot Partition read.
2731 : * \param bprsz Read size in multiples of 4 KiB to copy into the Boot Partition Memory Buffer.
2732 : * \param bprof Boot Partition offset to read from in 4 KiB units.
2733 : * \param bpid Boot Partition identifier for the Boot Partition read operation.
2734 : *
2735 : * \return 0 if Boot Partition read is successful. Negated errno on the following error conditions:
2736 : * -ENOMEM: if resources could not be allocated.
2737 : * -ENOTSUP: Boot Partition is not supported by the Controller.
2738 : * -EIO: Registers access failure.
2739 : * -EINVAL: Parameters are invalid.
2740 : * -EFAULT: Invalid address was specified as part of payload.
2741 : * -EALREADY: Boot Partition read already initiated.
2742 : */
2743 : int spdk_nvme_ctrlr_read_boot_partition_start(struct spdk_nvme_ctrlr *ctrlr, void *payload,
2744 : uint32_t bprsz, uint32_t bprof, uint32_t bpid);
2745 :
2746 : /**
2747 : * Poll the status of the Read from a Boot Partition.
2748 : *
2749 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2750 : *
2751 : * \param ctrlr NVMe controller to perform the Boot Partition read.
2752 : *
2753 : * \return 0 if Boot Partition read is successful. Negated errno on the following error conditions:
2754 : * -EIO: Registers access failure.
2755 : * -EINVAL: Invalid read status or the Boot Partition read is not initiated yet.
2756 : * -EAGAIN: If the read is still in progress; users must call
2757 : * spdk_nvme_ctrlr_read_boot_partition_poll again to check the read status.
2758 : */
2759 : int spdk_nvme_ctrlr_read_boot_partition_poll(struct spdk_nvme_ctrlr *ctrlr);
2760 :
2761 : /**
2762 : * Write to a Boot Partition.
2763 : *
2764 : * This function is thread safe and can be called at any point after spdk_nvme_probe().
2765 : * Users will get the completion after the data is downloaded, image is replaced and
2766 : * Boot Partition is activated or when the sequence encounters an error.
2767 : *
2768 : * \param ctrlr NVMe controller to perform the Boot Partition write.
2769 : * \param payload The data buffer for Boot Partition write.
2770 : * \param size Data size to write to the Boot Partition.
2771 : * \param bpid Boot Partition identifier for the Boot Partition write operation.
2772 : * \param cb_fn Callback function to invoke when the operation is completed.
2773 : * \param cb_arg Argument to pass to the callback function.
2774 : *
2775 : * \return 0 if Boot Partition write submit is successful. Negated errno on the following error conditions:
2776 : * -ENOMEM: if resources could not be allocated.
2777 : * -ENOTSUP: Boot Partition is not supported by the Controller.
2778 : * -EIO: Registers access failure.
2779 : * -EINVAL: Parameters are invalid.
2780 : */
2781 : int spdk_nvme_ctrlr_write_boot_partition(struct spdk_nvme_ctrlr *ctrlr, void *payload,
2782 : uint32_t size, uint32_t bpid, spdk_nvme_cmd_cb cb_fn, void *cb_arg);
2783 :
2784 : /**
2785 : * Return virtual address of PCIe NVM I/O registers
2786 : *
2787 : * This function returns a pointer to the PCIe I/O registers for a controller
2788 : * or NULL if unsupported for this transport.
2789 : *
2790 : * \param ctrlr Controller whose registers are to be accessed.
2791 : *
2792 : * \return Pointer to virtual address of register bank, or NULL.
2793 : */
2794 : volatile struct spdk_nvme_registers *spdk_nvme_ctrlr_get_registers(struct spdk_nvme_ctrlr *ctrlr);
2795 :
2796 : /**
2797 : * Reserve the controller memory buffer for data transfer use.
2798 : *
2799 : * This function reserves the full size of the controller memory buffer
2800 : * for use in data transfers. If submission queues or completion queues are
2801 : * already placed in the controller memory buffer, this call will fail.
2802 : *
2803 : * \param ctrlr Controller from which to allocate memory buffer
2804 : *
2805 : * \return The size of the controller memory buffer on success. Negated errno
2806 : * on failure.
2807 : */
2808 : int spdk_nvme_ctrlr_reserve_cmb(struct spdk_nvme_ctrlr *ctrlr);
2809 :
2810 : /**
2811 : * Map a previously reserved controller memory buffer so that it's data is
2812 : * visible from the CPU. This operation is not always possible.
2813 : *
2814 : * \param ctrlr Controller that contains the memory buffer
2815 : * \param size Size of buffer that was mapped.
2816 : *
2817 : * \return Pointer to controller memory buffer, or NULL on failure.
2818 : */
2819 : void *spdk_nvme_ctrlr_map_cmb(struct spdk_nvme_ctrlr *ctrlr, size_t *size);
2820 :
2821 : /**
2822 : * Free a controller memory I/O buffer.
2823 : *
2824 : * \param ctrlr Controller from which to unmap the memory buffer.
2825 : */
2826 : void spdk_nvme_ctrlr_unmap_cmb(struct spdk_nvme_ctrlr *ctrlr);
2827 :
2828 : /**
2829 : * Enable the Persistent Memory Region
2830 : *
2831 : * \param ctrlr Controller that contains the Persistent Memory Region
2832 : *
2833 : * \return 0 on success. Negated errno on the following error conditions:
2834 : * -ENOTSUP: PMR is not supported by the Controller.
2835 : * -EIO: Registers access failure.
2836 : * -EINVAL: PMR Time Units Invalid or PMR is already enabled.
2837 : * -ETIMEDOUT: Timed out to Enable PMR.
2838 : * -ENOSYS: Transport does not support Enable PMR function.
2839 : */
2840 : int spdk_nvme_ctrlr_enable_pmr(struct spdk_nvme_ctrlr *ctrlr);
2841 :
2842 : /**
2843 : * Disable the Persistent Memory Region
2844 : *
2845 : * \param ctrlr Controller that contains the Persistent Memory Region
2846 : *
2847 : * \return 0 on success. Negated errno on the following error conditions:
2848 : * -ENOTSUP: PMR is not supported by the Controller.
2849 : * -EIO: Registers access failure.
2850 : * -EINVAL: PMR Time Units Invalid or PMR is already disabled.
2851 : * -ETIMEDOUT: Timed out to Disable PMR.
2852 : * -ENOSYS: Transport does not support Disable PMR function.
2853 : */
2854 : int spdk_nvme_ctrlr_disable_pmr(struct spdk_nvme_ctrlr *ctrlr);
2855 :
2856 : /**
2857 : * Map the Persistent Memory Region so that it's data is
2858 : * visible from the CPU.
2859 : *
2860 : * \param ctrlr Controller that contains the Persistent Memory Region
2861 : * \param size Size of the region that was mapped.
2862 : *
2863 : * \return Pointer to Persistent Memory Region, or NULL on failure.
2864 : */
2865 : void *spdk_nvme_ctrlr_map_pmr(struct spdk_nvme_ctrlr *ctrlr, size_t *size);
2866 :
2867 : /**
2868 : * Free the Persistent Memory Region.
2869 : *
2870 : * \param ctrlr Controller from which to unmap the Persistent Memory Region.
2871 : *
2872 : * \return 0 on success, negative errno on failure.
2873 : * -ENXIO: Either PMR is not supported by the Controller or the PMR is already unmapped.
2874 : * -ENOSYS: Transport does not support Unmap PMR function.
2875 : */
2876 : int spdk_nvme_ctrlr_unmap_pmr(struct spdk_nvme_ctrlr *ctrlr);
2877 :
2878 : /**
2879 : * Get the transport ID for a given NVMe controller.
2880 : *
2881 : * \param ctrlr Controller to get the transport ID.
2882 : * \return Pointer to the controller's transport ID.
2883 : */
2884 : const struct spdk_nvme_transport_id *spdk_nvme_ctrlr_get_transport_id(
2885 : struct spdk_nvme_ctrlr *ctrlr);
2886 :
2887 : /**
2888 : * \brief Alloc NVMe I/O queue identifier.
2889 : *
2890 : * This function is only needed for the non-standard case of allocating queues using the raw
2891 : * command interface. In most cases \ref spdk_nvme_ctrlr_alloc_io_qpair should be sufficient.
2892 : *
2893 : * \param ctrlr Opaque handle to NVMe controller.
2894 : * \return qid on success, -1 on failure.
2895 : */
2896 : int32_t spdk_nvme_ctrlr_alloc_qid(struct spdk_nvme_ctrlr *ctrlr);
2897 :
2898 : /**
2899 : * \brief Free NVMe I/O queue identifier.
2900 : *
2901 : * This function must only be called with qids previously allocated with \ref spdk_nvme_ctrlr_alloc_qid.
2902 : *
2903 : * \param ctrlr Opaque handle to NVMe controller.
2904 : * \param qid NVMe Queue Identifier.
2905 : */
2906 : void spdk_nvme_ctrlr_free_qid(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid);
2907 :
2908 : /**
2909 : * Opaque handle for a poll group. A poll group is a collection of spdk_nvme_qpair
2910 : * objects that are polled for completions as a unit.
2911 : *
2912 : * Returned by spdk_nvme_poll_group_create().
2913 : */
2914 : struct spdk_nvme_poll_group;
2915 :
2916 :
2917 : /**
2918 : * This function alerts the user to disconnected qpairs when calling
2919 : * spdk_nvme_poll_group_process_completions.
2920 : */
2921 : typedef void (*spdk_nvme_disconnected_qpair_cb)(struct spdk_nvme_qpair *qpair,
2922 : void *poll_group_ctx);
2923 :
2924 : /**
2925 : * Create a new poll group.
2926 : *
2927 : * \param ctx A user supplied context that can be retrieved later with spdk_nvme_poll_group_get_ctx
2928 : * \param table The call back table defined by users which contains the accelerated functions
2929 : * which can be used to accelerate some operations such as crc32c.
2930 : *
2931 : * \return Pointer to the new poll group, or NULL on error.
2932 : */
2933 : struct spdk_nvme_poll_group *spdk_nvme_poll_group_create(void *ctx,
2934 : struct spdk_nvme_accel_fn_table *table);
2935 :
2936 : /**
2937 : * Get a optimal poll group.
2938 : *
2939 : * \param qpair The qpair to get the optimal poll group.
2940 : *
2941 : * \return Pointer to the optimal poll group, or NULL if not found.
2942 : */
2943 : struct spdk_nvme_poll_group *spdk_nvme_qpair_get_optimal_poll_group(struct spdk_nvme_qpair *qpair);
2944 :
2945 : /**
2946 : * Add an spdk_nvme_qpair to a poll group. qpairs may only be added to
2947 : * a poll group if they are in the disconnected state; i.e. either they were
2948 : * just allocated and not yet connected or they have been disconnected with a call
2949 : * to spdk_nvme_ctrlr_disconnect_io_qpair.
2950 : *
2951 : * \param group The group to which the qpair will be added.
2952 : * \param qpair The qpair to add to the poll group.
2953 : *
2954 : * return 0 on success, -EINVAL if the qpair is not in the disabled state, -ENODEV if the transport
2955 : * doesn't exist, -ENOMEM on memory allocation failures, or -EPROTO on a protocol (transport) specific failure.
2956 : */
2957 : int spdk_nvme_poll_group_add(struct spdk_nvme_poll_group *group, struct spdk_nvme_qpair *qpair);
2958 :
2959 : /**
2960 : * Remove a disconnected spdk_nvme_qpair from a poll group.
2961 : *
2962 : * \param group The group from which to remove the qpair.
2963 : * \param qpair The qpair to remove from the poll group.
2964 : *
2965 : * return 0 on success, -ENOENT if the qpair is not found in the group, -EINVAL if the qpair is not
2966 : * disconnected in the group, or -EPROTO on a protocol (transport) specific failure.
2967 : */
2968 : int spdk_nvme_poll_group_remove(struct spdk_nvme_poll_group *group, struct spdk_nvme_qpair *qpair);
2969 :
2970 : /**
2971 : * Destroy an empty poll group.
2972 : *
2973 : * \param group The group to destroy.
2974 : *
2975 : * return 0 on success, -EBUSY if the poll group is not empty.
2976 : */
2977 : int spdk_nvme_poll_group_destroy(struct spdk_nvme_poll_group *group);
2978 :
2979 : /**
2980 : * Poll for completions on all qpairs in this poll group.
2981 : *
2982 : * the disconnected_qpair_cb will be called for all disconnected qpairs in the poll group
2983 : * including qpairs which fail within the context of this call.
2984 : * The user is responsible for trying to reconnect or destroy those qpairs.
2985 : *
2986 : * \param group The group on which to poll for completions.
2987 : * \param completions_per_qpair The maximum number of completions per qpair.
2988 : * \param disconnected_qpair_cb A callback function of type spdk_nvme_disconnected_qpair_cb. Must be non-NULL.
2989 : *
2990 : * return The number of completions across all qpairs, -EINVAL if no disconnected_qpair_cb is passed, or
2991 : * -EIO if the shared completion queue cannot be polled for the RDMA transport.
2992 : */
2993 : int64_t spdk_nvme_poll_group_process_completions(struct spdk_nvme_poll_group *group,
2994 : uint32_t completions_per_qpair, spdk_nvme_disconnected_qpair_cb disconnected_qpair_cb);
2995 :
2996 : /**
2997 : * Check if all qpairs in the poll group are connected.
2998 : *
2999 : * This function allows the caller to check if all qpairs in a poll group are
3000 : * connected. This API is generally only suitable during application startup,
3001 : * to check when a large number of async connections have completed.
3002 : *
3003 : * It is useful for applications like benchmarking tools to create
3004 : * a large number of qpairs, but then ensuring they are all fully connected before
3005 : * proceeding with I/O.
3006 : *
3007 : * \param group The group on which to poll connecting qpairs.
3008 : *
3009 : * return 0 if all qpairs are in CONNECTED state, -EIO if any connections failed to connect, -EAGAIN if
3010 : * any qpairs are still trying to connected.
3011 : */
3012 : int spdk_nvme_poll_group_all_connected(struct spdk_nvme_poll_group *group);
3013 :
3014 : /**
3015 : * Retrieve the user context for this specific poll group.
3016 : *
3017 : * \param group The poll group from which to retrieve the context.
3018 : *
3019 : * \return A pointer to the user provided poll group context.
3020 : */
3021 : void *spdk_nvme_poll_group_get_ctx(struct spdk_nvme_poll_group *group);
3022 :
3023 : /**
3024 : * Retrieves transport statistics for the given poll group.
3025 : *
3026 : * Note: the structure returned by this function should later be freed with
3027 : * @b spdk_nvme_poll_group_free_stats function
3028 : *
3029 : * \param group Pointer to NVME poll group
3030 : * \param stats Double pointer to statistics to be filled by this function
3031 : * \return 0 on success or negated errno on failure
3032 : */
3033 : int spdk_nvme_poll_group_get_stats(struct spdk_nvme_poll_group *group,
3034 : struct spdk_nvme_poll_group_stat **stats);
3035 :
3036 : /**
3037 : * Frees poll group statistics retrieved using @b spdk_nvme_poll_group_get_stats function
3038 : *
3039 : * @param group Pointer to a poll group
3040 : * @param stat Pointer to statistics to be released
3041 : */
3042 : void spdk_nvme_poll_group_free_stats(struct spdk_nvme_poll_group *group,
3043 : struct spdk_nvme_poll_group_stat *stat);
3044 :
3045 : /**
3046 : * Get the identify namespace data as defined by the NVMe specification.
3047 : *
3048 : * This function is thread safe and can be called at any point while the controller
3049 : * is attached to the SPDK NVMe driver.
3050 : *
3051 : * \param ns Namespace.
3052 : *
3053 : * \return a pointer to the namespace data.
3054 : */
3055 : const struct spdk_nvme_ns_data *spdk_nvme_ns_get_data(struct spdk_nvme_ns *ns);
3056 :
3057 : /**
3058 : * Get the I/O command set specific identify namespace data for NVM command set
3059 : * as defined by the NVMe specification.
3060 : *
3061 : * This function is thread safe and can be called at any point while the controller
3062 : * is attached to the SPDK NVMe driver.
3063 : *
3064 : * \param ns Namespace.
3065 : *
3066 : * \return a pointer to the identify namespace data.
3067 : */
3068 : const struct spdk_nvme_nvm_ns_data *spdk_nvme_nvm_ns_get_data(struct spdk_nvme_ns *ns);
3069 :
3070 : /**
3071 : * Get the namespace id (index number) from the given namespace handle.
3072 : *
3073 : * This function is thread safe and can be called at any point while the controller
3074 : * is attached to the SPDK NVMe driver.
3075 : *
3076 : * \param ns Namespace.
3077 : *
3078 : * \return namespace id.
3079 : */
3080 : uint32_t spdk_nvme_ns_get_id(struct spdk_nvme_ns *ns);
3081 :
3082 : /**
3083 : * Get the controller with which this namespace is associated.
3084 : *
3085 : * This function is thread safe and can be called at any point while the controller
3086 : * is attached to the SPDK NVMe driver.
3087 : *
3088 : * \param ns Namespace.
3089 : *
3090 : * \return a pointer to the controller.
3091 : */
3092 : struct spdk_nvme_ctrlr *spdk_nvme_ns_get_ctrlr(struct spdk_nvme_ns *ns);
3093 :
3094 : /**
3095 : * Determine whether a namespace is active.
3096 : *
3097 : * Inactive namespaces cannot be the target of I/O commands.
3098 : *
3099 : * \param ns Namespace to query.
3100 : *
3101 : * \return true if active, or false if inactive.
3102 : */
3103 : bool spdk_nvme_ns_is_active(struct spdk_nvme_ns *ns);
3104 :
3105 : /**
3106 : * Get the maximum transfer size, in bytes, for an I/O sent to the given namespace.
3107 : *
3108 : * This function is thread safe and can be called at any point while the controller
3109 : * is attached to the SPDK NVMe driver.
3110 : *
3111 : * \param ns Namespace to query.
3112 : *
3113 : * \return the maximum transfer size in bytes.
3114 : */
3115 : uint32_t spdk_nvme_ns_get_max_io_xfer_size(struct spdk_nvme_ns *ns);
3116 :
3117 : /**
3118 : * Get the sector size, in bytes, of the given namespace.
3119 : *
3120 : * This function returns the size of the data sector only. It does not
3121 : * include metadata size.
3122 : *
3123 : * This function is thread safe and can be called at any point while the controller
3124 : * is attached to the SPDK NVMe driver.
3125 : *
3126 : * \param ns Namespace to query.
3127 : *
3128 : * /return the sector size in bytes.
3129 : */
3130 : uint32_t spdk_nvme_ns_get_sector_size(struct spdk_nvme_ns *ns);
3131 :
3132 : /**
3133 : * Get the extended sector size, in bytes, of the given namespace.
3134 : *
3135 : * This function returns the size of the data sector plus metadata.
3136 : *
3137 : * This function is thread safe and can be called at any point while the controller
3138 : * is attached to the SPDK NVMe driver.
3139 : *
3140 : * \param ns Namespace to query.
3141 : *
3142 : * /return the extended sector size in bytes.
3143 : */
3144 : uint32_t spdk_nvme_ns_get_extended_sector_size(struct spdk_nvme_ns *ns);
3145 :
3146 : /**
3147 : * Get the number of sectors for the given namespace.
3148 : *
3149 : * This function is thread safe and can be called at any point while the controller
3150 : * is attached to the SPDK NVMe driver.
3151 : *
3152 : * \param ns Namespace to query.
3153 : *
3154 : * \return the number of sectors.
3155 : */
3156 : uint64_t spdk_nvme_ns_get_num_sectors(struct spdk_nvme_ns *ns);
3157 :
3158 : /**
3159 : * Get the size, in bytes, of the given namespace.
3160 : *
3161 : * This function is thread safe and can be called at any point while the controller
3162 : * is attached to the SPDK NVMe driver.
3163 : *
3164 : * \param ns Namespace to query.
3165 : *
3166 : * \return the size of the given namespace in bytes.
3167 : */
3168 : uint64_t spdk_nvme_ns_get_size(struct spdk_nvme_ns *ns);
3169 :
3170 : /**
3171 : * Get the end-to-end data protection information type of the given namespace.
3172 : *
3173 : * This function is thread safe and can be called at any point while the controller
3174 : * is attached to the SPDK NVMe driver.
3175 : *
3176 : * \param ns Namespace to query.
3177 : *
3178 : * \return the end-to-end data protection information type.
3179 : */
3180 : enum spdk_nvme_pi_type spdk_nvme_ns_get_pi_type(struct spdk_nvme_ns *ns);
3181 :
3182 : /**
3183 : * Get the end-to-end data protection information format of the given namespace.
3184 : *
3185 : * This function is thread safe and can be called at any point while the controller
3186 : * is attached to the SPDK NVMe driver.
3187 : *
3188 : * \param ns Namespace to query.
3189 : *
3190 : * \return the end-to-end data protection information format.
3191 : */
3192 : enum spdk_nvme_pi_format spdk_nvme_ns_get_pi_format(struct spdk_nvme_ns *ns);
3193 :
3194 : /**
3195 : * Get the metadata size, in bytes, of the given namespace.
3196 : *
3197 : * This function is thread safe and can be called at any point while the controller
3198 : * is attached to the SPDK NVMe driver.
3199 : *
3200 : * \param ns Namespace to query.
3201 : *
3202 : * \return the metadata size of the given namespace in bytes.
3203 : */
3204 : uint32_t spdk_nvme_ns_get_md_size(struct spdk_nvme_ns *ns);
3205 :
3206 : /**
3207 : * Get the format index of the given namespace.
3208 : *
3209 : * This function is thread safe and can be called at any point while the controller
3210 : * is attached to the SPDK NVMe driver.
3211 : *
3212 : * \param nsdata pointer to the NVMe namespace data.
3213 : *
3214 : * \return the format index of the given namespace.
3215 : */
3216 : uint32_t spdk_nvme_ns_get_format_index(const struct spdk_nvme_ns_data *nsdata);
3217 :
3218 : /**
3219 : * Check whether if the namespace can support extended LBA when end-to-end data
3220 : * protection enabled.
3221 : *
3222 : * This function is thread safe and can be called at any point while the controller
3223 : * is attached to the SPDK NVMe driver.
3224 : *
3225 : * \param ns Namespace to query.
3226 : *
3227 : * \return true if the namespace can support extended LBA when end-to-end data
3228 : * protection enabled, or false otherwise.
3229 : */
3230 : bool spdk_nvme_ns_supports_extended_lba(struct spdk_nvme_ns *ns);
3231 :
3232 : /**
3233 : * Check whether if the namespace supports compare operation
3234 : *
3235 : * This function is thread safe and can be called at any point while the controller
3236 : * is attached to the SPDK NVMe driver.
3237 : *
3238 : * \param ns Namespace to query.
3239 : *
3240 : * \return true if the namespace supports compare operation, or false otherwise.
3241 : */
3242 : bool spdk_nvme_ns_supports_compare(struct spdk_nvme_ns *ns);
3243 :
3244 : /**
3245 : * Determine the value returned when reading deallocated blocks.
3246 : *
3247 : * If deallocated blocks return 0, the deallocate command can be used as a more
3248 : * efficient alternative to the write_zeroes command, especially for large requests.
3249 : *
3250 : * \param ns Namespace.
3251 : *
3252 : * \return the logical block read value.
3253 : */
3254 : enum spdk_nvme_dealloc_logical_block_read_value spdk_nvme_ns_get_dealloc_logical_block_read_value(
3255 : struct spdk_nvme_ns *ns);
3256 :
3257 : /**
3258 : * Get the optimal I/O boundary, in blocks, for the given namespace.
3259 : *
3260 : * Read and write commands should not cross the optimal I/O boundary for best
3261 : * performance.
3262 : *
3263 : * \param ns Namespace to query.
3264 : *
3265 : * \return Optimal granularity of I/O commands, in blocks, or 0 if no optimal
3266 : * granularity is reported.
3267 : */
3268 : uint32_t spdk_nvme_ns_get_optimal_io_boundary(struct spdk_nvme_ns *ns);
3269 :
3270 : /**
3271 : * Get the NGUID for the given namespace.
3272 : *
3273 : * \param ns Namespace to query.
3274 : *
3275 : * \return a pointer to namespace NGUID, or NULL if ns does not have a NGUID.
3276 : */
3277 : const uint8_t *spdk_nvme_ns_get_nguid(const struct spdk_nvme_ns *ns);
3278 :
3279 : /**
3280 : * Get the UUID for the given namespace.
3281 : *
3282 : * \param ns Namespace to query.
3283 : *
3284 : * \return a pointer to namespace UUID, or NULL if ns does not have a UUID.
3285 : */
3286 : const struct spdk_uuid *spdk_nvme_ns_get_uuid(const struct spdk_nvme_ns *ns);
3287 :
3288 : /**
3289 : * Get the Command Set Identifier for the given namespace.
3290 : *
3291 : * \param ns Namespace to query.
3292 : *
3293 : * \return the namespace Command Set Identifier.
3294 : */
3295 : enum spdk_nvme_csi spdk_nvme_ns_get_csi(const struct spdk_nvme_ns *ns);
3296 :
3297 : /**
3298 : * \brief Namespace command support flags.
3299 : */
3300 : enum spdk_nvme_ns_flags {
3301 : SPDK_NVME_NS_DEALLOCATE_SUPPORTED = 1 << 0, /**< The deallocate command is supported */
3302 : SPDK_NVME_NS_FLUSH_SUPPORTED = 1 << 1, /**< The flush command is supported */
3303 : SPDK_NVME_NS_RESERVATION_SUPPORTED = 1 << 2, /**< The reservation command is supported */
3304 : SPDK_NVME_NS_WRITE_ZEROES_SUPPORTED = 1 << 3, /**< The write zeroes command is supported */
3305 : SPDK_NVME_NS_DPS_PI_SUPPORTED = 1 << 4, /**< The end-to-end data protection is supported */
3306 : SPDK_NVME_NS_EXTENDED_LBA_SUPPORTED = 1 << 5, /**< The extended lba format is supported,
3307 : metadata is transferred as a contiguous
3308 : part of the logical block that it is associated with */
3309 : SPDK_NVME_NS_WRITE_UNCORRECTABLE_SUPPORTED = 1 << 6, /**< The write uncorrectable command is supported */
3310 : SPDK_NVME_NS_COMPARE_SUPPORTED = 1 << 7, /**< The compare command is supported */
3311 : };
3312 :
3313 : /**
3314 : * Get the flags for the given namespace.
3315 : *
3316 : * See spdk_nvme_ns_flags for the possible flags returned.
3317 : *
3318 : * This function is thread safe and can be called at any point while the controller
3319 : * is attached to the SPDK NVMe driver.
3320 : *
3321 : * \param ns Namespace to query.
3322 : *
3323 : * \return the flags for the given namespace.
3324 : */
3325 : uint32_t spdk_nvme_ns_get_flags(struct spdk_nvme_ns *ns);
3326 :
3327 : /**
3328 : * Get the ANA group ID for the given namespace.
3329 : *
3330 : * This function should be called only if spdk_nvme_ctrlr_is_log_page_supported() returns
3331 : * true for the controller and log page ID SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS.
3332 : *
3333 : * This function is thread safe and can be called at any point while the controller
3334 : * is attached to the SPDK NVMe driver.
3335 : *
3336 : * \param ns Namespace to query.
3337 : *
3338 : * \return the ANA group ID for the given namespace.
3339 : */
3340 : uint32_t spdk_nvme_ns_get_ana_group_id(const struct spdk_nvme_ns *ns);
3341 :
3342 : /**
3343 : * Get the ANA state for the given namespace.
3344 : *
3345 : * This function should be called only if spdk_nvme_ctrlr_is_log_page_supported() returns
3346 : * true for the controller and log page ID SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS.
3347 : *
3348 : * This function is thread safe and can be called at any point while the controller
3349 : * is attached to the SPDK NVMe driver.
3350 : *
3351 : * \param ns Namespace to query.
3352 : *
3353 : * \return the ANA state for the given namespace.
3354 : */
3355 : enum spdk_nvme_ana_state spdk_nvme_ns_get_ana_state(const struct spdk_nvme_ns *ns);
3356 :
3357 : /**
3358 : * Submit a write I/O to the specified NVMe namespace.
3359 : *
3360 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3361 : * The user must ensure that only one thread submits I/O on a given qpair at any
3362 : * given time.
3363 : *
3364 : * \param ns NVMe namespace to submit the write I/O.
3365 : * \param qpair I/O queue pair to submit the request.
3366 : * \param payload Virtual address pointer to the data payload.
3367 : * \param lba Starting LBA to write the data.
3368 : * \param lba_count Length (in sectors) for the write operation.
3369 : * \param cb_fn Callback function to invoke when the I/O is completed.
3370 : * \param cb_arg Argument to pass to the callback function.
3371 : * \param io_flags Set flags, defined by the SPDK_NVME_IO_FLAGS_* entries in
3372 : * spdk/nvme_spec.h, for this I/O.
3373 : *
3374 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3375 : * -EINVAL: The request is malformed.
3376 : * -ENOMEM: The request cannot be allocated.
3377 : * -ENXIO: The qpair is failed at the transport level.
3378 : */
3379 : int spdk_nvme_ns_cmd_write(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
3380 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
3381 : void *cb_arg, uint32_t io_flags);
3382 :
3383 : /**
3384 : * Submit a write I/O to the specified NVMe namespace.
3385 : *
3386 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3387 : * The user must ensure that only one thread submits I/O on a given qpair at any
3388 : * given time.
3389 : *
3390 : * \param ns NVMe namespace to submit the write I/O.
3391 : * \param qpair I/O queue pair to submit the request.
3392 : * \param lba Starting LBA to write the data.
3393 : * \param lba_count Length (in sectors) for the write operation.
3394 : * \param cb_fn Callback function to invoke when the I/O is completed.
3395 : * \param cb_arg Argument to pass to the callback function.
3396 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
3397 : * \param reset_sgl_fn Callback function to reset scattered payload.
3398 : * \param next_sge_fn Callback function to iterate each scattered payload memory
3399 : * segment.
3400 : *
3401 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3402 : * -EINVAL: The request is malformed.
3403 : * -ENOMEM: The request cannot be allocated.
3404 : * -ENXIO: The qpair is failed at the transport level.
3405 : */
3406 : int spdk_nvme_ns_cmd_writev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3407 : uint64_t lba, uint32_t lba_count,
3408 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
3409 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3410 : spdk_nvme_req_next_sge_cb next_sge_fn);
3411 :
3412 : /**
3413 : * Submit a write I/O to the specified NVMe namespace.
3414 : *
3415 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3416 : * The user must ensure that only one thread submits I/O on a given qpair at any
3417 : * given time.
3418 : *
3419 : * \param ns NVMe namespace to submit the write I/O
3420 : * \param qpair I/O queue pair to submit the request
3421 : * \param lba starting LBA to write the data
3422 : * \param lba_count length (in sectors) for the write operation
3423 : * \param cb_fn callback function to invoke when the I/O is completed
3424 : * \param cb_arg argument to pass to the callback function
3425 : * \param io_flags set flags, defined in nvme_spec.h, for this I/O
3426 : * \param reset_sgl_fn callback function to reset scattered payload
3427 : * \param next_sge_fn callback function to iterate each scattered
3428 : * payload memory segment
3429 : * \param metadata virtual address pointer to the metadata payload, the length
3430 : * of metadata is specified by spdk_nvme_ns_get_md_size()
3431 : * \param apptag_mask application tag mask.
3432 : * \param apptag application tag to use end-to-end protection information.
3433 : *
3434 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3435 : * -EINVAL: The request is malformed.
3436 : * -ENOMEM: The request cannot be allocated.
3437 : * -ENXIO: The qpair is failed at the transport level.
3438 : */
3439 : int spdk_nvme_ns_cmd_writev_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3440 : uint64_t lba, uint32_t lba_count,
3441 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
3442 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3443 : spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata,
3444 : uint16_t apptag_mask, uint16_t apptag);
3445 :
3446 : /**
3447 : * Submit a write I/O to the specified NVMe namespace.
3448 : *
3449 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3450 : * The user must ensure that only one thread submits I/O on a given qpair at any
3451 : * given time.
3452 : *
3453 : * \param ns NVMe namespace to submit the write I/O
3454 : * \param qpair I/O queue pair to submit the request
3455 : * \param lba starting LBA to write the data
3456 : * \param lba_count length (in sectors) for the write operation
3457 : * \param cb_fn callback function to invoke when the I/O is completed
3458 : * \param cb_arg argument to pass to the callback function
3459 : * \param reset_sgl_fn callback function to reset scattered payload
3460 : * \param next_sge_fn callback function to iterate each scattered
3461 : * payload memory segment
3462 : * \param opts Optional structure with extended IO request options. If provided, the caller must
3463 : * guarantee that this structure is accessible until IO completes
3464 : *
3465 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3466 : * -EINVAL: The request is malformed.
3467 : * -ENOMEM: The request cannot be allocated.
3468 : * -ENXIO: The qpair is failed at the transport level.
3469 : * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
3470 : * with error status including dnr=1 in this case.
3471 : */
3472 : int spdk_nvme_ns_cmd_writev_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3473 : uint64_t lba, uint32_t lba_count,
3474 : spdk_nvme_cmd_cb cb_fn, void *cb_arg,
3475 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3476 : spdk_nvme_req_next_sge_cb next_sge_fn,
3477 : struct spdk_nvme_ns_cmd_ext_io_opts *opts);
3478 :
3479 : /**
3480 : * Submit a write I/O to the specified NVMe namespace.
3481 : *
3482 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3483 : * The user must ensure that only one thread submits I/O on a given qpair at any
3484 : * given time.
3485 : *
3486 : * \param ns NVMe namespace to submit the write I/O
3487 : * \param qpair I/O queue pair to submit the request
3488 : * \param payload Virtual address pointer to the data payload.
3489 : * \param lba starting LBA to write the data
3490 : * \param lba_count length (in sectors) for the write operation
3491 : * \param cb_fn callback function to invoke when the I/O is completed
3492 : * \param cb_arg argument to pass to the callback function
3493 : * \param opts Optional structure with extended IO request options. If provided, the caller must
3494 : * guarantee that this structure is accessible until IO completes
3495 : *
3496 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3497 : * -EINVAL: The request is malformed.
3498 : * -ENOMEM: The request cannot be allocated.
3499 : * -ENXIO: The qpair is failed at the transport level.
3500 : * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
3501 : * with error status including dnr=1 in this case.
3502 : */
3503 : int spdk_nvme_ns_cmd_write_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3504 : void *payload, uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn, void *cb_arg,
3505 : struct spdk_nvme_ns_cmd_ext_io_opts *opts);
3506 :
3507 : /**
3508 : * Submit a write I/O to the specified NVMe namespace.
3509 : *
3510 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3511 : * The user must ensure that only one thread submits I/O on a given qpair at any
3512 : * given time.
3513 : *
3514 : * \param ns NVMe namespace to submit the write I/O.
3515 : * \param qpair I/O queue pair to submit the request.
3516 : * \param payload Virtual address pointer to the data payload.
3517 : * \param metadata Virtual address pointer to the metadata payload, the length
3518 : * of metadata is specified by spdk_nvme_ns_get_md_size().
3519 : * \param lba Starting LBA to write the data.
3520 : * \param lba_count Length (in sectors) for the write operation.
3521 : * \param cb_fn Callback function to invoke when the I/O is completed.
3522 : * \param cb_arg Argument to pass to the callback function.
3523 : * \param io_flags Set flags, defined by the SPDK_NVME_IO_FLAGS_* entries in
3524 : * spdk/nvme_spec.h, for this I/O.
3525 : * \param apptag_mask Application tag mask.
3526 : * \param apptag Application tag to use end-to-end protection information.
3527 : *
3528 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3529 : * -EINVAL: The request is malformed.
3530 : * -ENOMEM: The request cannot be allocated.
3531 : * -ENXIO: The qpair is failed at the transport level.
3532 : */
3533 : int spdk_nvme_ns_cmd_write_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3534 : void *payload, void *metadata,
3535 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
3536 : void *cb_arg, uint32_t io_flags,
3537 : uint16_t apptag_mask, uint16_t apptag);
3538 :
3539 : /**
3540 : * Submit a write zeroes I/O to the specified NVMe namespace.
3541 : *
3542 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3543 : * The user must ensure that only one thread submits I/O on a given qpair at any
3544 : * given time.
3545 : *
3546 : * \param ns NVMe namespace to submit the write zeroes I/O.
3547 : * \param qpair I/O queue pair to submit the request.
3548 : * \param lba Starting LBA for this command.
3549 : * \param lba_count Length (in sectors) for the write zero operation.
3550 : * \param cb_fn Callback function to invoke when the I/O is completed.
3551 : * \param cb_arg Argument to pass to the callback function.
3552 : * \param io_flags Set flags, defined by the SPDK_NVME_IO_FLAGS_* entries in
3553 : * spdk/nvme_spec.h, for this I/O.
3554 : *
3555 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3556 : * -EINVAL: The request is malformed.
3557 : * -ENOMEM: The request cannot be allocated.
3558 : * -ENXIO: The qpair is failed at the transport level.
3559 : */
3560 : int spdk_nvme_ns_cmd_write_zeroes(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3561 : uint64_t lba, uint32_t lba_count,
3562 : spdk_nvme_cmd_cb cb_fn, void *cb_arg,
3563 : uint32_t io_flags);
3564 :
3565 : /**
3566 : * Submit a verify I/O to the specified NVMe namespace.
3567 : *
3568 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3569 : * The user must ensure that only one thread submits I/O on a given qpair at any
3570 : * given time.
3571 : *
3572 : * \param ns NVMe namespace to submit the verify I/O.
3573 : * \param qpair I/O queue pair to submit the request.
3574 : * \param lba Starting LBA to verify the data.
3575 : * \param lba_count Length (in sectors) for the verify operation.
3576 : * \param cb_fn Callback function to invoke when the I/O is completed.
3577 : * \param cb_arg Argument to pass to the callback function.
3578 : * \param io_flags Set flags, defined by the SPDK_NVME_IO_FLAGS_* entries in
3579 : * spdk/nvme_spec.h, for this I/O.
3580 : *
3581 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3582 : * -EINVAL: The request is malformed.
3583 : * -ENOMEM: The request cannot be allocated.
3584 : * -ENXIO: The qpair is failed at the transport level.
3585 : */
3586 : int spdk_nvme_ns_cmd_verify(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3587 : uint64_t lba, uint32_t lba_count,
3588 : spdk_nvme_cmd_cb cb_fn, void *cb_arg,
3589 : uint32_t io_flags);
3590 :
3591 : /**
3592 : * Submit a write uncorrectable I/O to the specified NVMe namespace.
3593 : *
3594 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3595 : * The user must ensure that only one thread submits I/O on a given qpair at any
3596 : * given time.
3597 : *
3598 : * \param ns NVMe namespace to submit the write uncorrectable I/O.
3599 : * \param qpair I/O queue pair to submit the request.
3600 : * \param lba Starting LBA for this command.
3601 : * \param lba_count Length (in sectors) for the write uncorrectable operation.
3602 : * \param cb_fn Callback function to invoke when the I/O is completed.
3603 : * \param cb_arg Argument to pass to the callback function.
3604 : *
3605 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3606 : * -EINVAL: The request is malformed.
3607 : * -ENOMEM: The request cannot be allocated.
3608 : * -ENXIO: The qpair is failed at the transport level.
3609 : */
3610 : int spdk_nvme_ns_cmd_write_uncorrectable(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3611 : uint64_t lba, uint32_t lba_count,
3612 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3613 :
3614 : /**
3615 : * \brief Submits a read I/O to the specified NVMe namespace.
3616 : *
3617 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3618 : * The user must ensure that only one thread submits I/O on a given qpair at any
3619 : * given time.
3620 : *
3621 : * \param ns NVMe namespace to submit the read I/O.
3622 : * \param qpair I/O queue pair to submit the request.
3623 : * \param payload Virtual address pointer to the data payload.
3624 : * \param lba Starting LBA to read the data.
3625 : * \param lba_count Length (in sectors) for the read operation.
3626 : * \param cb_fn Callback function to invoke when the I/O is completed.
3627 : * \param cb_arg Argument to pass to the callback function.
3628 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
3629 : *
3630 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3631 : * -EINVAL: The request is malformed.
3632 : * -ENOMEM: The request cannot be allocated.
3633 : * -ENXIO: The qpair is failed at the transport level.
3634 : */
3635 : int spdk_nvme_ns_cmd_read(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
3636 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
3637 : void *cb_arg, uint32_t io_flags);
3638 :
3639 : /**
3640 : * Submit a read I/O to the specified NVMe namespace.
3641 : *
3642 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3643 : * The user must ensure that only one thread submits I/O on a given qpair at any
3644 : * given time.
3645 : *
3646 : * \param ns NVMe namespace to submit the read I/O.
3647 : * \param qpair I/O queue pair to submit the request.
3648 : * \param lba Starting LBA to read the data.
3649 : * \param lba_count Length (in sectors) for the read operation.
3650 : * \param cb_fn Callback function to invoke when the I/O is completed.
3651 : * \param cb_arg Argument to pass to the callback function.
3652 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
3653 : * \param reset_sgl_fn Callback function to reset scattered payload.
3654 : * \param next_sge_fn Callback function to iterate each scattered payload memory
3655 : * segment.
3656 : *
3657 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3658 : * -EINVAL: The request is malformed.
3659 : * -ENOMEM: The request cannot be allocated.
3660 : * -ENXIO: The qpair is failed at the transport level.
3661 : */
3662 : int spdk_nvme_ns_cmd_readv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3663 : uint64_t lba, uint32_t lba_count,
3664 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
3665 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3666 : spdk_nvme_req_next_sge_cb next_sge_fn);
3667 :
3668 : /**
3669 : * Submit a read I/O to the specified NVMe namespace.
3670 : *
3671 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3672 : * The user must ensure that only one thread submits I/O on a given qpair at any given time.
3673 : *
3674 : * \param ns NVMe namespace to submit the read I/O
3675 : * \param qpair I/O queue pair to submit the request
3676 : * \param lba starting LBA to read the data
3677 : * \param lba_count length (in sectors) for the read operation
3678 : * \param cb_fn callback function to invoke when the I/O is completed
3679 : * \param cb_arg argument to pass to the callback function
3680 : * \param io_flags set flags, defined in nvme_spec.h, for this I/O
3681 : * \param reset_sgl_fn callback function to reset scattered payload
3682 : * \param next_sge_fn callback function to iterate each scattered
3683 : * payload memory segment
3684 : * \param metadata virtual address pointer to the metadata payload, the length
3685 : * of metadata is specified by spdk_nvme_ns_get_md_size()
3686 : * \param apptag_mask application tag mask.
3687 : * \param apptag application tag to use end-to-end protection information.
3688 : *
3689 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3690 : * -EINVAL: The request is malformed.
3691 : * -ENOMEM: The request cannot be allocated.
3692 : * -ENXIO: The qpair is failed at the transport level.
3693 : */
3694 : int spdk_nvme_ns_cmd_readv_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3695 : uint64_t lba, uint32_t lba_count,
3696 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
3697 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3698 : spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata,
3699 : uint16_t apptag_mask, uint16_t apptag);
3700 :
3701 : /**
3702 : * Submit a read I/O to the specified NVMe namespace.
3703 : *
3704 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3705 : * The user must ensure that only one thread submits I/O on a given qpair at any given time.
3706 : *
3707 : * \param ns NVMe namespace to submit the read I/O
3708 : * \param qpair I/O queue pair to submit the request
3709 : * \param lba starting LBA to read the data
3710 : * \param lba_count length (in sectors) for the read operation
3711 : * \param cb_fn callback function to invoke when the I/O is completed
3712 : * \param cb_arg argument to pass to the callback function
3713 : * \param reset_sgl_fn callback function to reset scattered payload
3714 : * \param next_sge_fn callback function to iterate each scattered
3715 : * payload memory segment
3716 : * \param opts Optional structure with extended IO request options. If provided, the caller must
3717 : * guarantee that this structure is accessible until IO completes
3718 : *
3719 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3720 : * -EINVAL: The request is malformed.
3721 : * -ENOMEM: The request cannot be allocated.
3722 : * -ENXIO: The qpair is failed at the transport level.
3723 : * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
3724 : * with error status including dnr=1 in this case.
3725 : */
3726 : int spdk_nvme_ns_cmd_readv_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3727 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
3728 : void *cb_arg, spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
3729 : spdk_nvme_req_next_sge_cb next_sge_fn,
3730 : struct spdk_nvme_ns_cmd_ext_io_opts *opts);
3731 :
3732 : /**
3733 : * Submit a read I/O to the specified NVMe namespace.
3734 : *
3735 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3736 : * The user must ensure that only one thread submits I/O on a given qpair at any given time.
3737 : *
3738 : * \param ns NVMe namespace to submit the read I/O
3739 : * \param qpair I/O queue pair to submit the request
3740 : * \param payload virtual address pointer to the data payload
3741 : * \param lba starting LBA to read the data
3742 : * \param lba_count length (in sectors) for the read operation
3743 : * \param cb_fn callback function to invoke when the I/O is completed
3744 : * \param cb_arg argument to pass to the callback function
3745 : * \param opts Optional structure with extended IO request options. If provided, the caller must
3746 : * guarantee that this structure is accessible until IO completes
3747 : *
3748 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3749 : * -EINVAL: The request is malformed.
3750 : * -ENOMEM: The request cannot be allocated.
3751 : * -ENXIO: The qpair is failed at the transport level.
3752 : * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
3753 : * with error status including dnr=1 in this case.
3754 : */
3755 : int spdk_nvme_ns_cmd_read_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
3756 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn, void *cb_arg,
3757 : struct spdk_nvme_ns_cmd_ext_io_opts *opts);
3758 :
3759 : /**
3760 : * Submits a read I/O to the specified NVMe namespace.
3761 : *
3762 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3763 : * The user must ensure that only one thread submits I/O on a given qpair at any
3764 : * given time.
3765 : *
3766 : * \param ns NVMe namespace to submit the read I/O
3767 : * \param qpair I/O queue pair to submit the request
3768 : * \param payload virtual address pointer to the data payload
3769 : * \param metadata virtual address pointer to the metadata payload, the length
3770 : * of metadata is specified by spdk_nvme_ns_get_md_size().
3771 : * \param lba starting LBA to read the data.
3772 : * \param lba_count Length (in sectors) for the read operation.
3773 : * \param cb_fn Callback function to invoke when the I/O is completed.
3774 : * \param cb_arg Argument to pass to the callback function.
3775 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
3776 : * \param apptag_mask Application tag mask.
3777 : * \param apptag Application tag to use end-to-end protection information.
3778 : *
3779 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3780 : * -EINVAL: The request is malformed.
3781 : * -ENOMEM: The request cannot be allocated.
3782 : * -ENXIO: The qpair is failed at the transport level.
3783 : */
3784 : int spdk_nvme_ns_cmd_read_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3785 : void *payload, void *metadata,
3786 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
3787 : void *cb_arg, uint32_t io_flags,
3788 : uint16_t apptag_mask, uint16_t apptag);
3789 :
3790 : /**
3791 : * Submit a data set management request to the specified NVMe namespace.
3792 : *
3793 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3794 : * The user must ensure that only one thread submits I/O on a given qpair at any
3795 : * given time.
3796 : *
3797 : * This is a convenience wrapper that will automatically allocate and construct
3798 : * the correct data buffers. Therefore, ranges does not need to be allocated from
3799 : * pinned memory and can be placed on the stack. If a higher performance, zero-copy
3800 : * version of DSM is required, simply build and submit a raw command using
3801 : * spdk_nvme_ctrlr_cmd_io_raw().
3802 : *
3803 : * \param ns NVMe namespace to submit the DSM request
3804 : * \param type A bit field constructed from \ref spdk_nvme_dsm_attribute.
3805 : * \param qpair I/O queue pair to submit the request
3806 : * \param ranges An array of \ref spdk_nvme_dsm_range elements describing the LBAs
3807 : * to operate on.
3808 : * \param num_ranges The number of elements in the ranges array.
3809 : * \param cb_fn Callback function to invoke when the I/O is completed
3810 : * \param cb_arg Argument to pass to the callback function
3811 : *
3812 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3813 : * -ENOMEM: The request cannot be allocated.
3814 : * -ENXIO: The qpair is failed at the transport level.
3815 : */
3816 : int spdk_nvme_ns_cmd_dataset_management(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3817 : uint32_t type,
3818 : const struct spdk_nvme_dsm_range *ranges,
3819 : uint16_t num_ranges,
3820 : spdk_nvme_cmd_cb cb_fn,
3821 : void *cb_arg);
3822 :
3823 : /**
3824 : * Submit a simple copy command request to the specified NVMe namespace.
3825 : *
3826 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3827 : * The user must ensure that only one thread submits I/O on a given qpair at any
3828 : * given time.
3829 : *
3830 : * This is a convenience wrapper that will automatically allocate and construct
3831 : * the correct data buffers. Therefore, ranges does not need to be allocated from
3832 : * pinned memory and can be placed on the stack. If a higher performance, zero-copy
3833 : * version of SCC is required, simply build and submit a raw command using
3834 : * spdk_nvme_ctrlr_cmd_io_raw().
3835 : *
3836 : * \param ns NVMe namespace to submit the SCC request
3837 : * \param qpair I/O queue pair to submit the request
3838 : * \param ranges An array of \ref spdk_nvme_scc_source_range elements describing the LBAs
3839 : * to operate on.
3840 : * \param num_ranges The number of elements in the ranges array.
3841 : * \param dest_lba Destination LBA to copy the data.
3842 : * \param cb_fn Callback function to invoke when the I/O is completed
3843 : * \param cb_arg Argument to pass to the callback function
3844 : *
3845 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3846 : * -ENOMEM: The request cannot be allocated.
3847 : * -EINVAL: Invalid ranges.
3848 : * -ENXIO: The qpair is failed at the transport level.
3849 : */
3850 : int spdk_nvme_ns_cmd_copy(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3851 : const struct spdk_nvme_scc_source_range *ranges,
3852 : uint16_t num_ranges,
3853 : uint64_t dest_lba,
3854 : spdk_nvme_cmd_cb cb_fn,
3855 : void *cb_arg);
3856 :
3857 : /**
3858 : * Submit a flush request to the specified NVMe namespace.
3859 : *
3860 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3861 : * The user must ensure that only one thread submits I/O on a given qpair at any
3862 : * given time.
3863 : *
3864 : * \param ns NVMe namespace to submit the flush request.
3865 : * \param qpair I/O queue pair to submit the request.
3866 : * \param cb_fn Callback function to invoke when the I/O is completed.
3867 : * \param cb_arg Argument to pass to the callback function.
3868 : *
3869 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3870 : * -ENOMEM: The request cannot be allocated.
3871 : * -ENXIO: The qpair is failed at the transport level.
3872 : */
3873 : int spdk_nvme_ns_cmd_flush(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
3874 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3875 :
3876 : /**
3877 : * Submit a reservation register to the specified NVMe namespace.
3878 : *
3879 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3880 : * The user must ensure that only one thread submits I/O on a given qpair at any
3881 : * given time.
3882 : *
3883 : * \param ns NVMe namespace to submit the reservation register request.
3884 : * \param qpair I/O queue pair to submit the request.
3885 : * \param payload Virtual address pointer to the reservation register data.
3886 : * \param ignore_key '1' the current reservation key check is disabled.
3887 : * \param action Specifies the registration action.
3888 : * \param cptpl Change the Persist Through Power Loss state.
3889 : * \param cb_fn Callback function to invoke when the I/O is completed.
3890 : * \param cb_arg Argument to pass to the callback function.
3891 : *
3892 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3893 : * -ENOMEM: The request cannot be allocated.
3894 : * -ENXIO: The qpair is failed at the transport level.
3895 : */
3896 : int spdk_nvme_ns_cmd_reservation_register(struct spdk_nvme_ns *ns,
3897 : struct spdk_nvme_qpair *qpair,
3898 : struct spdk_nvme_reservation_register_data *payload,
3899 : bool ignore_key,
3900 : enum spdk_nvme_reservation_register_action action,
3901 : enum spdk_nvme_reservation_register_cptpl cptpl,
3902 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3903 :
3904 : /**
3905 : * Submits a reservation release to the specified NVMe namespace.
3906 : *
3907 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3908 : * The user must ensure that only one thread submits I/O on a given qpair at any
3909 : * given time.
3910 : *
3911 : * \param ns NVMe namespace to submit the reservation release request.
3912 : * \param qpair I/O queue pair to submit the request.
3913 : * \param payload Virtual address pointer to current reservation key.
3914 : * \param ignore_key '1' the current reservation key check is disabled.
3915 : * \param action Specifies the reservation release action.
3916 : * \param type Reservation type for the namespace.
3917 : * \param cb_fn Callback function to invoke when the I/O is completed.
3918 : * \param cb_arg Argument to pass to the callback function.
3919 : *
3920 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3921 : * -ENOMEM: The request cannot be allocated.
3922 : * -ENXIO: The qpair is failed at the transport level.
3923 : */
3924 : int spdk_nvme_ns_cmd_reservation_release(struct spdk_nvme_ns *ns,
3925 : struct spdk_nvme_qpair *qpair,
3926 : struct spdk_nvme_reservation_key_data *payload,
3927 : bool ignore_key,
3928 : enum spdk_nvme_reservation_release_action action,
3929 : enum spdk_nvme_reservation_type type,
3930 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3931 :
3932 : /**
3933 : * Submits a reservation acquire to the specified NVMe namespace.
3934 : *
3935 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3936 : * The user must ensure that only one thread submits I/O on a given qpair at any
3937 : * given time.
3938 : *
3939 : * \param ns NVMe namespace to submit the reservation acquire request.
3940 : * \param qpair I/O queue pair to submit the request.
3941 : * \param payload Virtual address pointer to reservation acquire data.
3942 : * \param ignore_key '1' the current reservation key check is disabled.
3943 : * \param action Specifies the reservation acquire action.
3944 : * \param type Reservation type for the namespace.
3945 : * \param cb_fn Callback function to invoke when the I/O is completed.
3946 : * \param cb_arg Argument to pass to the callback function.
3947 : *
3948 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3949 : * -ENOMEM: The request cannot be allocated.
3950 : * -ENXIO: The qpair is failed at the transport level.
3951 : */
3952 : int spdk_nvme_ns_cmd_reservation_acquire(struct spdk_nvme_ns *ns,
3953 : struct spdk_nvme_qpair *qpair,
3954 : struct spdk_nvme_reservation_acquire_data *payload,
3955 : bool ignore_key,
3956 : enum spdk_nvme_reservation_acquire_action action,
3957 : enum spdk_nvme_reservation_type type,
3958 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3959 :
3960 : /**
3961 : * Submit a reservation report to the specified NVMe namespace.
3962 : *
3963 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3964 : * The user must ensure that only one thread submits I/O on a given qpair at any
3965 : * given time.
3966 : *
3967 : * \param ns NVMe namespace to submit the reservation report request.
3968 : * \param qpair I/O queue pair to submit the request.
3969 : * \param payload Virtual address pointer for reservation status data.
3970 : * \param len Length bytes for reservation status data structure.
3971 : * \param cb_fn Callback function to invoke when the I/O is completed.
3972 : * \param cb_arg Argument to pass to the callback function.
3973 : *
3974 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
3975 : * -ENOMEM: The request cannot be allocated.
3976 : * -ENXIO: The qpair is failed at the transport level.
3977 : */
3978 : int spdk_nvme_ns_cmd_reservation_report(struct spdk_nvme_ns *ns,
3979 : struct spdk_nvme_qpair *qpair,
3980 : void *payload, uint32_t len,
3981 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
3982 :
3983 : /**
3984 : * Submit an I/O management receive command to the specified NVMe namespace.
3985 : *
3986 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
3987 : * The user must ensure that only one thread submits I/O on a given qpair at any
3988 : * given time.
3989 : *
3990 : * \param ns NVMe namespace to submit the I/O mgmt receive request.
3991 : * \param qpair I/O queue pair to submit the request.
3992 : * \param payload Virtual address pointer for I/O mgmt receive data.
3993 : * \param len Length bytes for I/O mgmt receive data structure.
3994 : * \param mo Management operation to perform.
3995 : * \param mos Management operation specific field for the mo.
3996 : * \param cb_fn Callback function to invoke when the I/O is completed.
3997 : * \param cb_arg Argument to pass to the callback function.
3998 : *
3999 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4000 : * -ENOMEM: The request cannot be allocated.
4001 : * -ENXIO: The qpair is failed at the transport level.
4002 : */
4003 : int spdk_nvme_ns_cmd_io_mgmt_recv(struct spdk_nvme_ns *ns,
4004 : struct spdk_nvme_qpair *qpair, void *payload,
4005 : uint32_t len, uint8_t mo, uint16_t mos,
4006 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
4007 :
4008 : /**
4009 : * Submit an I/O management send command to the specified NVMe namespace.
4010 : *
4011 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
4012 : * The user must ensure that only one thread submits I/O on a given qpair at any
4013 : * given time.
4014 : *
4015 : * \param ns NVMe namespace to submit the I/O mgmt send request.
4016 : * \param qpair I/O queue pair to submit the request.
4017 : * \param payload Virtual address pointer for I/O mgmt send data.
4018 : * \param len Length bytes for I/O mgmt send data structure.
4019 : * \param mo Management operation to perform.
4020 : * \param mos Management operation specific field for the mo.
4021 : * \param cb_fn Callback function to invoke when the I/O is completed.
4022 : * \param cb_arg Argument to pass to the callback function.
4023 : *
4024 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4025 : * -ENOMEM: The request cannot be allocated.
4026 : * -ENXIO: The qpair is failed at the transport level.
4027 : */
4028 : int spdk_nvme_ns_cmd_io_mgmt_send(struct spdk_nvme_ns *ns,
4029 : struct spdk_nvme_qpair *qpair, void *payload,
4030 : uint32_t len, uint8_t mo, uint16_t mos,
4031 : spdk_nvme_cmd_cb cb_fn, void *cb_arg);
4032 :
4033 : /**
4034 : * Submit a compare I/O to the specified NVMe namespace.
4035 : *
4036 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
4037 : * The user must ensure that only one thread submits I/O on a given qpair at any
4038 : * given time.
4039 : *
4040 : * \param ns NVMe namespace to submit the compare I/O.
4041 : * \param qpair I/O queue pair to submit the request.
4042 : * \param payload Virtual address pointer to the data payload.
4043 : * \param lba Starting LBA to compare the data.
4044 : * \param lba_count Length (in sectors) for the compare operation.
4045 : * \param cb_fn Callback function to invoke when the I/O is completed.
4046 : * \param cb_arg Argument to pass to the callback function.
4047 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
4048 : *
4049 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4050 : * -EINVAL: The request is malformed.
4051 : * -ENOMEM: The request cannot be allocated.
4052 : * -ENXIO: The qpair is failed at the transport level.
4053 : */
4054 : int spdk_nvme_ns_cmd_compare(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
4055 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
4056 : void *cb_arg, uint32_t io_flags);
4057 :
4058 : /**
4059 : * Submit a compare I/O to the specified NVMe namespace.
4060 : *
4061 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
4062 : * The user must ensure that only one thread submits I/O on a given qpair at any
4063 : * given time.
4064 : *
4065 : * \param ns NVMe namespace to submit the compare I/O.
4066 : * \param qpair I/O queue pair to submit the request.
4067 : * \param lba Starting LBA to compare the data.
4068 : * \param lba_count Length (in sectors) for the compare operation.
4069 : * \param cb_fn Callback function to invoke when the I/O is completed.
4070 : * \param cb_arg Argument to pass to the callback function.
4071 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
4072 : * \param reset_sgl_fn Callback function to reset scattered payload.
4073 : * \param next_sge_fn Callback function to iterate each scattered payload memory
4074 : * segment.
4075 : *
4076 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4077 : * -EINVAL: The request is malformed.
4078 : * -ENOMEM: The request cannot be allocated.
4079 : * -ENXIO: The qpair is failed at the transport level.
4080 : */
4081 : int spdk_nvme_ns_cmd_comparev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
4082 : uint64_t lba, uint32_t lba_count,
4083 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
4084 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
4085 : spdk_nvme_req_next_sge_cb next_sge_fn);
4086 :
4087 : /**
4088 : * Submit a compare I/O to the specified NVMe namespace.
4089 : *
4090 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
4091 : * The user must ensure that only one thread submits I/O on a given qpair at any
4092 : * given time.
4093 : *
4094 : * \param ns NVMe namespace to submit the compare I/O.
4095 : * \param qpair I/O queue pair to submit the request.
4096 : * \param lba Starting LBA to compare the data.
4097 : * \param lba_count Length (in sectors) for the compare operation.
4098 : * \param cb_fn Callback function to invoke when the I/O is completed.
4099 : * \param cb_arg Argument to pass to the callback function.
4100 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
4101 : * \param reset_sgl_fn Callback function to reset scattered payload.
4102 : * \param next_sge_fn Callback function to iterate each scattered payload memory
4103 : * segment.
4104 : * \param metadata Virtual address pointer to the metadata payload, the length
4105 : * of metadata is specified by spdk_nvme_ns_get_md_size()
4106 : * \param apptag_mask Application tag mask.
4107 : * \param apptag Application tag to use end-to-end protection information.
4108 : *
4109 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4110 : * -EINVAL: The request is malformed.
4111 : * -ENOMEM: The request cannot be allocated.
4112 : * -ENXIO: The qpair is failed at the transport level.
4113 : */
4114 : int
4115 : spdk_nvme_ns_cmd_comparev_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
4116 : uint64_t lba, uint32_t lba_count,
4117 : spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
4118 : spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
4119 : spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata,
4120 : uint16_t apptag_mask, uint16_t apptag);
4121 :
4122 : /**
4123 : * Submit a compare I/O to the specified NVMe namespace.
4124 : *
4125 : * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
4126 : * The user must ensure that only one thread submits I/O on a given qpair at any
4127 : * given time.
4128 : *
4129 : * \param ns NVMe namespace to submit the compare I/O.
4130 : * \param qpair I/O queue pair to submit the request.
4131 : * \param payload Virtual address pointer to the data payload.
4132 : * \param metadata Virtual address pointer to the metadata payload, the length
4133 : * of metadata is specified by spdk_nvme_ns_get_md_size().
4134 : * \param lba Starting LBA to compare the data.
4135 : * \param lba_count Length (in sectors) for the compare operation.
4136 : * \param cb_fn Callback function to invoke when the I/O is completed.
4137 : * \param cb_arg Argument to pass to the callback function.
4138 : * \param io_flags Set flags, defined in nvme_spec.h, for this I/O.
4139 : * \param apptag_mask Application tag mask.
4140 : * \param apptag Application tag to use end-to-end protection information.
4141 : *
4142 : * \return 0 if successfully submitted, negated errnos on the following error conditions:
4143 : * -EINVAL: The request is malformed.
4144 : * -ENOMEM: The request cannot be allocated.
4145 : * -ENXIO: The qpair is failed at the transport level.
4146 : */
4147 : int spdk_nvme_ns_cmd_compare_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
4148 : void *payload, void *metadata,
4149 : uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
4150 : void *cb_arg, uint32_t io_flags,
4151 : uint16_t apptag_mask, uint16_t apptag);
4152 :
4153 : /**
4154 : * \brief Inject an error for the next request with a given opcode.
4155 : *
4156 : * \param ctrlr NVMe controller.
4157 : * \param qpair I/O queue pair to add the error command,
4158 : * NULL for Admin queue pair.
4159 : * \param opc Opcode for Admin or I/O commands.
4160 : * \param do_not_submit True if matching requests should not be submitted
4161 : * to the controller, but instead completed manually
4162 : * after timeout_in_us has expired. False if matching
4163 : * requests should be submitted to the controller and
4164 : * have their completion status modified after the
4165 : * controller completes the request.
4166 : * \param timeout_in_us Wait specified microseconds when do_not_submit is true.
4167 : * \param err_count Number of matching requests to inject errors.
4168 : * \param sct Status code type.
4169 : * \param sc Status code.
4170 : *
4171 : * \return 0 if successfully enabled, ENOMEM if an error command
4172 : * structure cannot be allocated.
4173 : *
4174 : * The function can be called multiple times to inject errors for different
4175 : * commands. If the opcode matches an existing entry, the existing entry
4176 : * will be updated with the values specified.
4177 : */
4178 : int spdk_nvme_qpair_add_cmd_error_injection(struct spdk_nvme_ctrlr *ctrlr,
4179 : struct spdk_nvme_qpair *qpair,
4180 : uint8_t opc,
4181 : bool do_not_submit,
4182 : uint64_t timeout_in_us,
4183 : uint32_t err_count,
4184 : uint8_t sct, uint8_t sc);
4185 :
4186 : /**
4187 : * \brief Clear the specified NVMe command with error status.
4188 : *
4189 : * \param ctrlr NVMe controller.
4190 : * \param qpair I/O queue pair to remove the error command,
4191 : * \ NULL for Admin queue pair.
4192 : * \param opc Opcode for Admin or I/O commands.
4193 : *
4194 : * The function will remove specified command in the error list.
4195 : */
4196 : void spdk_nvme_qpair_remove_cmd_error_injection(struct spdk_nvme_ctrlr *ctrlr,
4197 : struct spdk_nvme_qpair *qpair,
4198 : uint8_t opc);
4199 :
4200 : /**
4201 : * \brief Given NVMe status, return ASCII string for that error.
4202 : *
4203 : * \param status Status from NVMe completion queue element.
4204 : * \return Returns status as an ASCII string.
4205 : */
4206 : const char *spdk_nvme_cpl_get_status_string(const struct spdk_nvme_status *status);
4207 :
4208 : /**
4209 : * \brief Given NVMe status, return ASCII string for the type of that error.
4210 : *
4211 : * \param status Status from NVMe completion queue element.
4212 : * \return Returns status type as an ASCII string.
4213 : */
4214 : const char *spdk_nvme_cpl_get_status_type_string(const struct spdk_nvme_status *status);
4215 :
4216 : /**
4217 : * \brief Prints (SPDK_NOTICELOG) the contents of an NVMe submission queue entry (command).
4218 : *
4219 : * \param qpair Pointer to the NVMe queue pair - used to determine admin versus I/O queue.
4220 : * \param cmd Pointer to the submission queue command to be formatted.
4221 : */
4222 : void spdk_nvme_qpair_print_command(struct spdk_nvme_qpair *qpair,
4223 : struct spdk_nvme_cmd *cmd);
4224 :
4225 : /**
4226 : * \brief Prints (SPDK_NOTICELOG) the contents of an NVMe completion queue entry.
4227 : *
4228 : * \param qpair Pointer to the NVMe queue pair - presently unused.
4229 : * \param cpl Pointer to the completion queue element to be formatted.
4230 : */
4231 : void spdk_nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair,
4232 : struct spdk_nvme_cpl *cpl);
4233 :
4234 : /**
4235 : * \brief Gets the NVMe qpair ID for the specified qpair.
4236 : *
4237 : * \param qpair Pointer to the NVMe queue pair.
4238 : * \returns ID for the specified qpair.
4239 : */
4240 : uint16_t spdk_nvme_qpair_get_id(struct spdk_nvme_qpair *qpair);
4241 :
4242 : /**
4243 : * Gets the number of outstanding requests for the specified qpair.
4244 : *
4245 : * This number is not decremented until after a request's callback function is completed.
4246 : *
4247 : * This number is not matched necessarily to the number of NVMe commands submitted by the
4248 : * user. For example, nvme driver may split a request due to MDTS limitations, that will
4249 : * also allocate a request for the parent, etc.
4250 : *
4251 : * \param qpair Pointer to the NVMe queue pair.
4252 : * \returns number of outstanding requests for the specified qpair.
4253 : */
4254 : uint32_t spdk_nvme_qpair_get_num_outstanding_reqs(struct spdk_nvme_qpair *qpair);
4255 :
4256 : /**
4257 : * \brief Prints (SPDK_NOTICELOG) the contents of an NVMe submission queue entry (command).
4258 : *
4259 : * \param qid Queue identifier.
4260 : * \param cmd Pointer to the submission queue command to be formatted.
4261 : */
4262 : void spdk_nvme_print_command(uint16_t qid, struct spdk_nvme_cmd *cmd);
4263 :
4264 : /**
4265 : * \brief Prints (SPDK_NOTICELOG) the contents of an NVMe completion queue entry.
4266 : *
4267 : * \param qid Queue identifier.
4268 : * \param cpl Pointer to the completion queue element to be formatted.
4269 : */
4270 : void spdk_nvme_print_completion(uint16_t qid, struct spdk_nvme_cpl *cpl);
4271 :
4272 : /**
4273 : * Return the name of a digest.
4274 : *
4275 : * \param id Digest identifier (see `enum spdk_nvmf_dhchap_hash`).
4276 : *
4277 : * \return Name of the digest.
4278 : */
4279 : const char *spdk_nvme_dhchap_get_digest_name(int id);
4280 :
4281 : /**
4282 : * Return the id of a digest.
4283 : *
4284 : * \param name Name of a digest.
4285 : *
4286 : * \return Digest id (see `enum spdk_nvmf_dhchap_hash`) or negative errno on failure.
4287 : */
4288 : int spdk_nvme_dhchap_get_digest_id(const char *name);
4289 :
4290 : /**
4291 : * Return the length of a digest.
4292 : *
4293 : * \param id Digest identifier (see `enum spdk_nvmf_dhchap_hash`).
4294 : *
4295 : * \return Length of a digest or 0 if the id is unknown.
4296 : */
4297 : uint8_t spdk_nvme_dhchap_get_digest_length(int id);
4298 :
4299 : /**
4300 : * Return the name of a Diffie-Hellman group.
4301 : *
4302 : * \param id Diffie-Hellman group identifier (see `enum spdk_nvmf_dhchap_dhgroup`).
4303 : *
4304 : * \return Name of the Diffie-Hellman group.
4305 : */
4306 : const char *spdk_nvme_dhchap_get_dhgroup_name(int id);
4307 :
4308 : /**
4309 : * Return the id of a Diffie-Hellman group.
4310 : *
4311 : * \param name Name of a Diffie-Hellman group.
4312 : *
4313 : * \return Diffie-Hellman group id (see `enum spdk_nvmf_dhchap_dhgroup`) or negative errno
4314 : * on failure.
4315 : */
4316 : int spdk_nvme_dhchap_get_dhgroup_id(const char *name);
4317 :
4318 : struct ibv_context;
4319 : struct ibv_pd;
4320 : struct ibv_mr;
4321 :
4322 : /**
4323 : * RDMA Transport Hooks
4324 : */
4325 : struct spdk_nvme_rdma_hooks {
4326 : /**
4327 : * \brief Get an InfiniBand Verbs protection domain.
4328 : *
4329 : * \param trid the transport id
4330 : * \param verbs Infiniband verbs context
4331 : *
4332 : * \return pd of the nvme ctrlr
4333 : */
4334 : struct ibv_pd *(*get_ibv_pd)(const struct spdk_nvme_transport_id *trid,
4335 : struct ibv_context *verbs);
4336 :
4337 : /**
4338 : * \brief Get an InfiniBand Verbs memory region for a buffer.
4339 : *
4340 : * \param pd The protection domain returned from get_ibv_pd
4341 : * \param buf Memory buffer for which an rkey should be returned.
4342 : * \param size size of buf
4343 : *
4344 : * \return Infiniband remote key (rkey) for this buf
4345 : */
4346 : uint64_t (*get_rkey)(struct ibv_pd *pd, void *buf, size_t size);
4347 :
4348 : /**
4349 : * \brief Put back keys got from get_rkey.
4350 : *
4351 : * \param key The Infiniband remote key (rkey) got from get_rkey
4352 : *
4353 : */
4354 : void (*put_rkey)(uint64_t key);
4355 : };
4356 :
4357 : /**
4358 : * \brief Set the global hooks for the RDMA transport, if necessary.
4359 : *
4360 : * This call is optional and must be performed prior to probing for
4361 : * any devices. By default, the RDMA transport will use the ibverbs
4362 : * library to create protection domains and register memory. This
4363 : * is a mechanism to subvert that and use an existing registration.
4364 : *
4365 : * This function may only be called one time per process.
4366 : *
4367 : * \param hooks for initializing global hooks
4368 : */
4369 : void spdk_nvme_rdma_init_hooks(struct spdk_nvme_rdma_hooks *hooks);
4370 :
4371 : /**
4372 : * Get name of cuse device associated with NVMe controller.
4373 : *
4374 : * \param ctrlr Opaque handle to NVMe controller.
4375 : * \param name Buffer of be filled with cuse device name.
4376 : * \param size Size of name buffer.
4377 : *
4378 : * \return 0 on success. Negated errno on the following error conditions:
4379 : * -ENODEV: No cuse device registered for the controller.
4380 : * -ENSPC: Too small buffer size passed. Value of size pointer changed to the required length.
4381 : */
4382 : int spdk_nvme_cuse_get_ctrlr_name(struct spdk_nvme_ctrlr *ctrlr, char *name, size_t *size);
4383 :
4384 : /**
4385 : * Get name of cuse device associated with NVMe namespace.
4386 : *
4387 : * \param ctrlr Opaque handle to NVMe controller.
4388 : * \param nsid Namespace id.
4389 : * \param name Buffer of be filled with cuse device name.
4390 : * \param size Size of name buffer.
4391 : *
4392 : * \return 0 on success. Negated errno on the following error conditions:
4393 : * -ENODEV: No cuse device registered for the namespace.
4394 : * -ENSPC: Too small buffer size passed. Value of size pointer changed to the required length.
4395 : */
4396 : int spdk_nvme_cuse_get_ns_name(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
4397 : char *name, size_t *size);
4398 :
4399 : /**
4400 : * Create a character device at the path specified
4401 : *
4402 : * The character device can handle ioctls and is compatible with a standard
4403 : * Linux kernel NVMe device. Tools such as nvme-cli can be used to configure
4404 : * SPDK devices through this interface.
4405 : *
4406 : * The user is expected to be polling the admin qpair for this controller periodically
4407 : * for the CUSE device to function.
4408 : *
4409 : * \param ctrlr Opaque handle to the NVMe controller.
4410 : *
4411 : * \return 0 on success. Negated errno on failure.
4412 : */
4413 : int spdk_nvme_cuse_register(struct spdk_nvme_ctrlr *ctrlr);
4414 :
4415 : /**
4416 : * Remove a previously created character device
4417 : *
4418 : * \param ctrlr Opaque handle to the NVMe controller.
4419 : *
4420 : * \return 0 on success. Negated errno on failure.
4421 : */
4422 : int spdk_nvme_cuse_unregister(struct spdk_nvme_ctrlr *ctrlr);
4423 :
4424 : /**
4425 : * Get SPDK memory domains used by the given nvme controller.
4426 : *
4427 : * The user can call this function with \b domains set to NULL and \b array_size set to 0 to get the
4428 : * number of memory domains used by nvme controller
4429 : *
4430 : * \param ctrlr Opaque handle to the NVMe controller.
4431 : * \param domains Pointer to an array of memory domains to be filled by this function. The user should allocate big enough
4432 : * array to keep all memory domains used by nvme controller
4433 : * \param array_size size of \b domains array
4434 : * \return the number of entries in \b domains array or negated errno. If returned value is bigger than \b array_size passed by the user
4435 : * then the user should increase the size of \b domains array and call this function again. There is no guarantees that
4436 : * the content of \b domains array is valid in that case.
4437 : * -EINVAL if input parameters were invalid
4438 :
4439 : */
4440 : int spdk_nvme_ctrlr_get_memory_domains(const struct spdk_nvme_ctrlr *ctrlr,
4441 : struct spdk_memory_domain **domains, int array_size);
4442 :
4443 : /**
4444 : * Opaque handle for a transport poll group. Used by the transport function table.
4445 : */
4446 : struct spdk_nvme_transport_poll_group;
4447 :
4448 : /**
4449 : * Update and populate namespace CUSE devices (Experimental)
4450 : *
4451 : * \param ctrlr Opaque handle to the NVMe controller.
4452 : *
4453 : */
4454 : void spdk_nvme_cuse_update_namespaces(struct spdk_nvme_ctrlr *ctrlr);
4455 :
4456 : /**
4457 : * Signature for callback invoked after completing a register read/write operation.
4458 : *
4459 : * \param ctx Context passed by the user.
4460 : * \param value Value of the register, undefined in case of a failure.
4461 : * \param cpl Completion queue entry that contains the status of the command.
4462 : */
4463 : typedef void (*spdk_nvme_reg_cb)(void *ctx, uint64_t value, const struct spdk_nvme_cpl *cpl);
4464 :
4465 : struct nvme_request;
4466 :
4467 : struct spdk_nvme_transport;
4468 :
4469 : struct spdk_nvme_transport_ops {
4470 : char name[SPDK_NVMF_TRSTRING_MAX_LEN + 1];
4471 :
4472 : enum spdk_nvme_transport_type type;
4473 :
4474 : struct spdk_nvme_ctrlr *(*ctrlr_construct)(const struct spdk_nvme_transport_id *trid,
4475 : const struct spdk_nvme_ctrlr_opts *opts,
4476 : void *devhandle);
4477 :
4478 : int (*ctrlr_scan)(struct spdk_nvme_probe_ctx *probe_ctx, bool direct_connect);
4479 :
4480 : int (*ctrlr_destruct)(struct spdk_nvme_ctrlr *ctrlr);
4481 :
4482 : int (*ctrlr_enable)(struct spdk_nvme_ctrlr *ctrlr);
4483 :
4484 : int (*ctrlr_set_reg_4)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value);
4485 :
4486 : int (*ctrlr_set_reg_8)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint64_t value);
4487 :
4488 : int (*ctrlr_get_reg_4)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t *value);
4489 :
4490 : int (*ctrlr_get_reg_8)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint64_t *value);
4491 :
4492 : int (*ctrlr_set_reg_4_async)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value,
4493 : spdk_nvme_reg_cb cb_fn, void *cb_arg);
4494 :
4495 : int (*ctrlr_set_reg_8_async)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint64_t value,
4496 : spdk_nvme_reg_cb cb_fn, void *cb_arg);
4497 :
4498 : int (*ctrlr_get_reg_4_async)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset,
4499 : spdk_nvme_reg_cb cb_fn, void *cb_arg);
4500 :
4501 : int (*ctrlr_get_reg_8_async)(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset,
4502 : spdk_nvme_reg_cb cb_fn, void *cb_arg);
4503 :
4504 : uint32_t (*ctrlr_get_max_xfer_size)(struct spdk_nvme_ctrlr *ctrlr);
4505 :
4506 : uint16_t (*ctrlr_get_max_sges)(struct spdk_nvme_ctrlr *ctrlr);
4507 :
4508 : int (*ctrlr_reserve_cmb)(struct spdk_nvme_ctrlr *ctrlr);
4509 :
4510 : void *(*ctrlr_map_cmb)(struct spdk_nvme_ctrlr *ctrlr, size_t *size);
4511 :
4512 : int (*ctrlr_unmap_cmb)(struct spdk_nvme_ctrlr *ctrlr);
4513 :
4514 : int (*ctrlr_enable_pmr)(struct spdk_nvme_ctrlr *ctrlr);
4515 :
4516 : int (*ctrlr_disable_pmr)(struct spdk_nvme_ctrlr *ctrlr);
4517 :
4518 : void *(*ctrlr_map_pmr)(struct spdk_nvme_ctrlr *ctrlr, size_t *size);
4519 :
4520 : int (*ctrlr_unmap_pmr)(struct spdk_nvme_ctrlr *ctrlr);
4521 :
4522 : struct spdk_nvme_qpair *(*ctrlr_create_io_qpair)(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid,
4523 : const struct spdk_nvme_io_qpair_opts *opts);
4524 :
4525 : int (*ctrlr_delete_io_qpair)(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);
4526 :
4527 : int (*ctrlr_connect_qpair)(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);
4528 :
4529 : void (*ctrlr_disconnect_qpair)(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);
4530 :
4531 : void (*qpair_abort_reqs)(struct spdk_nvme_qpair *qpair, uint32_t dnr);
4532 :
4533 : int (*qpair_reset)(struct spdk_nvme_qpair *qpair);
4534 :
4535 : int (*qpair_submit_request)(struct spdk_nvme_qpair *qpair, struct nvme_request *req);
4536 :
4537 : int (*qpair_authenticate)(struct spdk_nvme_qpair *qpair);
4538 :
4539 : int32_t (*qpair_process_completions)(struct spdk_nvme_qpair *qpair, uint32_t max_completions);
4540 :
4541 : int (*qpair_iterate_requests)(struct spdk_nvme_qpair *qpair,
4542 : int (*iter_fn)(struct nvme_request *req, void *arg),
4543 : void *arg);
4544 :
4545 : void (*admin_qpair_abort_aers)(struct spdk_nvme_qpair *qpair);
4546 :
4547 : struct spdk_nvme_transport_poll_group *(*poll_group_create)(void);
4548 : struct spdk_nvme_transport_poll_group *(*qpair_get_optimal_poll_group)(
4549 : struct spdk_nvme_qpair *qpair);
4550 :
4551 : int (*poll_group_add)(struct spdk_nvme_transport_poll_group *tgroup, struct spdk_nvme_qpair *qpair);
4552 :
4553 : int (*poll_group_remove)(struct spdk_nvme_transport_poll_group *tgroup,
4554 : struct spdk_nvme_qpair *qpair);
4555 :
4556 : int (*poll_group_connect_qpair)(struct spdk_nvme_qpair *qpair);
4557 :
4558 : int (*poll_group_disconnect_qpair)(struct spdk_nvme_qpair *qpair);
4559 :
4560 : int64_t (*poll_group_process_completions)(struct spdk_nvme_transport_poll_group *tgroup,
4561 : uint32_t completions_per_qpair, spdk_nvme_disconnected_qpair_cb disconnected_qpair_cb);
4562 :
4563 : int (*poll_group_destroy)(struct spdk_nvme_transport_poll_group *tgroup);
4564 :
4565 : int (*poll_group_get_stats)(struct spdk_nvme_transport_poll_group *tgroup,
4566 : struct spdk_nvme_transport_poll_group_stat **stats);
4567 :
4568 : void (*poll_group_free_stats)(struct spdk_nvme_transport_poll_group *tgroup,
4569 : struct spdk_nvme_transport_poll_group_stat *stats);
4570 :
4571 : int (*ctrlr_get_memory_domains)(const struct spdk_nvme_ctrlr *ctrlr,
4572 : struct spdk_memory_domain **domains,
4573 : int array_size);
4574 :
4575 : int (*ctrlr_ready)(struct spdk_nvme_ctrlr *ctrlr);
4576 :
4577 : volatile struct spdk_nvme_registers *(*ctrlr_get_registers)(struct spdk_nvme_ctrlr *ctrlr);
4578 :
4579 : /* Optional callback for transports to process removal events of attached controllers. */
4580 : int (*ctrlr_scan_attached)(struct spdk_nvme_probe_ctx *probe_ctx);
4581 : };
4582 :
4583 : /**
4584 : * Register the operations for a given transport type.
4585 : *
4586 : * This function should be invoked by referencing the macro
4587 : * SPDK_NVME_TRANSPORT_REGISTER macro in the transport's .c file.
4588 : *
4589 : * \param ops The operations associated with an NVMe-oF transport.
4590 : */
4591 : void spdk_nvme_transport_register(const struct spdk_nvme_transport_ops *ops);
4592 :
4593 : /*
4594 : * Macro used to register new transports.
4595 : */
4596 : #define SPDK_NVME_TRANSPORT_REGISTER(name, transport_ops) \
4597 : static void __attribute__((constructor)) _spdk_nvme_transport_register_##name(void) \
4598 : { \
4599 : spdk_nvme_transport_register(transport_ops); \
4600 : }
4601 :
4602 : /**
4603 : * NVMe transport options.
4604 : */
4605 : struct spdk_nvme_transport_opts {
4606 : /**
4607 : * It is used for RDMA transport.
4608 : *
4609 : * The queue depth of a shared rdma receive queue.
4610 : */
4611 : uint32_t rdma_srq_size;
4612 :
4613 : /* Hole at bytes 4-7. */
4614 : uint8_t reserved4[4];
4615 :
4616 : /**
4617 : * The size of spdk_nvme_transport_opts according to the caller of this library is used for ABI
4618 : * compatibility. The library uses this field to know how many fields in this
4619 : * structure are valid. And the library will populate any remaining fields with default values.
4620 : */
4621 : size_t opts_size;
4622 :
4623 : /**
4624 : * It is used for RDMA transport.
4625 : *
4626 : * The maximum queue depth of a rdma completion queue.
4627 : * It is zero, which means unlimited, by default.
4628 : */
4629 : uint32_t rdma_max_cq_size;
4630 :
4631 : /**
4632 : * It is used for RDMA transport.
4633 : *
4634 : * RDMA CM event timeout in milliseconds.
4635 : */
4636 : uint16_t rdma_cm_event_timeout_ms;
4637 : };
4638 : SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_transport_opts) == 24, "Incorrect size");
4639 :
4640 : /**
4641 : * Get the current NVMe transport options.
4642 : *
4643 : * \param[out] opts Will be filled with the current options for spdk_nvme_transport_set_opts().
4644 : * \param opts_size Must be set to sizeof(struct spdk_nvme_transport_opts).
4645 : */
4646 : void spdk_nvme_transport_get_opts(struct spdk_nvme_transport_opts *opts, size_t opts_size);
4647 :
4648 : /**
4649 : * Set the NVMe transport options.
4650 : *
4651 : * \param opts Pointer to the allocated spdk_nvme_transport_opts structure with new values.
4652 : * \param opts_size Must be set to sizeof(struct spdk_nvme_transport_opts).
4653 : *
4654 : * \return 0 on success, or negated errno on failure.
4655 : */
4656 : int spdk_nvme_transport_set_opts(const struct spdk_nvme_transport_opts *opts, size_t opts_size);
4657 :
4658 : #ifdef __cplusplus
4659 : }
4660 : #endif
4661 :
4662 : #endif
|