Re: [PATCH v3 1/1] rust: pci: add extended capability and SR-IOV support

From: Gary Guo

Date: Mon Apr 20 2026 - 06:25:15 EST


On Mon Apr 20, 2026 at 11:13 AM BST, Zhi Wang wrote:
> On Mon, 13 Apr 2026 15:52:28 +0900
> "Alexandre Courbot" <acourbot@xxxxxxxxxx> wrote:
>
>> Hi Zhi,
>>
>> On Fri Apr 10, 2026 at 3:52 AM JST, Zhi Wang wrote:
>> <snip>
>> > +/// An extended PCI capability that implements [`Io`].
>> > +///
>> > +/// # Examples
>> > +///
>> > +/// ```no_run
>> > +/// use kernel::pci::{
>> > +/// self,
>> > +/// ExtSriovCapability, //
>> > +/// };
>> > +/// use kernel::io::Io;
>> > +///
>> > +/// fn probe_sriov(pdev: &pci::Device<kernel::device::Core>) ->
>> > Result<(), kernel::error::Error> { +/// let config =
>> > pdev.config_space_extended()?; +/// let sriov =
>> > ExtSriovCapability::find(&config)?; +///
>> > +/// let total_vfs = kernel::io_read!(&sriov, .total_vfs);
>> > +/// let vf_offset = kernel::io_read!(&sriov, .vf_offset);
>> > +/// let bar0 = kernel::io_read!(&sriov, .vf_bar[0]);
>> > +/// kernel::io_write!(&sriov, .num_vfs, 4u16);
>> > +/// let bar0_64 = sriov.read_vf_bar64(0)?;
>> > +///
>> > +/// Ok(())
>> > +/// }
>> > +/// ```
>> > +///
>> > +/// # Invariants
>> > +///
>> > +/// `ptr` is within the device's extended configuration space at a
>> > valid +/// capability. For sized `T`, the region is at least
>> > `size_of::<T>()` bytes. +pub struct ExtCapability<'a, T: ?Sized +
>> > KnownSize = Region<0>> {
>> > + config: &'a ConfigSpace<'a, Extended>,
>> > + ptr: *mut T,
>> > +}
>>
>> This strongly looks like this is reinventing `io::View`. :) Even the
>> internals look similar. Can you check whether `io::View` can replace
>> this type? This would remove all the macro business and impl blocks
>> and simplify this patch considerably.
>>
>
> Thanks for catching this. This should be updated with Gary's patches
> posted in the mailing list. Will address this in V4.

I'll rebase my series and resend this week.

Best,
Gary