Trait axdriver::prelude::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) -> 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>;
}
net
only.Expand description
Operations that require a network device (NIC) driver to implement.
Required Methods§
sourcefn mac_address(&self) -> EthernetAddress
fn mac_address(&self) -> EthernetAddress
The ethernet address of the NIC.
sourcefn can_transmit(&self) -> bool
fn can_transmit(&self) -> bool
Whether can transmit packets.
sourcefn can_receive(&self) -> bool
fn can_receive(&self) -> bool
Whether can receive packets.
sourcefn rx_queue_size(&self) -> usize
fn rx_queue_size(&self) -> usize
Size of the receive queue.
sourcefn tx_queue_size(&self) -> usize
fn tx_queue_size(&self) -> usize
Size of the transmit queue.
sourcefn recycle_rx_buffer(&mut self, rx_buf: NetBufPtr) -> Result<(), DevError>
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
.
sourcefn recycle_tx_buffers(&mut self) -> Result<(), DevError>
fn recycle_tx_buffers(&mut self) -> Result<(), DevError>
Poll the transmit queue and gives back the buffers for previous transmiting.
returns DevResult
.
sourcefn transmit(&mut self, tx_buf: NetBufPtr) -> Result<(), DevError>
fn transmit(&mut self, tx_buf: NetBufPtr) -> Result<(), DevError>
Transmits a packet in the buffer to the network, without blocking,
returns DevResult
.
sourcefn receive(&mut self) -> Result<NetBufPtr, DevError>
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
.