From: Radu Nicolau <radu.nicolau@intel.com>
To: stable@dpdk.org
Cc: Radu Nicolau <radu.nicolau@intel.com>,
ndabilpuram@marvell.com, Fan Zhang <roy.fan.zhang@intel.com>,
Akhil Goyal <gakhil@marvell.com>
Subject: [PATCH 20.11] examples/ipsec-secgw: fix Tx checksum offload flag
Date: Thu, 8 Dec 2022 13:46:45 +0000 [thread overview]
Message-ID: <20221208134645.513070-1-radu.nicolau@intel.com> (raw)
[ upstream commit 65bd9c7abc255ec2ce084d9f28e29c395e205402 ]
For the inline crypto path set the Tx checksum offload flag
only if the device supports it.
Fixes: 5f5d17a11498 ("examples/ipsec-secgw: use Tx checksum offload conditionally")
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>
---
examples/ipsec-secgw/sa.c | 45 ++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 34f0d8a39a..eb516ed16f 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1593,10 +1593,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];
@@ -1612,11 +1620,38 @@ 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 |= DEV_TX_OFFLOAD_SECURITY;
+ 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 |= DEV_TX_OFFLOAD_SECURITY;
+ break;
+ case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
+ *tx_offloads |= DEV_TX_OFFLOAD_SECURITY;
+ if (dev_info.tx_offload_capa &
+ DEV_TX_OFFLOAD_IPV4_CKSUM)
+ *tx_offloads |=
+ DEV_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 &
+ DEV_TX_OFFLOAD_IPV4_CKSUM)
+ *tx_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+ break;
+ }
+ } else {
+ if (dev_info.tx_offload_capa &
+ DEV_TX_OFFLOAD_IPV4_CKSUM)
+ *tx_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+ }
}
return 0;
}
--
2.25.1
next reply other threads:[~2022-12-08 13:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 13:46 Radu Nicolau [this message]
2022-12-08 16:54 ` Luca Boccassi
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=20221208134645.513070-1-radu.nicolau@intel.com \
--to=radu.nicolau@intel.com \
--cc=gakhil@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=roy.fan.zhang@intel.com \
--cc=stable@dpdk.org \
/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).