]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
mi: fixes for MI Identify command serialisation
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 20 Jun 2022 07:29:07 +0000 (15:29 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Mon, 20 Jun 2022 07:57:00 +0000 (15:57 +0800)
We have a couple of bugs when creating the Identify command message,
particularly on big-endian platforms. In general, we should be
performing endian-conversion on the whole cdw fields, rather than on
individual components, provided we've done the shift operations in the
same manner as the LSB/MSB descriptions in the spec.

We also had a swap of the cdw1 / cdw11 fields; cdw1 should contain the
NSID, cdw11 the CSI and CNS-specific ID.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi.c

index 141feb70470376db7f806e3fc79bd0a05e9155ce..244d400ce6e0d13af0fcbd93a9c61f92db73cfba 100644 (file)
@@ -163,14 +163,16 @@ int nvme_mi_admin_identify_partial(nvme_mi_ctrl_t ctrl,
                return -EINVAL;
 
        nvme_mi_admin_init_req(&req, &req_hdr, ctrl->id, nvme_admin_identify);
-       req_hdr.cdw10 = cpu_to_le16(args->cntid) << 16 | cpu_to_le16(args->cns);
-       req_hdr.cdw11 = cpu_to_le16(args->nsid);
-       req_hdr.cdw14 = args->uuidx & 0xff;
+       req_hdr.cdw1 = cpu_to_le32(args->nsid);
+       req_hdr.cdw10 = cpu_to_le32(args->cntid << 16 | args->cns);
+       req_hdr.cdw11 = cpu_to_le32((args->csi & 0xff) << 24 |
+                                   args->cns_specific_id);
+       req_hdr.cdw14 = cpu_to_le32(args->uuidx);
        req_hdr.dlen = cpu_to_le32(size & 0xffffffff);
        req_hdr.flags = 0x1;
        if (offset) {
                req_hdr.flags |= 0x2;
-               req_hdr.doff = offset;
+               req_hdr.doff = cpu_to_le32(offset);
        }
 
        nvme_mi_calc_req_mic(&req);