libnvme API design

Christoph Hellwig hch at lst.de
Sun Oct 12 23:47:00 PDT 2025


On Fri, Oct 10, 2025 at 10:44:39AM +0200, Daniel Wagner wrote:
> > > 	cmd->cdw11 |=  NVME_SET(nvmsetid, IDENTIFY_CDW11_CNSSPECID);
> > 
> > And NVME_SET still feels very oddly name..
> 
> It's on the TODO list but we might address this at the same time indeed.
> 
> Is it just the name or the macro itself?
> 
> Something like NVME_FIELD_PREP, REG_FIELD_PREP, FIELD_ENCODE,
> PACK_FIELD?
> 
> Yeah I am struggling coming up with good names...

I'm not good either, but the above already are much more descriptive.
But I'd keep thre NVME prefix.

> 
> Just for reference what v1 currently defines:
> 
> #define NVME_GET(value, name) \
> 	(((value) >> NVME_##name##_SHIFT) & NVME_##name##_MASK)

I'd preferable avoid the magic naming pasting as well, and just pass
in the shift and mask.




More information about the Linux-nvme mailing list