From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6D1BA00C2 for ; Thu, 8 Dec 2022 14:46:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 92B5740E28; Thu, 8 Dec 2022 14:46:53 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 88AA540A7E for ; Thu, 8 Dec 2022 14:46:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670507211; x=1702043211; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rhe9An9JCmUz57CNrrE+CuPfxRIN/HiTL9Gk7ti5wyw=; b=PaSGYMM3iUhd2cTNtmLvTQCZISI3U+EGboFvmK9fHz9jz1T0PlMnzN31 cT3KbyRJrvXSjouVJgh7d/K0emwhb/n9GEH7Bxkl6KfQChckPr2t+RHnH 9o++zmTSWZABrJYjd8rgysKk6HtBOpqUOtkKlJ1KHJrZlrkRzvmt+YmaR hk2LcDevtAOBSVb7VixqtHvXqGUD96HQMHaeggOtCw1mTSy05nbZddIti Yi1YE+aTil5RetVTFLBUykthOLiWKOhuctuG+rwdngLI3jjJdWlSu7/cK QMhxXUhpV5FMjlxeSnrlQnXUL0lXHI/jqvvJ03tm6p74HJtgOH0F8IXuK w==; X-IronPort-AV: E=McAfee;i="6500,9779,10554"; a="296861263" X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="296861263" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 05:46:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10554"; a="679534186" X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="679534186" Received: from silpixa00400884.ir.intel.com ([10.243.22.82]) by orsmga001.jf.intel.com with ESMTP; 08 Dec 2022 05:46:48 -0800 From: Radu Nicolau To: stable@dpdk.org Cc: Radu Nicolau , ndabilpuram@marvell.com, Fan Zhang , Akhil Goyal Subject: [PATCH 20.11] examples/ipsec-secgw: fix Tx checksum offload flag Date: Thu, 8 Dec 2022 13:46:45 +0000 Message-Id: <20221208134645.513070-1-radu.nicolau@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ 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 Acked-by: Fan Zhang Acked-by: Akhil Goyal --- 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