DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 2/4] app/testpmd: support UFO in checksum engine
@ 2023-04-13  5:34 Zhichao Zeng
  2023-06-01 11:58 ` Singh, Aman Deep
  0 siblings, 1 reply; 2+ messages in thread
From: Zhichao Zeng @ 2023-04-13  5:34 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, ke1.xu, Zhichao Zeng, Aman Singh, Yuying Zhang

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(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fc85c22a77..062eb09b36 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-01 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  5:34 [PATCH 2/4] app/testpmd: support UFO in checksum engine Zhichao Zeng
2023-06-01 11:58 ` Singh, Aman Deep

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).