[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <49d3ddb42f531618584f60c740d9469e5406e114.1561130674.git.echaudro@redhat.com>
Date: Fri, 21 Jun 2019 17:25:48 +0200
From: Eelco Chaudron <echaudro@...hat.com>
To: netdev@...r.kernel.org
Cc: ast@...nel.org, daniel@...earbox.net, kafai@...com,
songliubraving@...com, yhs@...com
Subject: [PATCH bpf-next] libbpf: add xsk_ring_prod__free() function
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@...hat.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)
+{
+ 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
Powered by blists - more mailing lists