libnvme API design

Daniel Wagner dwagner at suse.de
Mon Oct 13 07:22:32 PDT 2025


On Mon, Oct 13, 2025 at 03:02:11PM +0200, Daniel Wagner wrote:
> In this version here I decided to replace the 'nvme_nvm' with just
> 'nvme_'. I don't want to duplicate for each CSI value the API.
> The question if we want to introduce something like an update macro for
> the case, where only CSI fields needs to be changed:
> 
> #define NVME_FIELD_ENCODE_UPDATE(cdw, value, shift, mask) \
> 	(cdw & ~((mask) << (shift))) | \
> 	NVME_FIELD_ENCODE(value, shift, mask);
> 
> 
> static inline
> void nvme_init_identify_nvmset_list(struct nvme_passthru_cmd *cmd,
> 				    __u32 nsid, __u16 nvmsetid,
> 				    struct nvme_id_nvmset_list *nvmset)
> {
> 	nvme_init_identify(cmd, nsid,
> 			   NVME_IDENTIFY_CNS_NVMSET_LIST,
> 			   nvmset, sizeof(*nvmset));
> 	cmd->cdw11 |= NVME_FIELD_ENCODE(nvmsetid,
> 					NVME_IDENTIFY_CDW11_CNSSPECID_SHIFT,
> 					NVME_IDENTIFY_CDW11_CNSSPECID_MASK);
> }
> 
> nvme_init_identify_nvmset_list(cmd, nsid, nvmsetid, nvmset);
> cmd->cdw11 = NVME_FIELD_ENCODE_UPDATE(cmd->cdw11,
> 				      NVME_CSI_ZNS,
> 				      NVME_IDENTIFY_CDW11_CSI_SHIFT,
> 				      NVME_IDENTIFY_CDW11_CSI_MASK);
> 

Or we just keep the nvme_nvm prefix. I've checked the existing callssites
in nvme-cli for the Identify command. There are none.

NVME_CSI_ZNS used in the zns plugin which use the nvme_zns_cmd_mgmt_send
opcode, which is ZNS specific.

No need to make it more complex than necessary. If none is objection
now, we start updating the patches.



More information about the Linux-nvme mailing list