pub trait InterruptSourceGroup: Send + Sync {
    // Required methods
    fn interrupt_type(&self) -> InterruptSourceType;
    fn len(&self) -> InterruptIndex;
    fn base(&self) -> InterruptIndex;
    fn enable(&self, configs: &[InterruptSourceConfig]) -> Result<()>;
    fn disable(&self) -> Result<()>;
    fn update(
        &self,
        index: InterruptIndex,
        config: &InterruptSourceConfig
    ) -> Result<()>;
    fn trigger(&self, index: InterruptIndex) -> Result<()>;

    // Provided methods
    fn notifier(&self, _index: InterruptIndex) -> Option<&EventFd> { ... }
    fn mask(&self, _index: InterruptIndex) -> Result<()> { ... }
    fn unmask(&self, _index: InterruptIndex) -> Result<()> { ... }
    fn get_pending_state(&self, _index: InterruptIndex) -> bool { ... }
}
Expand description

Trait to manage a group of interrupt sources for a device.

A device may support several types of interrupts, and each type of interrupt may contain one or multiple continuous interrupt sources. For example, a PCI device may concurrently support:

  • Legacy Irq: exactly one interrupt source.
  • PCI MSI Irq: 1,2,4,8,16,32 interrupt sources.
  • PCI MSIx Irq: 2^n(n=0-11) interrupt sources.

PCI MSI interrupts of a device may not be configured individually, and must configured as a whole block. So all interrupts of the same type of a device are abstracted as an InterruptSourceGroup object, instead of abstracting each interrupt source as a distinct InterruptSource.

Required Methods§

source

fn interrupt_type(&self) -> InterruptSourceType

Get type of interrupt sources managed by the group.

source

fn len(&self) -> InterruptIndex

Get number of interrupt sources managed by the group.

source

fn base(&self) -> InterruptIndex

Get base of the assigned Interrupt Source Identifiers.

source

fn enable(&self, configs: &[InterruptSourceConfig]) -> Result<()>

Enable the interrupt sources in the group to generate interrupts.

source

fn disable(&self) -> Result<()>

Disable the interrupt sources in the group to generate interrupts.

source

fn update( &self, index: InterruptIndex, config: &InterruptSourceConfig ) -> Result<()>

Update the interrupt source group configuration.

Arguments
  • index: sub-index into the group.
  • config: configuration data for the interrupt source.
source

fn trigger(&self, index: InterruptIndex) -> Result<()>

Inject an interrupt from this interrupt source into the guest.

If the interrupt has an associated interrupt_status register, all bits set in flag will be atomically ORed into the interrupt_status register.

Provided Methods§

source

fn notifier(&self, _index: InterruptIndex) -> Option<&EventFd>

Returns an interrupt notifier from this interrupt.

An interrupt notifier allows for external components and processes to inject interrupts into guest, by writing to the file returned by this method.

source

fn mask(&self, _index: InterruptIndex) -> Result<()>

Mask an interrupt from this interrupt source.

source

fn unmask(&self, _index: InterruptIndex) -> Result<()>

Unmask an interrupt from this interrupt source.

source

fn get_pending_state(&self, _index: InterruptIndex) -> bool

Check whether there’s pending interrupt.

Implementors§