pub struct E1000Nic {
pub(crate) mmio: u64,
pub(crate) rx: RxRing<LegacyRxDesc>,
pub(crate) rx_bufs: [DmaRegion; 128],
pub(crate) rx_ring_phys: u64,
pub(crate) tx: TxRing<LegacyTxDesc>,
pub(crate) tx_bufs: [DmaRegion; 128],
pub(crate) tx_ring_phys: u64,
pub(crate) mac: [u8; 6],
pub(crate) link_up: bool,
pub(crate) stats: E1000Stats,
pub(crate) tx_since_last_reclaim: u64,
pub(crate) last_tdh: usize,
}Fields§
§mmio: u64§rx: RxRing<LegacyRxDesc>§rx_bufs: [DmaRegion; 128]§rx_ring_phys: u64§tx: TxRing<LegacyTxDesc>§tx_bufs: [DmaRegion; 128]§tx_ring_phys: u64§mac: [u8; 6]§link_up: bool§stats: E1000Stats§tx_since_last_reclaim: u64§last_tdh: usizeLast known TDH value for watchdog stall detection.
Implementations§
Source§impl E1000Nic
impl E1000Nic
pub fn init(mmio_base: u64, alloc: &dyn DmaAllocator) -> Result<Self, NetError>
pub fn mac_address(&self) -> [u8; 6]
pub fn link_up(&self) -> bool
pub fn check_link(&mut self) -> bool
pub fn stats(&self) -> &E1000Stats
Sourcepub(crate) fn recycle_rx_desc(&mut self, idx: usize)
pub(crate) fn recycle_rx_desc(&mut self, idx: usize)
Recycle an RX descriptor: clear status, restore buffer address, bump tail.
pub fn receive(&mut self, buf: &mut [u8]) -> Result<usize, NetError>
pub fn transmit(&mut self, buf: &[u8]) -> Result<(), NetError>
Sourcepub(crate) fn reclaim_completed_tx_buffers(&mut self)
pub(crate) fn reclaim_completed_tx_buffers(&mut self)
Reclaim TX descriptors that the hardware has completed (DD bit set). No per-packet DMA free is needed because the buffer pool is pre-allocated; we only reset the descriptor for reuse.
Sourcepub fn is_transmit_complete(&self) -> bool
pub fn is_transmit_complete(&self) -> bool
Non-blocking: check if the last submitted TX has completed.
Sourcepub fn wait_for_transmit(&self)
pub fn wait_for_transmit(&self)
Blocking spin until the last TX completes.
pub fn tx_is_done(&self, idx: usize) -> bool
Sourcepub fn handle_interrupt(&mut self) -> u32
pub fn handle_interrupt(&mut self) -> u32
Process a hardware interrupt. Returns the raw ICR value so the kernel adapter can decide what to do (e.g. wake a receive task).
Sourcepub fn watchdog_tick(&mut self, alloc: &dyn DmaAllocator) -> bool
pub fn watchdog_tick(&mut self, alloc: &dyn DmaAllocator) -> bool
Watchdog check: called periodically (e.g. from timer IRQ) to detect
and recover from a stalled link. Returns true if a reset was
performed.
Stall detection logic:
- If
tx_since_last_reclaimexceedsWATCHDOG_TX_THRESHOLDthe software has been submitting without any reclaim happening. - If TDH (hardware head) ==
last_tdh→ the hardware has not advanced → stall → reset. - If TDH advanced → update
last_tdhand reset counter (progress). - If TDH == tail (ring empty) → normal idle → reset counter.
Sourcepub(crate) fn reinit_hardware(&mut self, _alloc: &dyn DmaAllocator)
pub(crate) fn reinit_hardware(&mut self, _alloc: &dyn DmaAllocator)
Re-initialise hardware without tearing down the DMA rings. Used by the watchdog to recover from a stuck state.