Skip to content

libnvme: mi: add libnvme_mi_mi_controller_health_status_poll - #4006

Open
drakedog2008 wants to merge 2 commits into
linux-nvme:masterfrom
drakedog2008:ctrl-health-poll
Open

libnvme: mi: add libnvme_mi_mi_controller_health_status_poll#4006
drakedog2008 wants to merge 2 commits into
linux-nvme:masterfrom
drakedog2008:ctrl-health-poll

Conversation

@drakedog2008

Copy link
Copy Markdown
Contributor

Port Controller Health Status Poll changes from linux-nvme/libnvme#1144 to libnvme3.
Implement Controller Health Status Poll (Opcode 02h) defined in NVMe-MI 2.0 (Section 5.3 & 5.3.1) for libnvme3:

  1. mi: add libnvme_mi_mi_controller_health_status_poll:
    • Add nvme_mi_mi_opcode_ctrl_health_status_poll (0x02) to enum nvme_mi_mi_opcode.
    • Add NVME_MI_CSTS_TCIDA to enum nvme_mi_csts and NVME_MI_CHSC_* compatibility aliases.
    • Define struct libnvme_mi_ctrl_health_poll_args with args_size for ABI safety.
    • Implement libnvme_mi_mi_controller_health_status_poll() with automatic multi-request paging when requesting >255 entries.
    • Implement libnvme_mi_mi_controller_health_status_poll_all() convenience helper.
    • Export libnvme_mi_mi_controller_health_status_poll in libnvme-mi.ld (verified by check-public-symbols and check-public-headers).
    • Add unit tests in libnvme/tests/mi.c covering single-entry query, filter flags, multi-page chunk boundaries, and error validation.
  2. examples/mi-mctp: add controller health status support:
    • Update the controllers subcommand in mi-mctp to poll and display controller health status alongside topology and PCI configuration.
    • Add show_chsc_flags() to decode active changed flags (CHSCF).
      Signed-off-by: Hao Jiang jianghao@google.com

Add support for the NVMe-MI 2.0 Controller Health Status Poll command
(opcode 0x02) to read Controller Health Data Structures from an NVM
subsystem.

- Add nvme_mi_mi_opcode_ctrl_health_status_poll (0x02) to
  enum nvme_mi_mi_opcode.
- Add NVME_MI_CSTS_TCIDA to enum nvme_mi_csts and NVME_MI_CHSC_*
  compatibility aliases.
- Define struct libnvme_mi_ctrl_health_poll_args to configure command
  parameters (starting controller ID, clear changed flags,
  include/filter flags) and output buffers.
- Implement libnvme_mi_mi_controller_health_status_poll() with automatic
  multi-request paging when more than 255 entries are requested.
- Implement libnvme_mi_mi_controller_health_status_poll_all()
  convenience helper.
- Export libnvme_mi_mi_controller_health_status_poll in libnvme-mi.ld.
- Add unit tests in tests/mi.c covering single-entry query, filter flags,
  multi-page queries, and error parameter validation.

Signed-off-by: Hao Jiang <jianghao@google.com>
Update the controllers subcommand in mi-mctp to display controller
health status alongside controller topology and PCI configuration.

- Poll all controller health entries using
  libnvme_mi_mi_controller_health_status_poll_all().
- Group health information by controller ID inside show_ctrl().
- Add show_chsc_flags() to decode active Controller Health Status
  Changed Flags (CHSCF) whenever the status changed field is non-zero.

Signed-off-by: Hao Jiang <jianghao@google.com>
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.

1 participant