Skip to content

Commit

Permalink
add support of TCP segmentation offloading
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Aug 13, 2023
1 parent 9e453e0 commit 3d95f18
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 84 deletions.
41 changes: 20 additions & 21 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
3 changes: 2 additions & 1 deletion 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 @@ -152,6 +152,7 @@ impl VirtioNetDriver {
irq,
mtu,
checksums: ChecksumCapabilities::default(),
tso: TsoCapabilities::default(),
})
}

Expand Down
Loading

0 comments on commit 3d95f18

Please sign in to comment.