[PATCH v3 04/10] rust: pci: add is_physfn(), to check for PFs
From: Zhi Wang
Date: Wed Sep 30 2026 - 06:31:26 EST
From: Peter Colberg <peter@xxxxxxxxxxx>
Add an internal method to check if a PCI device is a Physical Function
(PF). The SR-IOV implementation uses this role check to validate
configuration requests.
Reviewed-by: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Signed-off-by: Peter Colberg <peter@xxxxxxxxxxx>
Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
---
rust/kernel/pci/iov.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/rust/kernel/pci/iov.rs b/rust/kernel/pci/iov.rs
index 272ed677f145..a4a23a9ea77a 100644
--- a/rust/kernel/pci/iov.rs
+++ b/rust/kernel/pci/iov.rs
@@ -12,6 +12,14 @@
};
impl Device {
+ /// Returns `true` if this device is a Physical Function (PF).
+ #[inline]
+ #[expect(dead_code)]
+ pub(crate) fn is_physfn(&self) -> bool {
+ // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
+ unsafe { (*self.as_raw()).is_physfn() != 0 }
+ }
+
/// Returns `true` if this device is a Virtual Function (VF).
#[inline]
pub fn is_virtfn(&self) -> bool {
--
2.53.0