From: Peter Colberg <pcolberg@redhat.com>
To: Dirk Behme <dirk.behme@de.bosch.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dave Ertman" <david.m.ertman@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
"Leon Romanovsky" <leon@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jonathan Corbet" <corbet@lwn.net>,
"Xu Yilun" <yilun.xu@intel.com>, "Tom Rix" <trix@redhat.com>,
"Moritz Fischer" <mdf@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Zhi Wang" <zhiw@nvidia.com>,
nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-doc@vger.kernel.org, linux-fpga@vger.kernel.org,
driver-core@lists.linux.dev, "Jason Gunthorpe" <jgg@ziepe.ca>
Subject: Re: [PATCH v2 10/10] samples: rust: add SR-IOV driver sample
Date: Tue, 17 Feb 2026 21:03:47 -0500 [thread overview]
Message-ID: <aZUeA1hmYlZIILQg@earendel> (raw)
In-Reply-To: <0e762787-7270-426f-81ee-b24761617c18@de.bosch.com>
Hi Dirk,
On Mon, Feb 16, 2026 at 09:27:44AM +0100, Dirk Behme wrote:
> Hi Peter,
>
> On 05.02.2026 21:59, Peter Colberg wrote:
> > Add a new SR-IOV driver sample that demonstrates how to enable and
> > disable the Single Root I/O Virtualization capability for a PCI device.
> >
> > The sample may be exercised using QEMU's 82576 (igb) emulation.
> >
> > Link: https://www.qemu.org/docs/master/system/devices/igb.html
> > Signed-off-by: Peter Colberg <pcolberg@redhat.com>
> > ---
> > Changes in v2:
> > - Use "kernel vertical" style on imports.
> > - Demonstrate how to reach driver data of PF device from VF device.
> > ---
> > MAINTAINERS | 1 +
> > samples/rust/Kconfig | 11 ++++
> > samples/rust/Makefile | 1 +
> > samples/rust/rust_driver_sriov.rs | 127 ++++++++++++++++++++++++++++++++++++++
> > 4 files changed, 140 insertions(+)
> >
> ...
> > diff --git a/samples/rust/rust_driver_sriov.rs b/samples/rust/rust_driver_sriov.rs
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..84d057629c7b03d743179a4e05ccc092f814bf6b
> > --- /dev/null
> > +++ b/samples/rust/rust_driver_sriov.rs
> > @@ -0,0 +1,127 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +//! Rust SR-IOV driver sample based on QEMU's 82576 ([igb]) emulation.
> > +//!
> > +//! To make this driver probe, QEMU must be run with `-device igb`.
> > +//!
> > +//! Further, enable [vIOMMU] with interrupt remapping using, e.g.,
> > +//!
> > +//! `-M q35,accel=kvm,kernel-irqchip=split -device intel-iommu,intremap=on,caching-mode=on`
> > +//!
> > +//! and append `intel_iommu=on` to the guest kernel arguments.
> > +//!
> > +//! [igb]: https://www.qemu.org/docs/master/system/devices/igb.html
> > +//! [vIOMMU]: https://wiki.qemu.org/Features/VT-d
> > +
> > +use kernel::{
> > + device::Core,
> > + pci,
> > + prelude::*,
> > + sync::aref::ARef, //
> > +};
> > +
> > +use core::any::TypeId;
> > +
> > +#[pin_data(PinnedDrop)]
> > +struct SampleDriver {
> > + pdev: ARef<pci::Device>,
> > + private: TypeId,
> > +}
> > +
> > +kernel::pci_device_table!(
> > + PCI_TABLE,
> > + MODULE_PCI_TABLE,
> > + <SampleDriver as pci::Driver>::IdInfo,
> > + [
> > + // E1000_DEV_ID_82576
> > + (pci::DeviceId::from_id(pci::Vendor::INTEL, 0x10c9), ()),
> > + // E1000_DEV_ID_82576_VF
> > + (pci::DeviceId::from_id(pci::Vendor::INTEL, 0x10ca), ())
> > + ]
> > +);
> > +
> > +#[vtable]
> > +impl pci::Driver for SampleDriver {
> > + type IdInfo = ();
> > +
> > + const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
> > +
> > + fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> {
> > + pin_init::pin_init_scope(move || {
> > + dev_info!(
> > + pdev.as_ref(),
>
> The `as_ref()` in the `dev_*()` prints can be dropped. Example:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/samples/rust/rust_driver_pci.rs?id=600de1c008b2302b56d69ff27d12a9d8d14892ac
Thank you for the pointer, dropped in v3.
Peter
>
> Best regards
>
> Dirk
>
next prev parent reply other threads:[~2026-02-18 2:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 20:59 [PATCH v2 00/10] rust: pci: add abstractions for SR-IOV capability Peter Colberg
2026-02-05 20:59 ` [PATCH v2 01/10] PCI: add driver flag to opt into disabling SR-IOV on remove() Peter Colberg
2026-02-05 20:59 ` [PATCH v2 02/10] fpga: dfl-pci: set driver flag to disable " Peter Colberg
2026-02-26 6:59 ` Xu Yilun
2026-02-05 20:59 ` [PATCH v2 03/10] rust: pci: add {enable,disable}_sriov(), to control SR-IOV capability Peter Colberg
2026-02-05 20:59 ` [PATCH v2 04/10] rust: pci: add vtable attribute to pci::Driver trait Peter Colberg
2026-02-05 20:59 ` [PATCH v2 05/10] rust: pci: add bus callback sriov_configure(), to control SR-IOV from sysfs Peter Colberg
2026-02-05 20:59 ` [PATCH v2 06/10] rust: pci: add is_virtfn(), to check for VFs Peter Colberg
2026-02-05 20:59 ` [PATCH v2 07/10] rust: pci: add is_physfn(), to check for PFs Peter Colberg
2026-02-05 20:59 ` [PATCH v2 08/10] rust: pci: add num_vf(), to return number of VFs Peter Colberg
2026-02-05 20:59 ` [PATCH v2 09/10] rust: pci: add physfn(), to return PF device for VF device Peter Colberg
2026-02-05 20:59 ` [PATCH v2 10/10] samples: rust: add SR-IOV driver sample Peter Colberg
2026-02-16 8:27 ` Dirk Behme
2026-02-18 2:03 ` Peter Colberg [this message]
2026-02-06 7:45 ` [PATCH v2 00/10] rust: pci: add abstractions for SR-IOV capability Dirk Behme
2026-02-06 10:47 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZUeA1hmYlZIILQg@earendel \
--to=pcolberg@redhat.com \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david.m.ertman@intel.com \
--cc=dirk.behme@de.bosch.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mdf@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
--cc=zhiw@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox