Skip to content

Commit

Permalink
types: Define FLBAS MASK and SHIFT to use NVME_GET
Browse files Browse the repository at this point in the history
Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Sep 21, 2023
1 parent 9797fd2 commit 09b13f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/nvme/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 09b13f7

Please sign in to comment.