lib/nvmf: add a default value to trtype enum.
For custom transports, we should use a range outside the spec value to identify them. Signed-off-by: Seth Howell <seth.howell@intel.com> Change-Id: I82b29c349e143b8906f79ce2de818def116a3fe4 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478747 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7ed0904b9b
commit
a050dcf21d
@ -284,6 +284,11 @@ enum spdk_nvme_transport_type {
|
||||
* TCP Transport
|
||||
*/
|
||||
SPDK_NVME_TRANSPORT_TCP = SPDK_NVMF_TRTYPE_TCP,
|
||||
|
||||
/**
|
||||
* Custom Transport (Not spec defined)
|
||||
*/
|
||||
SPDK_NVME_TRANSPORT_CUSTOM = 4096,
|
||||
};
|
||||
|
||||
/* typedef added for coding style reasons */
|
||||
|
@ -721,6 +721,7 @@ spdk_nvme_trid_populate_transport(struct spdk_nvme_transport_id *trid,
|
||||
case SPDK_NVME_TRANSPORT_TCP:
|
||||
trstring = SPDK_NVME_TRANSPORT_NAME_TCP;
|
||||
break;
|
||||
case SPDK_NVME_TRANSPORT_CUSTOM:
|
||||
default:
|
||||
SPDK_ERRLOG("don't use this for custom transports\n");
|
||||
break;
|
||||
@ -770,7 +771,7 @@ spdk_nvme_transport_id_parse_trtype(enum spdk_nvme_transport_type *trtype, const
|
||||
} else if (strcasecmp(str, "TCP") == 0) {
|
||||
*trtype = SPDK_NVME_TRANSPORT_TCP;
|
||||
} else {
|
||||
return -ENOENT;
|
||||
*trtype = SPDK_NVME_TRANSPORT_CUSTOM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ nvme_transport_unknown(enum spdk_nvme_transport_type trtype)
|
||||
#define TRANSPORT_RDMA_AVAILABLE false
|
||||
#endif
|
||||
#define TRANSPORT_FABRICS_FC(func_name, args) case SPDK_NVME_TRANSPORT_FC: SPDK_UNREACHABLE();
|
||||
#define TRANSPORT_FABRICS_CUSTOM(func_name, args) case SPDK_NVME_TRANSPORT_CUSTOM: SPDK_UNREACHABLE();
|
||||
|
||||
#define NVME_TRANSPORT_CALL(trtype, func_name, args) \
|
||||
do { \
|
||||
@ -69,6 +70,7 @@ nvme_transport_unknown(enum spdk_nvme_transport_type trtype)
|
||||
TRANSPORT_FABRICS_RDMA(func_name, args) \
|
||||
TRANSPORT_FABRICS_FC(func_name, args) \
|
||||
TRANSPORT_FABRICS_TCP(func_name, args) \
|
||||
TRANSPORT_FABRICS_CUSTOM(func_name, args) \
|
||||
TRANSPORT_DEFAULT(trtype) \
|
||||
} \
|
||||
SPDK_UNREACHABLE(); \
|
||||
@ -81,12 +83,14 @@ spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype)
|
||||
case SPDK_NVME_TRANSPORT_PCIE:
|
||||
case SPDK_NVME_TRANSPORT_TCP:
|
||||
return true;
|
||||
|
||||
case SPDK_NVME_TRANSPORT_RDMA:
|
||||
return TRANSPORT_RDMA_AVAILABLE;
|
||||
|
||||
case SPDK_NVME_TRANSPORT_FC:
|
||||
return false;
|
||||
case SPDK_NVME_TRANSPORT_CUSTOM:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -988,7 +988,8 @@ test_spdk_nvme_transport_id_parse_trtype(void)
|
||||
/* test function returned value when str and strtype not NULL, but str value
|
||||
* not "PCIe" or "RDMA" */
|
||||
str = "unit_test";
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse_trtype(trtype, str) == (-ENOENT));
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse_trtype(trtype, str) == 0);
|
||||
CU_ASSERT((*trtype) == SPDK_NVME_TRANSPORT_CUSTOM);
|
||||
|
||||
/* test trtype value when use function "strcasecmp" to compare str and "PCIe",not case-sensitive */
|
||||
str = "PCIe";
|
||||
|
Loading…
x
Reference in New Issue
Block a user