From patchwork Mon Aug 22 14:38:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 115335 X-Patchwork-Delegate: gakhil@marvell.com 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 C81B7A0540; Mon, 22 Aug 2022 16:38:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85957427F2; Mon, 22 Aug 2022 16:38:35 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 957AF427F9 for ; Mon, 22 Aug 2022 16:38:33 +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 27MDXFM3011695; Mon, 22 Aug 2022 07:38:29 -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=Rv/w2zIP7hNjKEoJr9SH/W9o4cpc8TgLllt1IYd0z1U=; b=hResOXVnYFKKsZZIrQpBPkbmkPc7e6hQDmbNUP8WGx5kHUUgOjGW0///cFQPJWc3T0kZ hxmFNHwhqEcmD8XgLZtXFEdnnJPyLVLvI2ao8vC1N/PykS0OuXrfRJsvDySA6mgzT4Xk 21qXmLdU5e8TveDntGdJK1U65o1Yd5wusIhw83+2TYYfDdeUuu9llu+ag0fNTxlcI23E a2xhceQNNkVQd5Misn7bszvinaESC7MnsUeK/ZvN2bO2v+oSSS/ocSoyMCRbSsISN98S vbP+jpwZzp8KdSHfeFK1bRhaGwd7EtT2u3zY9Z0sA1dAT96o5Qy1FDk2+BadVAL3p88t yw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3j4askg7gv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 22 Aug 2022 07:38:29 -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; Mon, 22 Aug 2022 07:38:27 -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; Mon, 22 Aug 2022 07:38:27 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 173173F7058; Mon, 22 Aug 2022 07:38:25 -0700 (PDT) From: Nithin Dabilpuram To: Akhil Goyal CC: , , , "Nithin Dabilpuram" Subject: [PATCH v3 4/5] app/test: update L2 header based on tunnel IP version Date: Mon, 22 Aug 2022 20:08:11 +0530 Message-ID: <20220822143812.30010-4-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220822143812.30010-1-ndabilpuram@marvell.com> References: <20220707072921.13448-1-ndabilpuram@marvell.com> <20220822143812.30010-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: z6UKaNkkLf1qlVYa0KmBTfAEwJxXVqHM X-Proofpoint-ORIG-GUID: z6UKaNkkLf1qlVYa0KmBTfAEwJxXVqHM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-22_08,2022-08-22_02,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 in the application as driver/HW is not expected to update L2 ether type post Outbound Inline protocol offload processing. Signed-off-by: Nithin Dabilpuram Acked-by: Akhil Goyal --- 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;