@@ -2545,6 +2545,90 @@ int spdk_nvme_ns_cmd_writev_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qp
25452545 spdk_nvme_req_next_sge_cb next_sge_fn , void * metadata ,
25462546 uint16_t apptag_mask , uint16_t apptag );
25472547
2548+ /**
2549+ * Callback used to get a Memory Key per IO request
2550+ *
2551+ * pd is input parameter and should point to a memory domain
2552+ * mkey is an output value
2553+ */
2554+ typedef int (* spdk_nvme_ns_cmd_io_get_mkey )(void * cb_arg , void * address , size_t length , void * pd ,
2555+ uint32_t * mkey );
2556+
2557+ enum spdk_nvme_ns_cmd_ext_io_opts_mem_types {
2558+ /** Memory in IO request belongs to another memory domain and it is described by Memory Key.
2559+ * If this value is set then \b mkey structure in spdk_nvme_ns_cmd_ext_io_opts_mem_type contains
2560+ * a callback and its argument that can be used to get a Memory Key */
2561+ SPDK_NVME_NS_CMD_EXT_IO_OPTS_MEM_TYPE_MEMORY_KEY = 0 ,
2562+ };
2563+
2564+ struct spdk_nvme_ns_cmd_ext_io_opts_mem_type {
2565+ /** This value determines which part of union should be used. Provides extensibility for this structure */
2566+ enum spdk_nvme_ns_cmd_ext_io_opts_mem_types type ;
2567+ union {
2568+ struct {
2569+ spdk_nvme_ns_cmd_io_get_mkey get_mkey_cb ;
2570+ } mkey ;
2571+ } u ;
2572+ };
2573+
2574+ enum spdk_nvme_ns_cmd_ext_io_opts_flags {
2575+ /** This flag determines the type of memory passed in IO request.
2576+ * Refer to \ref spdk_nvme_ns_cmd_ext_io_opts_mem_types for more information.
2577+ * If this flag is set in spdk_nvme_ns_cmd_ext_io_opts then \b mem_type member of
2578+ * \b spdk_nvme_ns_cmd_ext_io_opts should point to a structure that describes memory buffer */
2579+ SPDK_NVME_NS_CMD_EXT_IO_OPTS_MEM_TYPE = 1u << 0 ,
2580+ };
2581+
2582+ /**
2583+ * Structure with optional IO request parameters
2584+ */
2585+ struct spdk_nvme_ns_cmd_ext_io_opts {
2586+ /** Combination of bits defined in \b enum spdk_nvme_ns_cmd_ext_io_opts_flags */
2587+ uint64_t flags ;
2588+ /** Describes type of the memory used in IO request
2589+ * This structure must be filled by the user if \b SPDK_NVME_NS_CMD_EXT_IO_OPTS_MEM_TYPE bit is set
2590+ * in \b flags member. Used by RDMA transport, other transports ignore this extension */
2591+ struct spdk_nvme_ns_cmd_ext_io_opts_mem_type * mem_type ;
2592+ };
2593+
2594+ /**
2595+ * Submit a write I/O to the specified NVMe namespace.
2596+ *
2597+ * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
2598+ * The user must ensure that only one thread submits I/O on a given qpair at any
2599+ * given time.
2600+ *
2601+ * \param ns NVMe namespace to submit the write I/O
2602+ * \param qpair I/O queue pair to submit the request
2603+ * \param lba starting LBA to write the data
2604+ * \param lba_count length (in sectors) for the write operation
2605+ * \param cb_fn callback function to invoke when the I/O is completed
2606+ * \param cb_arg argument to pass to the callback function
2607+ * \param io_flags set flags, defined in nvme_spec.h, for this I/O
2608+ * \param reset_sgl_fn callback function to reset scattered payload
2609+ * \param next_sge_fn callback function to iterate each scattered
2610+ * payload memory segment
2611+ * \param metadata virtual address pointer to the metadata payload, the length
2612+ * of metadata is specified by spdk_nvme_ns_get_md_size()
2613+ * \param apptag_mask application tag mask.
2614+ * \param apptag application tag to use end-to-end protection information.
2615+ * \param opts Optional structure with extended IO request options.
2616+ *
2617+ * \return 0 if successfully submitted, negated errnos on the following error conditions:
2618+ * -EINVAL: The request is malformed.
2619+ * -ENOMEM: The request cannot be allocated.
2620+ * -ENXIO: The qpair is failed at the transport level.
2621+ * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
2622+ * with error status including dnr=1 in this case.
2623+ */
2624+ int spdk_nvme_ns_cmd_writev_with_md_ext (struct spdk_nvme_ns * ns , struct spdk_nvme_qpair * qpair ,
2625+ uint64_t lba , uint32_t lba_count ,
2626+ spdk_nvme_cmd_cb cb_fn , void * cb_arg , uint32_t io_flags ,
2627+ spdk_nvme_req_reset_sgl_cb reset_sgl_fn ,
2628+ spdk_nvme_req_next_sge_cb next_sge_fn , void * metadata ,
2629+ uint16_t apptag_mask , uint16_t apptag ,
2630+ struct spdk_nvme_ns_cmd_ext_io_opts * opts );
2631+
25482632/**
25492633 * Submit a write I/O to the specified NVMe namespace.
25502634 *
@@ -2725,6 +2809,43 @@ int spdk_nvme_ns_cmd_readv_with_md(struct spdk_nvme_ns *ns, struct spdk_nvme_qpa
27252809 spdk_nvme_req_next_sge_cb next_sge_fn , void * metadata ,
27262810 uint16_t apptag_mask , uint16_t apptag );
27272811
2812+ /**
2813+ * Submit a read I/O to the specified NVMe namespace.
2814+ *
2815+ * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
2816+ * The user must ensure that only one thread submits I/O on a given qpair at any given time.
2817+ *
2818+ * \param ns NVMe namespace to submit the read I/O
2819+ * \param qpair I/O queue pair to submit the request
2820+ * \param lba starting LBA to read the data
2821+ * \param lba_count length (in sectors) for the read operation
2822+ * \param cb_fn callback function to invoke when the I/O is completed
2823+ * \param cb_arg argument to pass to the callback function
2824+ * \param io_flags set flags, defined in nvme_spec.h, for this I/O
2825+ * \param reset_sgl_fn callback function to reset scattered payload
2826+ * \param next_sge_fn callback function to iterate each scattered
2827+ * payload memory segment
2828+ * \param metadata virtual address pointer to the metadata payload, the length
2829+ * of metadata is specified by spdk_nvme_ns_get_md_size()
2830+ * \param apptag_mask application tag mask.
2831+ * \param apptag application tag to use end-to-end protection information.
2832+ * \param opts Optional structure with extended IO request options.
2833+ *
2834+ * \return 0 if successfully submitted, negated errnos on the following error conditions:
2835+ * -EINVAL: The request is malformed.
2836+ * -ENOMEM: The request cannot be allocated.
2837+ * -ENXIO: The qpair is failed at the transport level.
2838+ * -EFAULT: Invalid address was specified as part of payload. cb_fn is also called
2839+ * with error status including dnr=1 in this case.
2840+ */
2841+ int spdk_nvme_ns_cmd_readv_with_md_ext (struct spdk_nvme_ns * ns , struct spdk_nvme_qpair * qpair ,
2842+ uint64_t lba , uint32_t lba_count ,
2843+ spdk_nvme_cmd_cb cb_fn , void * cb_arg , uint32_t io_flags ,
2844+ spdk_nvme_req_reset_sgl_cb reset_sgl_fn ,
2845+ spdk_nvme_req_next_sge_cb next_sge_fn , void * metadata ,
2846+ uint16_t apptag_mask , uint16_t apptag ,
2847+ struct spdk_nvme_ns_cmd_ext_io_opts * opts );
2848+
27282849/**
27292850 * Submits a read I/O to the specified NVMe namespace.
27302851 *
0 commit comments