Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: Define NS_FLBAS MASK and SHIFT to use NVME_GET #662

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion 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 Expand Up @@ -6513,7 +6526,7 @@ static inline __u32 nvme_status_get_type(int status)
*/
static inline __u32 nvme_status_get_value(int status)
{
return status & ~(NVME_STATUS_TYPE_MASK << NVME_STATUS_TYPE_SHIFT);
return status & ~NVME_SET(NVME_STATUS_TYPE_MASK, STATUS_TYPE);
}

/**
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