From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: [PATCH RFCv3 04/19] ring: add a function to return the ring size Date: Tue, 7 Feb 2017 14:12:42 +0000 Message-ID: <1486476777-24768-5-git-send-email-bruce.richardson@intel.com> References: <20170125121456.GA24344@bricha3-MOBL3.ger.corp.intel.com> Cc: thomas.monjalon@6wind.com, keith.wiles@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org, dev@dpdk.org, Bruce Richardson To: olivier.matz@6wind.com Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 18825F94B for ; Tue, 7 Feb 2017 15:13:40 +0100 (CET) In-Reply-To: <20170125121456.GA24344@bricha3-MOBL3.ger.corp.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" Applications and other libraries should not be reading inside the rte_ring structure directly to get the ring size. Instead add a fn to allow it to be queried. Signed-off-by: Bruce Richardson --- lib/librte_ring/rte_ring.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index 0a5c9ff..75bbcc1 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -1104,6 +1104,20 @@ rte_ring_free_count(const struct rte_ring *r) } /** + * Return the size of the ring. + * + * @param r + * A pointer to the ring structure. + * @return + * The number of elements which can be stored in the ring. + */ +static inline unsigned int +rte_ring_get_size(struct rte_ring *r) +{ + return r->prod.size; +} + +/** * Dump the status of all rings on the console * * @param f -- 2.9.3