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 Sep 13, 2023
1 parent 17429f7 commit 178fde7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
41 changes: 24 additions & 17 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1854,27 +1854,34 @@ enum nvme_id_nsfeat {
* enum nvme_id_ns_flbas - This field indicates the LBA data size & metadata
* size combination that the namespace has been
* formatted with
* @NVME_NS_FLBAS_LOWER_MASK: Mask to get the index of one of the supported
* LBA Formats's least significant
* 4bits indicated in
* :c:type:`struct nvme_id_ns <nvme_id_ns>`.lbaf.
* @NVME_NS_FLBAS_META_EXT: Applicable only if format contains metadata. If
* this bit is set, indicates that the metadata is
* transferred at the end of the data LBA, creating an
* extended data LBA. If cleared, indicates that all
* of the metadata for a command is transferred as a
* separate contiguous buffer of data.
* @NVME_NS_FLBAS_HIGHER_MASK: Mask to get the index of one of
* the supported LBA Formats's most significant
* 2bits indicated in
* :c:type:`struct nvme_id_ns <nvme_id_ns>`.lbaf.
* @NVME_NS_FLBAS_LOWER_MASK: Mask to get the index of one of the supported
* LBA Formats's least significant
* 4bits indicated in
* :c:type:`struct nvme_id_ns <nvme_id_ns>`.lbaf.
* @NVME_NS_FLBAS_META_EXT_MASK: Applicable only if format contains metadata. If
* this bit is set, indicates that the metadata is
* transferred at the end of the data LBA, creating an
* extended data LBA. If cleared, indicates that all
* of the metadata for a command is transferred as a
* separate contiguous buffer of data.
* @NVME_NS_FLBAS_HIGHER_MASK: Mask to get the index of one of
* the supported LBA Formats's most significant
* 2bits indicated in
* :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_EXT(flbas) NVME_GET(flbas, NS_FLBAS_META_EXT)
#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 @@ -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_NS_FLBAS_HIGHER(flbas) >> 1) |
NVME_NS_FLBAS_LOWER(flbas));
}

struct nvme_root;
Expand Down

0 comments on commit 178fde7

Please sign in to comment.