Skip to content

Commit

Permalink
prefix: Use Request or Response Length in DLEN and DOFF for MI
Browse files Browse the repository at this point in the history
For nvme_mi_admin_xfer the DOFF should be zero when sending req data and the DLEN should be req_data_size when sending request data, per spec.

Signed-off-by: Chuck Horkin <[email protected]>
  • Loading branch information
chorkin committed Oct 30, 2024
1 parent 8cdd746 commit 4fb1bee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/nvme/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ int nvme_mi_admin_xfer(nvme_mi_ctrl_t ctrl,
{
struct nvme_mi_resp resp;
struct nvme_mi_req req;
__u32 dlen, doff;
int rc;

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

/* limit the response size, specify offset */
admin_req->flags = 0x3;
admin_req->dlen = cpu_to_le32(resp.data_len & 0xffffffff);
admin_req->doff = cpu_to_le32(resp_data_offset & 0xffffffff);

/* dlen and doff have different interpretations depending on the data direction */
if (req_data_size) {
dlen = req_data_size & 0xffffffff;
doff = 0;
} else {
dlen = *resp_data_size & 0xffffffff;
doff = resp_data_offset & 0xffffffff;
}
admin_req->dlen = cpu_to_le32(dlen);
admin_req->doff = cpu_to_le32(doff);

rc = nvme_mi_submit(ctrl->ep, &req, &resp);
if (rc)
Expand Down

0 comments on commit 4fb1bee

Please sign in to comment.