pub struct MsixEmulator { /* private fields */ }Expand description
Emulator for the hardware-level interface required to configure and trigger MSI-X interrupts on a PCI device.
Implementations§
Source§impl MsixEmulator
impl MsixEmulator
Sourcepub fn new(
bar: u8,
count: u16,
msi_target: &MsiTarget,
) -> (Self, impl PciCapability + use<>)
pub fn new( bar: u8, count: u16, msi_target: &MsiTarget, ) -> (Self, impl PciCapability + use<>)
Create a new MsixEmulator instance, along with with its associated
PciCapability structure.
This implementation of MSI-X expects a dedicated BAR to store the vector and pending tables.
DEVNOTE: This current implementation of MSI-X isn’t particularly “flexible” with respect to the various ways the PCI spec allows MSI-X to be implemented. e.g: it uses a shared BAR for the table and BPA, with fixed offsets into the BAR for both of those tables. It would be nice to re-visit this code and make it more flexible.
Sourcepub fn bar_len(&self) -> u64
pub fn bar_len(&self) -> u64
Return the total length of the MSI-X BAR (Actually, the notion that there is an “MSI-X BAR” is an issue to fix sometime. MSI-X tables are often in the same bar as other things.)
Sourcepub fn write_u32(&mut self, offset: u64, val: u32)
pub fn write_u32(&mut self, offset: u64, val: u32)
Write a u32 to the MSI-X BAR at the given offset.
Sourcepub fn interrupt(&self, index: u16) -> Option<Interrupt>
pub fn interrupt(&self, index: u16) -> Option<Interrupt>
Return an [Interrupt] associated with the particular MSI-X vector, or
None if the index is out of bounds.
Sourcepub fn set_pending_bit(&self, index: u16)
pub fn set_pending_bit(&self, index: u16)
Sets the pending bit for the given vector index.
Used by device passthrough (e.g., VFIO with irqfd) to record that an interrupt arrived while the vector was masked, so PBA reads return the correct pending state.
Sourcepub fn enable_irqfd(
&self,
irqfd: &dyn IrqFd,
register: impl FnOnce(&[&Event]) -> Result<()>,
) -> Result<()>
pub fn enable_irqfd( &self, irqfd: &dyn IrqFd, register: impl FnOnce(&[&Event]) -> Result<()>, ) -> Result<()>
Enable kernel-mediated interrupt delivery for all vectors.
Creates one irqfd route per vector using the provided [IrqFd]
interface. The register callback receives references to the events
for all vectors. The caller uses this to pass events to the
interrupt source (e.g., VFIO map_msix or vhost-user
SET_VRING_CALL). After the callback returns, the routes are
installed in the emulator. When the guest programs MSI-X table
entries, the emulator automatically updates the kernel’s MSI routing.
Call disable_irqfd to tear down the routes.
Sourcepub fn disable_irqfd(&self)
pub fn disable_irqfd(&self)
Tear down kernel-mediated interrupt delivery.
Drops all irqfd routes, unregistering them from the hypervisor and freeing GSI allocations.
Trait Implementations§
Source§impl Clone for MsixEmulator
impl Clone for MsixEmulator
Source§fn clone(&self) -> MsixEmulator
fn clone(&self) -> MsixEmulator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more