Skip to content

Commit 0cb6a0c

Browse files
committed
mi: fixes for MI Identify command serialisation
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 <[email protected]>
1 parent a56e704 commit 0cb6a0c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/nvme/mi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,16 @@ int nvme_mi_admin_identify_partial(nvme_mi_ctrl_t ctrl,
163163
return -EINVAL;
164164

165165
nvme_mi_admin_init_req(&req, &req_hdr, ctrl->id, nvme_admin_identify);
166-
req_hdr.cdw10 = cpu_to_le16(args->cntid) << 16 | cpu_to_le16(args->cns);
167-
req_hdr.cdw11 = cpu_to_le16(args->nsid);
168-
req_hdr.cdw14 = args->uuidx & 0xff;
166+
req_hdr.cdw1 = cpu_to_le32(args->nsid);
167+
req_hdr.cdw10 = cpu_to_le32(args->cntid << 16 | args->cns);
168+
req_hdr.cdw11 = cpu_to_le32((args->csi & 0xff) << 24 |
169+
args->cns_specific_id);
170+
req_hdr.cdw14 = cpu_to_le32(args->uuidx);
169171
req_hdr.dlen = cpu_to_le32(size & 0xffffffff);
170172
req_hdr.flags = 0x1;
171173
if (offset) {
172174
req_hdr.flags |= 0x2;
173-
req_hdr.doff = offset;
175+
req_hdr.doff = cpu_to_le32(offset);
174176
}
175177

176178
nvme_mi_calc_req_mic(&req);

0 commit comments

Comments
 (0)