[dpdk-dev] [PATCH RFCv3 04/19] ring: add a function to return the ring size

Bruce Richardson bruce.richardson at intel.com
Tue Feb 7 15:12:42 CET 2017


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 <bruce.richardson at intel.com>
---
 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



More information about the dev mailing list