From 03437f29474881a557bd8ed4591b1f0bd238d849 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Thu, 23 Feb 2017 16:42:00 +0000 Subject: [PATCH] ring: add a function to return the ring size 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 Acked-by: Olivier Matz --- 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 e359affc5b..72ccca5874 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -1107,6 +1107,20 @@ rte_ring_free_count(const struct rte_ring *r) return (cons_tail - prod_tail - 1) & r->prod.mask; } +/** + * 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(const struct rte_ring *r) +{ + return r->prod.size; +} + /** * Dump the status of all rings on the console * -- 2.20.1