ipsec: optimize SA outbound sequence update
authorPhil Yang <phil.yang@arm.com>
Fri, 24 Apr 2020 04:33:04 +0000 (12:33 +0800)
committerAkhil Goyal <akhil.goyal@nxp.com>
Mon, 11 May 2020 11:17:43 +0000 (13:17 +0200)
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 <phil.yang@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
lib/librte_ipsec/ipsec_sqn.h
lib/librte_ipsec/sa.c
lib/librte_ipsec/sa.h

index 0c2f76a..2636cb1 100644 (file)
@@ -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 */
index ada195c..e59189d 100644 (file)
@@ -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;
 
index 29cfe72..1bffe75 100644 (file)
@@ -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 */