Skip to content

mi: set req_hdr dlen and flags for set-features with payload - #1157

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
chen-gz:mi-set-features-payload-dlen
Nov 11, 2026
Merged

igaw merged 1 commit into
linux-nvme:masterfrom
chen-gz:mi-set-features-payload-dlen

Conversation

@chen-gz

@chen-gz chen-gz commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Per NVMe-MI §6.1, when an NVMe Admin Command transfers data from the Management Controller to the NVMe Storage Device (Request Data, such as Set Features with data payload), the NVMe-MI Admin Command Request Header DLEN field must contain the transfer length, and Flags bit 0 (DLEN valid) must be set to 0x1.

Previously, nvme_mi_admin_set_features() cleared req_hdr via nvme_mi_admin_init_req() and attached the payload buffer to req.data / req.data_len, but never populated req_hdr.dlen or req_hdr.flags. Consequently, on features with data payloads such as OcpLatencyMonitor (FID 0xC5, transferring a 4096-byte payload), the request header on the wire declared 0 payload bytes while 4096 payload bytes were transmitted, violating NVMe-MI §6.1 and causing NVMe-MI controllers to reject the request (e.g. MI status 0x4 Invalid Parameter) or time out over MCTP.

Set req_hdr.dlen to args->data_len and req_hdr.flags to 0x1 in nvme_mi_admin_set_features() when payload data is present (args->data && args->data_len). Note that nvme_mi_admin_get_features() does not require this because Get Features is a read operation with no request data payload (req.data is NULL, req.data_len is 0).

Also extend the test_admin_set_features unit test in test/mi.c to assert that req_hdr.flags has bit 0 set and req_hdr.dlen matches the payload length.

@chen-gz
chen-gz force-pushed the mi-set-features-payload-dlen branch from afb07da to 7a9eab5 Compare November 6, 2026 23:42
@igaw

igaw commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

@chorkin @jk-ozlabs

@jk-ozlabs jk-ozlabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, just one comment inline, and one on the commit message:

Per NVMe-MI §6.1, when an NVMe Admin Command transfers data from the
Management Controller to the NVMe Storage Device (Request Data, such as
Set Features with data payload), the NVMe-MI Admin Command Request
Header DLEN field must contain the transfer length, and Flags bit 0
(DLEN valid) must be set to 0x1.

The last statement there (about the flags bit) is only applicable for NVMe-MI v1.1 and earlier. Controllers using v1.2 and later will ignore this flag bit.

Comment thread src/nvme/mi.c Resolved
Per NVMe-MI §6.1, when an NVMe Admin Command transfers data from the
Management Controller to the NVMe Storage Device (Request Data, such as
Set Features with data payload), the NVMe-MI Admin Command Request
Header DLEN field must contain the transfer length. In NVMe-MI v1.1 and
earlier, Flags bit 0 (DLEN valid) must also be set to 0x1 (and is
ignored by controllers using NVMe-MI v1.2 or later per spec).

Previously, nvme_mi_admin_set_features() cleared req_hdr via
nvme_mi_admin_init_req() and attached the payload buffer to
req.data / req.data_len, but never populated req_hdr.dlen or
req_hdr.flags. Consequently, on features with data payloads such as
OcpLatencyMonitor (FID 0xC5, transferring a 4096-byte payload), the
request header on the wire declared 0 payload bytes while 4096 payload
bytes were transmitted, violating NVMe-MI §6.1 and causing NVMe-MI
controllers to reject the request (e.g. MI status 0x4 Invalid Parameter)
or time out over MCTP.

Set req_hdr.dlen to args->data_len, req_hdr.flags to 0x1, and attach
args->data / args->data_len to req in nvme_mi_admin_set_features() when
payload data is present (args->data && args->data_len). Note that
nvme_mi_admin_get_features() does not require this because Get Features
is a read operation with no request data payload (req.data is NULL,
req.data_len is 0).

Also extend the test_admin_set_features unit test in test/mi.c to assert
that req_hdr.flags has bit 0 set and req_hdr.dlen matches the payload
length.

Signed-off-by: Guangzong Chen <guangzong@google.com>
@chen-gz
chen-gz force-pushed the mi-set-features-payload-dlen branch from 7a9eab5 to 07d5b6c Compare November 9, 2026 18:57
@igaw
igaw requested a review from jk-ozlabs November 10, 2026 07:47

@jk-ozlabs jk-ozlabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@igaw
igaw merged commit d983193 into linux-nvme:master Nov 11, 2026
12 checks passed
@igaw

igaw commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

(don't forget to send a matching PR for libnvme3)

@chen-gz

chen-gz commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. I check libnvme3. libnvme3 is good. Not PR is need for libnvme3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants