[RFC v2 0/1] Rust PCI capability infrastructure and SR-IOV support

From: Zhi Wang

Date: Wed Feb 25 2026 - 13:07:41 EST


This is a follow-up to the RFC series [1], reworked on top of Gary's
io_projection branch [2] to use the Io/IoCapable/View infrastructure.

Patch 1 from the RFC (fallible config space I/O) is no longer needed,
as it is already covered by Alex's "IoCapable to functional trait" change.

This patch introduces ExtCapability<T>, which implements the Io trait
for PCI extended capability regions. It delegates IoCapable to the
underlying ConfigSpace, so io_project!/io_read!/io_write! work directly
on capability register structs. ExtSriovRegs provides the #[repr(C)]
SR-IOV register layout, and ExtSriovCapability is a convenience alias.

Changes since RFC:
- Rebased on io_projection branch, using Gary's Io/IoCapable traits
- ExtCapability implements Io and delegates IoCapable to ConfigSpace
instead of duplicating config read/write logic
- Dropped the fallible I/O patch (now upstream in this tree)
- Added rust helper for PCI_EXT_CAP_NEXT() macro
- Replaced raw `as` casts with From conversions where possible
- Renamed SriovRegs/SriovCapability to ExtSriovRegs/ExtSriovCapability

[1] https://lore.kernel.org/rust-for-linux/20260126215957.541180-1-zhiw@xxxxxxxxxx/
[2] https://github.com/nbdd0121/linux/tree/io_projection

Zhi Wang (1):
rust: pci: add extended capability and SR-IOV support

rust/helpers/pci.c | 5 +
rust/kernel/pci.rs | 7 ++
rust/kernel/pci/cap.rs | 244 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 256 insertions(+)
create mode 100644 rust/kernel/pci/cap.rs


base-commit: d6d357817b3fea5798607d04ee5668894705a0e1
--
2.51.0