pub struct VirtioNetDriver { /* private fields */ }Expand description
VirtIO Network Driver
Implementations§
Source§impl VirtioNetDriver
impl VirtioNetDriver
Sourcepub fn new(mmio_base: usize) -> Result<Self, KernelError>
pub fn new(mmio_base: usize) -> Result<Self, KernelError>
Create a new VirtIO Network driver
Sourcepub fn transmit(&mut self, packet: &[u8]) -> Result<(), KernelError>
pub fn transmit(&mut self, packet: &[u8]) -> Result<(), KernelError>
Transmit a packet using virtqueue.
Prepends a VirtioNetHeader, copies the frame data into the pre-allocated TX data buffer, and kicks the device.
Sourcepub fn receive(&mut self) -> Result<Option<Packet>, KernelError>
pub fn receive(&mut self) -> Result<Option<Packet>, KernelError>
Receive a packet using virtqueue.
Checks the used ring for completed RX buffers, copies the received frame data (after stripping the VirtioNetHeader), recycles the descriptor, and returns the packet.
Sourcepub fn mac_address(&self) -> MacAddress
pub fn mac_address(&self) -> MacAddress
Get MAC address
Trait Implementations§
Source§impl NetworkDevice for VirtioNetDriver
impl NetworkDevice for VirtioNetDriver
Source§fn mac_address(&self) -> MacAddress
fn mac_address(&self) -> MacAddress
Get device MAC address
Source§fn capabilities(&self) -> DeviceCapabilities
fn capabilities(&self) -> DeviceCapabilities
Get device capabilities
Source§fn state(&self) -> DeviceState
fn state(&self) -> DeviceState
Get device state
Source§fn set_state(&mut self, state: DeviceState) -> Result<(), KernelError>
fn set_state(&mut self, state: DeviceState) -> Result<(), KernelError>
Set device state
Source§fn statistics(&self) -> DeviceStatistics
fn statistics(&self) -> DeviceStatistics
Get device statistics
Source§fn transmit(&mut self, packet: &Packet) -> Result<(), KernelError>
fn transmit(&mut self, packet: &Packet) -> Result<(), KernelError>
Transmit a packet
Source§fn receive(&mut self) -> Result<Option<Packet>, KernelError>
fn receive(&mut self) -> Result<Option<Packet>, KernelError>
Receive a packet (non-blocking)