Skip to content

Commit f3d4599

Browse files
chorkinigaw
authored andcommitted
prefix: Use Request or Response Length in DLEN and DOFF for MI
For nvme_mi_admin_xfer the DOFF should be zero when sending req data and the DLEN should be req_data_size in this case, per spec. Signed-off-by: Chuck Horkin <[email protected]>
1 parent 6a7b777 commit f3d4599

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/nvme/mi.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ int nvme_mi_admin_xfer(nvme_mi_ctrl_t ctrl,
634634
{
635635
struct nvme_mi_resp resp;
636636
struct nvme_mi_req req;
637+
__u32 dlen, doff;
637638
int rc;
638639

639640
/* length/offset checks. The common _submit() API will do further
@@ -692,8 +693,17 @@ int nvme_mi_admin_xfer(nvme_mi_ctrl_t ctrl,
692693

693694
/* limit the response size, specify offset */
694695
admin_req->flags = 0x3;
695-
admin_req->dlen = cpu_to_le32(resp.data_len & 0xffffffff);
696-
admin_req->doff = cpu_to_le32(resp_data_offset & 0xffffffff);
696+
697+
/* dlen and doff have different interpretations depending on the data direction */
698+
if (req_data_size) {
699+
dlen = req_data_size & 0xffffffff;
700+
doff = 0;
701+
} else {
702+
dlen = *resp_data_size & 0xffffffff;
703+
doff = resp_data_offset & 0xffffffff;
704+
}
705+
admin_req->dlen = cpu_to_le32(dlen);
706+
admin_req->doff = cpu_to_le32(doff);
697707

698708
rc = nvme_mi_submit(ctrl->ep, &req, &resp);
699709
if (rc)

0 commit comments

Comments
 (0)