pub struct VirtIONet<H: Hal, T: Transport, const QUEUE_SIZE: usize> { /* private fields */ }
Expand description
Driver for a VirtIO network device.
Unlike VirtIONetRaw
, it uses RxBuffer
s for transmission and
reception rather than the raw slices. On initialization, it pre-allocates
all receive buffers and puts them all in the receive queue.
The virtio network device is a virtual ethernet card.
It has enhanced rapidly and demonstrates clearly how support for new features are added to an existing device. Empty buffers are placed in one virtqueue for receiving packets, and outgoing packets are enqueued into another for transmission in that order. A third command queue is used to control advanced filtering features.
Implementations§
Source§impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONet<H, T, QUEUE_SIZE>
impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONet<H, T, QUEUE_SIZE>
Sourcepub fn ack_interrupt(&mut self) -> bool
pub fn ack_interrupt(&mut self) -> bool
Acknowledge interrupt.
Sourcepub fn disable_interrupts(&mut self)
pub fn disable_interrupts(&mut self)
Disable interrupts.
Sourcepub fn enable_interrupts(&mut self)
pub fn enable_interrupts(&mut self)
Enable interrupts.
Sourcepub fn mac_address(&self) -> [u8; 6]
pub fn mac_address(&self) -> [u8; 6]
Get MAC address.
Sourcepub fn receive(&mut self) -> Result<RxBuffer>
pub fn receive(&mut self) -> Result<RxBuffer>
Receives a RxBuffer
from network. If currently no data, returns an
error with type Error::NotReady
.
It will try to pop a buffer that completed data reception in the NIC queue.
Sourcepub fn recycle_rx_buffer(&mut self, rx_buf: RxBuffer) -> Result
pub fn recycle_rx_buffer(&mut self, rx_buf: RxBuffer) -> Result
Gives back the ownership of rx_buf
, and recycles it for next use.
It will add the buffer back to the NIC queue.
Sourcepub fn new_tx_buffer(&self, buf_len: usize) -> TxBuffer
pub fn new_tx_buffer(&self, buf_len: usize) -> TxBuffer
Allocate a new buffer for transmitting.