Commit 28b353a5 authored by Ankit Kumar's avatar Ankit Kumar Committed by Konrad Sztyber
Browse files

nvme: interface to retrieve fd for a queue



Applications that enable interrupts for completion notification will
register and unregister queue pair file descriptor with event source.
These application also require other necessary details such as event
source and file descriptor type during interrupt registration phase.

Added APIs spdk_nvme_qpair_get_fd() and spdk_nvme_ctrlr_get_admin_qp_fd()
to retrieve the file descriptor of an I/O and the admin queue pair of a
given controller respectively. These APIs accept spdk_event_handler_opts
which if specified, allows the transport layer to fill out event source
and fd type.

Change-Id: I5c24ae15ffc01afea879d0219e8721728cce592e
Signed-off-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24906


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
parent 58ae1bdd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -28,6 +28,11 @@ enabled during initialization. Make sure to check the resulting value after the
check for success. This mode is currently only supported for PCIe transport. This is only
supported within a primary SPDK process, and if enabled SPDK will not support secondary processes.

Added APIs `spdk_nvme_qpair_get_fd()` and `spdk_nvme_ctrlr_get_admin_qp_fd()` to retrieve the file
descriptor for an I/O and the admin queue pair of a given NVMe controller respectively.
These APIs accept `spdk_event_handler_opts` structure, and if specified the transport layer will
fill it out which can be used by the application to register interrupts on the queue pairs.

### nvmf

Added public API `spdk_nvmf_send_discovery_log_notice` to send discovery log page
+47 −0
Original line number Diff line number Diff line
@@ -1914,6 +1914,31 @@ void spdk_nvme_ctrlr_disconnect_io_qpair(struct spdk_nvme_qpair *qpair);
 */
int spdk_nvme_ctrlr_reconnect_io_qpair(struct spdk_nvme_qpair *qpair);

/**
 * Opaque extended event handler options.
 */
struct spdk_event_handler_opts;

/**
 * Get file descriptor for the admin queue pair of a controller.
 *
 * Applications that enable interrupts for completion notification will register and unregister
 * interrupt event source on its queue pair file descriptor. This function returns file descriptor
 * of the admin queue pair.
 * This function also allows the transport layer to fill out event handler opts required by the
 * application during interrupt registration phase.
 *
 * \param ctrlr Controller for which fd has to be fetched.
 * \param[out] opts Event handler options to be filled by the transport, or NULL.
 *
 * \return a valid fd on success, with opts filled out if specified.
 * -ENOTSUP if transport does not support fetching fd for this controller.
 * -EINVAL if opts is specified, but its size is incorrect.
 * -EINVAL if fds are not reserved, -1 if interrupts are not enabled for this controller.
 */
int spdk_nvme_ctrlr_get_admin_qp_fd(struct spdk_nvme_ctrlr *ctrlr,
				    struct spdk_event_handler_opts *opts);

/**
 * Returns the reason the admin qpair for a given controller is disconnected.
 *
@@ -2097,6 +2122,26 @@ int spdk_nvme_ctrlr_cmd_iov_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
					spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
					spdk_nvme_req_next_sge_cb next_sge_fn);

/**
 * Get file descriptor for an I/O queue pair.
 *
 * Applications that enable interrupts for completion notification will register and unregister
 * interrupt event source on its queue pair file descriptor. This function returns file descriptor
 * for an I/O queue pair.
 * This function also allows the transport layer to fill out event handler opts required by the
 * application during interrupt registration phase.
 *
 * \param qpair Opaque handle of the queue pair for which fd has to be fetched.
 * \param[out] opts Opaque event handler options to be filled by the transport, or NULL.
 *
 * \return a valid fd on success, with opts filled out if specified
 * -ENOTSUP if transport does not support fetching fd for the queue pair.
 * -EINVAL if opts is specified but its size is incorrect.
 * -EINVAL if fds are not reserved, -1 if interrupts are not enabled for the qpair controller.
 */
int spdk_nvme_qpair_get_fd(struct spdk_nvme_qpair *qpair,
			   struct spdk_event_handler_opts *opts);

/**
 * Process any outstanding completions for I/O submitted on a queue pair.
 *
@@ -4550,6 +4595,8 @@ struct spdk_nvme_transport_ops {
				      int (*iter_fn)(struct nvme_request *req, void *arg),
				      void *arg);

	int (*qpair_get_fd)(struct spdk_nvme_qpair *qpair, struct spdk_event_handler_opts *opts);

	void (*admin_qpair_abort_aers)(struct spdk_nvme_qpair *qpair);

	struct spdk_nvme_transport_poll_group *(*poll_group_create)(void);
+7 −0
Original line number Diff line number Diff line
@@ -422,6 +422,13 @@ spdk_nvme_ctrlr_disconnect_io_qpair(struct spdk_nvme_qpair *qpair)
	nvme_ctrlr_unlock(ctrlr);
}

int
spdk_nvme_ctrlr_get_admin_qp_fd(struct spdk_nvme_ctrlr *ctrlr,
				struct spdk_event_handler_opts *opts)
{
	return spdk_nvme_qpair_get_fd(ctrlr->adminq, opts);
}

struct spdk_nvme_qpair *
spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
			       const struct spdk_nvme_io_qpair_opts *user_opts,
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "spdk/nvmf_spec.h"
#include "spdk/tree.h"
#include "spdk/uuid.h"
#include "spdk/fd_group.h"

#include "spdk_internal/assert.h"
#include "spdk/log.h"
@@ -1699,6 +1700,8 @@ int nvme_transport_ctrlr_get_memory_domains(const struct spdk_nvme_ctrlr *ctrlr,
void nvme_transport_qpair_abort_reqs(struct spdk_nvme_qpair *qpair);
int nvme_transport_qpair_reset(struct spdk_nvme_qpair *qpair);
int nvme_transport_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req);
int nvme_transport_qpair_get_fd(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
				struct spdk_event_handler_opts *opts);
int32_t nvme_transport_qpair_process_completions(struct spdk_nvme_qpair *qpair,
		uint32_t max_completions);
void nvme_transport_admin_qpair_abort_aers(struct spdk_nvme_qpair *qpair);
+1 −0
Original line number Diff line number Diff line
@@ -1145,6 +1145,7 @@ const struct spdk_nvme_transport_ops pcie_ops = {
	.qpair_submit_request = nvme_pcie_qpair_submit_request,
	.qpair_process_completions = nvme_pcie_qpair_process_completions,
	.qpair_iterate_requests = nvme_pcie_qpair_iterate_requests,
	.qpair_get_fd = nvme_pcie_qpair_get_fd,
	.admin_qpair_abort_aers = nvme_pcie_admin_qpair_abort_aers,

	.poll_group_create = nvme_pcie_poll_group_create,
Loading