pub struct MsiTarget { /* private fields */ }Expand description
An MSI target that can be used to signal MSI interrupts.
Implementations§
Source§impl MsiTarget
impl MsiTarget
Sourcepub fn disconnected() -> Self
pub fn disconnected() -> Self
Returns a disconnected MSI target with a dummy BDF.
Useful in tests and contexts where MSI delivery is not needed.
Source§impl MsiTarget
impl MsiTarget
Sourcepub fn with_devfn(&self, devfn: u8) -> MsiTarget
pub fn with_devfn(&self, devfn: u8) -> MsiTarget
Returns a new MsiTarget sharing the same connection and bus
range but with the given devfn in the default BDF.
Use this to derive per-port targets: create one target per
bus range, then call with_devfn(port_number) to get a
target that resolves to (bus << 8) | devfn.
Sourcepub fn with_bus_range(
&self,
bus_range: AssignedBusRange,
devfn: u8,
) -> MsiTarget
pub fn with_bus_range( &self, bus_range: AssignedBusRange, devfn: u8, ) -> MsiTarget
Returns a new MsiTarget sharing the same connection but with
a different bus range and devfn.
Use this when a component (e.g. a PCIe switch) needs to derive targets using a bus range it owns rather than the parent’s.
Sourcepub fn with_rid(&self, rid: u16) -> MsiTarget
pub fn with_rid(&self, rid: u16) -> MsiTarget
Returns a new MsiTarget sharing the same connection and bus range
but with the requester-ID offset set so the target resolves to the
given absolute rid.
The offset is computed against the current secondary bus, so call
this only once the bus range is assigned. For targets derived before
the bus is programmed (e.g. SR-IOV VFs), use
with_rid_offset instead.
The resulting bus is validated against the assigned bus range when an
MSI is signaled (see signal_msi), not here.
Sourcepub fn with_rid_offset(&self, rid_offset: u16) -> MsiTarget
pub fn with_rid_offset(&self, rid_offset: u16) -> MsiTarget
Returns a new MsiTarget sharing the same connection and bus range
but with the requester-ID offset set to rid_offset.
The RID is resolved at signal time as (secondary_bus << 8) + rid_offset, so the target tracks the live bus assignment. This is the
primitive for SR-IOV VFs, which are constructed before the PF’s bus is
programmed: pass the VF’s RID offset (e.g. VF Offset + index × VF
Stride) and it resolves correctly once the bus range is assigned.
Sourcepub fn signal_msi(&self, address: u64, data: u32)
pub fn signal_msi(&self, address: u64, data: u32)
Signals an MSI interrupt to this target, using this target’s default BDF as the requester ID.
Sourcepub fn signal_msi_with_rid(&self, rid: u16, address: u64, data: u32)
pub fn signal_msi_with_rid(&self, rid: u16, address: u64, data: u32)
Signals an MSI interrupt to this target, using an explicit
segment-local BDF (rid) as the requester ID.
Use this for multi-function devices whose functions span
multiple buses: the caller composes the full (bus << 8) | devfn
itself from whatever bus range it owns. This target’s own
default devfn is bypassed.
The bus portion of rid is validated against this target’s
assigned bus range; if it falls outside the range the MSI is
dropped and a ratelimited warning is emitted.
Sourcepub fn new_route(&self) -> Option<Result<MsiRoute>>
pub fn new_route(&self) -> Option<Result<MsiRoute>>
Creates a new kernel-mediated MSI route for direct interrupt delivery.
The route inherits this target’s default BDF source so that
MsiRoute::enable resolves the BDF the same way
signal_msi does.
Returns None if no [IrqFd] has been connected.
Sourcepub fn supports_direct_msi(&self) -> bool
pub fn supports_direct_msi(&self) -> bool
Returns whether this target supports direct MSI routes.