mod.rs 800 B

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