[2/4] app/testpmd: support UFO in checksum engine
Checks
Commit Message
This commit supports UFO for both non-tunnel and tunneled packets.
Similar to TSO, the command "tso set <tso_segsz> <port_id>" or
"tunnel_tso set <tso_segsz> <port_id>" is used to enable UFO,
and the following conditions need to be met:
a. The NIC supports UFO;
b. For enabling UFO in tunnel packets, "csum parse_tunnel" must be set to
recognize tunnel packets;
c. For IPv4 tunnel packets, "csum set outer-ip" must be set to hw, because
UFO changes the total_len of the external IP header and the checksum
calculated by SW becomes incorrect; This is not necessary for IPv6
tunnel packets since there's no checksum field to fill in.
Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
app/test-pmd/csumonly.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
Comments
On 4/13/2023 11:04 AM, Zhichao Zeng wrote:
> This commit supports UFO for both non-tunnel and tunneled packets.
>
> Similar to TSO, the command "tso set <tso_segsz> <port_id>" or
> "tunnel_tso set <tso_segsz> <port_id>" is used to enable UFO,
> and the following conditions need to be met:
> a. The NIC supports UFO;
> b. For enabling UFO in tunnel packets, "csum parse_tunnel" must be set to
> recognize tunnel packets;
> c. For IPv4 tunnel packets, "csum set outer-ip" must be set to hw, because
> UFO changes the total_len of the external IP header and the checksum
> calculated by SW becomes incorrect; This is not necessary for IPv6
> tunnel packets since there's no checksum field to fill in.
>
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
<snip>
@@ -505,7 +505,9 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
udp_hdr = (struct rte_udp_hdr *)((char *)l3_hdr + info->l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
- if (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) {
+ if (tso_segsz)
+ ol_flags |= RTE_MBUF_F_TX_UDP_SEG;
+ else if (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) {
ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM;
} else {
if (info->is_tunnel)
@@ -590,8 +592,10 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info,
udp_hdr = (struct rte_udp_hdr *)
((char *)outer_l3_hdr + info->outer_l3_len);
- if (tso_enabled)
+ if (tso_enabled && info->l4_proto == IPPROTO_TCP)
ol_flags |= RTE_MBUF_F_TX_TCP_SEG;
+ else if (tso_enabled && info->l4_proto == IPPROTO_UDP)
+ ol_flags |= RTE_MBUF_F_TX_UDP_SEG;
/* Skip SW outer UDP checksum generation if HW supports it */
if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) {
@@ -991,7 +995,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (info.is_tunnel == 1) {
tx_ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
tx_offloads,
- !!(tx_ol_flags & RTE_MBUF_F_TX_TCP_SEG),
+ !!(tx_ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
+ RTE_MBUF_F_TX_UDP_SEG)),
m);
}
@@ -1083,11 +1088,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
m->outer_l2_len,
m->outer_l3_len);
if (info.tunnel_tso_segsz != 0 &&
- (m->ol_flags & RTE_MBUF_F_TX_TCP_SEG))
+ (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
+ RTE_MBUF_F_TX_UDP_SEG)))
printf("tx: m->tso_segsz=%d\n",
m->tso_segsz);
} else if (info.tso_segsz != 0 &&
- (m->ol_flags & RTE_MBUF_F_TX_TCP_SEG))
+ (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
+ RTE_MBUF_F_TX_UDP_SEG)))
printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
printf("tx: flags=%s", buf);