From 09b13f7148a77b4caf44131d4c566b27fc6e77b7 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sat, 17 Jun 2023 10:24:56 +0900 Subject: [PATCH] types: Define FLBAS MASK and SHIFT to use NVME_GET Signed-off-by: Tokunori Ikegami --- src/nvme/types.h | 13 +++++++++++++ src/nvme/util.h | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/nvme/types.h b/src/nvme/types.h index da08c15b..7eb56669 100644 --- a/src/nvme/types.h +++ b/src/nvme/types.h @@ -611,6 +611,19 @@ static const __u64 NVME_PMRMSC_CBA_MASK = 0xfffffffffffffull; #define NVME_PMRMSC_CMSE(pmrmsc) NVME_GET(pmrmsc, PMRMSC_CMSE) #define NVME_PMRMSC_CBA(pmrmsc) NVME_GET(pmrmsc, PMRMSC_CBA) +enum nvme_flbas { + NVME_FLBAS_LOWER_SHIFT = 0, + NVME_FLBAS_META_EXT_SHIFT = 4, + NVME_FLBAS_HIGHER_SHIFT = 5, + NVME_FLBAS_LOWER_MASK = 0xf, + NVME_FLBAS_META_EXT_MASK = 0x1, + NVME_FLBAS_HIGHER_MASK = 0x3, +}; + +#define NVME_FLBAS_LOWER(flbas) NVME_GET(flbas, FLBAS_LOWER) +#define NVME_FLBAS_META_EXT(flbas) NVME_GET(flbas, FLBAS_META_EXT) +#define NVME_FLBAS_HIGHER(flbas) NVME_GET(flbas, FLBAS_HIGHER) + /** * enum nvme_psd_flags - Possible flag values in nvme power state descriptor * @NVME_PSD_FLAGS_MXPS: Indicates the scale for the Maximum Power diff --git a/src/nvme/util.h b/src/nvme/util.h index 0739cf2f..efdf9757 100644 --- a/src/nvme/util.h +++ b/src/nvme/util.h @@ -449,8 +449,8 @@ static inline void nvme_feature_decode_namespace_write_protect(__u32 value, static inline void nvme_id_ns_flbas_to_lbaf_inuse(__u8 flbas, __u8 *lbaf_inuse) { - *lbaf_inuse = (((flbas & NVME_NS_FLBAS_HIGHER_MASK) >> 1) | - (flbas & NVME_NS_FLBAS_LOWER_MASK)); + *lbaf_inuse = ((NVME_FLBAS_HIGHER(flbas) >> 1) | + NVME_FLBAS_LOWER(flbas)); } struct nvme_root;