Commit 4ad99808 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Benjamin Walker
Browse files

nvme: allow user to override controller defaults



Provide a new structure, spdk_nvme_ctrlr_opts, to let the user modify
the default controller initialization options during probe/attach.

Currently, only the number of queue pairs can be modified in this way;
other options will be added later.

Change-Id: Ie27b9429291d93a9353c0d820f0ad467d3b0e7cb
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 23f95df8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -771,7 +771,7 @@ parse_args(int argc, char **argv)
}

static bool
probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
probe_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr_opts *opts)
{
	if (spdk_pci_device_has_non_uio_driver(dev)) {
		fprintf(stderr, "non-uio kernel driver attached to NVMe\n");
@@ -788,7 +788,8 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
}

static void
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr)
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr,
	  const struct spdk_nvme_ctrlr_opts *opts)
{
	print_controller(ctrlr, pci_dev);
	spdk_nvme_detach(ctrlr);
+3 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ cmp_devs(const void *ap, const void *bp)
}

static bool
probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
probe_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr_opts *opts)
{
	if (spdk_pci_device_has_non_uio_driver(dev)) {
		fprintf(stderr, "non-uio kernel driver attached to NVMe\n");
@@ -113,7 +113,8 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
}

static void
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr)
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr,
	  const struct spdk_nvme_ctrlr_opts *opts)
{
	struct dev *dev;

+3 −2
Original line number Diff line number Diff line
@@ -884,7 +884,7 @@ register_workers(void)
}

static bool
probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
probe_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr_opts *opts)
{
	if (spdk_pci_device_has_non_uio_driver(dev)) {
		fprintf(stderr, "non-uio kernel driver attached to NVMe\n");
@@ -907,7 +907,8 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
}

static void
attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctrlr)
attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctrlr,
	  const struct spdk_nvme_ctrlr_opts *opts)
{
	printf("Attached to %04x:%02x:%02x.%02x\n",
	       spdk_pci_device_get_domain(dev),
+3 −2
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ reserve_controller(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
}

static bool
probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
probe_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr_opts *opts)
{
	if (spdk_pci_device_has_non_uio_driver(dev)) {
		fprintf(stderr, "non-uio kernel driver attached to NVMe\n");
@@ -399,7 +399,8 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *dev)
}

static void
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr)
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr,
	  const struct spdk_nvme_ctrlr_opts *opts)
{
	struct dev *dev;

+25 −2
Original line number Diff line number Diff line
@@ -56,18 +56,41 @@ extern int32_t spdk_nvme_retry_count;
/** \brief Opaque handle to a controller. Returned by \ref spdk_nvme_probe()'s attach_cb. */
struct spdk_nvme_ctrlr;

/**
 * \brief NVMe controller initialization options.
 *
 * A pointer to this structure will be provided for each probe callback from spdk_nvme_probe() to
 * allow the user to request non-default options, and the actual options enabled on the controller
 * will be provided during the attach callback.
 */
struct spdk_nvme_ctrlr_opts {
	/**
	 * Number of I/O queues to request (used to set Number of Queues feature)
	 */
	uint32_t num_io_queues;
};

/**
 * Callback for spdk_nvme_probe() enumeration.
 *
 * \param opts NVMe controller initialization options.  This structure will be populated with the
 * default values on entry, and the user callback may update any options to request a different
 * value.  The controller may not support all requested parameters, so the final values will be
 * provided during the attach callback.
 * \return true to attach to this device.
 */
typedef bool (*spdk_nvme_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev);
typedef bool (*spdk_nvme_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev,
				   struct spdk_nvme_ctrlr_opts *opts);

/**
 * Callback for spdk_nvme_probe() to report a device that has been attached to the userspace NVMe driver.
 *
 * \param opts NVMe controller initialization options that were actually used.  Options may differ
 * from the requested options from the probe call depending on what the controller supports.
 */
typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev,
				    struct spdk_nvme_ctrlr *ctrlr);
				    struct spdk_nvme_ctrlr *ctrlr,
				    const struct spdk_nvme_ctrlr_opts *opts);

/**
 * \brief Enumerate the NVMe devices attached to the system and attach the userspace NVMe driver
Loading