aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_ring_mpmc_internal.h
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2020-09-02 14:28:37 +0300
committerMatias Elo <matias.elo@nokia.com>2020-09-03 12:33:19 +0300
commit2cf7bd0f03d13f94fa99d428b96aea3f7570b659 (patch)
tree27d3fd9cec0ccb4b8ce8c845ff6704ab46de5b79 /platform/linux-generic/include/odp_ring_mpmc_internal.h
parent7363834810919fe56d4b762ba5109863e106a279 (diff)
linux-gen: ring: add functions for reading current ring lengths
Add functions for reading the current count of elements in each ring type. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform/linux-generic/include/odp_ring_mpmc_internal.h')
-rw-r--r--platform/linux-generic/include/odp_ring_mpmc_internal.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/platform/linux-generic/include/odp_ring_mpmc_internal.h b/platform/linux-generic/include/odp_ring_mpmc_internal.h
index 74bbb8fc7..0a659249a 100644
--- a/platform/linux-generic/include/odp_ring_mpmc_internal.h
+++ b/platform/linux-generic/include/odp_ring_mpmc_internal.h
@@ -162,6 +162,15 @@ static inline int ring_mpmc_is_empty(ring_mpmc_t *ring)
return head == tail;
}
+/* Return current ring length */
+static inline uint32_t ring_mpmc_length(ring_mpmc_t *ring)
+{
+ uint32_t head = odp_atomic_load_u32(&ring->r_head);
+ uint32_t tail = odp_atomic_load_u32(&ring->w_tail);
+
+ return tail - head;
+}
+
#ifdef __cplusplus
}
#endif