xref: /DragonOS/kernel/src/driver/net/mod.rs (revision 91e9d4ab55ef960f57a1b6287bc523ca4341f67a)
113776c11Slogin use alloc::string::String;
213776c11Slogin use smoltcp::{
313776c11Slogin     iface,
413776c11Slogin     wire::{self, EthernetAddress},
513776c11Slogin };
613776c11Slogin 
7a03c4f9dSLoGin use super::base::device::driver::Driver;
8*91e9d4abSLoGin use crate::libs::spinlock::SpinLock;
9*91e9d4abSLoGin use system_error::SystemError;
1013776c11Slogin 
1177799ccaSWu Mianzhi mod dma;
1277799ccaSWu Mianzhi pub mod e1000e;
1313776c11Slogin pub mod virtio_net;
1413776c11Slogin 
1513776c11Slogin pub trait NetDriver: Driver {
1613776c11Slogin     /// @brief 获取网卡的MAC地址
1713776c11Slogin     fn mac(&self) -> EthernetAddress;
1813776c11Slogin 
1913776c11Slogin     fn name(&self) -> String;
2013776c11Slogin 
2113776c11Slogin     /// @brief 获取网卡的id
2213776c11Slogin     fn nic_id(&self) -> usize;
2313776c11Slogin 
2413776c11Slogin     fn poll(&self, sockets: &mut iface::SocketSet) -> Result<(), SystemError>;
2513776c11Slogin 
2613776c11Slogin     fn update_ip_addrs(&self, ip_addrs: &[wire::IpCidr]) -> Result<(), SystemError>;
2713776c11Slogin 
2813776c11Slogin     /// @brief 获取smoltcp的网卡接口类型
2913776c11Slogin     fn inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface>;
3013776c11Slogin     // fn as_any_ref(&'static self) -> &'static dyn core::any::Any;
3113776c11Slogin }
32