nvme: export transport ID trtype and adrfam parsers
Change-Id: I8d417c5baa68832c568c3df0927d84e2f44bb887 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
007196152f
commit
a3a3d7dddf
@ -195,6 +195,24 @@ struct spdk_nvme_transport_id {
|
|||||||
*/
|
*/
|
||||||
int spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *str);
|
int spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the string representation of a transport ID tranport type.
|
||||||
|
*
|
||||||
|
* \param trtype Output transport type (allocated by caller).
|
||||||
|
* \param str Input string representation of transport type (e.g. "PCIe", "RDMA")
|
||||||
|
* \return 0 if parsing was successful and trtype is filled out, or negated errno values on failure.
|
||||||
|
*/
|
||||||
|
int spdk_nvme_transport_id_parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the string representation of a tranport ID address family.
|
||||||
|
*
|
||||||
|
* \param adrfam Output address family (allocated by caller).
|
||||||
|
* \param str Input string representation of address family (e.g. "IPv4", "IPv6")
|
||||||
|
* \return 0 if parsing was successful and adrfam is filled out, or negated errno values on failure.
|
||||||
|
*/
|
||||||
|
int spdk_nvme_transport_id_parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const char *str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the NVMe library can handle a specific NVMe over Fabrics transport type.
|
* Determine whether the NVMe library can handle a specific NVMe over Fabrics transport type.
|
||||||
*
|
*
|
||||||
|
@ -443,9 +443,13 @@ spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str)
|
spdk_nvme_transport_id_parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str)
|
||||||
{
|
{
|
||||||
|
if (trtype == NULL || str == NULL) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcasecmp(str, "PCIe") == 0) {
|
if (strcasecmp(str, "PCIe") == 0) {
|
||||||
*trtype = SPDK_NVME_TRANSPORT_PCIE;
|
*trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
} else if (strcasecmp(str, "RDMA") == 0) {
|
} else if (strcasecmp(str, "RDMA") == 0) {
|
||||||
@ -456,9 +460,13 @@ parse_trtype(enum spdk_nvme_transport_type *trtype, const char *str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const char *str)
|
spdk_nvme_transport_id_parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const char *str)
|
||||||
{
|
{
|
||||||
|
if (adrfam == NULL || str == NULL) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcasecmp(str, "IPv4") == 0) {
|
if (strcasecmp(str, "IPv4") == 0) {
|
||||||
*adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
*adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
||||||
} else if (strcasecmp(str, "IPv6") == 0) {
|
} else if (strcasecmp(str, "IPv6") == 0) {
|
||||||
@ -524,12 +532,12 @@ spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *st
|
|||||||
str += val_len;
|
str += val_len;
|
||||||
|
|
||||||
if (strcasecmp(key, "trtype") == 0) {
|
if (strcasecmp(key, "trtype") == 0) {
|
||||||
if (parse_trtype(&trid->trtype, val) != 0) {
|
if (spdk_nvme_transport_id_parse_trtype(&trid->trtype, val) != 0) {
|
||||||
SPDK_ERRLOG("Unknown trtype '%s'\n", val);
|
SPDK_ERRLOG("Unknown trtype '%s'\n", val);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
} else if (strcasecmp(key, "adrfam") == 0) {
|
} else if (strcasecmp(key, "adrfam") == 0) {
|
||||||
if (parse_adrfam(&trid->adrfam, val) != 0) {
|
if (spdk_nvme_transport_id_parse_adrfam(&trid->adrfam, val) != 0) {
|
||||||
SPDK_ERRLOG("Unknown adrfam '%s'\n", val);
|
SPDK_ERRLOG("Unknown adrfam '%s'\n", val);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user