diff --git a/rust/src/bin/arping.rs b/rust/src/bin/arping.rs index 6c9f943..e25df47 100644 --- a/rust/src/bin/arping.rs +++ b/rust/src/bin/arping.rs @@ -7,11 +7,12 @@ extern crate rcore_user; extern crate alloc; -use rcore_user::syscall::*; +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; use isomorphic_drivers::net::ethernet::intel::ixgbe; use isomorphic_drivers::provider; -use alloc::prelude::*; -use alloc::vec; +use rcore_user::syscall::*; #[derive(Copy, Clone)] pub struct Provider; @@ -51,7 +52,6 @@ impl provider::Provider for Provider { } } - // IMPORTANT: Must define main() like this #[no_mangle] pub fn main() { @@ -63,14 +63,16 @@ pub fn main() { println!("IXGBE driver up"); loop { println!("IXGBE driver sending data"); - let data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac + let data = [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac 0x00, 0x16, 0x31, 0xff, 0xa4, 0x9f, // mac 0x08, 0x06, // arp - 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac + 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, // mac 0x0a, 0x00, 0x00, 0x02, // ip 0x00, 0x16, 0x31, 0xff, 0xa4, 0x9f, // mac - 0x0a, 0x00, 0x00, 0x01]; // ip + 0x0a, 0x00, 0x00, 0x01, + ]; // ip ixgbe.send(&data); sys_sleep(1); } diff --git a/rust/src/bin/genpkts.rs b/rust/src/bin/genpkts.rs index c90f83d..cb0af2a 100644 --- a/rust/src/bin/genpkts.rs +++ b/rust/src/bin/genpkts.rs @@ -7,11 +7,12 @@ extern crate rcore_user; extern crate alloc; -use rcore_user::syscall::*; +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; use isomorphic_drivers::net::ethernet::intel::ixgbe; use isomorphic_drivers::provider; -use alloc::prelude::*; -use alloc::vec; +use rcore_user::syscall::*; #[derive(Copy, Clone)] pub struct Provider; @@ -51,7 +52,6 @@ impl provider::Provider for Provider { } } - // IMPORTANT: Must define main() like this #[no_mangle] pub fn main() { @@ -62,14 +62,16 @@ pub fn main() { println!("IXGBE addr at {:#X}", addr); let ixgbe = ixgbe::IXGBEDriver::init(Provider::new(), addr as usize, 0x20000); println!("IXGBE driver up"); - let data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac + let data = [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac 0x00, 0x16, 0x31, 0xff, 0xa4, 0x9f, // mac 0x08, 0x06, // arp - 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // mac + 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, // mac 0x0a, 0x00, 0x00, 0x02, // ip 0x00, 0x16, 0x31, 0xff, 0xa4, 0x9f, // mac - 0x0a, 0x00, 0x00, 0x01]; // ip + 0x0a, 0x00, 0x00, 0x01, + ]; // ip let size = 2048; let tx_batch = vec![&data[..]; size]; println!("IXGBE driver waiting for link up"); diff --git a/rust/src/bin/iperf.rs b/rust/src/bin/iperf.rs index 13681aa..791d524 100644 --- a/rust/src/bin/iperf.rs +++ b/rust/src/bin/iperf.rs @@ -7,12 +7,14 @@ extern crate rcore_user; extern crate alloc; -use rcore_user::syscall::*; -use isomorphic_drivers::net::ethernet::intel::ixgbe; -use isomorphic_drivers::provider; -use alloc::prelude::*; +use alloc::boxed::Box; use alloc::collections::BTreeMap; +use alloc::string::String; use alloc::vec; +use alloc::vec::Vec; +use isomorphic_drivers::net::ethernet::intel::ixgbe; +use isomorphic_drivers::provider; +use rcore_user::syscall::*; use smoltcp::iface::*; use smoltcp::phy; @@ -62,7 +64,7 @@ impl provider::Provider for Provider { #[derive(Clone)] struct IXGBEDriver { - inner: ixgbe::IXGBEDriver + inner: ixgbe::IXGBEDriver, } pub struct IXGBERxToken(Vec); @@ -95,7 +97,7 @@ impl<'a> phy::Device<'a> for IXGBEDriver { fn capabilities(&self) -> DeviceCapabilities { let mut caps = DeviceCapabilities::default(); caps.max_transmission_unit = ixgbe::IXGBEDriver::get_mtu(); // max MTU - //caps.max_transmission_unit = 1500; // max MTU + //caps.max_transmission_unit = 1500; // max MTU caps.max_burst_size = Some(256); // IP Rx checksum is offloaded with RXCSUM caps.checksum.ipv4 = Checksum::Tx; @@ -136,7 +138,7 @@ enum State { DATA_SOCKET_CONNECT, DATA_COOKIE_SENT, TEST_START, - TEST_RUNNING + TEST_RUNNING, } // IMPORTANT: Must define main() like this @@ -156,7 +158,7 @@ pub fn main() { let ethernet_addr = ixgbe.get_mac(); let ip_addrs = [IpCidr::new(IpAddress::v4(10, 0, 0, 2), 24)]; let neighbor_cache = NeighborCache::new(BTreeMap::new()); - let mut iface = EthernetInterfaceBuilder::new(IXGBEDriver{ inner:ixgbe }) + let mut iface = EthernetInterfaceBuilder::new(IXGBEDriver { inner: ixgbe }) .ethernet_addr(EthernetAddress::from_bytes(ðernet_addr.as_bytes())) .ip_addrs(ip_addrs) .neighbor_cache(neighbor_cache) @@ -183,7 +185,7 @@ pub fn main() { let mut sockets = SocketSet::new(vec![]); let tcp_handle = sockets.add(tcp_socket); let tcp2_handle = sockets.add(tcp2_socket); - + let mut tick = 0; let mut state = State::BEGIN; let mut last_state = State::BEGIN; @@ -194,8 +196,12 @@ pub fn main() { { let mut socket = sockets.get::(tcp_handle); if let State::BEGIN = state { - socket.connect(IpEndpoint::new(IpAddress::v4(10, 0, 0, 1), 5201), - IpEndpoint::new(IpAddress::v4(10, 0, 0, 2), 5201)).unwrap(); + socket + .connect( + IpEndpoint::new(IpAddress::v4(10, 0, 0, 1), 5201), + IpEndpoint::new(IpAddress::v4(10, 0, 0, 2), 5201), + ) + .unwrap(); state = State::CONTROL_SOCKET_CONNECT; } else if let State::CONTROL_SOCKET_CONNECT = state { if socket.may_send() { @@ -250,8 +256,12 @@ pub fn main() { { let mut socket = sockets.get::(tcp2_handle); if let State::CREATE_STREAMS = state { - socket.connect(IpEndpoint::new(IpAddress::v4(10, 0, 0, 1), 5201), - IpEndpoint::new(IpAddress::v4(10, 0, 0, 2), 5202)).unwrap(); + socket + .connect( + IpEndpoint::new(IpAddress::v4(10, 0, 0, 1), 5201), + IpEndpoint::new(IpAddress::v4(10, 0, 0, 2), 5202), + ) + .unwrap(); state = State::DATA_SOCKET_CONNECT; } else if let State::DATA_SOCKET_CONNECT = state { if socket.may_send() {