nvme: introduce function to get nguid

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: Ida07eca2e3cbc390d8ee481f63b20f5715a53631
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8626
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jacek Kalwas 2021-07-02 08:04:35 -04:00 committed by Tomasz Zawadzki
parent b8b1f19222
commit a410fb4438
3 changed files with 26 additions and 0 deletions

View File

@ -2639,6 +2639,15 @@ enum spdk_nvme_dealloc_logical_block_read_value spdk_nvme_ns_get_dealloc_logical
*/
uint32_t spdk_nvme_ns_get_optimal_io_boundary(struct spdk_nvme_ns *ns);
/**
* Get the NGUID for the given namespace.
*
* \param ns Namespace to query.
*
* \return a pointer to namespace NGUID, or NULL if ns does not have a NGUID.
*/
const uint8_t *spdk_nvme_ns_get_nguid(const struct spdk_nvme_ns *ns);
/**
* Get the UUID for the given namespace.
*

View File

@ -406,6 +406,22 @@ nvme_ns_find_id_desc(const struct spdk_nvme_ns *ns, enum spdk_nvme_nidt type, si
return NULL;
}
const uint8_t *
spdk_nvme_ns_get_nguid(const struct spdk_nvme_ns *ns)
{
const uint8_t *nguid;
size_t size;
nguid = nvme_ns_find_id_desc(ns, SPDK_NVME_NIDT_NGUID, &size);
if (nguid && size != sizeof(((struct spdk_nvme_ns_data *)0)->nguid)) {
SPDK_WARNLOG("Invalid NIDT_NGUID descriptor length reported: %zu (expected: %zu)\n",
size, sizeof(((struct spdk_nvme_ns_data *)0)->nguid));
return NULL;
}
return nguid;
}
const struct spdk_uuid *
spdk_nvme_ns_get_uuid(const struct spdk_nvme_ns *ns)
{

View File

@ -124,6 +124,7 @@
spdk_nvme_ns_supports_compare;
spdk_nvme_ns_get_dealloc_logical_block_read_value;
spdk_nvme_ns_get_optimal_io_boundary;
spdk_nvme_ns_get_nguid;
spdk_nvme_ns_get_uuid;
spdk_nvme_ns_get_csi;
spdk_nvme_ns_get_flags;