]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/include/spdk/nvme.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / spdk / include / spdk / nvme.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /** \file
35 * NVMe driver public API
36 */
37
38 #ifndef SPDK_NVME_H
39 #define SPDK_NVME_H
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 #include <stdbool.h>
46 #include <stddef.h>
47 #include <stdint.h>
48
49 #include "spdk/env.h"
50 #include "spdk/nvme_spec.h"
51 #include "spdk/nvmf_spec.h"
52
53 #define SPDK_NVME_DEFAULT_RETRY_COUNT (4)
54 extern int32_t spdk_nvme_retry_count;
55
56
57
58 /** \brief Opaque handle to a controller. Returned by \ref spdk_nvme_probe()'s attach_cb. */
59 struct spdk_nvme_ctrlr;
60
61 /**
62 * \brief NVMe controller initialization options.
63 *
64 * A pointer to this structure will be provided for each probe callback from spdk_nvme_probe() to
65 * allow the user to request non-default options, and the actual options enabled on the controller
66 * will be provided during the attach callback.
67 */
68 struct spdk_nvme_ctrlr_opts {
69 /**
70 * Number of I/O queues to request (used to set Number of Queues feature)
71 */
72 uint32_t num_io_queues;
73
74 /**
75 * Enable submission queue in controller memory buffer
76 */
77 bool use_cmb_sqs;
78
79 /**
80 * Type of arbitration mechanism
81 */
82 enum spdk_nvme_cc_ams arb_mechanism;
83
84 /**
85 * Keep alive timeout in milliseconds (0 = disabled).
86 *
87 * The NVMe library will set the Keep Alive Timer feature to this value and automatically
88 * send Keep Alive commands as needed. The library user must call
89 * spdk_nvme_ctrlr_process_admin_completions() periodically to ensure Keep Alive commands
90 * are sent.
91 */
92 uint32_t keep_alive_timeout_ms;
93
94 /**
95 * Specify the retry number when there is issue with the transport
96 */
97 int transport_retry_count;
98
99 /**
100 * The queue depth of each NVMe I/O queue.
101 */
102 uint32_t io_queue_size;
103
104 /**
105 * The host NQN to use when connecting to NVMe over Fabrics controllers.
106 *
107 * Unused for local PCIe-attached NVMe devices.
108 */
109 char hostnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
110
111 /**
112 * The number of requests to allocate for each NVMe I/O queue.
113 *
114 * This should be at least as large as io_queue_size.
115 *
116 * A single I/O may allocate more than one request, since splitting may be necessary to
117 * conform to the device's maximum transfer size, PRP list compatibility requirements,
118 * or driver-assisted striping.
119 */
120 uint32_t io_queue_requests;
121 };
122
123 /**
124 * NVMe library transports
125 *
126 * NOTE: These are mapped directly to the NVMe over Fabrics TRTYPE values, except for PCIe,
127 * which is a special case since NVMe over Fabrics does not define a TRTYPE for local PCIe.
128 *
129 * Currently, this uses 256 for PCIe which is intentionally outside of the 8-bit range of TRTYPE.
130 * If the NVMe-oF specification ever defines a PCIe TRTYPE, this should be updated.
131 */
132 enum spdk_nvme_transport_type {
133 /**
134 * PCIe Transport (locally attached devices)
135 */
136 SPDK_NVME_TRANSPORT_PCIE = 256,
137
138 /**
139 * RDMA Transport (RoCE, iWARP, etc.)
140 */
141 SPDK_NVME_TRANSPORT_RDMA = SPDK_NVMF_TRTYPE_RDMA,
142 };
143
144 /**
145 * NVMe transport identifier.
146 *
147 * This identifies a unique endpoint on an NVMe fabric.
148 *
149 * A string representation of a transport ID may be converted to this type using
150 * spdk_nvme_transport_id_parse().
151 */
152 struct spdk_nvme_transport_id {
153 /**
154 * NVMe transport type.
155 */
156 enum spdk_nvme_transport_type trtype;
157
158 /**
159 * Address family of the transport address.
160 *
161 * For PCIe, this value is ignored.
162 */
163 enum spdk_nvmf_adrfam adrfam;
164
165 /**
166 * Transport address of the NVMe-oF endpoint. For transports which use IP
167 * addressing (e.g. RDMA), this should be an IP address. For PCIe, this
168 * can either be a zero length string (the whole bus) or a PCI address
169 * in the format DDDD:BB:DD.FF
170 */
171 char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
172
173 /**
174 * Transport service id of the NVMe-oF endpoint. For transports which use
175 * IP addressing (e.g. RDMA), this field shoud be the port number. For PCIe,
176 * this is always a zero length string.
177 */
178 char trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
179
180 /**
181 * Subsystem NQN of the NVMe over Fabrics endpoint. May be a zero length string.
182 */
183 char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
184 };
185
186 /**
187 * Parse the string representation of a transport ID.
188 *
189 * \param trid Output transport ID structure (must be allocated and initialized by caller).
190 * \param str Input string representation of a transport ID to parse.
191 * \return 0 if parsing was successful and trid is filled out, or negated errno values on failure.
192 *
193 * str must be a zero-terminated C string containing one or more key:value pairs separated by
194 * whitespace.
195 *
196 * Key | Value
197 * ------------ | -----
198 * trtype | Transport type (e.g. PCIe, RDMA)
199 * adrfam | Address family (e.g. IPv4, IPv6)
200 * traddr | Transport address (e.g. 0000:04:00.0 for PCIe or 192.168.100.8 for RDMA)
201 * trsvcid | Transport service identifier (e.g. 4420)
202 * subnqn | Subsystem NQN
203 *
204 * Unspecified fields of trid are left unmodified, so the caller must initialize trid (for example,
205 * memset() to 0) before calling this function.
206 */
207 int spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *str);
208
209 /**
210 * Parse the string representation of a transport ID tranport type.
211 *
212 * \param trtype Output transport type (allocated by caller).
213 * \param str Input string representation of transport type (e.g. "PCIe", "RDMA")
214 * \return 0 if parsing was successful and trtype is filled out, or negated errno values on failure.
215 */
216 int spdk_nvme_transport_id_parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str);
217
218 /**
219 * Parse the string representation of a tranport ID address family.
220 *
221 * \param adrfam Output address family (allocated by caller).
222 * \param str Input string representation of address family (e.g. "IPv4", "IPv6")
223 * \return 0 if parsing was successful and adrfam is filled out, or negated errno values on failure.
224 */
225 int spdk_nvme_transport_id_parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const char *str);
226
227 /**
228 * Compare two transport IDs.
229 *
230 * \param trid1 First transport ID to compare.
231 * \param trid2 Second transport ID to compare.
232 *
233 * \return 0 if trid1 == trid2, less than 0 if trid1 < trid2, greater than 0 if trid1 > trid2.
234 *
235 * The result of this function may be used to sort transport IDs in a consistent order; however,
236 * the comparison result is not guaranteed to be consistent across library versions.
237 *
238 * This function uses a case-insensitive comparison for string fields, but it does not otherwise
239 * normalize the transport ID. It is the caller's responsibility to provide the transport IDs in
240 * a consistent format.
241 */
242 int spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
243 const struct spdk_nvme_transport_id *trid2);
244
245 /**
246 * Determine whether the NVMe library can handle a specific NVMe over Fabrics transport type.
247 *
248 * \param trtype NVMe over Fabrics transport type to check.
249 *
250 * \return true if trtype is supported or false if it is not supported.
251 */
252 bool spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype);
253
254 /**
255 * Callback for spdk_nvme_probe() enumeration.
256 *
257 * \param opts NVMe controller initialization options. This structure will be populated with the
258 * default values on entry, and the user callback may update any options to request a different
259 * value. The controller may not support all requested parameters, so the final values will be
260 * provided during the attach callback.
261 * \return true to attach to this device.
262 */
263 typedef bool (*spdk_nvme_probe_cb)(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
264 struct spdk_nvme_ctrlr_opts *opts);
265
266 /**
267 * Callback for spdk_nvme_probe() to report a device that has been attached to the userspace NVMe driver.
268 *
269 * \param opts NVMe controller initialization options that were actually used. Options may differ
270 * from the requested options from the probe call depending on what the controller supports.
271 */
272 typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
273 struct spdk_nvme_ctrlr *ctrlr,
274 const struct spdk_nvme_ctrlr_opts *opts);
275
276 /**
277 * Callback for spdk_nvme_probe() to report that a device attached to the userspace NVMe driver
278 * has been removed from the system.
279 *
280 * The controller will remain in a failed state (any new I/O submitted will fail).
281 *
282 * The controller must be detached from the userspace driver by calling spdk_nvme_detach()
283 * once the controller is no longer in use. It is up to the library user to ensure that
284 * no other threads are using the controller before calling spdk_nvme_detach().
285 *
286 * \param ctrlr NVMe controller instance that was removed.
287 */
288 typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr);
289
290 /**
291 * \brief Enumerate the bus indicated by the transport ID and attach the userspace NVMe driver
292 * to each device found if desired.
293 *
294 * \param trid The transport ID indicating which bus to enumerate. If the trtype is PCIe or trid is NULL,
295 * this will scan the local PCIe bus. If the trtype is RDMA, the traddr and trsvcid must point at the
296 * location of an NVMe-oF discovery service.
297 * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks.
298 * \param probe_cb will be called once per NVMe device found in the system.
299 * \param attach_cb will be called for devices for which probe_cb returned true once that NVMe
300 * controller has been attached to the userspace driver.
301 * \param remove_cb will be called for devices that were attached in a previous spdk_nvme_probe()
302 * call but are no longer attached to the system. Optional; specify NULL if removal notices are not
303 * desired.
304 *
305 * This function is not thread safe and should only be called from one thread at a time while no
306 * other threads are actively using any NVMe devices.
307 *
308 * If called from a secondary process, only devices that have been attached to the userspace driver
309 * in the primary process will be probed.
310 *
311 * If called more than once, only devices that are not already attached to the SPDK NVMe driver
312 * will be reported.
313 *
314 * To stop using the the controller and release its associated resources,
315 * call \ref spdk_nvme_detach with the spdk_nvme_ctrlr instance returned by this function.
316 */
317 int spdk_nvme_probe(const struct spdk_nvme_transport_id *trid,
318 void *cb_ctx,
319 spdk_nvme_probe_cb probe_cb,
320 spdk_nvme_attach_cb attach_cb,
321 spdk_nvme_remove_cb remove_cb);
322
323 /**
324 * \brief Detaches specified device returned by \ref spdk_nvme_probe()'s attach_cb from the NVMe driver.
325 *
326 * On success, the spdk_nvme_ctrlr handle is no longer valid.
327 *
328 * This function should be called from a single thread while no other threads
329 * are actively using the NVMe device.
330 *
331 */
332 int spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr);
333
334 /**
335 * \brief Perform a full hardware reset of the NVMe controller.
336 *
337 * This function should be called from a single thread while no other threads
338 * are actively using the NVMe device.
339 *
340 * Any pointers returned from spdk_nvme_ctrlr_get_ns() and spdk_nvme_ns_get_data() may be invalidated
341 * by calling this function. The number of namespaces as returned by spdk_nvme_ctrlr_get_num_ns() may
342 * also change.
343 */
344 int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr);
345
346 /**
347 * \brief Get the identify controller data as defined by the NVMe specification.
348 *
349 * This function is thread safe and can be called at any point while the controller is attached to
350 * the SPDK NVMe driver.
351 *
352 */
353 const struct spdk_nvme_ctrlr_data *spdk_nvme_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr);
354
355 /**
356 * \brief Get the NVMe controller CSTS (Status) register.
357 */
358 union spdk_nvme_csts_register spdk_nvme_ctrlr_get_regs_csts(struct spdk_nvme_ctrlr *ctrlr);
359
360 /**
361 * \brief Get the NVMe controller CAP (Capabilities) register.
362 */
363 union spdk_nvme_cap_register spdk_nvme_ctrlr_get_regs_cap(struct spdk_nvme_ctrlr *ctrlr);
364
365 /**
366 * \brief Get the NVMe controller VS (Version) register.
367 */
368 union spdk_nvme_vs_register spdk_nvme_ctrlr_get_regs_vs(struct spdk_nvme_ctrlr *ctrlr);
369
370 /**
371 * \brief Get the number of namespaces for the given NVMe controller.
372 *
373 * This function is thread safe and can be called at any point while the controller is attached to
374 * the SPDK NVMe driver.
375 *
376 * This is equivalent to calling spdk_nvme_ctrlr_get_data() to get the
377 * spdk_nvme_ctrlr_data and then reading the nn field.
378 *
379 */
380 uint32_t spdk_nvme_ctrlr_get_num_ns(struct spdk_nvme_ctrlr *ctrlr);
381
382 /**
383 * \brief Determine if a particular log page is supported by the given NVMe controller.
384 *
385 * This function is thread safe and can be called at any point while the controller is attached to
386 * the SPDK NVMe driver.
387 *
388 * \sa spdk_nvme_ctrlr_cmd_get_log_page()
389 */
390 bool spdk_nvme_ctrlr_is_log_page_supported(struct spdk_nvme_ctrlr *ctrlr, uint8_t log_page);
391
392 /**
393 * \brief Determine if a particular feature is supported by the given NVMe controller.
394 *
395 * This function is thread safe and can be called at any point while the controller is attached to
396 * the SPDK NVMe driver.
397 *
398 * \sa spdk_nvme_ctrlr_cmd_get_feature()
399 */
400 bool spdk_nvme_ctrlr_is_feature_supported(struct spdk_nvme_ctrlr *ctrlr, uint8_t feature_code);
401
402 /**
403 * Signature for callback function invoked when a command is completed.
404 *
405 * The spdk_nvme_cpl parameter contains the completion status.
406 */
407 typedef void (*spdk_nvme_cmd_cb)(void *, const struct spdk_nvme_cpl *);
408
409 /**
410 * Signature for callback function invoked when an asynchronous error
411 * request command is completed.
412 *
413 * The aer_cb_arg parameter is set to the context specified by
414 * spdk_nvme_register_aer_callback().
415 * The spdk_nvme_cpl parameter contains the completion status of the
416 * asynchronous event request that was completed.
417 */
418 typedef void (*spdk_nvme_aer_cb)(void *aer_cb_arg,
419 const struct spdk_nvme_cpl *);
420
421 void spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
422 spdk_nvme_aer_cb aer_cb_fn,
423 void *aer_cb_arg);
424
425 /**
426 * \brief Opaque handle to a queue pair.
427 *
428 * I/O queue pairs may be allocated using spdk_nvme_ctrlr_alloc_io_qpair().
429 */
430 struct spdk_nvme_qpair;
431
432 /**
433 * Signature for the callback function invoked when a timeout is
434 * detected on a request.
435 * For timeouts detected on the admin queue pair, the qpair returned
436 * here will be NULL.
437 */
438 typedef void (*spdk_nvme_timeout_cb)(void *cb_arg,
439 struct spdk_nvme_ctrlr *ctrlr,
440 struct spdk_nvme_qpair *qpair,
441 uint16_t cid);
442
443 /**
444 * \brief Register for timeout callback on a controller.
445 *
446 * The application can choose to register for timeout callback or not register
447 * for timeout callback.
448 *
449 * \param ctrlr NVMe controller on which to monitor for timeout.
450 * \param timeout_sec Timeout value in seconds.
451 * \param cb_fn A function pointer that points to the callback function
452 * \param cb_arg Argument to the callback function.
453 */
454 void spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
455 uint32_t timeout_sec, spdk_nvme_timeout_cb cb_fn, void *cb_arg);
456
457 /**
458 * \brief Allocate an I/O queue pair (submission and completion queue).
459 *
460 * Each queue pair should only be used from a single thread at a time (mutual exclusion must be
461 * enforced by the user).
462 *
463 * \param ctrlr NVMe controller for which to allocate the I/O queue pair.
464 * \param qprio Queue priority for weighted round robin arbitration. If a different arbitration
465 * method is in use, pass 0.
466 */
467 struct spdk_nvme_qpair *spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
468 enum spdk_nvme_qprio qprio);
469
470 /**
471 * \brief Free an I/O queue pair that was allocated by spdk_nvme_ctrlr_alloc_io_qpair().
472 */
473 int spdk_nvme_ctrlr_free_io_qpair(struct spdk_nvme_qpair *qpair);
474
475 /**
476 * \brief Send the given NVM I/O command to the NVMe controller.
477 *
478 * This is a low level interface for submitting I/O commands directly. Prefer
479 * the spdk_nvme_ns_cmd_* functions instead. The validity of the command will
480 * not be checked!
481 *
482 * When constructing the nvme_command it is not necessary to fill out the PRP
483 * list/SGL or the CID. The driver will handle both of those for you.
484 *
485 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
486 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
487 */
488 int spdk_nvme_ctrlr_cmd_io_raw(struct spdk_nvme_ctrlr *ctrlr,
489 struct spdk_nvme_qpair *qpair,
490 struct spdk_nvme_cmd *cmd,
491 void *buf, uint32_t len,
492 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
493
494 /**
495 * \brief Process any outstanding completions for I/O submitted on a queue pair.
496 *
497 * This call is non-blocking, i.e. it only
498 * processes completions that are ready at the time of this function call. It does not
499 * wait for outstanding commands to finish.
500 *
501 * For each completed command, the request's callback function will
502 * be called if specified as non-NULL when the request was submitted.
503 *
504 * \param qpair Queue pair to check for completions.
505 * \param max_completions Limit the number of completions to be processed in one call, or 0
506 * for unlimited.
507 *
508 * \return Number of completions processed (may be 0) or negative on error.
509 *
510 * \sa spdk_nvme_cmd_cb
511 *
512 * This function may be called at any point while the controller is attached to
513 * the SPDK NVMe driver.
514 *
515 * The caller must ensure that each queue pair is only used from one thread at a time.
516 */
517 int32_t spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair,
518 uint32_t max_completions);
519
520 /**
521 * \brief Send the given admin command to the NVMe controller.
522 *
523 * This is a low level interface for submitting admin commands directly. Prefer
524 * the spdk_nvme_ctrlr_cmd_* functions instead. The validity of the command will
525 * not be checked!
526 *
527 * When constructing the nvme_command it is not necessary to fill out the PRP
528 * list/SGL or the CID. The driver will handle both of those for you.
529 *
530 * This function is thread safe and can be called at any point while the controller is attached to
531 * the SPDK NVMe driver.
532 *
533 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
534 * of commands submitted through this function.
535 */
536 int spdk_nvme_ctrlr_cmd_admin_raw(struct spdk_nvme_ctrlr *ctrlr,
537 struct spdk_nvme_cmd *cmd,
538 void *buf, uint32_t len,
539 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
540
541 /**
542 * \brief Process any outstanding completions for admin commands.
543 *
544 * This will process completions for admin commands submitted on any thread.
545 *
546 * This call is non-blocking, i.e. it only processes completions that are ready
547 * at the time of this function call. It does not wait for outstanding commands to
548 * finish.
549 *
550 * \return Number of completions processed (may be 0) or negative on error.
551 *
552 * This function is thread safe and can be called at any point while the controller is attached to
553 * the SPDK NVMe driver.
554 */
555 int32_t spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr);
556
557
558 /** \brief Opaque handle to a namespace. Obtained by calling spdk_nvme_ctrlr_get_ns(). */
559 struct spdk_nvme_ns;
560
561 /**
562 * \brief Get a handle to a namespace for the given controller.
563 *
564 * Namespaces are numbered from 1 to the total number of namespaces. There will never
565 * be any gaps in the numbering. The number of namespaces is obtained by calling
566 * spdk_nvme_ctrlr_get_num_ns().
567 *
568 * This function is thread safe and can be called at any point while the controller is attached to
569 * the SPDK NVMe driver.
570 */
571 struct spdk_nvme_ns *spdk_nvme_ctrlr_get_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t ns_id);
572
573 /**
574 * \brief Get a specific log page from the NVMe controller.
575 *
576 * \param ctrlr NVMe controller to query.
577 * \param log_page The log page identifier.
578 * \param nsid Depending on the log page, this may be 0, a namespace identifier, or SPDK_NVME_GLOBAL_NS_TAG.
579 * \param payload The pointer to the payload buffer.
580 * \param payload_size The size of payload buffer.
581 * \param offset Offset in bytes within the log page to start retrieving log page data.
582 * May only be non-zero if the controller supports extended data for Get Log Page
583 * as reported in the controller data log page attributes.
584 * \param cb_fn Callback function to invoke when the log page has been retrieved.
585 * \param cb_arg Argument to pass to the callback function.
586 *
587 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
588 *
589 * This function is thread safe and can be called at any point while the controller is attached to
590 * the SPDK NVMe driver.
591 *
592 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
593 * of commands submitted through this function.
594 *
595 * \sa spdk_nvme_ctrlr_is_log_page_supported()
596 */
597 int spdk_nvme_ctrlr_cmd_get_log_page(struct spdk_nvme_ctrlr *ctrlr,
598 uint8_t log_page, uint32_t nsid,
599 void *payload, uint32_t payload_size,
600 uint64_t offset,
601 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
602
603 /**
604 * \brief Abort a specific previously-submitted NVMe command.
605 *
606 * \param ctrlr NVMe controller to which the command was submitted.
607 * \param qpair NVMe queue pair to which the command was submitted.
608 * For admin commands, pass NULL for the qpair.
609 * \param cid Command ID of the command to abort.
610 * \param cb_fn Callback function to invoke when the abort has completed.
611 * \param cb_arg Argument to pass to the callback function.\
612 *
613 * \return 0 if successfully submitted, negated errno value otherwise.
614 *
615 * \sa spdk_nvme_ctrlr_register_timeout_callback()
616 */
617 int spdk_nvme_ctrlr_cmd_abort(struct spdk_nvme_ctrlr *ctrlr,
618 struct spdk_nvme_qpair *qpair,
619 uint16_t cid,
620 spdk_nvme_cmd_cb cb_fn,
621 void *cb_arg);
622
623 /**
624 * \brief Set specific feature for the given NVMe controller.
625 *
626 * \param ctrlr NVMe controller to manipulate.
627 * \param feature The feature identifier.
628 * \param cdw11 as defined by the specification for this command.
629 * \param cdw12 as defined by the specification for this command.
630 * \param payload The pointer to the payload buffer.
631 * \param payload_size The size of payload buffer.
632 * \param cb_fn Callback function to invoke when the feature has been set.
633 * \param cb_arg Argument to pass to the callback function.
634 *
635 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
636 *
637 * This function is thread safe and can be called at any point while the controller is attached to
638 * the SPDK NVMe driver.
639 *
640 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
641 * of commands submitted through this function.
642 *
643 * \sa spdk_nvme_ctrlr_cmd_get_feature()
644 */
645 int spdk_nvme_ctrlr_cmd_set_feature(struct spdk_nvme_ctrlr *ctrlr,
646 uint8_t feature, uint32_t cdw11, uint32_t cdw12,
647 void *payload, uint32_t payload_size,
648 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
649
650 /**
651 * \brief Get specific feature from given NVMe controller.
652 *
653 * \param ctrlr NVMe controller to query.
654 * \param feature The feature identifier.
655 * \param cdw11 as defined by the specification for this command.
656 * \param payload The pointer to the payload buffer.
657 * \param payload_size The size of payload buffer.
658 * \param cb_fn Callback function to invoke when the feature has been retrieved.
659 * \param cb_arg Argument to pass to the callback function.
660 *
661 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
662 *
663 * This function is thread safe and can be called at any point while the controller is attached to
664 * the SPDK NVMe driver.
665 *
666 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
667 * of commands submitted through this function.
668 *
669 * \sa spdk_nvme_ctrlr_cmd_set_feature()
670 */
671 int spdk_nvme_ctrlr_cmd_get_feature(struct spdk_nvme_ctrlr *ctrlr,
672 uint8_t feature, uint32_t cdw11,
673 void *payload, uint32_t payload_size,
674 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
675
676 /**
677 * \brief Attach the specified namespace to controllers.
678 *
679 * \param ctrlr NVMe controller to use for command submission.
680 * \param nsid Namespace identifier for namespace to attach.
681 * \param payload The pointer to the controller list.
682 *
683 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
684 *
685 * This function is thread safe and can be called at any point after spdk_nvme_attach().
686 *
687 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
688 * of commands submitted through this function.
689 */
690 int spdk_nvme_ctrlr_attach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
691 struct spdk_nvme_ctrlr_list *payload);
692
693 /**
694 * \brief Detach the specified namespace from controllers.
695 *
696 * \param ctrlr NVMe controller to use for command submission.
697 * \param nsid Namespace ID to detach.
698 * \param payload The pointer to the controller list.
699 *
700 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
701 *
702 * This function is thread safe and can be called at any point after spdk_nvme_attach().
703 *
704 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
705 * of commands submitted through this function.
706 */
707 int spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
708 struct spdk_nvme_ctrlr_list *payload);
709
710 /**
711 * \brief Create a namespace.
712 *
713 * \param ctrlr NVMe controller to create namespace on.
714 * \param payload The pointer to the NVMe namespace data.
715 *
716 * \return Namespace ID (>= 1) if successfully created, or 0 if the request failed.
717 *
718 * This function is thread safe and can be called at any point after spdk_nvme_attach().
719 */
720 uint32_t spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr,
721 struct spdk_nvme_ns_data *payload);
722
723 /**
724 * \brief Delete a namespace.
725 *
726 * \param ctrlr NVMe controller to delete namespace from.
727 * \param nsid The namespace identifier.
728 *
729 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
730 *
731 * This function is thread safe and can be called at any point after spdk_nvme_attach().
732 *
733 * Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
734 * of commands submitted through this function.
735 */
736 int spdk_nvme_ctrlr_delete_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid);
737
738 /**
739 * \brief Format NVM.
740 *
741 * This function requests a low-level format of the media.
742 *
743 * \param ctrlr NVMe controller to format.
744 * \param nsid The namespace identifier. May be SPDK_NVME_GLOBAL_NS_TAG to format all namespaces.
745 * \param format The format information for the command.
746 *
747 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
748 *
749 * This function is thread safe and can be called at any point after spdk_nvme_attach().
750 */
751 int spdk_nvme_ctrlr_format(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
752 struct spdk_nvme_format *format);
753
754 /**
755 * \brief Download a new firmware image.
756 *
757 * \param payload The data buffer for the firmware image.
758 * \param size The data size will be downloaded.
759 * \param slot The slot that the firmware image will be committed to.
760 *
761 * \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request,
762 * -1 if the size is not multiple of 4.
763 *
764 * This function is thread safe and can be called at any point after spdk_nvme_attach().
765 */
766 int spdk_nvme_ctrlr_update_firmware(struct spdk_nvme_ctrlr *ctrlr, void *payload, uint32_t size,
767 int slot);
768
769 /**
770 * \brief Get the identify namespace data as defined by the NVMe specification.
771 *
772 * This function is thread safe and can be called at any point while the controller is attached to
773 * the SPDK NVMe driver.
774 */
775 const struct spdk_nvme_ns_data *spdk_nvme_ns_get_data(struct spdk_nvme_ns *ns);
776
777 /**
778 * \brief Get the namespace id (index number) from the given namespace handle.
779 *
780 * This function is thread safe and can be called at any point while the controller is attached to
781 * the SPDK NVMe driver.
782 */
783 uint32_t spdk_nvme_ns_get_id(struct spdk_nvme_ns *ns);
784
785 /**
786 * \brief Determine whether a namespace is active.
787 *
788 * Inactive namespaces cannot be the target of I/O commands.
789 */
790 bool spdk_nvme_ns_is_active(struct spdk_nvme_ns *ns);
791
792 /**
793 * \brief Get the maximum transfer size, in bytes, for an I/O sent to the given namespace.
794 *
795 * This function is thread safe and can be called at any point while the controller is attached to
796 * the SPDK NVMe driver.
797 */
798 uint32_t spdk_nvme_ns_get_max_io_xfer_size(struct spdk_nvme_ns *ns);
799
800 /**
801 * \brief Get the sector size, in bytes, of the given namespace.
802 *
803 * This function is thread safe and can be called at any point while the controller is attached to
804 * the SPDK NVMe driver.
805 */
806 uint32_t spdk_nvme_ns_get_sector_size(struct spdk_nvme_ns *ns);
807
808 /**
809 * \brief Get the number of sectors for the given namespace.
810 *
811 * This function is thread safe and can be called at any point while the controller is attached to
812 * the SPDK NVMe driver.
813 */
814 uint64_t spdk_nvme_ns_get_num_sectors(struct spdk_nvme_ns *ns);
815
816 /**
817 * \brief Get the size, in bytes, of the given namespace.
818 *
819 * This function is thread safe and can be called at any point while the controller is attached to
820 * the SPDK NVMe driver.
821 */
822 uint64_t spdk_nvme_ns_get_size(struct spdk_nvme_ns *ns);
823
824 /**
825 * \brief Get the end-to-end data protection information type of the given namespace.
826 *
827 * This function is thread safe and can be called at any point while the controller is attached to
828 * the SPDK NVMe driver.
829 */
830 enum spdk_nvme_pi_type spdk_nvme_ns_get_pi_type(struct spdk_nvme_ns *ns);
831
832 /**
833 * \brief Get the metadata size, in bytes, of the given namespace.
834 *
835 * This function is thread safe and can be called at any point while the controller is attached to
836 * the SPDK NVMe driver.
837 */
838 uint32_t spdk_nvme_ns_get_md_size(struct spdk_nvme_ns *ns);
839
840 /**
841 * \brief True if the namespace can support extended LBA when end-to-end data protection enabled.
842 *
843 * This function is thread safe and can be called at any point while the controller is attached to
844 * the SPDK NVMe driver.
845 */
846 bool spdk_nvme_ns_supports_extended_lba(struct spdk_nvme_ns *ns);
847
848 /**
849 * \brief Namespace command support flags.
850 */
851 enum spdk_nvme_ns_flags {
852 SPDK_NVME_NS_DEALLOCATE_SUPPORTED = 0x1, /**< The deallocate command is supported */
853 SPDK_NVME_NS_FLUSH_SUPPORTED = 0x2, /**< The flush command is supported */
854 SPDK_NVME_NS_RESERVATION_SUPPORTED = 0x4, /**< The reservation command is supported */
855 SPDK_NVME_NS_WRITE_ZEROES_SUPPORTED = 0x8, /**< The write zeroes command is supported */
856 SPDK_NVME_NS_DPS_PI_SUPPORTED = 0x10, /**< The end-to-end data protection is supported */
857 SPDK_NVME_NS_EXTENDED_LBA_SUPPORTED = 0x20, /**< The extended lba format is supported,
858 metadata is transferred as a contiguous
859 part of the logical block that it is associated with */
860 };
861
862 /**
863 * \brief Get the flags for the given namespace.
864 *
865 * See spdk_nvme_ns_flags for the possible flags returned.
866 *
867 * This function is thread safe and can be called at any point while the controller is attached to
868 * the SPDK NVMe driver.
869 */
870 uint32_t spdk_nvme_ns_get_flags(struct spdk_nvme_ns *ns);
871
872 /**
873 * Restart the SGL walk to the specified offset when the command has scattered payloads.
874 *
875 * The cb_arg parameter is the value passed to readv/writev.
876 */
877 typedef void (*spdk_nvme_req_reset_sgl_cb)(void *cb_arg, uint32_t offset);
878
879 /**
880 * Fill out *address and *length with the current SGL entry and advance to the next
881 * entry for the next time the callback is invoked.
882 *
883 * The cb_arg parameter is the value passed to readv/writev.
884 * The address parameter contains the virtual address of this segment.
885 * The length parameter contains the length of this physical segment.
886 */
887 typedef int (*spdk_nvme_req_next_sge_cb)(void *cb_arg, void **address, uint32_t *length);
888
889 /**
890 * \brief Submits a write I/O to the specified NVMe namespace.
891 *
892 * \param ns NVMe namespace to submit the write I/O
893 * \param qpair I/O queue pair to submit the request
894 * \param payload virtual address pointer to the data payload
895 * \param lba starting LBA to write the data
896 * \param lba_count length (in sectors) for the write operation
897 * \param cb_fn callback function to invoke when the I/O is completed
898 * \param cb_arg argument to pass to the callback function
899 * \param io_flags set flags, defined by the SPDK_NVME_IO_FLAGS_* entries
900 * in spdk/nvme_spec.h, for this I/O.
901 *
902 * \return 0 if successfully submitted, ENOMEM if an nvme_request
903 * structure cannot be allocated for the I/O request
904 *
905 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
906 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
907 */
908 int spdk_nvme_ns_cmd_write(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
909 uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
910 void *cb_arg, uint32_t io_flags);
911
912 /**
913 * \brief Submits a write I/O to the specified NVMe namespace.
914 *
915 * \param ns NVMe namespace to submit the write I/O
916 * \param qpair I/O queue pair to submit the request
917 * \param lba starting LBA to write the data
918 * \param lba_count length (in sectors) for the write operation
919 * \param cb_fn callback function to invoke when the I/O is completed
920 * \param cb_arg argument to pass to the callback function
921 * \param io_flags set flags, defined in nvme_spec.h, for this I/O
922 * \param reset_sgl_fn callback function to reset scattered payload
923 * \param next_sge_fn callback function to iterate each scattered
924 * payload memory segment
925 *
926 * \return 0 if successfully submitted, ENOMEM if an nvme_request
927 * structure cannot be allocated for the I/O request
928 *
929 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
930 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
931 */
932 int spdk_nvme_ns_cmd_writev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
933 uint64_t lba, uint32_t lba_count,
934 spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
935 spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
936 spdk_nvme_req_next_sge_cb next_sge_fn);
937
938 /**
939 * \brief Submits a write I/O to the specified NVMe namespace.
940 *
941 * \param ns NVMe namespace to submit the write I/O
942 * \param qpair I/O queue pair to submit the request
943 * \param payload virtual address pointer to the data payload
944 * \param metadata virtual address pointer to the metadata payload, the length
945 * of metadata is specified by spdk_nvme_ns_get_md_size()
946 * \param lba starting LBA to write the data
947 * \param lba_count length (in sectors) for the write operation
948 * \param cb_fn callback function to invoke when the I/O is completed
949 * \param cb_arg argument to pass to the callback function
950 * \param io_flags set flags, defined by the SPDK_NVME_IO_FLAGS_* entries
951 * in spdk/nvme_spec.h, for this I/O.
952 * \param apptag_mask application tag mask.
953 * \param apptag application tag to use end-to-end protection information.
954 *
955 * \return 0 if successfully submitted, ENOMEM if an nvme_request
956 * structure cannot be allocated for the I/O request
957 *
958 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
959 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
960 */
961 int spdk_nvme_ns_cmd_write_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
962 void *payload, void *metadata,
963 uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
964 void *cb_arg, uint32_t io_flags,
965 uint16_t apptag_mask, uint16_t apptag);
966
967 /**
968 * \brief Submits a write zeroes I/O to the specified NVMe namespace.
969 *
970 * \param ns NVMe namespace to submit the write zeroes I/O
971 * \param qpair I/O queue pair to submit the request
972 * \param lba starting LBA for this command
973 * \param lba_count length (in sectors) for the write zero operation
974 * \param cb_fn callback function to invoke when the I/O is completed
975 * \param cb_arg argument to pass to the callback function
976 * \param io_flags set flags, defined by the SPDK_NVME_IO_FLAGS_* entries
977 * in spdk/nvme_spec.h, for this I/O.
978 *
979 * \return 0 if successfully submitted, ENOMEM if an nvme_request
980 * structure cannot be allocated for the I/O request
981 *
982 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
983 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
984 */
985 int spdk_nvme_ns_cmd_write_zeroes(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
986 uint64_t lba, uint32_t lba_count,
987 spdk_nvme_cmd_cb cb_fn, void *cb_arg,
988 uint32_t io_flags);
989
990 /**
991 * \brief Submits a read I/O to the specified NVMe namespace.
992 *
993 * \param ns NVMe namespace to submit the read I/O
994 * \param qpair I/O queue pair to submit the request
995 * \param payload virtual address pointer to the data payload
996 * \param lba starting LBA to read the data
997 * \param lba_count length (in sectors) for the read operation
998 * \param cb_fn callback function to invoke when the I/O is completed
999 * \param cb_arg argument to pass to the callback function
1000 * \param io_flags set flags, defined in nvme_spec.h, for this I/O
1001 *
1002 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1003 * structure cannot be allocated for the I/O request
1004 *
1005 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1006 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1007 */
1008 int spdk_nvme_ns_cmd_read(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, void *payload,
1009 uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
1010 void *cb_arg, uint32_t io_flags);
1011
1012 /**
1013 * \brief Submits a read I/O to the specified NVMe namespace.
1014 *
1015 * \param ns NVMe namespace to submit the read I/O
1016 * \param qpair I/O queue pair to submit the request
1017 * \param lba starting LBA to read the data
1018 * \param lba_count length (in sectors) for the read operation
1019 * \param cb_fn callback function to invoke when the I/O is completed
1020 * \param cb_arg argument to pass to the callback function
1021 * \param io_flags set flags, defined in nvme_spec.h, for this I/O
1022 * \param reset_sgl_fn callback function to reset scattered payload
1023 * \param next_sge_fn callback function to iterate each scattered
1024 * payload memory segment
1025 *
1026 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1027 * structure cannot be allocated for the I/O request
1028 *
1029 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1030 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1031 */
1032 int spdk_nvme_ns_cmd_readv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
1033 uint64_t lba, uint32_t lba_count,
1034 spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
1035 spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
1036 spdk_nvme_req_next_sge_cb next_sge_fn);
1037
1038 /**
1039 * \brief Submits a read I/O to the specified NVMe namespace.
1040 *
1041 * \param ns NVMe namespace to submit the read I/O
1042 * \param qpair I/O queue pair to submit the request
1043 * \param payload virtual address pointer to the data payload
1044 * \param metadata virtual address pointer to the metadata payload, the length
1045 * of metadata is specified by spdk_nvme_ns_get_md_size()
1046 * \param lba starting LBA to read the data
1047 * \param lba_count length (in sectors) for the read operation
1048 * \param cb_fn callback function to invoke when the I/O is completed
1049 * \param cb_arg argument to pass to the callback function
1050 * \param io_flags set flags, defined in nvme_spec.h, for this I/O
1051 * \param apptag_mask application tag mask.
1052 * \param apptag application tag to use end-to-end protection information.
1053 *
1054 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1055 * structure cannot be allocated for the I/O request
1056 *
1057 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1058 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1059 */
1060 int spdk_nvme_ns_cmd_read_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
1061 void *payload, void *metadata,
1062 uint64_t lba, uint32_t lba_count, spdk_nvme_cmd_cb cb_fn,
1063 void *cb_arg, uint32_t io_flags,
1064 uint16_t apptag_mask, uint16_t apptag);
1065
1066 /**
1067 * \brief Submits a data set management request to the specified NVMe namespace. Data set
1068 * management operations are designed to optimize interaction with the block
1069 * translation layer inside the device. The most common type of operation is
1070 * deallocate, which is often referred to as TRIM or UNMAP.
1071 *
1072 * \param ns NVMe namespace to submit the DSM request
1073 * \param type A bit field constructed from \ref enum spdk_nvme_dsm_attribute.
1074 * \param qpair I/O queue pair to submit the request
1075 * \param ranges An array of \ref spdk_nvme_dsm_range elements describing
1076 the LBAs to operate on.
1077 * \param num_ranges The number of elements in the ranges array.
1078 * \param cb_fn callback function to invoke when the I/O is completed
1079 * \param cb_arg argument to pass to the callback function
1080 *
1081 * \return 0 if successfully submitted, negated POSIX errno values otherwise.
1082 *
1083 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1084 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1085 *
1086 * This is a convenience wrapper that will automatically allocate and construct the correct
1087 * data buffers. Therefore, ranges does not need to be allocated from pinned memory and
1088 * can be placed on the stack. If a higher performance, zero-copy version of DSM is
1089 * required, simply build and submit a raw command using spdk_nvme_ctrlr_cmd_io_raw().
1090 */
1091 int spdk_nvme_ns_cmd_dataset_management(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
1092 uint32_t type,
1093 const struct spdk_nvme_dsm_range *ranges,
1094 uint16_t num_ranges,
1095 spdk_nvme_cmd_cb cb_fn,
1096 void *cb_arg);
1097
1098 /**
1099 * \brief Submits a flush request to the specified NVMe namespace.
1100 *
1101 * \param ns NVMe namespace to submit the flush request
1102 * \param qpair I/O queue pair to submit the request
1103 * \param cb_fn callback function to invoke when the I/O is completed
1104 * \param cb_arg argument to pass to the callback function
1105 *
1106 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1107 * structure cannot be allocated for the I/O request
1108 *
1109 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1110 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1111 */
1112 int spdk_nvme_ns_cmd_flush(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
1113 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1114
1115 /**
1116 * \brief Submits a reservation register to the specified NVMe namespace.
1117 *
1118 * \param ns NVMe namespace to submit the reservation register request
1119 * \param qpair I/O queue pair to submit the request
1120 * \param payload virtual address pointer to the reservation register data
1121 * \param ignore_key '1' the current reservation key check is disabled
1122 * \param action specifies the registration action
1123 * \param cptpl change the Persist Through Power Loss state
1124 * \param cb_fn callback function to invoke when the I/O is completed
1125 * \param cb_arg argument to pass to the callback function
1126 *
1127 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1128 * structure cannot be allocated for the I/O request
1129 *
1130 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1131 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1132 */
1133 int spdk_nvme_ns_cmd_reservation_register(struct spdk_nvme_ns *ns,
1134 struct spdk_nvme_qpair *qpair,
1135 struct spdk_nvme_reservation_register_data *payload,
1136 bool ignore_key,
1137 enum spdk_nvme_reservation_register_action action,
1138 enum spdk_nvme_reservation_register_cptpl cptpl,
1139 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1140
1141 /**
1142 * \brief Submits a reservation release to the specified NVMe namespace.
1143 *
1144 * \param ns NVMe namespace to submit the reservation release request
1145 * \param qpair I/O queue pair to submit the request
1146 * \param payload virtual address pointer to current reservation key
1147 * \param ignore_key '1' the current reservation key check is disabled
1148 * \param action specifies the reservation release action
1149 * \param type reservation type for the namespace
1150 * \param cb_fn callback function to invoke when the I/O is completed
1151 * \param cb_arg argument to pass to the callback function
1152 *
1153 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1154 * structure cannot be allocated for the I/O request
1155 *
1156 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1157 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1158 */
1159 int spdk_nvme_ns_cmd_reservation_release(struct spdk_nvme_ns *ns,
1160 struct spdk_nvme_qpair *qpair,
1161 struct spdk_nvme_reservation_key_data *payload,
1162 bool ignore_key,
1163 enum spdk_nvme_reservation_release_action action,
1164 enum spdk_nvme_reservation_type type,
1165 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1166
1167 /**
1168 * \brief Submits a reservation acquire to the specified NVMe namespace.
1169 *
1170 * \param ns NVMe namespace to submit the reservation acquire request
1171 * \param qpair I/O queue pair to submit the request
1172 * \param payload virtual address pointer to reservation acquire data
1173 * \param ignore_key '1' the current reservation key check is disabled
1174 * \param action specifies the reservation acquire action
1175 * \param type reservation type for the namespace
1176 * \param cb_fn callback function to invoke when the I/O is completed
1177 * \param cb_arg argument to pass to the callback function
1178 *
1179 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1180 * structure cannot be allocated for the I/O request
1181 *
1182 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1183 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1184 */
1185 int spdk_nvme_ns_cmd_reservation_acquire(struct spdk_nvme_ns *ns,
1186 struct spdk_nvme_qpair *qpair,
1187 struct spdk_nvme_reservation_acquire_data *payload,
1188 bool ignore_key,
1189 enum spdk_nvme_reservation_acquire_action action,
1190 enum spdk_nvme_reservation_type type,
1191 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1192
1193 /**
1194 * \brief Submits a reservation report to the specified NVMe namespace.
1195 *
1196 * \param ns NVMe namespace to submit the reservation report request
1197 * \param qpair I/O queue pair to submit the request
1198 * \param payload virtual address pointer for reservation status data
1199 * \param len length bytes for reservation status data structure
1200 * \param cb_fn callback function to invoke when the I/O is completed
1201 * \param cb_arg argument to pass to the callback function
1202 *
1203 * \return 0 if successfully submitted, ENOMEM if an nvme_request
1204 * structure cannot be allocated for the I/O request
1205 *
1206 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
1207 * The user must ensure that only one thread submits I/O on a given qpair at any given time.
1208 */
1209 int spdk_nvme_ns_cmd_reservation_report(struct spdk_nvme_ns *ns,
1210 struct spdk_nvme_qpair *qpair,
1211 void *payload, uint32_t len,
1212 spdk_nvme_cmd_cb cb_fn, void *cb_arg);
1213
1214 #ifdef __cplusplus
1215 }
1216 #endif
1217
1218 #endif