From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE537A0C47; Thu, 19 Aug 2021 08:05:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54E144067E; Thu, 19 Aug 2021 08:05:10 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id D117040141 for ; Thu, 19 Aug 2021 08:05:08 +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 2AFF5101E; Wed, 18 Aug 2021 23:05:08 -0700 (PDT) Received: from net-arm-n1sdp.shanghai.arm.com (net-arm-n1sdp.shanghai.arm.com [10.169.208.222]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EC4C63F70D; Wed, 18 Aug 2021 23:05:05 -0700 (PDT) From: Joyce Kong To: ferruh.yigit@intel.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com Cc: dev@dpdk.org, nd@arm.com Date: Thu, 19 Aug 2021 01:04:42 -0500 Message-Id: <20210819060442.19014-1-joyce.kong@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] kni: remove non-C11 path from FIFO sync 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 Sender: "dev" Non-C11 path was meant to not break build with GCC version < 4.7(when C11 atomics were introduced), while now minimum GCC version supported by DPDK has been 4.9, C11 atomics support in compiler is no longer a problem. So non-C11 path can be removed. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- lib/kni/rte_kni_common.h | 9 ++------ lib/kni/rte_kni_fifo.h | 48 +++++++--------------------------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/lib/kni/rte_kni_common.h b/lib/kni/rte_kni_common.h index b547ea5501..20d94eaa9b 100644 --- a/lib/kni/rte_kni_common.h +++ b/lib/kni/rte_kni_common.h @@ -58,13 +58,8 @@ struct rte_kni_request { * Writing should never overwrite the read position */ struct rte_kni_fifo { -#ifdef RTE_USE_C11_MEM_MODEL - unsigned write; /**< Next position to be written*/ - unsigned read; /**< Next position to be read */ -#else - volatile unsigned write; /**< Next position to be written*/ - volatile unsigned read; /**< Next position to be read */ -#endif + unsigned write; /**< Next position to be written*/ + unsigned read; /**< Next position to be read */ unsigned len; /**< Circular buffer length */ unsigned elem_size; /**< Pointer size - for 32/64 bit OS */ void *volatile buffer[]; /**< The buffer contains mbuf pointers */ diff --git a/lib/kni/rte_kni_fifo.h b/lib/kni/rte_kni_fifo.h index d2ec82fe87..057f6b3ded 100644 --- a/lib/kni/rte_kni_fifo.h +++ b/lib/kni/rte_kni_fifo.h @@ -2,38 +2,6 @@ * Copyright(c) 2010-2014 Intel Corporation */ - - -/** - * @internal when c11 memory model enabled use c11 atomic memory barrier. - * when under non c11 memory model use rte_smp_* memory barrier. - * - * @param src - * Pointer to the source data. - * @param dst - * Pointer to the destination data. - * @param value - * Data value. - */ -#ifdef RTE_USE_C11_MEM_MODEL -#define __KNI_LOAD_ACQUIRE(src) ({ \ - __atomic_load_n((src), __ATOMIC_ACQUIRE); \ - }) -#define __KNI_STORE_RELEASE(dst, value) do { \ - __atomic_store_n((dst), value, __ATOMIC_RELEASE); \ - } while(0) -#else -#define __KNI_LOAD_ACQUIRE(src) ({ \ - typeof (*(src)) val = *(src); \ - rte_smp_rmb(); \ - val; \ - }) -#define __KNI_STORE_RELEASE(dst, value) do { \ - *(dst) = value; \ - rte_smp_wmb(); \ - } while(0) -#endif - /** * Initializes the kni fifo structure */ @@ -59,7 +27,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) unsigned i = 0; unsigned fifo_write = fifo->write; unsigned new_write = fifo_write; - unsigned fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); + unsigned fifo_read = __atomic_load_n(&fifo->read, __ATOMIC_ACQUIRE); for (i = 0; i < num; i++) { new_write = (new_write + 1) & (fifo->len - 1); @@ -69,7 +37,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) fifo->buffer[fifo_write] = data[i]; fifo_write = new_write; } - __KNI_STORE_RELEASE(&fifo->write, fifo_write); + __atomic_store_n(&fifo->write, fifo_write, __ATOMIC_RELEASE); return i; } @@ -81,7 +49,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) { unsigned i = 0; unsigned new_read = fifo->read; - unsigned fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); + unsigned fifo_write = __atomic_load_n(&fifo->write, __ATOMIC_ACQUIRE); for (i = 0; i < num; i++) { if (new_read == fifo_write) @@ -90,7 +58,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) data[i] = fifo->buffer[new_read]; new_read = (new_read + 1) & (fifo->len - 1); } - __KNI_STORE_RELEASE(&fifo->read, new_read); + __atomic_store_n(&fifo->read, new_read, __ATOMIC_RELEASE); return i; } @@ -100,8 +68,8 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) static inline uint32_t kni_fifo_count(struct rte_kni_fifo *fifo) { - unsigned fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); - unsigned fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); + unsigned fifo_write = __atomic_load_n(&fifo->write, __ATOMIC_ACQUIRE); + unsigned fifo_read = __atomic_load_n(&fifo->read, __ATOMIC_ACQUIRE); return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1); } @@ -111,7 +79,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo) static inline uint32_t kni_fifo_free_count(struct rte_kni_fifo *fifo) { - uint32_t fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); - uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); + uint32_t fifo_write = __atomic_load_n(&fifo->write, __ATOMIC_ACQUIRE); + uint32_t fifo_read = __atomic_load_n(&fifo->read, __ATOMIC_ACQUIRE); return (fifo_read - fifo_write - 1) & (fifo->len - 1); } -- 2.17.1