Skip to content

Commit 08d77ab

Browse files
lrq-maxkernel-patches-bot
authored andcommitted
libbpf: add support for canceling cached_cons advance
Add a new function for returning descriptors the user received after an xsk_ring_cons__peek call. After the application has gotten a number of descriptors from a ring, it might not be able to or want to process them all for various reasons. Therefore, it would be useful to have an interface for returning or cancelling a number of them so that they are returned to the ring. This patch adds a new function called xsk_ring_cons__cancel that performs this operation on nb descriptors counted from the end of the batch of descriptors that was received through the peek call. Signed-off-by: Li RongQing <[email protected]> [ Magnus Karlsson: rewrote changelog ] Cc: Magnus Karlsson <[email protected]> diff with v1: fix the building, and rewrote changelog tools/lib/bpf/xsk.h | 6 ++++++ 1 file changed, 6 insertions(+)
1 parent 758936a commit 08d77ab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/lib/bpf/xsk.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons,
153153
return entries;
154154
}
155155

156+
static inline void xsk_ring_cons__cancel(struct xsk_ring_cons *cons,
157+
size_t nb)
158+
{
159+
cons->cached_cons -= nb;
160+
}
161+
156162
static inline void xsk_ring_cons__release(struct xsk_ring_cons *cons, size_t nb)
157163
{
158164
/* Make sure data has been read before indicating we are done

0 commit comments

Comments
 (0)