morpheus_network::driver::virtio::rx

Function receive

Source
pub fn receive(
    rx_state: &mut VirtqueueState,
    rx_pool: &mut BufferPool,
    out_buffer: &mut [u8],
) -> Result<Option<usize>, RxError>
Expand description

Receive a packet via VirtIO.

§Arguments

  • rx_state: RX virtqueue state
  • rx_pool: RX buffer pool
  • out_buffer: Buffer to copy received frame into

§Returns

  • Ok(Some(len)): Frame received, len bytes copied (without VirtIO header)
  • Ok(None): No frame available (normal)
  • Err(RxError): Receive error

§Contract

  • MUST return immediately (no blocking)