Skip to content

Commit

Permalink
Planning progress
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-noland committed Nov 30, 2024
1 parent 86a2944 commit d507ea4
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 64 deletions.
141 changes: 83 additions & 58 deletions dpdk/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,31 +387,55 @@ impl From<TxOffloadConfig> for TxOffload {
use wrte_eth_tx_offload::*;
TxOffload(
if value.geneve_tnl_tso {
GENEVE_TNL_TSO
TX_OFFLOAD_GENEVE_TNL_TSO
} else {
0
} | if value.gre_tnl_tso { GRE_TNL_TSO } else { 0 }
| if value.ipip_tnl_tso { IPIP_TNL_TSO } else { 0 }
| if value.ipv4_cksum { IPV4_CKSUM } else { 0 }
| if value.macsec_insert {
MACSEC_INSERT
} | if value.gre_tnl_tso {
TX_OFFLOAD_GRE_TNL_TSO
} else {
0
} | if value.ipip_tnl_tso {
TX_OFFLOAD_IPIP_TNL_TSO
} else {
0
} | if value.ipv4_cksum {
TX_OFFLOAD_IPV4_CKSUM
} else {
0
} | if value.macsec_insert {
TX_OFFLOAD_MACSEC_INSERT
} else {
0
} | if value.outer_ipv4_cksum {
TX_OFFLOAD_OUTER_IPV4_CKSUM
} else {
0
} | if value.qinq_insert {
TX_OFFLOAD_QINQ_INSERT
} else {
0
} | if value.sctp_cksum {
TX_OFFLOAD_SCTP_CKSUM
} else {
0
} | if value.tcp_cksum {
TX_OFFLOAD_TCP_CKSUM
} else {
0
} | if value.tcp_tso { TX_OFFLOAD_TCP_TSO } else { 0 }
| if value.udp_cksum {
TX_OFFLOAD_UDP_CKSUM
} else {
0
}
| if value.outer_ipv4_cksum {
OUTER_IPV4_CKSUM
| if value.udp_tso { TX_OFFLOAD_UDP_TSO } else { 0 }
| if value.vlan_insert {
TX_OFFLOAD_VLAN_INSERT
} else {
0
}
| if value.qinq_insert { QINQ_INSERT } else { 0 }
| if value.sctp_cksum { SCTP_CKSUM } else { 0 }
| if value.tcp_cksum { TCP_CKSUM } else { 0 }
| if value.tcp_tso { TCP_TSO } else { 0 }
| if value.udp_cksum { UDP_CKSUM } else { 0 }
| if value.udp_tso { UDP_TSO } else { 0 }
| if value.vlan_insert { VLAN_INSERT } else { 0 }
| if value.vxlan_tnl_tso {
VXLAN_TNL_TSO
TX_OFFLOAD_VXLAN_TNL_TSO
} else {
0
}
Expand All @@ -424,73 +448,74 @@ impl From<TxOffload> for TxOffloadConfig {
fn from(value: TxOffload) -> Self {
use wrte_eth_tx_offload::*;
TxOffloadConfig {
geneve_tnl_tso: value.0 & GENEVE_TNL_TSO != 0,
gre_tnl_tso: value.0 & GRE_TNL_TSO != 0,
ipip_tnl_tso: value.0 & IPIP_TNL_TSO != 0,
ipv4_cksum: value.0 & IPV4_CKSUM != 0,
macsec_insert: value.0 & MACSEC_INSERT != 0,
outer_ipv4_cksum: value.0 & OUTER_IPV4_CKSUM != 0,
qinq_insert: value.0 & QINQ_INSERT != 0,
sctp_cksum: value.0 & SCTP_CKSUM != 0,
tcp_cksum: value.0 & TCP_CKSUM != 0,
tcp_tso: value.0 & TCP_TSO != 0,
udp_cksum: value.0 & UDP_CKSUM != 0,
udp_tso: value.0 & UDP_TSO != 0,
vlan_insert: value.0 & VLAN_INSERT != 0,
vxlan_tnl_tso: value.0 & VXLAN_TNL_TSO != 0,
geneve_tnl_tso: value.0 & TX_OFFLOAD_GENEVE_TNL_TSO != 0,
gre_tnl_tso: value.0 & TX_OFFLOAD_GRE_TNL_TSO != 0,
ipip_tnl_tso: value.0 & TX_OFFLOAD_IPIP_TNL_TSO != 0,
ipv4_cksum: value.0 & TX_OFFLOAD_IPV4_CKSUM != 0,
macsec_insert: value.0 & TX_OFFLOAD_MACSEC_INSERT != 0,
outer_ipv4_cksum: value.0 & TX_OFFLOAD_OUTER_IPV4_CKSUM != 0,
qinq_insert: value.0 & TX_OFFLOAD_QINQ_INSERT != 0,
sctp_cksum: value.0 & TX_OFFLOAD_SCTP_CKSUM != 0,
tcp_cksum: value.0 & TX_OFFLOAD_TCP_CKSUM != 0,
tcp_tso: value.0 & TX_OFFLOAD_TCP_TSO != 0,
udp_cksum: value.0 & TX_OFFLOAD_UDP_CKSUM != 0,
udp_tso: value.0 & TX_OFFLOAD_UDP_TSO != 0,
vlan_insert: value.0 & TX_OFFLOAD_VLAN_INSERT != 0,
vxlan_tnl_tso: value.0 & TX_OFFLOAD_VXLAN_TNL_TSO != 0,
unknown: value.0 & !TxOffload::ALL_KNOWN.0,
}
}
}

impl TxOffload {
/// GENEVE tunnel segmentation offload.
pub const GENEVE_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::GENEVE_TNL_TSO);
pub const GENEVE_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_GENEVE_TNL_TSO);
/// GRE tunnel segmentation offload.
pub const GRE_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::GRE_TNL_TSO);
pub const GRE_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_GRE_TNL_TSO);
/// IPIP tunnel segmentation offload.
pub const IPIP_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::IPIP_TNL_TSO);
pub const IPIP_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_IPIP_TNL_TSO);
/// IPv4 checksum calculation.
pub const IPV4_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::IPV4_CKSUM);
pub const IPV4_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_IPV4_CKSUM);
/// MACsec insertion.
pub const MACSEC_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::MACSEC_INSERT);
pub const MACSEC_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_MACSEC_INSERT);
/// Outer IPv4 checksum calculation.
pub const OUTER_IPV4_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::OUTER_IPV4_CKSUM);
pub const OUTER_IPV4_CKSUM: TxOffload =
TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_OUTER_IPV4_CKSUM);
/// QinQ (double VLAN) insertion.
pub const QINQ_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::QINQ_INSERT);
pub const QINQ_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_QINQ_INSERT);
/// SCTP checksum calculation.
pub const SCTP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::SCTP_CKSUM);
pub const SCTP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_SCTP_CKSUM);
/// TCP checksum calculation.
pub const TCP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::TCP_CKSUM);
pub const TCP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_TCP_CKSUM);
/// TCP segmentation offload.
pub const TCP_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TCP_TSO);
pub const TCP_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_TCP_TSO);
/// UDP checksum calculation.
pub const UDP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::UDP_CKSUM);
pub const UDP_CKSUM: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_UDP_CKSUM);
/// UDP segmentation offload.
pub const UDP_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::UDP_TSO);
pub const UDP_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_UDP_TSO);
/// VXLAN tunnel segmentation offload.
pub const VXLAN_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::VXLAN_TNL_TSO);
pub const VXLAN_TNL_TSO: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_VXLAN_TNL_TSO);
/// VLAN tag insertion.
pub const VLAN_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::VLAN_INSERT);
pub const VLAN_INSERT: TxOffload = TxOffload(wrte_eth_tx_offload::TX_OFFLOAD_VLAN_INSERT);

/// Union of all [`TxOffload`]s documented at the time of writing.
pub const ALL_KNOWN: TxOffload = {
use wrte_eth_tx_offload::*;
TxOffload(
GENEVE_TNL_TSO
| GRE_TNL_TSO
| IPIP_TNL_TSO
| IPV4_CKSUM
| MACSEC_INSERT
| OUTER_IPV4_CKSUM
| QINQ_INSERT
| SCTP_CKSUM
| TCP_CKSUM
| TCP_TSO
| UDP_CKSUM
| UDP_TSO
| VLAN_INSERT
| VXLAN_TNL_TSO,
TX_OFFLOAD_GENEVE_TNL_TSO
| TX_OFFLOAD_GRE_TNL_TSO
| TX_OFFLOAD_IPIP_TNL_TSO
| TX_OFFLOAD_IPV4_CKSUM
| TX_OFFLOAD_MACSEC_INSERT
| TX_OFFLOAD_OUTER_IPV4_CKSUM
| TX_OFFLOAD_QINQ_INSERT
| TX_OFFLOAD_SCTP_CKSUM
| TX_OFFLOAD_TCP_CKSUM
| TX_OFFLOAD_TCP_TSO
| TX_OFFLOAD_UDP_CKSUM
| TX_OFFLOAD_UDP_TSO
| TX_OFFLOAD_VLAN_INSERT
| TX_OFFLOAD_VXLAN_TNL_TSO,
)
};
}
Expand Down
12 changes: 6 additions & 6 deletions scratch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ fn check_hairpin_cap(port_id: u16) {
fn init_port2(port_id: u16, mbuf_pool: &mut rte_mempool) {
let mut port_conf = rte_eth_conf {
txmode: rte_eth_txmode {
offloads: wrte_eth_tx_offload::VLAN_INSERT
| wrte_eth_tx_offload::IPV4_CKSUM
| wrte_eth_tx_offload::UDP_CKSUM
| wrte_eth_tx_offload::TCP_CKSUM
| wrte_eth_tx_offload::SCTP_CKSUM
| wrte_eth_tx_offload::TCP_TSO,
offloads: wrte_eth_tx_offload::TX_OFFLOAD_VLAN_INSERT
| wrte_eth_tx_offload::TX_OFFLOAD_IPV4_CKSUM
| wrte_eth_tx_offload::TX_OFFLOAD_UDP_CKSUM
| wrte_eth_tx_offload::TX_OFFLOAD_TCP_CKSUM
| wrte_eth_tx_offload::TX_OFFLOAD_SCTP_CKSUM
| wrte_eth_tx_offload::TX_OFFLOAD_TCP_TSO,
..Default::default()
},
..Default::default()
Expand Down

0 comments on commit d507ea4

Please sign in to comment.