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