Skip to content

Commit

Permalink
add simple benchmark to evaluate the bandwidth / latency (#16)
Browse files Browse the repository at this point in the history
* add simple benchmark to evaluate the performance

* The benchmark is derived from on rust-tcp-io-perf. A detail description is published in the readme.

* all network functions are able to return errors because the network initialization is able to fail

* test also the branch devel
  • Loading branch information
stlankes committed May 8, 2020
1 parent b24be19 commit 2bee7b3
Show file tree
Hide file tree
Showing 20 changed files with 1,051 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- master
- devel
pull_request:
branches:
- master
- devel
schedule:
- cron: '0 0 * * 6'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- master
- devel
pull_request:
branches:
- master
- devel

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- master
- devel
schedule:
- cron: '0 0 * * 6'

Expand Down
141 changes: 141 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"hermit-abi",
"hermit-sys",
"demo",
"netbench",
]
exclude = ["target", "loader", "libhermit-rs"]

Expand Down
20 changes: 15 additions & 5 deletions hermit-sys/src/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use smoltcp::time::Instant;
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address};

extern "Rust" {
fn sys_get_mac_address() -> [u8; 6];
fn sys_get_mtu() -> u16;
fn sys_get_mac_address() -> Result<[u8; 6], ()>;
fn sys_get_mtu() -> Result<u16, ()>;
fn sys_get_tx_buffer(len: usize) -> Result<(*mut u8, usize), ()>;
fn sys_send_tx_buffer(handle: usize, len: usize) -> Result<(), ()>;
fn sys_receive_rx_buffer() -> Result<&'static mut [u8], ()>;
fn sys_rx_buffer_consumed();
fn sys_rx_buffer_consumed() -> Result<(), ()>;
}

/// Data type to determine the mac address
Expand All @@ -35,14 +35,24 @@ impl HermitNet {

impl NetworkInterface<HermitNet> {
pub fn new() -> Option<Self> {
let mtu = unsafe { sys_get_mtu() };
let mtu = match unsafe { sys_get_mtu() } {
Ok(mtu) => mtu,
Err(_) => {
return None;
}
};
let device = HermitNet::new(mtu);
#[cfg(feature = "trace")]
let device = EthernetTracer::new(device, |_timestamp, printer| {
trace!("{}", printer);
});

let mac: [u8; 6] = unsafe { sys_get_mac_address() };
let mac: [u8; 6] = match unsafe { sys_get_mac_address() } {
Ok(mac) => mac,
Err(_) => {
return None;
}
};
let myip: [u8; 4] = [10, 0, 5, 3];
let mygw: [u8; 4] = [10, 0, 5, 1];
let mymask: [u8; 4] = [255, 255, 255, 0];
Expand Down
2 changes: 1 addition & 1 deletion libhermit-rs

0 comments on commit 2bee7b3

Please sign in to comment.