Skip to main content

NetDriverOps

Trait NetDriverOps 

Source
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) -> DevResult;
    fn recycle_tx_buffers(&mut self) -> DevResult;
    fn transmit(&mut self, tx_buf: NetBufPtr) -> DevResult;
    fn receive(&mut self) -> DevResult<NetBufPtr>;
    fn alloc_tx_buffer(&mut self, size: usize) -> DevResult<NetBufPtr>;
}
Expand description

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

Required Methods§

Source

fn mac_address(&self) -> EthernetAddress

The ethernet address of the NIC.

Source

fn can_transmit(&self) -> bool

Whether can transmit packets.

Source

fn can_receive(&self) -> bool

Whether can receive packets.

Source

fn rx_queue_size(&self) -> usize

Size of the receive queue.

Source

fn tx_queue_size(&self) -> usize

Size of the transmit queue.

Source

fn recycle_rx_buffer(&mut self, rx_buf: NetBufPtr) -> DevResult

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.

Source

fn recycle_tx_buffers(&mut self) -> DevResult

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

Source

fn transmit(&mut self, tx_buf: NetBufPtr) -> DevResult

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

Source

fn receive(&mut self) -> DevResult<NetBufPtr>

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.

Source

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

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

Implementors§

Source§

impl NetDriverOps for FXmacNic

Available on crate feature fxmac only.
Source§

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

Available on crate feature ixgbe only.