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

Tunneled LSO/CSO Support #614

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a0d65d6
Offload testing: lie to MAC.
FelixMcFelix Nov 4, 2024
0f0dd86
Correct MSS setting to Not Emit More Packets
FelixMcFelix Nov 6, 2024
e266aa8
bad merge.
FelixMcFelix Nov 12, 2024
0d2c6c0
Test: fill MEOI in dlbk_t
FelixMcFelix Nov 13, 2024
84021b5
More compact MEOI/tuninfo in dblk
FelixMcFelix Nov 14, 2024
7bdef24
Conditionally expose LSO/CSO capabs based on underlay
FelixMcFelix Nov 15, 2024
3042e76
Playing nice, again.
FelixMcFelix Dec 14, 2024
c7516dc
Fmt.
FelixMcFelix Dec 19, 2024
b33c0a2
Merge branch 'master' into ingot-and-offload
FelixMcFelix Dec 23, 2024
9eea967
Bad merge.
FelixMcFelix Dec 23, 2024
60dbd62
Smuggle V2P/V2B use out via ActionMeta.
FelixMcFelix Dec 23, 2024
8d74090
Cleanup, emulate csum on loopback.
FelixMcFelix Dec 31, 2024
5b8dff8
First-class some dedicated ActionMeta.
FelixMcFelix Dec 31, 2024
fab7c2b
Further cleanup.
FelixMcFelix Dec 31, 2024
90fe450
Copy offload flags during prepend.
FelixMcFelix Jan 8, 2025
2b0386f
Make use of illumos 17032 on rx
FelixMcFelix Jan 9, 2025
1e23d63
Quick rework for inflight changes.
FelixMcFelix Jan 15, 2025
09cd206
Merge branch 'master' into ingot-and-offload
FelixMcFelix Jan 20, 2025
e5e5ad4
Respin against newer-er illumos bits.
FelixMcFelix Jan 28, 2025
009d82c
New API post merge-pileup.
FelixMcFelix Feb 10, 2025
9345439
Whelp, these flags moved about.
FelixMcFelix Feb 10, 2025
2a62156
More explicit flagshift, safety around zone-IP.
FelixMcFelix Feb 18, 2025
bc19340
Bump Rust->1.85, Nightly, move to 2024 edition.
FelixMcFelix Feb 21, 2025
e049022
Rerun fmt a few more times.
FelixMcFelix Feb 21, 2025
204d087
New method name, force offloads to lean on hw_emul
FelixMcFelix Feb 27, 2025
1678408
Flag crimes for an all-emulated world.
FelixMcFelix Feb 27, 2025
268139e
Merge branch 'master' into ingot-and-offload
FelixMcFelix Feb 27, 2025
f8271cd
Fmt.
FelixMcFelix Feb 28, 2025
d870573
Rework rust toolchain installation
FelixMcFelix Mar 4, 2025
0430548
Merge branch 'unbreak-ci' into rust-2024
FelixMcFelix Mar 4, 2025
c4ae722
Bump API version (??)
FelixMcFelix Mar 4, 2025
40f63c8
Formalise style change to 2024
FelixMcFelix Mar 4, 2025
d517019
Clippy -- unsafe op in unsafe fn
FelixMcFelix Mar 4, 2025
8a6fc62
Undo/improve some automatic if let 'fixes' from cargo
FelixMcFelix Mar 5, 2025
828768c
Formatting changed in rustup 1.28.1, sigh.
FelixMcFelix Mar 5, 2025
4175bba
Merge branch 'unbreak-ci' into rust-2024
FelixMcFelix Mar 5, 2025
10427c3
Merge branch 'rust-2024' into ingot-and-offload
FelixMcFelix Mar 5, 2025
45c6f13
Rebasing fixed.
FelixMcFelix Mar 5, 2025
139d043
Review feedback.
FelixMcFelix Mar 5, 2025
4852376
Merge branch 'rust-2024' into ingot-and-offload
FelixMcFelix Mar 6, 2025
aad2455
Downgrade OPTE version for sanity-testing omicron
FelixMcFelix Mar 6, 2025
85649ef
Correctly fixup L3 Checksums when L4 has been offloaded.
FelixMcFelix Mar 7, 2025
1da3d33
Cleanup and self review. Codify 'always advertise offloads'.
FelixMcFelix Mar 7, 2025
e6199c9
`kbench` warnings missed on raand upgrade.
FelixMcFelix Mar 7, 2025
c2b5635
Set_pktinfo is now `void`.
FelixMcFelix Mar 10, 2025
151aeb6
Merge branch 'master' into ingot-and-offload
FelixMcFelix Mar 12, 2025
45f57e3
Nit.
FelixMcFelix Mar 12, 2025
304b249
Merge branch 'master' into ingot-and-offload
FelixMcFelix Mar 14, 2025
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion crates/illumos-sys-hdrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ repository.workspace = true

[features]
default = []
kernel = []
kernel = []

[dependencies]
bitflags.workspace = true
6 changes: 6 additions & 0 deletions crates/illumos-sys-hdrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub mod kernel;
#[cfg(feature = "kernel")]
pub use kernel::*;

pub mod mac;

use core::ptr;
use core::sync::atomic::AtomicI32;
use core::sync::atomic::AtomicI64;
Expand Down Expand Up @@ -246,6 +248,8 @@ pub struct dblk_t {
pub db_struioun: u64, // imprecise
pub db_fthdr: *const c_void, // imprecise
pub db_credp: *const c_void, // imprecise

pub db_meoi: [u8; 16], // imprecise
}

impl Default for dblk_t {
Expand All @@ -269,6 +273,8 @@ impl Default for dblk_t {
db_struioun: 0,
db_fthdr: ptr::null(),
db_credp: ptr::null(),

db_meoi: Default::default(),
}
}
}
Expand Down
175 changes: 175 additions & 0 deletions crates/illumos-sys-hdrs/src/mac.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// Copyright 2025 Oxide Computer Company

#[cfg(feature = "kernel")]
use crate::mblk_t;
use bitflags::bitflags;
#[cfg(feature = "kernel")]
use core::ffi::c_int;

// ======================================================================
// uts/common/sys/mac_provider.h
// ======================================================================

bitflags! {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
/// Flags which denote the valid fields of a `mac_ether_offload_info_t`
/// or `mac_ether_tun_info_t`.
pub struct MacEtherOffloadFlags: u32 {
/// `l2hlen` and `l3proto` are set.
const L2INFO_SET = 1 << 0;
/// `l3hlen` and `l4proto` are set.
const L3INFO_SET = 1 << 1;
/// `l4hlen` is set.
const L4INFO_SET = 1 << 2;
/// `tunhlen` is set.
const TUNINFO_SET = 1 << 3;
/// The ethernet header contains a VLAN tag.
const VLAN_TAGGED = 1 << 4;
/// The packet is fragmented at L3.
const L3_FRAGMENT = 1 << 5;
}
}

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
pub struct MacTunType(u32);

impl MacTunType {
pub const NONE: Self = Self(0);
pub const GENEVE: Self = Self(1);
pub const VXLAN: Self = Self(2);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub struct mac_ether_offload_info_t {
pub meoi_flags: MacEtherOffloadFlags,
pub meoi_tuntype: MacTunType,
pub meoi_len: u32,
pub meoi_l2hlen: u8,
pub meoi_l3proto: u16,
pub meoi_l3hlen: u16,
pub meoi_l4proto: u8,
pub meoi_l4hlen: u8,
pub meoi_tunhlen: u16,
}

#[cfg(feature = "kernel")]
unsafe extern "C" {
pub fn lso_info_set(mp: *mut mblk_t, mss: u32, flags: u32);
pub fn lso_info_cleanup(mp: *mut mblk_t);
pub fn mac_hcksum_set(
mp: *mut mblk_t,
start: u32,
stuff: u32,
end: u32,
value: u32,
flags: u32,
);
pub fn mac_hcksum_get(
mp: *mut mblk_t,
start: *mut u32,
stuff: *mut u32,
end: *mut u32,
value: *mut u32,
flags: *mut u32,
);
pub fn mac_lso_get(mp: *mut mblk_t, mss: *mut u32, flags: *mut u32);
pub fn mac_ether_set_pktinfo(
mp: *mut mblk_t,
outer_info: *const mac_ether_offload_info_t,
inner_info: *const mac_ether_offload_info_t,
);
}

// ======================================================================
// uts/common/sys/pattr.h
// ======================================================================

bitflags! {
/// Flags which denote checksum and LSO state for an `mblk_t`.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct MblkOffloadFlags: u16 {
/// Tx: IPv4 header checksum must be computer by hardware.
const HCK_IPV4_HDRCKSUM = 1 << 0;
/// Rx: IPv4 header checksum was verified correct by hardware.
const HCK_IPV4_HDRCKSUM_OK = Self::HCK_IPV4_HDRCKSUM.bits();
/// * Tx: Compute partial checksum based on start/stuff/end offsets.
/// * Rx: Partial checksum computed and attached.
const HCK_PARTIALCKSUM = 1 << 1;
/// * Tx: Compute full (pseudo + l4 + payload) cksum for this packet.
/// * Rx: Full checksum was computed in hardware, and is attached.
const HCK_FULLCKSUM = 1 << 2;
/// Rx: Hardware has verified that L3/L4 checksums are correct.
const HCK_FULLCKSUM_OK = 1 << 3;
/// Tx: Hardware must perform LSO.
const HW_LSO = 1 << 4;

const HCK_INNER_V4CKSUM = 1 << 5;

const HCK_INNER_V4CKSUM_OK = 1 << 6;

const HCK_INNER_PARTIAL = 1 << 7;

const HCK_INNER_FULL = 1 << 8;

const HCK_INNER_FULL_OK = 1 << 9;

const HCK_FLAGS = Self::HCK_IPV4_HDRCKSUM.bits() |
Self::HCK_PARTIALCKSUM.bits() | Self::HCK_FULLCKSUM.bits() |
Self::HCK_FULLCKSUM_OK.bits() | Self::HCK_INNER_V4CKSUM.bits() |
Self::HCK_INNER_V4CKSUM_OK.bits() | Self::HCK_INNER_PARTIAL.bits() |
Self::HCK_INNER_FULL.bits() | Self::HCK_INNER_FULL_OK.bits();

const HCK_TX_FLAGS = Self::HCK_IPV4_HDRCKSUM.bits() |
Self::HCK_PARTIALCKSUM.bits() | Self::HCK_FULLCKSUM.bits() |
Self::HCK_INNER_V4CKSUM.bits() | Self::HCK_INNER_PARTIAL.bits() |
Self::HCK_INNER_FULL.bits();

const HCK_OUTER_TX_FLAGS = Self::HCK_IPV4_HDRCKSUM.bits() |
Self::HCK_PARTIALCKSUM.bits() | Self::HCK_FULLCKSUM.bits();

const HCK_OUTER_FLAGS = Self::HCK_OUTER_TX_FLAGS.bits() |
Self::HCK_IPV4_HDRCKSUM_OK.bits() | Self::HCK_FULLCKSUM_OK.bits();

const HCK_INNER_TX_FLAGS = Self::HCK_INNER_V4CKSUM.bits() |
Self::HCK_INNER_PARTIAL.bits() | Self::HCK_INNER_FULL.bits();

const HCK_INNER_FLAGS = Self::HCK_INNER_TX_FLAGS.bits() |
Self::HCK_INNER_V4CKSUM_OK.bits() | Self::HCK_INNER_FULL_OK.bits();

const HW_LSO_FLAGS = Self::HW_LSO.bits();
}
}

impl MblkOffloadFlags {
/// Move any outer offload flags to the inner layer, as part of
/// encapsulation.
pub fn shift_in(self) -> Self {
let mut out =
self.difference(Self::HCK_INNER_FLAGS.union(Self::HCK_OUTER_FLAGS));

if self.contains(Self::HCK_IPV4_HDRCKSUM) {
out |= Self::HCK_INNER_V4CKSUM;
}

if self.contains(Self::HCK_PARTIALCKSUM) {
out |= Self::HCK_INNER_PARTIAL;
}

if self.contains(Self::HCK_FULLCKSUM) {
out |= Self::HCK_INNER_FULL;
}

if self.contains(Self::HCK_FULLCKSUM_OK) {
out |= Self::HCK_INNER_FULL_OK;
}

out
}
}
2 changes: 1 addition & 1 deletion lib/opte/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ opte-api.workspace = true

ingot.workspace = true

bitflags.workspace = true
bitflags = { workspace = true , features = ["serde"] }
cfg-if.workspace = true
crc32fast = { workspace = true, optional = true }
dyn-clone.workspace = true
Expand Down
Loading