Skip to content

Commit

Permalink
nvme: add spdk_nvme_ctrlr_is_fabrics()
Browse files Browse the repository at this point in the history
We map the SPDK_NVME_TRANSPORT_* values directly to
the NVMe-oF trtype values.  Since PCIe isn't
Fabrics, we choose 256 which is outside of the
8-bit trtype range of values.

So we can just check if trtype >= 256 to determine
if the trid is for fabrics or not.  This is
preferable to checking PCIE || VFIOUSER in case
additional non-fabrics transport types are added
in the future.

I considered taking a trid as the parameter instead,
but went this route since it is consistent with
the existing spdk_nvme_ctrlr_is_discovery().

Signed-off-by: Jim Harris <[email protected]>
Change-Id: Ib62ff4d30549b2324486c81f2dce67f0f1741e9b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8077
Tested-by: SPDK CI Jenkins <[email protected]>
Community-CI: Mellanox Build Bot
Reviewed-by: Ziye Yang <[email protected]>
Reviewed-by: Aleksey Marchuk <[email protected]>
Reviewed-by: Changpeng Liu <[email protected]>
  • Loading branch information
jimharris authored and tomzawadzki committed Jun 1, 2021
1 parent d6f6ffd commit 9f5e3c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/spdk/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ struct spdk_nvme_accel_fn_table {
*/
bool spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr);

/**
* Indicate whether a ctrlr handle is associated with a fabrics controller.
*
* \param ctrlr Opaque handle to NVMe controller.
*
* \return true if a fabrics controller, else false.
*/
bool spdk_nvme_ctrlr_is_fabrics(struct spdk_nvme_ctrlr *ctrlr);

/**
* Get the default options for the creation of a specific NVMe controller.
*
Expand Down
11 changes: 11 additions & 0 deletions lib/nvme/nvme_ctrlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4230,6 +4230,17 @@ spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr)
strlen(SPDK_NVMF_DISCOVERY_NQN));
}

bool
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;
}

int
spdk_nvme_ctrlr_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
uint16_t spsp, uint8_t nssf, void *payload, size_t size)
Expand Down
1 change: 1 addition & 0 deletions lib/nvme/spdk_nvme.map
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
spdk_nvme_pcie_set_hotplug_filter;

spdk_nvme_ctrlr_is_discovery;
spdk_nvme_ctrlr_is_fabrics;
spdk_nvme_ctrlr_get_default_ctrlr_opts;
spdk_nvme_ctrlr_set_trid;
spdk_nvme_ctrlr_reset_subsystem;
Expand Down

0 comments on commit 9f5e3c9

Please sign in to comment.