Queue

Trait Queue 

Source
pub trait Queue: Send + InspectMut {
    // Required methods
    fn poll_ready(
        &mut self,
        cx: &mut Context<'_>,
        pool: &mut dyn BufferAccess,
    ) -> Poll<()>;
    fn rx_avail(&mut self, pool: &mut dyn BufferAccess, done: &[RxId]);
    fn rx_poll(
        &mut self,
        pool: &mut dyn BufferAccess,
        packets: &mut [RxId],
    ) -> Result<usize>;
    fn tx_avail(
        &mut self,
        pool: &mut dyn BufferAccess,
        segments: &[TxSegment],
    ) -> Result<(bool, usize)>;
    fn tx_poll(
        &mut self,
        pool: &mut dyn BufferAccess,
        done: &mut [TxId],
    ) -> Result<usize, TxError>;

    // Provided methods
    fn update_target_vp<'life0, 'async_trait>(
        &'life0 mut self,
        target_vp: u32,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn queue_stats(&self) -> Option<&dyn BackendQueueStats> { ... }
}
Expand description

A single TX/RX data path for sending and receiving network packets.

Created by Endpoint::get_queues and driven by the frontend in a poll loop. Every method that touches receive buffers takes pool: &mut dyn BufferAccess so the frontend retains ownership of guest memory state.

Typical poll loop:

loop {
    poll_ready(cx, pool)  // wait for backend events
    rx_poll(pool, ..)     // drain completed receives
    tx_avail(pool, ..)    // post guest TX packets
    tx_poll(pool, ..)     // drain TX completions
}

Required Methods§

Source

fn poll_ready( &mut self, cx: &mut Context<'_>, pool: &mut dyn BufferAccess, ) -> Poll<()>

Polls the queue for readiness.

Source

fn rx_avail(&mut self, pool: &mut dyn BufferAccess, done: &[RxId])

Makes receive buffers available for use by the device.

Source

fn rx_poll( &mut self, pool: &mut dyn BufferAccess, packets: &mut [RxId], ) -> Result<usize>

Polls the device for receives.

Source

fn tx_avail( &mut self, pool: &mut dyn BufferAccess, segments: &[TxSegment], ) -> Result<(bool, usize)>

Posts transmits to the device.

Returns Ok(false) if the segments will complete asynchronously.

Source

fn tx_poll( &mut self, pool: &mut dyn BufferAccess, done: &mut [TxId], ) -> Result<usize, TxError>

Polls the device for transmit completions.

Provided Methods§

Source

fn update_target_vp<'life0, 'async_trait>( &'life0 mut self, target_vp: u32, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates the queue’s target VP.

Source

fn queue_stats(&self) -> Option<&dyn BackendQueueStats>

Get queue statistics

Implementors§