From patchwork Thu Jul 7 07:29:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 113775 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3CB32A0540; Thu, 7 Jul 2022 09:29:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D228840A7B; Thu, 7 Jul 2022 09:29:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 0E904406B4 for ; Thu, 7 Jul 2022 09:29:30 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 266NFQSh008098; Thu, 7 Jul 2022 00:29:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=gJpELI0IdRCt9/s3u2ItLNxsdVuHkEGaG3TkLMzqkvA=; b=GI0RiDHVc5Twww6xbhYr2pC98/TqCnMeQWHp43+5c55QGrHWHBKUlYz5PKU3dFJvd1F+ UmbwOYgX+NBc25Q2ov+4l7eWWNioOH6hawzlVbGcVLuj6K2pjZNgZM9rCS+Rg2uecu4Q 9YUxD2iOnppt33OrpeWNIs4P+Rg68kFSxyTtZ1gUAYjsIjDtCzBjD1FSzxqOyQW1QSF/ xxAMX7RwqdyGPfr49lyM5dZcNIhnX2SIBp8Ufy2dgpizDYhnujaYhwcnkYyZ32MyEVTF sirUVP7BOvIpqAFPUtdeF0G4mlJxlS+nZo/WlI+muYGNhJQIrhI+W2WDqTdH3w//IlTT nw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h5kwj1g3y-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 07 Jul 2022 00:29:28 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 7 Jul 2022 00:29:27 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 7 Jul 2022 00:29:27 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id A0FEF3F7061; Thu, 7 Jul 2022 00:29:25 -0700 (PDT) From: Nithin Dabilpuram To: Olivier Matz CC: , , , "Nithin Dabilpuram" Subject: [PATCH 1/4] mbuf: clarify meta data needed for Outbound Inline Date: Thu, 7 Jul 2022 12:59:17 +0530 Message-ID: <20220707072921.13448-1-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: YiG0U1eSLbNbGbMnjyzgZrfvg9wV7cc7 X-Proofpoint-GUID: YiG0U1eSLbNbGbMnjyzgZrfvg9wV7cc7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-07_05,2022-06-28_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Clarify mbuf meta data needed for Outbound Inline processing. Application needs to provide mbuf.l3_len and L3 type in mbuf.ol_flags so that like tunnel mode using mbuf.l2_len, transport mode can make use of l3_len and l3_type to determine perform proper transport mode IPsec processing. Signed-off-by: Nithin Dabilpuram --- doc/guides/nics/features.rst | 2 +- lib/mbuf/rte_mbuf_core.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 7f6cb91..b4a8e98 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -431,7 +431,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:RTE_ETH_TX_OFFLOAD_SECURITY``. -* **[uses] mbuf**: ``mbuf.l2_len``. +* **[uses] mbuf**: ``mbuf.l2_len``, ``mbuf.l3_len``, ``mbuf.ol_flags``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``. diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h index 3d6ddd6..b62a7c6 100644 --- a/lib/mbuf/rte_mbuf_core.h +++ b/lib/mbuf/rte_mbuf_core.h @@ -267,7 +267,8 @@ extern "C" { /** * Request security offload processing on the TX packet. * To use Tx security offload, the user needs to fill l2_len in mbuf - * indicating L2 header size and where L3 header starts. + * indicating L2 header size and where L3 header starts. Similarly, + * l3_len should also be filled along with ol_flags reflecting current L3 type. */ #define RTE_MBUF_F_TX_SEC_OFFLOAD (1ULL << 43) #define PKT_TX_SEC_OFFLOAD RTE_DEPRECATED(PKT_TX_SEC_OFFLOAD) \ From patchwork Thu Jul 7 07:29:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 113776 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C6D0DA0540; Thu, 7 Jul 2022 09:29:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9026427F0; Thu, 7 Jul 2022 09:29:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 614E8406B4 for ; Thu, 7 Jul 2022 09:29:32 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2677JHFO011071 for ; Thu, 7 Jul 2022 00:29:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=j41rwEB4PnLBYm8i7mVw3nMl2TxAX/xGaP4fUzm1S14=; b=kqGkSOUr0bVQ6UdPlOaHU7WEM8LJ7dv/7KKeTqeqnQPvcWgFGxUHWDMciKbfq89nbaap nT84NlSuJGTQF5SBadv/f5kY0AHN9KrNPTX2kV8yfgakMDSnlRiEavwAmixzqc4PGXGO X69D1CoZP+oGpDObV6bxvlmS1yQKUH1L/UwmRa4Ztii9t2cObzgq2qivm7MyyIxLlq3S nOgWxwlpjXMiqjkvnqgyGaCkYxM8uWt4wbaBDtwMxSmCCFhc+PaRV1CejWYL03GO8QrK /HoMikn0KvA0vL8IEyjvT+R1Tj1KLtgJFuyEQO49xE9E+hQBraIExjC8n9/p0/sS6aYq 5Q== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h56wt4s32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 07 Jul 2022 00:29:31 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jul 2022 00:29:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 7 Jul 2022 00:29:29 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 4836E3F7061; Thu, 7 Jul 2022 00:29:28 -0700 (PDT) From: Nithin Dabilpuram To: Akhil Goyal CC: , , Nithin Dabilpuram Subject: [PATCH 2/4] security: clarify L2 header requirement for outbound inline Date: Thu, 7 Jul 2022 12:59:18 +0530 Message-ID: <20220707072921.13448-2-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220707072921.13448-1-ndabilpuram@marvell.com> References: <20220707072921.13448-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: yiSYtBouIWPKQ79KB4HpBXyrKHtUubw- X-Proofpoint-GUID: yiSYtBouIWPKQ79KB4HpBXyrKHtUubw- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-07_05,2022-06-28_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Clarify that for Outbound Inline IPsec processing, L2 header needs to be up to date with ether type which will be applicable post IPsec processing as the IPsec offload only touches L3 and above. Signed-off-by: Nithin Dabilpuram --- doc/guides/prog_guide/rte_security.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst index 72ca0bd..be158f6 100644 --- a/doc/guides/prog_guide/rte_security.rst +++ b/doc/guides/prog_guide/rte_security.rst @@ -146,7 +146,9 @@ adding the relevant protocol headers and encrypting the data before sending the packet out. The software should make sure that the buffer has required head room and tail room for any protocol header addition. The software may also do early fragmentation if the resultant packet is expected -to cross the MTU size. +to cross the MTU size. The software should also make sure that L2 header contents +are updated with the final L2 header which is expected post IPsec processing as +the IPsec offload will only update L3 and above in egress path. .. note:: From patchwork Thu Jul 7 07:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 113777 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF7CCA0540; Thu, 7 Jul 2022 09:29:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF2824282E; Thu, 7 Jul 2022 09:29:36 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7B2434282D for ; Thu, 7 Jul 2022 09:29:35 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2677G3am004956 for ; Thu, 7 Jul 2022 00:29:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=4vDrsBbmHZ7wY3uRyP+S5uTUv9qGv2icpuU7+elJDbQ=; b=HZCPVA0F/TYr3ZThRCBEscTuF4k31vq98bTwF+8g3jAiMQRZJ9IeN0UXWzhKwBripe+l 51m6lXInH/NR1F1kjDSgL9BkFwzGSeSjeDvNeyPQ2SvnVQL9GMYWbsZwlRSl31NlwoGv FPbyZ+DWN6FeKqLPQxq8pM7wM8E0dP7Wa0qKSyW4rgKTxGY5Fbd2hIHXgCHv9lzzdFcH f03e9kVHQxqKfItNHJxl0TqLZdMn2p3Fvgcdl6Dyno9WsViEnN/Qnoe42Eczrs7L/ulo /L6beCQFp6+hLB513XzOxaFqDuddYbKnyfeYAfGgEiNrSCa33ICs1ZtMIph/ZuIPUD3l 1w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h56wt4s3c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 07 Jul 2022 00:29:34 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jul 2022 00:29:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 7 Jul 2022 00:29:32 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 9BBA93F706B; Thu, 7 Jul 2022 00:29:30 -0700 (PDT) From: Nithin Dabilpuram To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , , Subject: [PATCH 3/4] net/cnxk: remove l2 header update for outbound inline pkts Date: Thu, 7 Jul 2022 12:59:19 +0530 Message-ID: <20220707072921.13448-3-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220707072921.13448-1-ndabilpuram@marvell.com> References: <20220707072921.13448-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dYEHyg6bYdCTc-zHh6oukLRfPg3FEdY7 X-Proofpoint-GUID: dYEHyg6bYdCTc-zHh6oukLRfPg3FEdY7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-07_05,2022-06-28_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove L2 header update for outbound inline packets as application is already taking care of the same. Signed-off-by: Nithin Dabilpuram --- drivers/net/cnxk/cn10k_tx.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h index ea13866..4bd47ef 100644 --- a/drivers/net/cnxk/cn10k_tx.h +++ b/drivers/net/cnxk/cn10k_tx.h @@ -362,15 +362,6 @@ cn10k_nix_prep_sec_vec(struct rte_mbuf *m, uint64x2_t *cmd0, uint64x2_t *cmd1, dptr += l2_len; - if (sess_priv.mode == ROC_IE_SA_MODE_TUNNEL) { - if (sess_priv.outer_ip_ver == ROC_IE_SA_IP_VERSION_4) - *((uint16_t *)(dptr - 2)) = - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); - else - *((uint16_t *)(dptr - 2)) = - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - } - ucode_cmd[1] = dptr; ucode_cmd[2] = dptr; @@ -490,14 +481,6 @@ cn10k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr, dptr += l2_len; - if (sess_priv.mode == ROC_IE_SA_MODE_TUNNEL) { - if (sess_priv.outer_ip_ver == ROC_IE_SA_IP_VERSION_4) - *((uint16_t *)(dptr - 2)) = - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); - else - *((uint16_t *)(dptr - 2)) = - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - } ucode_cmd[1] = dptr; ucode_cmd[2] = dptr; From patchwork Thu Jul 7 07:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 113778 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B8B1A0540; Thu, 7 Jul 2022 09:29:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A833342905; Thu, 7 Jul 2022 09:29:38 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 045514284D for ; Thu, 7 Jul 2022 09:29:37 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2677GK58005237 for ; Thu, 7 Jul 2022 00:29:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=QFt/vXh6TrUXg0zQJsNAXmzYTUm/TyzqmCtSkmCwwnU=; b=b+gWi8hFtHgc8ZwuKFcICi4QSCqpsV/9BBa3gyWZm8o2q2CQaJ1Nj02ylN1kbPMoSGKD 1VIcw/krHHM6/fEKj47KblamSPFRu8xL/NCYzCzVKVeLk5CbjgoZR+x5LQYG214PbX44 L3LV5xR6kghdUgvj5SuXdQacny07Br87GsIPoKxNlCUIxSvcLXZx3JpCJtJhy8dSfKSr GZ5CXylACa/rs8gzSHj68tisOQYAhA3iu1qpzGwVq4fPuRQByP6WTPo5j3qlDjkVcvtW 6xCXemMymOlMZD6YLnZp9Efrb8d++qhRJxGWb6CM87QPHI06Q4GopyAkgrxa7eVvk2at Jw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h56wt4s3j-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 07 Jul 2022 00:29:37 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jul 2022 00:29:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 7 Jul 2022 00:29:35 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id BE42D3F7061; Thu, 7 Jul 2022 00:29:33 -0700 (PDT) From: Nithin Dabilpuram To: Akhil Goyal CC: , , Nithin Dabilpuram Subject: [PATCH 4/4] app/test: update l2 header based on tunnel ip version Date: Thu, 7 Jul 2022 12:59:20 +0530 Message-ID: <20220707072921.13448-4-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220707072921.13448-1-ndabilpuram@marvell.com> References: <20220707072921.13448-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: vePO7yq8xp60YKM2Xv18RnnJUPol1bCp X-Proofpoint-GUID: vePO7yq8xp60YKM2Xv18RnnJUPol1bCp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-07_05,2022-06-28_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update l2 header based on tunnel ip version. Signed-off-by: Nithin Dabilpuram --- app/test/test_security_inline_proto.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c index 5f26a04..b282e7d 100644 --- a/app/test/test_security_inline_proto.c +++ b/app/test/test_security_inline_proto.c @@ -418,15 +418,29 @@ copy_buf_to_pkt_segs(const uint8_t *buf, unsigned int len, rte_memcpy(seg_buf, buf + copied, (size_t) len); } +static bool +is_outer_ipv4(struct ipsec_test_data *td) +{ + bool outer_ipv4; + + if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS || + td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT) + outer_ipv4 = (((td->input_text.data[0] & 0xF0) >> 4) == IPVERSION); + else + outer_ipv4 = (td->ipsec_xform.tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV4); + return outer_ipv4; +} + static inline struct rte_mbuf * -init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len) +init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool outer_ipv4) { struct rte_mbuf *pkt; pkt = rte_pktmbuf_alloc(mp); if (pkt == NULL) return NULL; - if (((data[0] & 0xF0) >> 4) == IPVERSION) { + + if (outer_ipv4) { rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN), &dummy_ipv4_eth_hdr, RTE_ETHER_HDR_LEN); pkt->l3_len = sizeof(struct rte_ipv4_hdr); @@ -711,6 +725,7 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector, struct rte_security_ctx *ctx; unsigned int i, nb_rx = 0, j; uint32_t ol_flags; + bool outer_ipv4; int ret = 0; burst_sz = vector->burst ? ENCAP_DECAP_BURST_SZ : 1; @@ -740,11 +755,15 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector, memset(tx_pkts_burst, 0, sizeof(tx_pkts_burst[0]) * nb_tx); memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_tx); + memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data)); + sa_data.ipsec_xform.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS; + outer_ipv4 = is_outer_ipv4(&sa_data); + for (i = 0; i < nb_tx; i += vector->nb_frags) { for (j = 0; j < vector->nb_frags; j++) { tx_pkts_burst[i+j] = init_packet(mbufpool, vector->frags[j]->data, - vector->frags[j]->len); + vector->frags[j]->len, outer_ipv4); if (tx_pkts_burst[i+j] == NULL) { ret = -1; printf("\n packed init failed\n"); @@ -963,6 +982,7 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, int nb_rx = 0, nb_sent; uint32_t ol_flags; int i, j = 0, ret; + bool outer_ipv4; memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_pkts); @@ -994,9 +1014,11 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, if (ret) goto out; } + outer_ipv4 = is_outer_ipv4(td); + for (i = 0; i < nb_pkts; i++) { tx_pkts_burst[i] = init_packet(mbufpool, td->input_text.data, - td->input_text.len); + td->input_text.len, outer_ipv4); if (tx_pkts_burst[i] == NULL) { while (i--) rte_pktmbuf_free(tx_pkts_burst[i]); @@ -1194,6 +1216,7 @@ test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[], struct rte_security_session *ses; struct rte_security_ctx *ctx; uint32_t ol_flags; + bool outer_ipv4; int i, ret; if (td[0].aead) { @@ -1224,10 +1247,11 @@ test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[], if (ret) goto out; } + outer_ipv4 = is_outer_ipv4(td); for (i = 0; i < nb_pkts; i++) { tx_pkt = init_packet(mbufpool, td[i].input_text.data, - td[i].input_text.len); + td[i].input_text.len, outer_ipv4); if (tx_pkt == NULL) { ret = TEST_FAILED; goto out;