Netdev List
 help / color / mirror / Atom feed
From: "Eelco Chaudron" <echaudro@redhat.com>
To: "Andrii Nakryiko" <andrii.nakryiko@gmail.com>,
	"Karlsson, Magnus" <magnus.karlsson@intel.com>
Cc: Networking <netdev@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Martin Lau" <kafai@fb.com>, "Song Liu" <songliubraving@fb.com>,
	"Yonghong Song" <yhs@fb.com>
Subject: Re: [PATCH bpf-next] libbpf: add xsk_ring_prod__free() function
Date: Mon, 24 Jun 2019 11:37:40 +0200	[thread overview]
Message-ID: <1C59E98E-7F4B-4FCA-AB95-68D3819C489C@redhat.com> (raw)
In-Reply-To: <CAEf4BzZsmH+4A0dADeXYUDqeEK9N_-PVqzHW_=vPytjEX1hqTA@mail.gmail.com>



On 21 Jun 2019, at 21:13, Andrii Nakryiko wrote:

> On Fri, Jun 21, 2019 at 8:26 AM Eelco Chaudron <echaudro@redhat.com> 
> wrote:
>>
>> When an AF_XDP application received X packets, it does not mean X
>> frames can be stuffed into the producer ring. To make it easier for
>> AF_XDP applications this API allows them to check how many frames can
>> be added into the ring.
>>
>> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
>> ---
>>  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 82ea71a0f3ec..86f3d485e957 100644
>> --- a/tools/lib/bpf/xsk.h
>> +++ b/tools/lib/bpf/xsk.h
>> @@ -95,6 +95,12 @@ static inline __u32 xsk_prod_nb_free(struct 
>> xsk_ring_prod *r, __u32 nb)
>>         return r->cached_cons - r->cached_prod;
>>  }
>>
>> +static inline __u32 xsk_ring_prod__free(struct xsk_ring_prod *r)
>
> This is a very bad name choice. __free is used for functions that free
> memory and resources. One function below I see avail is used in the
> name, why not xsk_ring_prog__avail?

Must agree that free sound like you are freeing entries… However, I 
just kept the naming already in the API/file (see above, 
xsk_prod_nb_free()).
Reading the code there is a difference as xx_avail() means available 
filled entries, where xx_free() means available free entries.

So I could rename it to xsk_ring_prod__nb_free() maybe?

Forgot to include Magnus in the email, so copied him in, for some 
comments.

>> +{
>> +       r->cached_cons = *r->consumer + r->size;
>> +       return r->cached_cons - r->cached_prod;
>> +}
>> +
>>  static inline __u32 xsk_cons_nb_avail(struct xsk_ring_cons *r, __u32 
>> nb)
>>  {
>>         __u32 entries = r->cached_prod - r->cached_cons;
>> --
>> 2.20.1
>>

  reply	other threads:[~2019-06-24  9:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 15:25 [PATCH bpf-next] libbpf: add xsk_ring_prod__free() function Eelco Chaudron
2019-06-21 19:13 ` Andrii Nakryiko
2019-06-24  9:37   ` Eelco Chaudron [this message]
2019-06-24 10:15     ` Magnus Karlsson
2019-06-24 16:42     ` Andrii Nakryiko
2019-06-25  7:58       ` Eelco Chaudron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1C59E98E-7F4B-4FCA-AB95-68D3819C489C@redhat.com \
    --to=echaudro@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox