Commit 7d5bcb48 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvme: remove spdk_nvme_transport_type from API



Use the NVMe over Fabrics spec definitions for TRTYPE rather than the
internal library transport type.

Change-Id: Idead559a8f8d95274fc580d10e82033822e6eda8
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 9a40113a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -925,7 +925,7 @@ parse_args(int argc, char **argv)
		return 0;
	}

	info.type = SPDK_NVME_TRANSPORT_RDMA;
	info.trtype = SPDK_NVMF_TRTYPE_RDMA;
	optind = 1;

	return 0;
@@ -972,7 +972,7 @@ int main(int argc, char **argv)
	}

	rc = 0;
	if (info.type == SPDK_NVME_TRANSPORT_RDMA) {
	if (info.trtype == SPDK_NVMF_TRTYPE_RDMA) {
		if (spdk_nvme_discover(&info, NULL, probe_cb, attach_cb, NULL) != 0) {
			fprintf(stderr, "spdk_nvme_probe() failed\n");
		}
+17 −16
Original line number Diff line number Diff line
@@ -102,21 +102,6 @@ struct spdk_nvme_ctrlr_opts {
	int queue_size;
};

/**
 * NVMe transport type
 */
enum spdk_nvme_transport_type {
	/**
	 * NVMe connected via local PCI Express
	 */
	SPDK_NVME_TRANSPORT_PCIE,

	/**
	 * NVMe over Fabrics with RDMA transport
	 */
	SPDK_NVME_TRANSPORT_RDMA,
};

/**
 * NVMe over Fabrics discovery parameters.
 *
@@ -126,7 +111,7 @@ struct spdk_nvme_discover_info {
	/**
	 * NVMe over Fabrics transport type.
	 */
	enum spdk_nvme_transport_type type;
	enum spdk_nvmf_trtype trtype;

	/**
	 * Subsystem NQN of the NVMe over Fabrics discovery service.
@@ -171,6 +156,13 @@ struct spdk_nvme_probe_info {
	 */
	char nqn[SPDK_NVMF_NQN_MAX_LEN + 1];

	/**
	 * NVMe over Fabrics transport type.
	 *
	 * This field will be 0 if this is not an NVMe over Fabrics controller.
	 */
	enum spdk_nvmf_trtype trtype;

	/**
	 * Transport address of the NVMe over Fabrics target. For transports which use IP
	 * addressing (e.g. RDMA), this will be an IP-based address.
@@ -184,6 +176,15 @@ struct spdk_nvme_probe_info {
	char trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
};

/**
 * Determine whether the NVMe library can handle a specific NVMe over Fabrics transport type.
 *
 * \param trtype NVMe over Fabrics transport type to check.
 *
 * \return true if trtype is supported or false if it is not supported.
 */
bool spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype);

/**
 * Callback for spdk_nvme_probe() enumeration.
 *
+13 −7
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ struct nvme_driver *g_spdk_nvme_driver = &_g_nvme_driver;
int32_t		spdk_nvme_retry_count;

struct spdk_nvme_ctrlr *
nvme_attach(enum spdk_nvme_transport_type transport, void *devhandle)
nvme_attach(enum spdk_nvme_transport transport, void *devhandle)
{
	struct spdk_nvme_ctrlr	*ctrlr;

@@ -229,7 +229,7 @@ nvme_mutex_init_shared(pthread_mutex_t *mtx)
}

int
nvme_probe_one(enum spdk_nvme_transport_type type, spdk_nvme_probe_cb probe_cb, void *cb_ctx,
nvme_probe_one(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx,
	       struct spdk_nvme_probe_info *probe_info, void *devhandle)
{
	struct spdk_nvme_ctrlr *ctrlr;
@@ -238,7 +238,7 @@ nvme_probe_one(enum spdk_nvme_transport_type type, spdk_nvme_probe_cb probe_cb,
	spdk_nvme_ctrlr_opts_set_defaults(&opts);

	if (probe_cb(cb_ctx, probe_info, &opts)) {
		ctrlr = nvme_attach(type, devhandle);
		ctrlr = nvme_attach(transport, devhandle);
		if (ctrlr == NULL) {
			SPDK_ERRLOG("nvme_attach() failed\n");
			return -1;
@@ -260,7 +260,7 @@ _spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
{
	int rc, start_rc;
	struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
	enum spdk_nvme_transport_type type;
	enum spdk_nvme_transport transport;

	if (!spdk_process_is_primary()) {
		while (g_spdk_nvme_driver->initialized == false) {
@@ -281,12 +281,18 @@ _spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
	}

	if (!info) {
		type = SPDK_NVME_TRANSPORT_PCIE;
		transport = SPDK_NVME_TRANSPORT_PCIE;
	} else {
		type = info->type;
		if (!spdk_nvme_transport_available(info->trtype)) {
			SPDK_ERRLOG("NVMe over Fabrics trtype %u not available\n", info->trtype);
			pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
			return -1;
		}

		transport = (uint8_t)info->trtype;
	}

	rc = nvme_transport_ctrlr_scan(type, probe_cb, cb_ctx, (void *)info);
	rc = nvme_transport_ctrlr_scan(transport, probe_cb, cb_ctx, (void *)info);

	/*
	 * Keep going even if one or more nvme_attach() calls failed,
+20 −6
Original line number Diff line number Diff line
@@ -220,6 +220,20 @@ struct nvme_request {
	void				*user_buffer;
};

/*
 * NVMe library transports
 *
 * NOTE: These are mapped directly to the NVMe over Fabrics TRTYPE values, except for PCIe,
 * which is a special case since NVMe over Fabrics does not define a TRTYPE for local PCIe.
 *
 * Currently, this uses 0 for PCIe since it is reserved by NVMe-oF.  If 0 is ever assigned as a
 * valid TRTYPE, this would need to be changed.
 */
enum spdk_nvme_transport {
	SPDK_NVME_TRANSPORT_PCIE = 0,
	SPDK_NVME_TRANSPORT_RDMA = SPDK_NVMF_TRTYPE_RDMA,
};

struct nvme_completion_poll_status {
	struct spdk_nvme_cpl	cpl;
	bool			done;
@@ -234,7 +248,7 @@ struct nvme_async_event_request {
struct spdk_nvme_qpair {
	STAILQ_HEAD(, nvme_request)	queued_req;

	enum spdk_nvme_transport_type	transport;
	enum spdk_nvme_transport	transport;

	uint16_t			id;

@@ -323,7 +337,7 @@ struct spdk_nvme_ctrlr {
	/** Array of namespaces indexed by nsid - 1 */
	struct spdk_nvme_ns		*ns;

	enum spdk_nvme_transport_type	transport;
	enum spdk_nvme_transport	transport;

	uint32_t			num_ns;

@@ -480,7 +494,7 @@ void nvme_completion_poll_cb(void *arg, const struct spdk_nvme_cpl *cpl);
int	nvme_ctrlr_add_process(struct spdk_nvme_ctrlr *ctrlr, void *devhandle);
void	nvme_ctrlr_free_processes(struct spdk_nvme_ctrlr *ctrlr);

int	nvme_probe_one(enum spdk_nvme_transport_type type, spdk_nvme_probe_cb probe_cb, void *cb_ctx,
int	nvme_probe_one(enum spdk_nvme_transport type, spdk_nvme_probe_cb probe_cb, void *cb_ctx,
		       struct spdk_nvme_probe_info *probe_info, void *devhandle);

int	nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr);
@@ -525,13 +539,13 @@ int nvme_mutex_init_recursive_shared(pthread_mutex_t *mtx);
bool	nvme_completion_is_retry(const struct spdk_nvme_cpl *cpl);
void	nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd);
void	nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cpl *cpl);
struct	spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport_type transport, void *devhandle);
struct	spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport transport, void *devhandle);

/* Transport specific functions */
#define DECLARE_TRANSPORT(name) \
	struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport_type transport, void *devhandle); \
	struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport transport, void *devhandle); \
	int nvme_ ## name ## _ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr); \
	int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport_type transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle); \
	int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle); \
	int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \
	int nvme_ ## name ## _ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id); \
	int nvme_ ## name ## _ctrlr_set_reg_4(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value); \
+2 −2
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
}

int
nvme_pcie_ctrlr_scan(enum spdk_nvme_transport_type transport,
nvme_pcie_ctrlr_scan(enum spdk_nvme_transport transport,
		     spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle)
{
	struct nvme_pcie_enum_ctx enum_ctx;
@@ -468,7 +468,7 @@ nvme_pcie_ctrlr_scan(enum spdk_nvme_transport_type transport,
	return spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx);
}

struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport_type transport,
struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport transport,
		void *devhandle)
{
	struct spdk_pci_device *pci_dev = devhandle;
Loading