Skip to content

mi: add NVMe-MI PCIe Command Set helpers, unit tests, and mi-mctp subcommands - #1160

Open
chen-gz wants to merge 1 commit into
linux-nvme:masterfrom
chen-gz:mi-pcie-cmd-set
Open

chen-gz wants to merge 1 commit into
linux-nvme:masterfrom
chen-gz:mi-pcie-cmd-set

Conversation

@chen-gz

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

Copy link
Copy Markdown
Contributor

Add high-level helper APIs, unit tests, and mi-mctp CLI support for the NVMe-MI 1.2c Section 7 PCIe Command Set (NMIMT = 4h):

  • libnvme-mi (src/nvme/mi.h, src/nvme/mi.c, src/libnvme-mi.map): Define enum nvme_mi_pcie_opcode and add nvme_mi_pcie_config_{read,write}(), nvme_mi_pcie_mem_{read,write}(), and nvme_mi_pcie_io_{read,write}() with 4-byte dword alignment handling and bounds checks.
  • Unit tests (test/mi.c): Add unit tests covering all six opcodes, unaligned payload lengths, invalid parameter checks, and MI error status propagation.
  • CLI (examples/mi-mctp.c): Add pcie-cfg-{read,write}, pcie-mem-{read,write}, pcie-io-{read,write}, and raw pcie subcommands.

@igaw

igaw commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

from a quick glance it looks okay.

@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.

Just a concern about the automatic padding, but looks OK otherwise.

Also, @igaw may have different requirements, but for me, there is no need to restate the diff in the commit-message dot-points. I can read it from the code. You only need to explain any context, background or design points that are not apparent in the actual code change.

Comment thread src/nvme/mi.c Resolved
Comment thread src/nvme/mi.c Resolved
Comment thread src/nvme/mi.c Resolved
@igaw

igaw commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

The AI bots really like to add the 'what' and 'how' to commit message. Both can be seen in the patch. If the patch is too difficult to understand it is most of the time a good indicator that the commit could be improved. The 'why' should be in the commit message.

fwiw, I ussaly tell the bots to mimick hch's style of writting commit message :)

@chen-gz

chen-gz commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @igaw and @jk-ozlabs for the commit message style suggestion. I will do that in the future.

@jk-ozlabs

Copy link
Copy Markdown
Collaborator

Thanks for the updates. Can you squash the fixup change into the original patches though?

nvme_mi_pcie_xfer() only exposes the raw NVMe-MI PCIe Command Set
transport, leaving every caller to hand-encode opcodes, NMD0..NMD2
bitfields, 64-bit BAR offsets, bounds checks, and the 4-byte dword
payload alignment required by NVMe-MI Section 7.

Add enum nvme_mi_pcie_opcode and typed Configuration, Memory, and I/O
read/write helpers on top of nvme_mi_pcie_xfer() so callers do not
duplicate wire-format and padding logic. Expose the new commands in
mi-mctp (along with raw pcie passthrough) for out-of-band PCIe triage
when the in-band link or Admin queue is unavailable, and add unit tests
covering all opcodes, unaligned payloads, boundary validation, and MI
status/PEL propagation.

Signed-off-by: Guangzong Chen <guangzong@google.com>
@chen-gz

chen-gz commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Sure, I squash them to one commit and update the commit message.

@jk-ozlabs

Copy link
Copy Markdown
Collaborator

The three-patch series was fine - more that the final change (to use a symbolic value for the number of BARs) was a fixup for earlier patches, so that one should be squashed in to the appropriate earlier change that it fixes.

But the one-patch implementation might be okay too.

@igaw

igaw commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Looks fine from a quick glance. I understand @jk-ozlabs is also okay with it, if so I'll merge it.

This branch has not been deployed

No deployments
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