pub trait VhostVdpa: VhostBackend {
fn get_device_id(&self) -> Result<u32>;
fn get_status(&self) -> Result<u8>;
fn set_status(&self, status: u8) -> Result<()>;
fn get_config(&self, offset: u32, buffer: &mut [u8]) -> Result<()>;
fn set_config(&self, offset: u32, buffer: &[u8]) -> Result<()>;
fn set_vring_enable(&self, queue_index: usize, enabled: bool) -> Result<()>;
fn get_vring_num(&self) -> Result<u16>;
fn set_config_call(&self, fd: &EventFd) -> Result<()>;
fn get_iova_range(&self) -> Result<VhostVdpaIovaRange>;
fn dma_map(
&self,
iova: u64,
size: u64,
vaddr: *const u8,
readonly: bool
) -> Result<()>;
fn dma_unmap(&self, iova: u64, size: u64) -> Result<()>;
}
Expand description
Trait to control vhost-vdpa backend drivers.
vDPA (virtio Data Path Acceleration) devices has datapath compliant with the virtio specification and the control path is vendor specific. vDPA devices can be both physically located on the hardware or emulated by software.
Compared to vhost acceleration, vDPA offers more control over the device lifecycle. For this reason, the vhost-vdpa interface extends the vhost API, offering additional APIs for controlling the device (e.g. changing the state or accessing the configuration space
Required methods
fn get_device_id(&self) -> Result<u32>
fn get_device_id(&self) -> Result<u32>
Get the device id. The device ids follow the same definition of the device id defined in virtio-spec.
fn get_status(&self) -> Result<u8>
fn get_status(&self) -> Result<u8>
Get the status. The status bits follow the same definition of the device status defined in virtio-spec.
fn set_status(&self, status: u8) -> Result<()>
fn set_status(&self, status: u8) -> Result<()>
Set the status. The status bits follow the same definition of the device status defined in virtio-spec.
Arguments
status
- Status bits to set
Get the device configuration.
Arguments
offset
- Offset in the device configuration spacebuffer
- Buffer for configuration data
Set the device configuration.
Arguments
offset
- Offset in the device configuration spacebuffer
- Buffer for configuration data
Set the status for a given vring.
Arguments
queue_index
- Index of the queue to enable/disable.enabled
- true to enable the vring, false to disable it.
fn get_vring_num(&self) -> Result<u16>
fn get_vring_num(&self) -> Result<u16>
Get the maximum number of descriptors in the vring supported by the device.
fn set_config_call(&self, fd: &EventFd) -> Result<()>
fn set_config_call(&self, fd: &EventFd) -> Result<()>
fn get_iova_range(&self) -> Result<VhostVdpaIovaRange>
fn get_iova_range(&self) -> Result<VhostVdpaIovaRange>
Get the valid I/O virtual addresses range supported by the device.
Map DMA region.
Arguments
iova
- I/O virtual address.size
- Size of the I/O mapping.vaddr
- Virtual address in the current process.readonly
- true if the region is read-only, false if reads and writes are allowed.