Repository navigation
mi: set req_hdr dlen and flags for set-features with payload - #1157
Merged
Merged
Conversation
chen-gz
force-pushed
the
mi-set-features-payload-dlen
branch
from
November 6, 2026 23:42
afb07da to
7a9eab5
Compare
Collaborator
jk-ozlabs
suggested changes
Nov 9, 2026
jk-ozlabs
left a comment
Collaborator
There was a problem hiding this comment.
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.
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
force-pushed
the
mi-set-features-payload-dlen
branch
from
November 9, 2026 18:57
7a9eab5 to
07d5b6c
Compare
Collaborator
|
Thanks! (don't forget to send a matching PR for libnvme3) |
Contributor
Author
|
Thank you. I check libnvme3. libnvme3 is good. Not PR is need for libnvme3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.