Skip to content

Commit ac65735

Browse files
committed
mi: endian fixes
We have a couple of endian issues in the mi code: one where we're not converting cdw0 for MI commands, and one where we're using the wrong byte length for an existing conversion. There is also an error in the test suite, where we should be converting the nsze field of a nvme_id_ns. This change fixes those, so that the test suite passes on a BE platform (ppc64 in my case). Fixes: #524 Signed-off-by: Jeremy Kerr <[email protected]>
1 parent d516933 commit ac65735

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/nvme/mi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan)
334334
struct nvme_mi_ctrl *ctrl;
335335
__u16 id;
336336

337-
id = le32_to_cpu(list.identifier[i]);
337+
id = le16_to_cpu(list.identifier[i]);
338338

339339
ctrl = nvme_mi_init_ctrl(ep, id);
340340
if (!ctrl)
@@ -1280,7 +1280,7 @@ static int nvme_mi_read_data(nvme_mi_ep_t ep, __u32 cdw0,
12801280
req_hdr.hdr.nmp = (NVME_MI_ROR_REQ << 7) |
12811281
(NVME_MI_MT_MI << 3); /* we always use command slot 0 */
12821282
req_hdr.opcode = nvme_mi_mi_opcode_mi_data_read;
1283-
req_hdr.cdw0 = cdw0;
1283+
req_hdr.cdw0 = cpu_to_le32(cdw0);
12841284

12851285
memset(&req, 0, sizeof(req));
12861286
req.hdr = &req_hdr.hdr;

test/mi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ static void test_admin_ns_mgmt_create(struct nvme_mi_ep *ep)
13531353
assert(!rc);
13541354
assert(ns == 0x01020304);
13551355

1356-
nsid.nsze = 42;
1356+
nsid.nsze = cpu_to_le64(42);
13571357
rc = nvme_mi_admin_ns_mgmt_create(ctrl, &nsid, 0, &ns);
13581358
assert(rc);
13591359
}

0 commit comments

Comments
 (0)