libnvme API design
Christoph Hellwig
hch at lst.de
Fri Oct 10 00:26:58 PDT 2025
On Thu, Oct 09, 2025 at 01:07:47PM +0200, Daniel Wagner wrote:
> Hi Christoph,
>
> As you have suggested the command API should be inverted, that is the
> only stable API will be nvme_submit_admin_passthru and struct
> nvme_passthru_cmd and a bunch of helpers to initialize the cmd.
>
> I've done updated a bunch of the identify commands and below is the
> result. I think we could reduce the number of helpers a bit,
>
> nvme_nvm_init_identify_ns vs nvme_nvm_init_identify_ns_csi.
>
> Is this what you had in mind
Yes.
> (obviously I haven't gone the whole way to
> macros only, I like some type safty)?
What actual type safety do we actually gain here?
> static inline
> void nvme_nvm_init_identify_ns(struct nvme_passthru_cmd *cmd,
> __u32 nsid, struct nvme_id_ns *ns)
> {
> nvme_nvm_init_identify(cmd,
> NVME_IDENTIFY_CNS_NS,
> ns, sizeof(*ns));
> cmd->nsid = nsid;
Given that identify includes nsid and just specified how it is
cleared to zero for the non-ns commands, maybe pass a nsid to
nvme_nvm_init_identify to simplify things?
> cmd->cdw11 |= NVME_SET(nvmsetid, IDENTIFY_CDW11_CNSSPECID);
And NVME_SET still feels very oddly name..
More information about the Linux-nvme
mailing list