Commit 3ab7a1f6 authored by Ankit Kumar's avatar Ankit Kumar Committed by Konrad Sztyber
Browse files

nvme: enable interrupts for pcie nvme devices



Add an option enable_interrupts to the spdk_nvme_ctrlr_opts structure.
If this is set to true for pcie controllers interrupts may be enabled
during initialization. Applications are required to check the resulting
value after the attach step to check for success.
Maximum of 256 eventfds can be reserved for I/O queues, but the actual
number can be lower and is based on the minimum requested I/O queues
and number of available I/O queues.
The nvme_pcie_ctrlr_cmd_create_io_cq() interface has been modified to
create I/O completion queues with interrupts. The interrupt vector field
corresponds to the queue identifier in this case.

This is only supported within a primary SPDK process, and if enabled
SPDK will not support any secondary processes.

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


Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
parent f7f0fdf5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,13 @@ If multipathing shall be enabled for nvme bdev, `bdev_opts.multipath` shall be s
Added 3 APIs to handle multiple interrupts for PCI device `spdk_pci_device_enable_interrupts()`,
`spdk_pci_device_disable_interrupts()`, and `spdk_pci_device_get_interrupt_efd_by_index()`.

### nvme

Added `enable_interrupts` option to `spdk_nvme_ctrlr_opts`. If set to true then interrupts may be
enabled during initialization. Make sure to check the resulting value after the attach step to
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.

### nvmf

Added public API `spdk_nvmf_send_discovery_log_notice` to send discovery log page
+8 −2
Original line number Diff line number Diff line
@@ -61,8 +61,14 @@ struct spdk_nvme_ctrlr_opts {
	 */
	bool no_shn_notification;

	/* Hole at bytes 6-7. */
	uint8_t	reserved6[2];
	/**
	 * Enable interrupts for completion notification. This is only supported within a primary
	 * SPDK process, and if enabled SPDK will not support secondary processes.
	 */
	bool enable_interrupts;

	/* Hole at byte 7. */
	uint8_t	reserved7;

	/**
	 * Type of arbitration mechanism
+1 −0
Original line number Diff line number Diff line
@@ -985,6 +985,7 @@ nvme_ctrlr_opts_init(struct spdk_nvme_ctrlr_opts *opts,
	SET_FIELD(num_io_queues);
	SET_FIELD(use_cmb_sqs);
	SET_FIELD(no_shn_notification);
	SET_FIELD(enable_interrupts);
	SET_FIELD(arb_mechanism);
	SET_FIELD(arbitration_burst);
	SET_FIELD(low_priority_weight);
+15 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t
	SET_FIELD(num_io_queues, DEFAULT_MAX_IO_QUEUES);
	SET_FIELD(use_cmb_sqs, false);
	SET_FIELD(no_shn_notification, false);
	SET_FIELD(enable_interrupts, false);
	SET_FIELD(arb_mechanism, SPDK_NVME_CC_AMS_RR);
	SET_FIELD(arbitration_burst, 0);
	SET_FIELD(low_priority_weight, 0);
@@ -467,6 +468,11 @@ spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
		}
	}

	if (ctrlr->opts.enable_interrupts && opts.delay_cmd_submit) {
		NVME_CTRLR_ERRLOG(ctrlr, "delay command submit cannot work with interrupts\n");
		goto unlock;
	}

	qpair = nvme_ctrlr_create_io_qpair(ctrlr, &opts);

	if (qpair == NULL || opts.create_only == true) {
@@ -2945,6 +2951,15 @@ nvme_ctrlr_set_num_queues_done(void *arg, const struct spdk_nvme_cpl *cpl)

		/* Set number of queues to be minimum of requested and actually allocated. */
		ctrlr->opts.num_io_queues = spdk_min(min_allocated, ctrlr->opts.num_io_queues);

		if (ctrlr->opts.enable_interrupts) {
			ctrlr->opts.num_io_queues = spdk_min(MAX_IO_QUEUES_WITH_INTERRUPTS,
							     ctrlr->opts.num_io_queues);
			if (nvme_transport_ctrlr_enable_interrupts(ctrlr) < 0) {
				NVME_CTRLR_ERRLOG(ctrlr, "Failed to enable interrupts!\n");
				ctrlr->opts.enable_interrupts = false;
			}
		}
	}

	ctrlr->free_io_qids = spdk_bit_array_create(ctrlr->opts.num_io_queues + 1);
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ extern struct spdk_nvme_transport_opts g_spdk_nvme_transport_opts;
 *  try to configure, if available.
 */
#define DEFAULT_MAX_IO_QUEUES		(1024)
#define MAX_IO_QUEUES_WITH_INTERRUPTS	(256)
#define DEFAULT_ADMIN_QUEUE_SIZE	(32)
#define DEFAULT_IO_QUEUE_SIZE		(256)
#define DEFAULT_IO_QUEUE_SIZE_FOR_QUIRK	(1024) /* Matches Linux kernel driver */
Loading