aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/libbpf.h
diff options
context:
space:
mode:
authorMartin Kelly <[email protected]>2023-09-25 21:50:36 +0000
committerAndrii Nakryiko <[email protected]>2023-09-25 23:22:42 +0000
commit059a8c0c5acd37ecfa64f1832e8765d30f253ce8 (patch)
tree121e16ee53c4f30fdcac2e5452510c153c6ce7aa /tools/lib/bpf/libbpf.h
parentselftests/bpf: Add tests for ring_buffer__ring (diff)
downloadkernel-059a8c0c5acd37ecfa64f1832e8765d30f253ce8.tar.gz
kernel-059a8c0c5acd37ecfa64f1832e8765d30f253ce8.zip
libbpf: Add ring__producer_pos, ring__consumer_pos
Add APIs to get the producer and consumer position for a given ringbuffer. Signed-off-by: Martin Kelly <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r--tools/lib/bpf/libbpf.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index de3ef59b9641..ab470179b7fe 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -1264,6 +1264,24 @@ LIBBPF_API int ring_buffer__epoll_fd(const struct ring_buffer *rb);
LIBBPF_API struct ring *ring_buffer__ring(struct ring_buffer *rb,
unsigned int idx);
+/**
+ * @brief **ring__consumer_pos()** returns the current consumer position in the
+ * given ringbuffer.
+ *
+ * @param r A ringbuffer object.
+ * @return The current consumer position.
+ */
+LIBBPF_API unsigned long ring__consumer_pos(const struct ring *r);
+
+/**
+ * @brief **ring__producer_pos()** returns the current producer position in the
+ * given ringbuffer.
+ *
+ * @param r A ringbuffer object.
+ * @return The current producer position.
+ */
+LIBBPF_API unsigned long ring__producer_pos(const struct ring *r);
+
struct user_ring_buffer_opts {
size_t sz; /* size of this struct, for forward/backward compatibility */
};