Commit 771d7593 authored by Seth Howell's avatar Seth Howell Committed by Tomasz Zawadzki
Browse files

lib/nvme: add spdk_nvme_transport_available_by_name



This new api function will enable us to work with custom transports.

This is needed to enable properly parsing and comparing custom transport
IDs that may all resolve to the same enum value.

Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Change-Id: I26aa3cb8f76f8273f564799d9b2af8041ea0d219
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478752


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent f038354e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1684,7 +1684,7 @@ parse_args(int argc, char **argv)
{
	int op, rc;

	g_trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
	spdk_nvme_trid_populate_transport(&g_trid, SPDK_NVME_TRANSPORT_PCIE);
	snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);

	while ((op = getopt(argc, argv, "d:i:p:r:xHL:V")) != -1) {
+13 −1
Original line number Diff line number Diff line
@@ -544,10 +544,22 @@ const char *spdk_nvme_prchk_flags_str(uint32_t prchk_flags);
 *
 * \param trtype NVMe over Fabrics transport type to check.
 *
 * \return true if trtype is supported or false if it is not supported.
 * \return true if trtype is supported or false if it is not supported or if
 * SPDK_NVME_TRANSPORT_CUSTOM is supplied as trtype since it can represent multiple
 * transports.
 */
bool spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype);

/**
 * Determine whether the NVMe library can handle a specific NVMe over Fabrics
 * transport type.
 *
 * \param transport_name Name of the NVMe over Fabrics transport type to check.
 *
 * \return true if transport_name is supported or false if it is not supported.
 */
bool spdk_nvme_transport_available_by_name(const char *transport_name);

/**
 * Callback for spdk_nvme_probe() enumeration.
 *
+1 −1
Original line number Diff line number Diff line
@@ -558,7 +558,7 @@ spdk_nvme_probe_internal(struct spdk_nvme_probe_ctx *probe_ctx,
	int rc;
	struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;

	if (!spdk_nvme_transport_available(probe_ctx->trid.trtype)) {
	if (!spdk_nvme_transport_available_by_name(probe_ctx->trid.trstring)) {
		SPDK_ERRLOG("NVMe trtype %u not available\n", probe_ctx->trid.trtype);
		return -1;
	}
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ nvme_fabric_discover_probe(struct spdk_nvmf_discovery_log_page_entry *entry,

	trid.trtype = entry->trtype;
	spdk_nvme_transport_id_populate_trstring(&trid, spdk_nvme_transport_id_trtype_str(entry->trtype));
	if (!spdk_nvme_transport_available(trid.trtype)) {
	if (!spdk_nvme_transport_available_by_name(trid.trstring)) {
		SPDK_WARNLOG("NVMe transport type %u not available; skipping probe\n",
			     trid.trtype);
		return;
+9 −0
Original line number Diff line number Diff line
@@ -96,6 +96,15 @@ spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype)
	return false;
}

bool
spdk_nvme_transport_available_by_name(const char *transport_name)
{
	enum spdk_nvme_transport_type trtype;

	spdk_nvme_transport_id_parse_trtype(&trtype, transport_name);
	return spdk_nvme_transport_available(trtype);
}

struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(const struct spdk_nvme_transport_id *trid,
		const struct spdk_nvme_ctrlr_opts *opts,
		void *devhandle)
Loading