xref: /cloud-hypervisor/vm-device/src/dma_mapping/mod.rs (revision d90fa96bb70492dfa8cf7419120dab5051e768ed)
1 // Copyright © 2021 Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
4 
5 /// Trait to trigger DMA mapping updates for devices managed by virtio-iommu
6 ///
7 /// Trait meant for triggering the DMA mapping update related to an external
8 /// device not managed fully through virtio. It is dedicated to virtio-iommu
9 /// in order to trigger the map update anytime the mapping is updated from the
10 /// guest.
11 pub trait ExternalDmaMapping: Send + Sync {
12     /// Map a memory range
13     fn map(&self, iova: u64, gpa: u64, size: u64) -> std::result::Result<(), std::io::Error>;
14 
15     /// Unmap a memory range
16     fn unmap(&self, iova: u64, size: u64) -> std::result::Result<(), std::io::Error>;
17 }
18