From patchwork Tue Aug 9 10:53:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 114752 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 40041A00C2; Tue, 9 Aug 2022 12:55:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4532342BE7; Tue, 9 Aug 2022 12:54:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 7A42542C0A for ; Tue, 9 Aug 2022 12:54:23 +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 2791G2gB015667 for ; Tue, 9 Aug 2022 03:54:22 -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=Lt5En0iNnf3iEtTDhzPIHZ6WpGSX/nQJAm2ATQ3LWuM=; b=DEMEDaTqBfhPv5lJcooYp8LsXfkWxxL3tvMeC4wRa8xNqEwRJ0hc4OhoDYD8E7l49oWj GP+dK0hDrq1+RG6Wc7TeTT23TO7Rdh3XKlg4TL5txujtC1TxqtBtE4lwNvJkV17GzHzO JISFpPZdpQ39XhOR2ABoRMwkiVQC9ABppzwm+w2Q/kPXtag9hlkT/bfB4cVi+NsYhHhB U5KbLCVlsINLa4Yx3o9PnnIOG2lRVrCyNs97fYYsqh2ji7fcABXrztOb0EqVwauHdjtX 08uy580obrzgKWxHqJuNVqnkFPHXekUTAqA5YdyHRclb6TGTO9totR+63S/uv/fCyLr0 vQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3huds2sq7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 09 Aug 2022 03:54:22 -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; Tue, 9 Aug 2022 03:54:20 -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; Tue, 9 Aug 2022 03:54:20 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.193.69.70]) by maili.marvell.com (Postfix) with ESMTP id 6464D5B6970; Tue, 9 Aug 2022 03:54:18 -0700 (PDT) From: Anoob Joseph To: Akhil Goyal , Jerin Jacob CC: Tejasree Kondoj , Archana Muniganti , Subject: [PATCH v2 08/18] crypto/cnxk: fix endianness in anti-replay Date: Tue, 9 Aug 2022 16:23:46 +0530 Message-ID: <20220809105356.561-9-anoobj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220809105356.561-1-anoobj@marvell.com> References: <20220808080606.220-1-anoobj@marvell.com> <20220809105356.561-1-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ZQJx-T9Humc5Vnp-1SxX6HJ4MuBe1fhr X-Proofpoint-GUID: ZQJx-T9Humc5Vnp-1SxX6HJ4MuBe1fhr 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-08-09_03,2022-08-09_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 From: Tejasree Kondoj Fixing anti-replay endianness issue in lookaside IPsec. Fixes: c1eac1b966c2 ("crypto/cnxk: add anti-replay as per new firmware") Cc: ktejasree@marvell.com Signed-off-by: Tejasree Kondoj --- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c index 3d69723809..b753c1cb4b 100644 --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c @@ -487,22 +487,19 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t base, struct rte_crypto_op *op) } static inline int -ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, - struct roc_ie_on_inb_hdr *data) +ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, struct roc_ie_on_inb_hdr *data) { + uint32_t esn_low, esn_hi, seql, seqh = 0; struct roc_ie_on_common_sa *common_sa; struct roc_ie_on_inb_sa *in_sa; - struct roc_ie_on_sa_ctl *ctl; - uint32_t seql, seqh = 0; - uint64_t seq; + uint64_t seq, seq_in_sa; uint8_t esn; int ret; in_sa = &sa->in_sa; common_sa = &in_sa->common_sa; - ctl = &common_sa->ctl; - esn = ctl->esn_en; + esn = common_sa->ctl.esn_en; seql = rte_be_to_cpu_32(data->seql); if (!esn) { @@ -517,9 +514,13 @@ ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, ret = cnxk_on_anti_replay_check(seq, &sa->ar, win_sz); if (esn && !ret) { - common_sa = &sa->in_sa.common_sa; - if (seq > common_sa->seq_t.u64) - common_sa->seq_t.u64 = seq; + esn_low = rte_be_to_cpu_32(common_sa->seq_t.tl); + esn_hi = rte_be_to_cpu_32(common_sa->seq_t.th); + seq_in_sa = ((uint64_t)esn_hi << 32) | esn_low; + if (seq > seq_in_sa) { + common_sa->seq_t.tl = rte_cpu_to_be_32(seql); + common_sa->seq_t.th = rte_cpu_to_be_32(seqh); + } } return ret;