pub struct CdevDevice { /* private fields */ }Expand description
A VFIO device opened via the cdev interface (/dev/vfio/devices/vfioN).
This is the modern per-device access path. After opening, the device must
be bound to an iommufd fd via bind_iommufd and
then attached to an IOAS or HWPT via attach_ioas
before any DMA can occur.
Once bound and attached, call into_device to get
the standard Device for config space, BAR, IRQ, and
mmap operations.
Implementations§
Source§impl CdevDevice
impl CdevDevice
Sourcepub fn bind_iommufd(&self, iommufd_fd: RawFd) -> Result<u32>
pub fn bind_iommufd(&self, iommufd_fd: RawFd) -> Result<u32>
Bind this device to an iommufd instance.
Returns the kernel-assigned device ID within the iommufd context. This must be called before any DMA operations.
Sourcepub fn attach_ioas(&self, pt_id: u32) -> Result<u32>
pub fn attach_ioas(&self, pt_id: u32) -> Result<u32>
Attach the device to an IOAS or HWPT by its iommufd object ID.
Pass an IOAS ID for identity DMA translation, or a HWPT ID for nested translation.
Returns the attached page table ID (may differ from input if the kernel auto-created a HWPT for the IOAS).
Sourcepub fn detach_ioas(&self) -> Result<()>
pub fn detach_ioas(&self) -> Result<()>
Detach the device from its current IOAS/HWPT.
After detaching, the device is in a blocking DMA state.