examples/ipsec-secgw: fix Tx checksum offload flag

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

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>
This commit is contained in:
Radu Nicolau 2022-06-29 17:46:07 +01:00 committed by Akhil Goyal
parent 1086465695
commit 65bd9c7abc

View File

@ -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++) { for (idx_sa = 0; idx_sa < nb_sa_out; idx_sa++) {
rule = &sa_out[idx_sa]; rule = &sa_out[idx_sa];
rule_type = ipsec_get_action_type(rule); rule_type = ipsec_get_action_type(rule);
switch (rule_type) { if (rule->portid == port_id) {
case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL: switch (rule_type) {
/* Checksum offload is not needed for inline protocol as case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
* all processing for Outbound IPSec packets will be /* Checksum offload is not needed for inline
* implicitly taken care and for non-IPSec packets, * protocol as all processing for Outbound IPSec
* there is no need of IPv4 Checksum offload. * packets will be implicitly taken care and for
*/ * non-IPSec packets, there is no need of
if (rule->portid == port_id) { * IPv4 Checksum offload.
*/
*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY; *tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
if (rule->mss) if (rule->mss)
*tx_offloads |= (RTE_ETH_TX_OFFLOAD_TCP_TSO | *tx_offloads |= (RTE_ETH_TX_OFFLOAD_TCP_TSO |
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM); RTE_ETH_TX_OFFLOAD_IPV4_CKSUM);
} break;
break; case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
if (rule->portid == port_id) {
*tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY; *tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
if (rule->mss) if (rule->mss)
*tx_offloads |= *tx_offloads |=
RTE_ETH_TX_OFFLOAD_TCP_TSO; 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; } else {
default:
/* Enable IPv4 checksum offload even if one of lookaside
* SA's are present.
*/
if (dev_info.tx_offload_capa & if (dev_info.tx_offload_capa &
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
*tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM; *tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
break;
} }
} }
return 0; return 0;