DPDK patches and discussions
 help / color / mirror / Atom feed
From: Radu Nicolau <radu.nicolau@intel.com>
To: Radu Nicolau <radu.nicolau@intel.com>, Akhil Goyal <gakhil@marvell.com>
Cc: dev@dpdk.org, roy.fan.zhang@intel.com,
	vladimir.medvedkin@intel.com, ndabilpuram@marvell.com
Subject: [PATCH v2] examples/ipsec-secgw: fix Tx checksum offload flag
Date: Wed, 29 Jun 2022 17:46:07 +0100	[thread overview]
Message-ID: <20220629164607.2317125-1-radu.nicolau@intel.com> (raw)
In-Reply-To: <20220622092808.1952992-1-radu.nicolau@intel.com>

For the inline crypto path set the Tx checksum offload flag
only if the device supports it.

Fixes: d24471e5786b ("examples/ipsec-secgw: disable Tx checksum for inline")
Cc: ndabilpuram@marvell.com

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
---
v2: when supported the checksum offload flag needs to also be set for ports that don't have SAs programmed

 examples/ipsec-secgw/sa.c | 44 ++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 5d9cec97db..b364ac5881 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1828,37 +1828,43 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,
 	for (idx_sa = 0; idx_sa < nb_sa_out; idx_sa++) {
 		rule = &sa_out[idx_sa];
 		rule_type = ipsec_get_action_type(rule);
-		switch (rule_type) {
-		case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
-			/* Checksum offload is not needed for inline protocol as
-			 * all processing for Outbound IPSec packets will be
-			 * implicitly taken care and for non-IPSec packets,
-			 * there is no need of IPv4 Checksum offload.
-			 */
-			if (rule->portid == port_id) {
+		if (rule->portid == port_id) {
+			switch (rule_type) {
+			case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
+				/* Checksum offload is not needed for inline
+				 * protocol as all processing for Outbound IPSec
+				 * packets will be implicitly taken care and for
+				 * non-IPSec packets, there is no need of
+				 * IPv4 Checksum offload.
+				 */
 				*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
 				if (rule->mss)
 					*tx_offloads |= (RTE_ETH_TX_OFFLOAD_TCP_TSO |
 							 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM);
-			}
-			break;
-		case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
-			if (rule->portid == port_id) {
+				break;
+			case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
 				*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
 				if (rule->mss)
 					*tx_offloads |=
 						RTE_ETH_TX_OFFLOAD_TCP_TSO;
-				*tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+				if (dev_info.tx_offload_capa &
+						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
+					*tx_offloads |=
+						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+				break;
+			default:
+				/* Enable IPv4 checksum offload even if
+				 * one of lookaside SA's are present.
+				 */
+				if (dev_info.tx_offload_capa &
+				    RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
+					*tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+				break;
 			}
-			break;
-		default:
-			/* Enable IPv4 checksum offload even if one of lookaside
-			 * SA's are present.
-			 */
+		} else {
 			if (dev_info.tx_offload_capa &
 			    RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
 				*tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
-			break;
 		}
 	}
 	return 0;
-- 
2.25.1


  parent reply	other threads:[~2022-06-29 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  9:28 [PATCH] " Radu Nicolau
2022-06-22  9:46 ` Zhang, Roy Fan
2022-06-28  8:36   ` Akhil Goyal
2022-06-29 16:46 ` Radu Nicolau [this message]
2022-06-30  5:01   ` [EXT] [PATCH v2] " Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220629164607.2317125-1-radu.nicolau@intel.com \
    --to=radu.nicolau@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).