Skip to main content

Domain

Struct Domain 

Source
pub struct Domain {
    id: DomainId,
    sbdf: Sbdf,
    state: SpinLock<DomainState>,
}
Expand description

A DMA domain attached to one PCI function.

Fields§

§id: DomainId§sbdf: Sbdf§state: SpinLock<DomainState>

Implementations§

Source§

impl Domain

Source

fn new(id: DomainId, sbdf: Sbdf) -> Self

Constructor for tests and kernel-internal domains without an owner.

Source

fn new_owned( id: DomainId, sbdf: Sbdf, owner: Option<u32>, policy: FaultPolicy, ) -> Self

Source

pub const fn id(&self) -> DomainId

Domain identifier.

Source

pub const fn sbdf(&self) -> Sbdf

PCI function this domain is bound to.

Source

pub fn owner(&self) -> Option<u32>

Owning silo SID, when the domain was created for a userspace driver.

Source

pub fn fault_policy(&self) -> FaultPolicy

Fault policy attached to this domain.

Source

pub fn set_fault_policy(&self, policy: FaultPolicy)

Change the fault policy.

Source

pub fn is_quiesced(&self) -> bool

True when new mappings are refused.

Source

pub fn quiesce(&self)

Stop accepting new mappings (hot-unplug prep).

Source

pub fn resume(&self)

Accept new mappings again.

Source

pub fn stats(&self) -> DomainStats

Per-domain statistics.

Source

pub fn mapped_bytes(&self) -> u64

Number of bytes currently mapped.

Source

pub fn refs(&self) -> usize

Logical reference count (one per outstanding delegation).

Source

pub fn acquire(&self) -> usize

Take one more logical reference.

Source

pub fn release(&self) -> usize

Drop one logical reference, returning the new count.

Source

pub fn generation(&self) -> u64

Monotonic generation, bumped on every map/unmap.

Source

pub fn mapping_count(&self) -> usize

Number of live mappings.

Source

pub fn mappings(&self) -> Vec<Mapping>

Snapshot of the mappings, sorted by IOVA.

Source

pub fn is_active(&self) -> bool

True when the domain has at least one mapping.

Source

pub fn map( &self, iova: u64, phys: u64, len: u64, prot: DmaProt, ) -> Result<(), IommuError>

Map len bytes of physical memory at iova.

The range must be page-aligned, non-empty and must not overlap an existing mapping. The overlap check is O(log n).

Source

pub fn map_kind( &self, iova: u64, phys: u64, len: u64, prot: DmaProt, kind: MappingKind, ) -> Result<(), IommuError>

Map len bytes using an explicit page granularity.

Source

pub fn map_reserved( &self, iova: u64, phys: u64, len: u64, prot: DmaProt, ) -> Result<(), IommuError>

Identity-map a firmware-reserved range (RMRR/IVMD) into this domain.

This bypasses the reserved-region conflict check: it is the one path allowed to touch those pages, and only for their owning device.

Source

fn map_impl( &self, iova: u64, phys: u64, len: u64, prot: DmaProt, kind: MappingKind, allow_reserved: bool, ) -> Result<(), IommuError>

Source

pub fn map_auto( &self, phys: u64, len: u64, prot: DmaProt, ) -> Result<u64, IommuError>

Allocate a free IOVA range and map phys into it.

Source

pub fn unmap(&self, iova: u64, len: u64) -> Result<usize, IommuError>

Remove every mapping fully contained in [iova, iova + len).

Returns how many mappings were removed. A partial overlap is an error: callers must unmap on the granularity they mapped.

Source

pub fn unmap_exact(&self, iova: u64) -> Result<Mapping, IommuError>

Remove exactly one mapping that starts at iova.

Source

pub fn translate(&self, iova: u64) -> Option<Translation>

Translate an IOVA with the software table.

This is the source of truth while hardware translation is disabled, and a verification aid afterwards.

Source

pub fn reset(&self)

Remove every mapping, keeping the domain alive.

Source

pub fn report_fault( &self, iova: u64, reason: FaultReason, access: DmaProt, ) -> Option<FaultRecord>

Record a fault for this domain and apply its policy.

Returns the queued record (with the action that was taken). The per-domain burst budget bounds the work done by a misbehaving device; excess records are counted and dropped.

Trait Implementations§

Source§

impl Debug for Domain

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Domain

§

impl !RefUnwindSafe for Domain

§

impl Forget for Domain

§

impl Move for Domain

§

impl Send for Domain

§

impl Sync for Domain

§

impl Unpin for Domain

§

impl UnsafeUnpin for Domain

§

impl UnwindSafe for Domain

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.