morpheus_network::driver::virtio::transport

Struct VirtioTransport

Source
pub struct VirtioTransport {
    pub transport_type: TransportType,
    pub base: u64,
    pub pci_modern: PciModernConfig,
}
Expand description

Unified VirtIO transport handle

Fields§

§transport_type: TransportType

Transport type

§base: u64

For MMIO: the MMIO base address For PCI Modern: common_cfg base address

§pci_modern: PciModernConfig

PCI Modern specific config (only valid if transport_type == PciModern)

Implementations§

Source§

impl VirtioTransport

Source

pub fn mmio(mmio_base: u64) -> Self

Create MMIO transport

Source

pub fn pci_modern(config: PciModernConfig) -> Self

Create PCI Modern transport

Source

pub fn get_status(&self) -> u8

Get device status

Source

pub fn set_status(&self, status: u8)

Set device status

Source

pub fn reset(&self, tsc_freq: u64) -> bool

Reset device

Source

pub fn read_features(&self) -> u64

Read device feature bits (64-bit)

Source

pub fn write_features(&self, features: u64)

Write driver-accepted features

Source

pub fn get_num_queues(&self) -> u16

Get number of queues (PCI Modern only, MMIO needs different approach)

Source

pub fn select_queue(&self, queue_idx: u16)

Select a queue for configuration

Source

pub fn get_queue_size(&self) -> u16

Get max queue size for selected queue

Source

pub fn set_queue_size(&self, size: u16)

Set queue size

Source

pub fn set_queue_desc(&self, addr: u64)

Set queue descriptor table address

Source

pub fn set_queue_avail(&self, addr: u64)

Set queue available ring address

Source

pub fn set_queue_used(&self, addr: u64)

Set queue used ring address

Source

pub fn enable_queue(&self)

Enable the selected queue

Source

pub fn get_notify_addr(&self, queue_idx: u16) -> u64

Get notify address for a queue Returns (notify_addr, queue_notify_offset)

Source

pub fn notify_queue(&self, queue_idx: u16)

Notify device about queue

Source

pub fn read_mac(&self, mac_out: &mut [u8; 6]) -> bool

Read MAC address (net device specific)

Source

pub fn setup_queue( &self, queue_idx: u16, desc_addr: u64, avail_addr: u64, used_addr: u64, queue_size: u16, ) -> Result<u64, VirtioInitError>

Setup a virtqueue. Returns the notify address on success.

§Arguments
  • queue_idx: Queue index (0 for blk, 0/1 for net RX/TX)
  • desc_addr: Physical address of descriptor table
  • avail_addr: Physical address of available ring
  • used_addr: Physical address of used ring
  • queue_size: Number of descriptors
Source

pub fn read_blk_capacity(&self) -> u64

Read block device capacity (blk device specific)

Source

pub fn read_blk_size(&self) -> u32

Read block device sector size (blk device specific)

Trait Implementations§

Source§

impl Clone for VirtioTransport

Source§

fn clone(&self) -> VirtioTransport

Returns a copy 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 VirtioTransport

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for VirtioTransport

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> 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.