From patchwork Wed Oct 19 14:15:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 118577 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 DD9F9A06C8; Wed, 19 Oct 2022 16:15:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 913B742BDE; Wed, 19 Oct 2022 16:15:31 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B94FA410D1 for ; Wed, 19 Oct 2022 16:15:29 +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 29JC0JSh011929 for ; Wed, 19 Oct 2022 07:15: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-transfer-encoding : content-type; s=pfpt0220; bh=d4xDM/ak0KYmq/wkBRJtgqCeCztMJGRKFAs36cuSSyg=; b=TKFm26aU3WB+nO0Lbh261MyUWuGk/gR6LMAb+0HRAAlXHH6JJlyePr3OAxHp3Xu4Z+MS dNDk3wd+5RwvmVjuAFYNyK2e6Fi23ghV6TygUBmsx7mhEicDaL1al8Cd59cZFlpt9g4y lDBM6wv/vva+5wV6lLww8aJJf9KuiX2JmfeORglVPaNe58182kxLlnPchI1fpd/tkZEz l/wPNrj9WKFcGLUrULDDl+kFypPziF+b7ZO0joR4qHispciA03nzemd2dAJ2f9pY2l9g oomNAIyLdI5Bqxeg4C9FPif/b0HZ03QZbjOJyeFTnMPrl1cf9iJpgBFk5K5axDiu0bds 2g== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3k7vcph6ba-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 19 Oct 2022 07:15:29 -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; Wed, 19 Oct 2022 07:15:26 -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; Wed, 19 Oct 2022 07:15:26 -0700 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id 3146B3F7041; Wed, 19 Oct 2022 07:15:24 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal CC: Vidya Sagar Velumuri , Anoob Joseph , Subject: [PATCH 05/13] common/cnxk: support custom UDP port values Date: Wed, 19 Oct 2022 19:45:05 +0530 Message-ID: <20221019141513.1969052-6-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019141513.1969052-1-ktejasree@marvell.com> References: <20221019141513.1969052-1-ktejasree@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: a25hpcUIzv8567nsyMHnB5_u5WivE89H X-Proofpoint-GUID: a25hpcUIzv8567nsyMHnB5_u5WivE89H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-19_08,2022-10-19_03,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 From: Vidya Sagar Velumuri Add support for custom port values for UDP encapsulation Signed-off-by: Vidya Sagar Velumuri --- drivers/common/cnxk/cnxk_security.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/common/cnxk/cnxk_security.c b/drivers/common/cnxk/cnxk_security.c index f8bdeabeac..f220d2577f 100644 --- a/drivers/common/cnxk/cnxk_security.c +++ b/drivers/common/cnxk/cnxk_security.c @@ -1219,6 +1219,7 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec, struct rte_ipv6_hdr *ip6; struct rte_ipv4_hdr *ip4; const uint8_t *auth_key; + uint16_t sport, dport; int auth_key_len = 0; size_t ctx_len; int ret; @@ -1266,10 +1267,20 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec, } ip4 = (struct rte_ipv4_hdr *)&template->ip4.ipv4_hdr; + /* If custom port values are provided, Overwrite default port values. */ if (ipsec->options.udp_encap) { + sport = 4500; + dport = 4500; + + if (ipsec->udp.sport) + sport = ipsec->udp.sport; + + if (ipsec->udp.dport) + dport = ipsec->udp.dport; + ip4->next_proto_id = IPPROTO_UDP; - template->ip4.udp_src = rte_be_to_cpu_16(4500); - template->ip4.udp_dst = rte_be_to_cpu_16(4500); + template->ip4.udp_src = rte_be_to_cpu_16(sport); + template->ip4.udp_dst = rte_be_to_cpu_16(dport); } else { if (ipsec->proto == RTE_SECURITY_IPSEC_SA_PROTO_AH) ip4->next_proto_id = IPPROTO_AH; @@ -1303,13 +1314,12 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec, ip6 = (struct rte_ipv6_hdr *)&template->ip6.ipv6_hdr; if (ipsec->options.udp_encap) { ip6->proto = IPPROTO_UDP; - template->ip6.udp_src = rte_be_to_cpu_16(4500); - template->ip6.udp_dst = rte_be_to_cpu_16(4500); + template->ip6.udp_src = rte_be_to_cpu_16(sport); + template->ip6.udp_dst = rte_be_to_cpu_16(dport); } else { - ip6->proto = (ipsec->proto == - RTE_SECURITY_IPSEC_SA_PROTO_ESP) ? - IPPROTO_ESP : - IPPROTO_AH; + ip6->proto = (ipsec->proto == RTE_SECURITY_IPSEC_SA_PROTO_ESP) ? + IPPROTO_ESP : + IPPROTO_AH; } ip6->vtc_flow = rte_cpu_to_be_32(0x60000000 |