1 use alloc::string::String; 2 use smoltcp::{ 3 iface, 4 wire::{self, EthernetAddress}, 5 }; 6 7 use super::base::device::driver::Driver; 8 use crate::libs::spinlock::SpinLock; 9 use system_error::SystemError; 10 11 mod dma; 12 pub mod e1000e; 13 pub mod irq_handle; 14 pub mod virtio_net; 15 16 pub trait NetDriver: Driver { 17 /// @brief 获取网卡的MAC地址 mac(&self) -> EthernetAddress18 fn mac(&self) -> EthernetAddress; 19 name(&self) -> String20 fn name(&self) -> String; 21 22 /// @brief 获取网卡的id nic_id(&self) -> usize23 fn nic_id(&self) -> usize; 24 poll(&self, sockets: &mut iface::SocketSet) -> Result<(), SystemError>25 fn poll(&self, sockets: &mut iface::SocketSet) -> Result<(), SystemError>; 26 update_ip_addrs(&self, ip_addrs: &[wire::IpCidr]) -> Result<(), SystemError>27 fn update_ip_addrs(&self, ip_addrs: &[wire::IpCidr]) -> Result<(), SystemError>; 28 29 /// @brief 获取smoltcp的网卡接口类型 inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface>30 fn inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface>; 31 // fn as_any_ref(&'static self) -> &'static dyn core::any::Any; 32 } 33