From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gage Eads Subject: [PATCH v8 2/6] ring: add a ring start marker Date: Mon, 18 Mar 2019 20:20:06 -0500 Message-ID: <20190319012010.16793-3-gage.eads@intel.com> References: <20190318213555.17345-1-gage.eads@intel.com> <20190319012010.16793-1-gage.eads@intel.com> Cc: olivier.matz@6wind.com, arybchenko@solarflare.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org, jerinj@marvell.com, mczekaj@marvell.com, nd@arm.com, Ola.Liljedahl@arm.com, gage.eads@intel.com To: dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C5AE6324D for ; Tue, 19 Mar 2019 02:20:42 +0100 (CET) In-Reply-To: <20190319012010.16793-1-gage.eads@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This marker allows us to replace "&r[1]" with "&r->ring" to locate the start of the ring. Signed-off-by: Gage Eads --- lib/librte_ring/rte_ring.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index c78db6916..f16d77b8a 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -118,6 +118,7 @@ struct rte_ring { struct rte_ring_headtail_ptr cons_ptr __rte_cache_aligned; }; char pad2 __rte_cache_aligned; /**< empty cache line */ + void *ring[] __rte_cache_aligned; /**< empty marker for ring start */ }; #define RING_F_SP_ENQ 0x0001 /**< The default enqueue is "single-producer". */ @@ -361,7 +362,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table, if (n == 0) goto end; - ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *); + ENQUEUE_PTRS(r, &r->ring, prod_head, obj_table, n, void *); update_tail(&r->prod, prod_head, prod_next, is_sp, 1); end: @@ -403,7 +404,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table, if (n == 0) goto end; - DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *); + DEQUEUE_PTRS(r, &r->ring, cons_head, obj_table, n, void *); update_tail(&r->cons, cons_head, cons_next, is_sc, 0); -- 2.13.6