From 10b2229d56c0d39b5dada524f79f29893a4913fd Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Fri, 29 Oct 2021 21:57:44 +0800 Subject: [PATCH] nvme: add an API to check existing transport type is fabric or not We already provides the API `spdk_nvme_ctrlr_is_fabrics` to return input controller is fabrics controller or not, but it needs a controller data structure as the input, so here we add another API to do the same thing and it takes the transport type as the input, with this change, both nvme and nvmf library can use the API. Also we should treat UINT8_MAX(255) as valid fabrics transport type. Change-Id: Ib62e7d3eca3da1ddb1a4cc55b0b62e274522f1ce Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10059 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- CHANGELOG.md | 5 +++++ include/spdk/nvme.h | 8 ++++++++ lib/nvme/nvme_ctrlr.c | 5 +---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 488b3241d..74e762751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## v22.01: (Upcoming Release) +### nvme + +API `spdk_nvme_trtype_is_fabrics` was added to return existing transport type +is fabric or not. + ### bdev The parameter `retry_count` of the RPC `bdev_nvme_set_options` was deprecated and will be diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 72d3f2897..a418d339d 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -387,6 +387,14 @@ enum spdk_nvme_transport_type { SPDK_NVME_TRANSPORT_CUSTOM = 4096, }; +static inline bool spdk_nvme_trtype_is_fabrics(enum spdk_nvme_transport_type trtype) +{ + /* We always define non-fabrics trtypes outside of the 8-bit range + * of NVMe-oF trtype. + */ + return trtype <= UINT8_MAX; +} + /* typedef added for coding style reasons */ typedef enum spdk_nvme_transport_type spdk_nvme_transport_type_t; diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 31842f27d..cf87e4b62 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -5039,10 +5039,7 @@ spdk_nvme_ctrlr_is_fabrics(struct spdk_nvme_ctrlr *ctrlr) { assert(ctrlr); - /* We always define non-fabrics trtypes outside of the 8-bit range - * of NVMe-oF trtype. - */ - return ctrlr->trid.trtype < UINT8_MAX; + return spdk_nvme_trtype_is_fabrics(ctrlr->trid.trtype); } int