Skip to content

Commit

Permalink
types: Define NS_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 Jun 17, 2023
1 parent 4c62b27 commit d93f592
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1870,11 +1870,18 @@ enum nvme_id_nsfeat {
* :c:type:`struct nvme_id_ns <nvme_id_ns>`.lbaf.
*/
enum nvme_id_ns_flbas {
NVME_NS_FLBAS_LOWER_MASK = 15 << 0,
NVME_NS_FLBAS_META_EXT = 1 << 4,
NVME_NS_FLBAS_HIGHER_MASK = 3 << 5,
NVME_NS_FLBAS_LOWER_SHIFT = 0,
NVME_NS_FLBAS_META_EXT_SHIFT = 4,
NVME_NS_FLBAS_HIGHER_SHIFT = 5,
NVME_NS_FLBAS_LOWER_MASK = 0xf,
NVME_NS_FLBAS_META_EXT_MASK = 0x1,
NVME_NS_FLBAS_HIGHER_MASK = 0x3,
};

#define NVME_NS_FLBAS_LOWER(flbas) NVME_GET(flbas, NS_FLBAS_LOWER)
#define NVME_NS_FLBAS_META_EX(flbas) NVME_GET(flbas, NS_FLBAS_META_EX)
#define NVME_NS_FLBAS_HIGHER(flbas) NVME_GET(flbas, NS_FLBAS_HIGHER)

/**
* enum nvme_nvm_id_ns_elbaf - This field indicates the extended LBA format
* @NVME_NVM_ELBAF_STS_MASK: Mask to get the storage tag size used to determine
Expand Down
4 changes: 2 additions & 2 deletions src/nvme/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,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_NS_FLBAS_HIGHER(flbas) >> 1) |
NVME_NS_FLBAS_LOWER(flbas));
}

struct nvme_root;
Expand Down

0 comments on commit d93f592

Please sign in to comment.