Skip to main content

MsiTarget

Struct MsiTarget 

Source
pub struct MsiTarget { /* private fields */ }
Expand description

An MSI target that can be used to signal MSI interrupts.

Implementations§

Source§

impl MsiTarget

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn supports_direct_msi(&self) -> bool

Returns whether this target supports direct MSI routes.

Trait Implementations§

Source§

impl Clone for MsiTarget

Source§

fn clone(&self) -> MsiTarget

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MsiTarget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more