From: Phil Yang Date: Fri, 24 Apr 2020 04:33:04 +0000 (+0800) Subject: ipsec: optimize SA outbound sequence update X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1a805dee01f329128ed4862a5f835a85cbb914cf;p=dpdk.git ipsec: optimize SA outbound sequence update 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 Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_ipsec/ipsec_sqn.h b/lib/librte_ipsec/ipsec_sqn.h index 0c2f76a7ac..2636cb1539 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 ada195cf84..e59189d215 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 29cfe7279a..1bffe751f5 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 */