Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: turn on tcp feature in examples #119

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- uses: actions/checkout@v4
- name: Check code format
uses: actions-rs/cargo@v1
with:
Expand All @@ -28,11 +23,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v4
- name: Build with no features
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -69,27 +60,15 @@ jobs:
- x86_64
include:
- example: aarch64
toolchain: stable
target: aarch64-unknown-none
packages: qemu-system-arm gcc-aarch64-linux-gnu
- example: riscv
toolchain: nightly-2022-11-03
target: riscv64imac-unknown-none-elf
packages: qemu-system-misc
- example: x86_64
toolchain: nightly
target: x86_64-unknown-none
packages: qemu-system-x86
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install QEMU
run: sudo apt update && sudo apt install ${{ matrix.packages }} && sudo chmod 666 /dev/vhost-vsock
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
components: llvm-tools-preview, rustfmt
- name: Check code format
working-directory: examples/${{ matrix.example }}
run: cargo fmt --all -- --check
Expand Down
5 changes: 5 additions & 0 deletions examples/aarch64/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
components = ["rustfmt", "llvm-tools"]
targets = ["aarch64-unknown-none"]
profile = "minimal"
2 changes: 1 addition & 1 deletion examples/riscv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mode := release
kernel := target/$(target)/$(mode)/riscv
img := target/$(target)/$(mode)/img

tcp ?= off
tcp ?= on

sysroot := $(shell rustc --print sysroot)
objdump := $(shell find $(sysroot) -name llvm-objdump) --arch-name=$(arch)
Expand Down
1 change: 0 additions & 1 deletion examples/riscv/rust-toolchain

This file was deleted.

5 changes: 5 additions & 0 deletions examples/riscv/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "nightly"
components = ["rustfmt", "llvm-tools"]
targets = ["riscv64imac-unknown-none-elf"]
profile = "minimal"
5 changes: 3 additions & 2 deletions examples/riscv/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::{Device, DeviceCapabilities, Medium, RxToken, TxToken};
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address};
use smoltcp::{socket::tcp, time::Instant};
use virtio_drivers::device::net::{NetBuffer, VirtIONet};
use virtio_drivers::device::net::{RxBuffer, VirtIONet};
use virtio_drivers::{transport::Transport, Error};

use super::{HalImpl, NET_QUEUE_SIZE};
Expand Down Expand Up @@ -64,7 +64,7 @@ impl<T: Transport> Device for DeviceWrapper<T> {
}
}

struct VirtioRxToken<T: Transport>(Rc<RefCell<DeviceImpl<T>>>, NetBuffer);
struct VirtioRxToken<T: Transport>(Rc<RefCell<DeviceImpl<T>>>, RxBuffer);
struct VirtioTxToken<T: Transport>(Rc<RefCell<DeviceImpl<T>>>);

impl<T: Transport> RxToken for VirtioRxToken<T> {
Expand Down Expand Up @@ -175,6 +175,7 @@ pub fn test_echo_server<T: Transport>(dev: DeviceImpl<T>) {
} else if socket.may_send() {
info!("tcp:{} close", PORT);
socket.close();
break;
}
}
}
2 changes: 1 addition & 1 deletion examples/x86_64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mode := release
kernel := target/$(target)/$(mode)/$(arch)
img := target/$(target)/$(mode)/img
accel ?= on
tcp ?= off
tcp ?= on

sysroot := $(shell rustc --print sysroot)
objdump := $(shell find $(sysroot) -name llvm-objdump) --arch-name=$(arch)
Expand Down
1 change: 0 additions & 1 deletion examples/x86_64/rust-toolchain

This file was deleted.

5 changes: 5 additions & 0 deletions examples/x86_64/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "nightly"
components = ["rustfmt", "llvm-tools"]
targets = ["x86_64-unknown-none"]
profile = "minimal"
3 changes: 2 additions & 1 deletion examples/x86_64/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<T: Transport> TxToken for VirtioTxToken<T> {
let mut tx_buf = dev.new_tx_buffer(len);
let result = f(tx_buf.packet_mut());
trace!("SEND {} bytes: {:02X?}", len, tx_buf.packet());
dev.transmit(tx_buf).unwrap();
dev.send(tx_buf).unwrap();
result
}
}
Expand Down Expand Up @@ -176,6 +176,7 @@ pub fn test_echo_server<T: Transport>(dev: DeviceImpl<T>) {
} else if socket.may_send() {
info!("tcp:{} close", PORT);
socket.close();
break;
}
}
}
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]
profile = "minimal"
Loading