Trait axdriver::prelude::NetDriverOps

pub trait NetDriverOps: BaseDriverOps {
    // Required methods
    fn mac_address(&self) -> EthernetAddress;
    fn can_transmit(&self) -> bool;
    fn can_receive(&self) -> bool;
    fn rx_queue_size(&self) -> usize;
    fn tx_queue_size(&self) -> usize;
    fn recycle_rx_buffer(&mut self, rx_buf: NetBufPtr) -> Result<(), DevError>;
    fn recycle_tx_buffers(&mut self) -> Result<(), DevError>;
    fn transmit(&mut self, tx_buf: NetBufPtr) -> Result<(), DevError>;
    fn receive(&mut self) -> Result<NetBufPtr, DevError>;
    fn alloc_tx_buffer(&mut self, size: usize) -> Result<NetBufPtr, DevError>;
}
Available on crate feature net only.
Expand description

Operations that require a network device (NIC) driver to implement.

Required Methods§

fn mac_address(&self) -> EthernetAddress

The ethernet address of the NIC.

fn can_transmit(&self) -> bool

Whether can transmit packets.

fn can_receive(&self) -> bool

Whether can receive packets.

fn rx_queue_size(&self) -> usize

Size of the receive queue.

fn tx_queue_size(&self) -> usize

Size of the transmit queue.

fn recycle_rx_buffer(&mut self, rx_buf: NetBufPtr) -> Result<(), DevError>

Gives back the rx_buf to the receive queue for later receiving.

rx_buf should be the same as the one returned by NetDriverOps::receive.

fn recycle_tx_buffers(&mut self) -> Result<(), DevError>

Poll the transmit queue and gives back the buffers for previous transmiting. returns DevResult.

fn transmit(&mut self, tx_buf: NetBufPtr) -> Result<(), DevError>

Transmits a packet in the buffer to the network, without blocking, returns DevResult.

fn receive(&mut self) -> Result<NetBufPtr, DevError>

Receives a packet from the network and store it in the [NetBuf], returns the buffer.

Before receiving, the driver should have already populated some buffers in the receive queue by NetDriverOps::recycle_rx_buffer.

If currently no incomming packets, returns an error with type DevError::Again.

fn alloc_tx_buffer(&mut self, size: usize) -> Result<NetBufPtr, DevError>

Allocate a memory buffer of a specified size for network transmission, returns DevResult

Implementations on Foreign Types§

§

impl<H, T, const QS: usize> NetDriverOps for VirtIoNetDev<H, T, QS>
where H: Hal, T: Transport,

§

fn mac_address(&self) -> EthernetAddress

§

fn can_transmit(&self) -> bool

§

fn can_receive(&self) -> bool

§

fn rx_queue_size(&self) -> usize

§

fn tx_queue_size(&self) -> usize

§

fn recycle_rx_buffer(&mut self, rx_buf: NetBufPtr) -> Result<(), DevError>

§

fn recycle_tx_buffers(&mut self) -> Result<(), DevError>

§

fn transmit(&mut self, tx_buf: NetBufPtr) -> Result<(), DevError>

§

fn receive(&mut self) -> Result<NetBufPtr, DevError>

§

fn alloc_tx_buffer(&mut self, size: usize) -> Result<NetBufPtr, DevError>

Implementors§

§

impl<H, const QS: usize, const QN: u16> NetDriverOps for IxgbeNic<H, QS, QN>
where H: IxgbeHal,