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
impl Domain
Sourcefn new(id: DomainId, sbdf: Sbdf) -> Self
fn new(id: DomainId, sbdf: Sbdf) -> Self
Constructor for tests and kernel-internal domains without an owner.
fn new_owned( id: DomainId, sbdf: Sbdf, owner: Option<u32>, policy: FaultPolicy, ) -> Self
Sourcepub fn owner(&self) -> Option<u32>
pub fn owner(&self) -> Option<u32>
Owning silo SID, when the domain was created for a userspace driver.
Sourcepub fn fault_policy(&self) -> FaultPolicy
pub fn fault_policy(&self) -> FaultPolicy
Fault policy attached to this domain.
Sourcepub fn set_fault_policy(&self, policy: FaultPolicy)
pub fn set_fault_policy(&self, policy: FaultPolicy)
Change the fault policy.
Sourcepub fn is_quiesced(&self) -> bool
pub fn is_quiesced(&self) -> bool
True when new mappings are refused.
Sourcepub fn stats(&self) -> DomainStats
pub fn stats(&self) -> DomainStats
Per-domain statistics.
Sourcepub fn mapped_bytes(&self) -> u64
pub fn mapped_bytes(&self) -> u64
Number of bytes currently mapped.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Monotonic generation, bumped on every map/unmap.
Sourcepub fn mapping_count(&self) -> usize
pub fn mapping_count(&self) -> usize
Number of live mappings.
Sourcepub fn map(
&self,
iova: u64,
phys: u64,
len: u64,
prot: DmaProt,
) -> Result<(), IommuError>
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).
Sourcepub fn map_kind(
&self,
iova: u64,
phys: u64,
len: u64,
prot: DmaProt,
kind: MappingKind,
) -> Result<(), IommuError>
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.
Sourcepub fn map_reserved(
&self,
iova: u64,
phys: u64,
len: u64,
prot: DmaProt,
) -> Result<(), IommuError>
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.
fn map_impl( &self, iova: u64, phys: u64, len: u64, prot: DmaProt, kind: MappingKind, allow_reserved: bool, ) -> Result<(), IommuError>
Sourcepub fn map_auto(
&self,
phys: u64,
len: u64,
prot: DmaProt,
) -> Result<u64, IommuError>
pub fn map_auto( &self, phys: u64, len: u64, prot: DmaProt, ) -> Result<u64, IommuError>
Allocate a free IOVA range and map phys into it.
Sourcepub fn unmap(&self, iova: u64, len: u64) -> Result<usize, IommuError>
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.
Sourcepub fn unmap_exact(&self, iova: u64) -> Result<Mapping, IommuError>
pub fn unmap_exact(&self, iova: u64) -> Result<Mapping, IommuError>
Remove exactly one mapping that starts at iova.
Sourcepub fn translate(&self, iova: u64) -> Option<Translation>
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.
Sourcepub fn report_fault(
&self,
iova: u64,
reason: FaultReason,
access: DmaProt,
) -> Option<FaultRecord>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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