[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe9eeaa5-d40a-9be4-a96b-cdd80095da47@iogearbox.net>
Date: Tue, 24 Nov 2020 22:58:03 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Magnus Karlsson <magnus.karlsson@...il.com>,
Li RongQing <lirongqing@...du.com>
Cc: Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@...el.com>
Subject: Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance
On 11/24/20 9:12 AM, Magnus Karlsson wrote:
> On Tue, Nov 24, 2020 at 8:33 AM Li RongQing <lirongqing@...du.com> wrote:
>>
>> 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 <lirongqing@...du.com>
>> [ Magnus Karlsson: rewrote changelog ]
>> Cc: Magnus Karlsson <magnus.karlsson@...el.com>
>> ---
>> diff with v1: fix the building, and rewrote changelog
>>
>> tools/lib/bpf/xsk.h | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
>> index 1069c46364ff..1719a327e5f9 100644
>> --- a/tools/lib/bpf/xsk.h
>> +++ b/tools/lib/bpf/xsk.h
>> @@ -153,6 +153,12 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons,
>> return entries;
>> }
>>
>> +static inline void xsk_ring_cons__cancel(struct xsk_ring_cons *cons,
>> + size_t nb)
>> +{
>> + cons->cached_cons -= nb;
>> +}
>> +
>> static inline void xsk_ring_cons__release(struct xsk_ring_cons *cons, size_t nb)
>> {
>> /* Make sure data has been read before indicating we are done
>> --
>> 2.17.3
>
> Thank you RongQing.
>
> Acked-by: Magnus Karlsson <magnus.karlsson@...el.com>
@Magnus: shouldn't the xsk_ring_cons__cancel() nb type be '__u32 nb' instead?
Thanks,
Daniel
Powered by blists - more mailing lists