From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8630BA00C4; Fri, 24 Apr 2020 06:33:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 427761C1F6; Fri, 24 Apr 2020 06:33:27 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id F210D1C1F4 for ; Fri, 24 Apr 2020 06:33:25 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 264A031B; Thu, 23 Apr 2020 21:33:25 -0700 (PDT) Received: from phil-VirtualBox.arm.com (A010647.Arm.com [10.170.243.74]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E0FC53F73D; Thu, 23 Apr 2020 21:33:21 -0700 (PDT) From: Phil Yang To: konstantin.ananyev@intel.com, dev@dpdk.org Cc: thomas@monjalon.net, jerinj@marvell.com, akhil.goyal@nxp.com, bernard.iremonger@intel.com, vladimir.medvedkin@intel.com, Honnappa.Nagarahalli@arm.com, gavin.hu@arm.com, ruifeng.wang@arm.com, nd@arm.com Date: Fri, 24 Apr 2020 12:33:04 +0800 Message-Id: <1587702784-31586-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587662187-28193-1-git-send-email-phil.yang@arm.com> References: <1587662187-28193-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v3] ipsec: optimize with c11 atomic for sa outbound sqn update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For SA outbound packets, rte_atomic64_add_return is used to generate SQN atomically. Use c11 atomics with RELAXED ordering for outbound SQN update instead of rte_atomic ops which enforce unnecessary barriers on aarch64. Signed-off-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Gavin Hu --- v3: 1. since libatomic dependency for 32-bit clang added globally, so remove the redundant code. 2. collapse union outb to unint64_t outb as the rte_atomic is no needed. v2: split from the "generic rte atomic APIs deprecate proposal" patchset. lib/librte_ipsec/ipsec_sqn.h | 6 +++--- lib/librte_ipsec/sa.c | 2 +- lib/librte_ipsec/sa.h | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/librte_ipsec/ipsec_sqn.h b/lib/librte_ipsec/ipsec_sqn.h index 0c2f76a..2636cb1 100644 --- a/lib/librte_ipsec/ipsec_sqn.h +++ b/lib/librte_ipsec/ipsec_sqn.h @@ -128,10 +128,10 @@ esn_outb_update_sqn(struct rte_ipsec_sa *sa, uint32_t *num) n = *num; if (SQN_ATOMIC(sa)) - sqn = (uint64_t)rte_atomic64_add_return(&sa->sqn.outb.atom, n); + sqn = __atomic_add_fetch(&sa->sqn.outb, n, __ATOMIC_RELAXED); else { - sqn = sa->sqn.outb.raw + n; - sa->sqn.outb.raw = sqn; + sqn = sa->sqn.outb + n; + sa->sqn.outb = sqn; } /* overflow */ diff --git a/lib/librte_ipsec/sa.c b/lib/librte_ipsec/sa.c index ada195c..e59189d 100644 --- a/lib/librte_ipsec/sa.c +++ b/lib/librte_ipsec/sa.c @@ -283,7 +283,7 @@ esp_outb_init(struct rte_ipsec_sa *sa, uint32_t hlen) { uint8_t algo_type; - sa->sqn.outb.raw = 1; + sa->sqn.outb = 1; algo_type = sa->algo_type; diff --git a/lib/librte_ipsec/sa.h b/lib/librte_ipsec/sa.h index d22451b..508dd2b 100644 --- a/lib/librte_ipsec/sa.h +++ b/lib/librte_ipsec/sa.h @@ -119,10 +119,7 @@ struct rte_ipsec_sa { * place from other frequently accesed data. */ union { - union { - rte_atomic64_t atom; - uint64_t raw; - } outb; + uint64_t outb; struct { uint32_t rdidx; /* read index */ uint32_t wridx; /* write index */ -- 2.7.4