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

add support of TCP segmentation offloading #834

Closed
wants to merge 3 commits into from
Closed
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
45 changes: 22 additions & 23 deletions Cargo.lock

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

13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,15 @@ features = [
"proto-ipv6",
"socket-tcp",
"socket-udp",
# Enable IP fragmentation
#"proto-ipv4-fragmentation",
#
# Assume a MTU size of 9000
#"fragmentation-buffer-size-8192",
#"reassembly-buffer-size-8192",
#
# Enable for increased output
# "log",
# "verbose",
"log",
"verbose",
]

[patch.crates-io]
smoltcp= { git = "https://github.com/hermitcore/smoltcp.git", branch = "tso" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
multiboot = "0.8"
uart_16550 = "0.3"
Expand Down
10 changes: 7 additions & 3 deletions src/drivers/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod virtio_net;
#[cfg(all(feature = "pci", not(feature = "rtl8139")))]
pub mod virtio_pci;

use smoltcp::phy::ChecksumCapabilities;
use smoltcp::phy::{ChecksumCapabilities, TsoCapabilities};

#[cfg(target_arch = "x86_64")]
use crate::arch::kernel::apic;
Expand All @@ -25,10 +25,14 @@ use crate::executor::device::{RxToken, TxToken};

/// A trait for accessing the network interface
pub(crate) trait NetworkDriver {
/// Returns smoltcp's checksum capabilities
fn get_checksums(&self) -> ChecksumCapabilities {
/// A description of checksum behavior for every supported protocol.
fn get_checksum(&self) -> ChecksumCapabilities {
ChecksumCapabilities::default()
}
/// Specifies if the device support TCP segmentation offloading (TSO)
fn get_tso(&self) -> TsoCapabilities {
TsoCapabilities::None
}
/// Returns the mac address of the device.
fn get_mac_address(&self) -> [u8; 6];
/// Returns the current MTU of the device.
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/net/virtio_mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::ptr::read_volatile;
use core::str::FromStr;
use core::sync::atomic::{fence, Ordering};

use smoltcp::phy::ChecksumCapabilities;
use smoltcp::phy::{Checksum, ChecksumCapabilities, TsoCapabilities};

use crate::drivers::net::virtio_net::constants::{FeatureSet, Status};
use crate::drivers::net::virtio_net::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver};
Expand Down Expand Up @@ -151,7 +151,8 @@ impl VirtioNetDriver {
num_vqs: 0,
irq,
mtu,
checksums: ChecksumCapabilities::default(),
checksum: ChecksumCapabilities::default(),
tso: TsoCapabilities::default(),
})
}

Expand Down
Loading
Loading