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;