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

Define MASK, SHIFT to use NVME_GET #148

Open
sc108-lee opened this issue Dec 16, 2021 · 6 comments
Open

Define MASK, SHIFT to use NVME_GET #148

sc108-lee opened this issue Dec 16, 2021 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@sc108-lee
Copy link
Contributor

sc108-lee commented Dec 16, 2021

I would like to do some modify based on usage of NVME_GET
I Just wrote only for nvme_id_nsfeat currently, Example below!
Any opinion?

From 519337c64316d8805b3d988f1b475591347f22f2 Mon Sep 17 00:00:00 2001
From: Steven Seungcheol Lee [email protected]
Date: Thu, 16 Dec 2021 17:17:24 +0900
Subject: [PATCH] types: Define enum to use NVME_GET define
Signed-off-by: Steven Seungcheol Lee [email protected]
3 files changed, 32 insertions(+), 27 deletions(-)

--- a/src/nvme/types.h
+++ b/src/nvme/types.h
@@ -1668,32 +1668,37 @@ struct nvme_id_ns {

enum nvme_id_nsfeat {
- NVME_NS_FEAT_THIN = 1 << 0,
- NVME_NS_FEAT_NATOMIC = 1 << 1,
- NVME_NS_FEAT_DULBE = 1 << 2,
- NVME_NS_FEAT_ID_REUSE = 1 << 3,
- NVME_NS_FEAT_IO_OPT = 1 << 4,
+ NVME_NS_FEAT_THINP_SHIFT = 0,
+ NVME_NS_FEAT_THINP_MASK = 0x1,
+ NVME_NS_FEAT_NSABP_SHIFT = 1,
+ NVME_NS_FEAT_NSABP_MASK = 0x1,
+ NVME_NS_FEAT_DAE_SHIFT = 2,
+ NVME_NS_FEAT_DAE_MASK = 0x1,
+ NVME_NS_FEAT_UIDREUSE_SHIFT = 3,
+ NVME_NS_FEAT_UIDREUSE_MASK = 0x1,
+ NVME_NS_FEAT_OPTERF_SHIFT = 4,
+ NVME_NS_FEAT_OPTERF_MASK = 0x1,
};

@igaw
Copy link
Collaborator

igaw commented Dec 16, 2021

We seem to have both styles of enums in types.h and it seems it is inconsistently applied. I suppose the shift/mask pattern with helpers also makes shifting/masking simpler for users of these APIs. I don't have any strong opinion on this. Something @hreinecke or @keithbusch might have more input on.

@igaw igaw added the question Further information is requested label Dec 23, 2021
@igaw
Copy link
Collaborator

igaw commented Jan 18, 2022

@hreinecke Any comments on this? As I said i don't have a strong opinion but we should figure this out now. After the 1.0 release, it's too late.

@hreinecke
Copy link
Collaborator

I'd vote for a consistent approach, and use NVME_GET() (ie the MASK and SHIFT definitions) throughout the code.

@igaw
Copy link
Collaborator

igaw commented Jan 19, 2022

Sounds good to me. Let's get this sorted out then.

@igaw igaw added this to the 1.0 milestone Jan 19, 2022
@igaw igaw added enhancement New feature or request and removed question Further information is requested labels Jan 19, 2022
@igaw igaw modified the milestones: 1.0, 2.0 Jan 31, 2022
@igaw
Copy link
Collaborator

igaw commented Jan 31, 2022

So this is going to be bigger effort with a lot of potential to introduce regressions. As we are in the process of getting 1.0 out the door this is not going to happen. Alongside this effort we should also introduce a test frame work so we can actually test this stuff.

sc108-lee added a commit to sc108-lee/libnvme that referenced this issue Mar 4, 2022
the error comes from fc274c5
using NVME_GET for masked value linux-nvme#148

Signed-off-by: Steven Seungcheol Lee <[email protected]>
@igaw
Copy link
Collaborator

igaw commented Jul 3, 2024

The upcoming new spec will have a JSON file which defines all types and data structs. We will use a code generator for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants