patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 21.11] examples/ipsec-secgw: fix Tx checksum offload flag
@ 2022-12-08 10:44 Radu Nicolau
  2022-12-09 11:25 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Radu Nicolau @ 2022-12-08 10:44 UTC (permalink / raw)
  To: stable; +Cc: Radu Nicolau, Fan Zhang, Akhil Goyal

[ upstream commit 65bd9c7abc255ec2ce084d9f28e29c395e205402 ]

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

Fixes: 4edcee19fc20 ("examples/ipsec-secgw: use Tx checksum offload conditionally")

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>
---
 examples/ipsec-secgw/sa.c | 52 +++++++++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 89131f71e5..2f8b9bce27 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1773,10 +1773,18 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,
 	struct ipsec_sa *rule;
 	uint32_t idx_sa;
 	enum rte_security_session_action_type rule_type;
+	struct rte_eth_dev_info dev_info;
+	int ret;
 
 	*rx_offloads = 0;
 	*tx_offloads = 0;
 
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		rte_exit(EXIT_FAILURE,
+			"Error during getting device (port %u) info: %s\n",
+			port_id, strerror(-ret));
+
 	/* Check for inbound rules that use offloads and use this port */
 	for (idx_sa = 0; idx_sa < nb_sa_in; idx_sa++) {
 		rule = &sa_in[idx_sa];
@@ -1792,13 +1800,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);
-		if ((rule_type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				rule_type ==
-				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL)
-				&& rule->portid == port_id) {
-			*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
-			if (rule->mss)
-				*tx_offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+		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:
+				*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
+				if (rule->mss)
+					*tx_offloads |=
+						RTE_ETH_TX_OFFLOAD_TCP_TSO;
+				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;
+			}
+		} else {
+			if (dev_info.tx_offload_capa &
+			    RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
+				*tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
 		}
 	}
 	return 0;
-- 
2.25.1


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

* Re: [PATCH 21.11] examples/ipsec-secgw: fix Tx checksum offload flag
  2022-12-08 10:44 [PATCH 21.11] examples/ipsec-secgw: fix Tx checksum offload flag Radu Nicolau
@ 2022-12-09 11:25 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2022-12-09 11:25 UTC (permalink / raw)
  To: Radu Nicolau, stable; +Cc: Fan Zhang, Akhil Goyal

On 08/12/2022 10:44, Radu Nicolau wrote:
> [ upstream commit 65bd9c7abc255ec2ce084d9f28e29c395e205402 ]
> 
> For the inline crypto path set the Tx checksum offload flag
> only if the device supports it.
> 
> Fixes: 4edcee19fc20 ("examples/ipsec-secgw: use Tx checksum offload conditionally")
> 
> 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>
> ---

Applied, thanks. Note, this is not part of RC1 and at present there is 
not planned to be an RC2, so it will be relying on your dev testing and CI.


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

end of thread, other threads:[~2022-12-09 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 10:44 [PATCH 21.11] examples/ipsec-secgw: fix Tx checksum offload flag Radu Nicolau
2022-12-09 11:25 ` Kevin Traynor

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