[PATCH v5 3/9] rust: pci: add is_virtfn(), to check for VFs
From: Simon Song
Date: Fri Oct 30 2026 - 13:21:16 EST
From: John Hubbard <jhubbard@xxxxxxxxxx>
Add a method to check if a PCI device is a Virtual Function (VF) created
through Single Root I/O Virtualization (SR-IOV).
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>
Reviewed-by: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Signed-off-by: Peter Colberg <peter@xxxxxxxxxxx>
Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
Signed-off-by: Simon Song <xinmengs@xxxxxxxxxx>
---
rust/kernel/pci.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index c60edd01b70..9e1d02588af 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -363,6 +363,13 @@ fn as_raw(&self) -> *mut bindings::pci_dev {
}
impl Device {
+ /// Returns `true` if this device is a Virtual Function (VF).
+ #[inline]
+ pub fn is_virtfn(&self) -> bool {
+ // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
+ unsafe { (*self.as_raw()).is_virtfn() != 0 }
+ }
+
/// Returns the PCI vendor ID as [`Vendor`].
///
/// # Examples
--
2.43.7