mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Clean up smoltcp dependencies
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d62bb1ca76
commit
51334c4a36
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -135,6 +135,7 @@ name = "aster-network"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"align_ext",
|
"align_ext",
|
||||||
|
"aster-bigtcp",
|
||||||
"aster-rights",
|
"aster-rights",
|
||||||
"aster-util",
|
"aster-util",
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
@ -143,7 +144,6 @@ dependencies = [
|
|||||||
"int-to-c-enum",
|
"int-to-c-enum",
|
||||||
"log",
|
"log",
|
||||||
"ostd",
|
"ostd",
|
||||||
"smoltcp",
|
|
||||||
"spin 0.9.8",
|
"spin 0.9.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -247,6 +247,7 @@ name = "aster-virtio"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"align_ext",
|
"align_ext",
|
||||||
|
"aster-bigtcp",
|
||||||
"aster-block",
|
"aster-block",
|
||||||
"aster-console",
|
"aster-console",
|
||||||
"aster-input",
|
"aster-input",
|
||||||
@ -261,7 +262,6 @@ dependencies = [
|
|||||||
"int-to-c-enum",
|
"int-to-c-enum",
|
||||||
"log",
|
"log",
|
||||||
"ostd",
|
"ostd",
|
||||||
"smoltcp",
|
|
||||||
"spin 0.9.8",
|
"spin 0.9.8",
|
||||||
"typeflags-util",
|
"typeflags-util",
|
||||||
]
|
]
|
||||||
|
@ -9,24 +9,11 @@ edition = "2021"
|
|||||||
align_ext = { path = "../../../ostd/libs/align_ext" }
|
align_ext = { path = "../../../ostd/libs/align_ext" }
|
||||||
aster-util = { path = "../../libs/aster-util" }
|
aster-util = { path = "../../libs/aster-util" }
|
||||||
aster-rights = { path = "../../libs/aster-rights" }
|
aster-rights = { path = "../../libs/aster-rights" }
|
||||||
|
aster-bigtcp = { path = "../../libs/aster-bigtcp" }
|
||||||
bitflags = "1.3"
|
bitflags = "1.3"
|
||||||
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
|
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
|
||||||
component = { path = "../../libs/comp-sys/component" }
|
component = { path = "../../libs/comp-sys/component" }
|
||||||
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
ostd = { path = "../../../ostd" }
|
ostd = { path = "../../../ostd" }
|
||||||
smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "dc08e0b", default-features = false, features = [
|
|
||||||
"alloc",
|
|
||||||
"log",
|
|
||||||
"medium-ethernet",
|
|
||||||
"medium-ip",
|
|
||||||
"proto-dhcpv4",
|
|
||||||
"proto-ipv4",
|
|
||||||
"proto-igmp",
|
|
||||||
"socket-icmp",
|
|
||||||
"socket-udp",
|
|
||||||
"socket-tcp",
|
|
||||||
"socket-raw",
|
|
||||||
"socket-dhcpv4",
|
|
||||||
] }
|
|
||||||
spin = "0.9.4"
|
spin = "0.9.4"
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
|
|
||||||
|
use aster_bigtcp::{device, time::Instant};
|
||||||
use ostd::mm::VmWriter;
|
use ostd::mm::VmWriter;
|
||||||
use smoltcp::{phy, time::Instant};
|
|
||||||
|
|
||||||
use crate::{buffer::RxBuffer, AnyNetworkDevice};
|
use crate::{buffer::RxBuffer, AnyNetworkDevice};
|
||||||
|
|
||||||
impl phy::Device for dyn AnyNetworkDevice {
|
impl device::Device for dyn AnyNetworkDevice {
|
||||||
type RxToken<'a> = RxToken;
|
type RxToken<'a> = RxToken;
|
||||||
type TxToken<'a> = TxToken<'a>;
|
type TxToken<'a> = TxToken<'a>;
|
||||||
|
|
||||||
@ -28,13 +28,13 @@ impl phy::Device for dyn AnyNetworkDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capabilities(&self) -> phy::DeviceCapabilities {
|
fn capabilities(&self) -> device::DeviceCapabilities {
|
||||||
self.capabilities()
|
self.capabilities()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct RxToken(RxBuffer);
|
pub struct RxToken(RxBuffer);
|
||||||
|
|
||||||
impl phy::RxToken for RxToken {
|
impl device::RxToken for RxToken {
|
||||||
fn consume<R, F>(self, f: F) -> R
|
fn consume<R, F>(self, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&[u8]) -> R,
|
F: FnOnce(&[u8]) -> R,
|
||||||
@ -48,7 +48,7 @@ impl phy::RxToken for RxToken {
|
|||||||
|
|
||||||
pub struct TxToken<'a>(&'a mut dyn AnyNetworkDevice);
|
pub struct TxToken<'a>(&'a mut dyn AnyNetworkDevice);
|
||||||
|
|
||||||
impl<'a> phy::TxToken for TxToken<'a> {
|
impl<'a> device::TxToken for TxToken<'a> {
|
||||||
fn consume<R, F>(self, len: usize, f: F) -> R
|
fn consume<R, F>(self, len: usize, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut [u8]) -> R,
|
F: FnOnce(&mut [u8]) -> R,
|
||||||
|
@ -15,6 +15,7 @@ extern crate alloc;
|
|||||||
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
||||||
use core::{any::Any, fmt::Debug};
|
use core::{any::Any, fmt::Debug};
|
||||||
|
|
||||||
|
use aster_bigtcp::device::DeviceCapabilities;
|
||||||
pub use buffer::{RxBuffer, TxBuffer, RX_BUFFER_POOL, TX_BUFFER_POOL};
|
pub use buffer::{RxBuffer, TxBuffer, RX_BUFFER_POOL, TX_BUFFER_POOL};
|
||||||
use component::{init_component, ComponentInitError};
|
use component::{init_component, ComponentInitError};
|
||||||
pub use dma_pool::DmaSegment;
|
pub use dma_pool::DmaSegment;
|
||||||
@ -22,7 +23,6 @@ use ostd::{
|
|||||||
sync::{LocalIrqDisabled, SpinLock},
|
sync::{LocalIrqDisabled, SpinLock},
|
||||||
Pod,
|
Pod,
|
||||||
};
|
};
|
||||||
use smoltcp::phy;
|
|
||||||
use spin::Once;
|
use spin::Once;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Pod)]
|
#[derive(Debug, Clone, Copy, Pod)]
|
||||||
@ -40,7 +40,7 @@ pub trait AnyNetworkDevice: Send + Sync + Any + Debug {
|
|||||||
// ================Device Information=================
|
// ================Device Information=================
|
||||||
|
|
||||||
fn mac_addr(&self) -> EthernetAddr;
|
fn mac_addr(&self) -> EthernetAddr;
|
||||||
fn capabilities(&self) -> phy::DeviceCapabilities;
|
fn capabilities(&self) -> DeviceCapabilities;
|
||||||
|
|
||||||
// ================Device Operation===================
|
// ================Device Operation===================
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ aster-network = { path = "../network" }
|
|||||||
aster-console = { path = "../console" }
|
aster-console = { path = "../console" }
|
||||||
aster-util = { path = "../../libs/aster-util" }
|
aster-util = { path = "../../libs/aster-util" }
|
||||||
aster-rights = { path = "../../libs/aster-rights" }
|
aster-rights = { path = "../../libs/aster-rights" }
|
||||||
|
aster-bigtcp = { path = "../../libs/aster-bigtcp" }
|
||||||
id-alloc = { path = "../../../ostd/libs/id-alloc" }
|
id-alloc = { path = "../../../ostd/libs/id-alloc" }
|
||||||
typeflags-util = { path = "../../libs/typeflags-util" }
|
typeflags-util = { path = "../../libs/typeflags-util" }
|
||||||
ostd = { path = "../../../ostd" }
|
ostd = { path = "../../../ostd" }
|
||||||
@ -23,17 +24,3 @@ component = { path = "../../libs/comp-sys/component" }
|
|||||||
log = "0.4"
|
log = "0.4"
|
||||||
bit_field = "0.10.1"
|
bit_field = "0.10.1"
|
||||||
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
||||||
smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "dc08e0b", default-features = false, features = [
|
|
||||||
"alloc",
|
|
||||||
"log",
|
|
||||||
"medium-ethernet",
|
|
||||||
"medium-ip",
|
|
||||||
"proto-dhcpv4",
|
|
||||||
"proto-ipv4",
|
|
||||||
"proto-igmp",
|
|
||||||
"socket-icmp",
|
|
||||||
"socket-udp",
|
|
||||||
"socket-tcp",
|
|
||||||
"socket-raw",
|
|
||||||
"socket-dhcpv4",
|
|
||||||
] }
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use alloc::{boxed::Box, string::ToString, sync::Arc};
|
use alloc::{boxed::Box, string::ToString, sync::Arc};
|
||||||
use core::{fmt::Debug, hint::spin_loop, mem::size_of};
|
use core::{fmt::Debug, hint::spin_loop, mem::size_of};
|
||||||
|
|
||||||
|
use aster_bigtcp::device::{DeviceCapabilities, Medium};
|
||||||
use aster_network::{
|
use aster_network::{
|
||||||
AnyNetworkDevice, EthernetAddr, RxBuffer, TxBuffer, VirtioNetError, RX_BUFFER_POOL,
|
AnyNetworkDevice, EthernetAddr, RxBuffer, TxBuffer, VirtioNetError, RX_BUFFER_POOL,
|
||||||
TX_BUFFER_POOL,
|
TX_BUFFER_POOL,
|
||||||
@ -10,7 +11,6 @@ use aster_network::{
|
|||||||
use aster_util::slot_vec::SlotVec;
|
use aster_util::slot_vec::SlotVec;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use ostd::{sync::SpinLock, trap::TrapFrame};
|
use ostd::{sync::SpinLock, trap::TrapFrame};
|
||||||
use smoltcp::phy::{DeviceCapabilities, Medium};
|
|
||||||
|
|
||||||
use super::{config::VirtioNetConfig, header::VirtioNetHdr};
|
use super::{config::VirtioNetConfig, header::VirtioNetHdr};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
pub use smoltcp::phy::{Device, Loopback, Medium};
|
pub use smoltcp::phy::{Device, DeviceCapabilities, Loopback, Medium, RxToken, TxToken};
|
||||||
|
|
||||||
/// A trait that allows to obtain a mutable reference of [`Device`].
|
/// A trait that allows to obtain a mutable reference of [`Device`].
|
||||||
///
|
///
|
||||||
|
@ -18,6 +18,7 @@ pub mod device;
|
|||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod iface;
|
pub mod iface;
|
||||||
pub mod socket;
|
pub mod socket;
|
||||||
|
pub mod time;
|
||||||
pub mod wire;
|
pub mod wire;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
3
kernel/libs/aster-bigtcp/src/time.rs
Normal file
3
kernel/libs/aster-bigtcp/src/time.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
pub use smoltcp::time::Instant;
|
Reference in New Issue
Block a user