aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/xsk.h
diff options
context:
space:
mode:
authorMagnus Karlsson <magnus.karlsson@intel.com>2019-04-16 14:58:11 +0200
committerAlexei Starovoitov <ast@kernel.org>2019-04-16 20:13:10 -0700
commitb7e3a28019c92ffe1f55de278c5641de33b6259a (patch)
tree5182b3b6a640803c871995f07040247bd3d6f4b0 /tools/lib/bpf/xsk.h
parentlibbpf: remove likely/unlikely in xsk.h (diff)
downloadlinux-dev-b7e3a28019c92ffe1f55de278c5641de33b6259a.tar.xz
linux-dev-b7e3a28019c92ffe1f55de278c5641de33b6259a.zip
libbpf: remove dependency on barrier.h in xsk.h
The use of smp_rmb() and smp_wmb() creates a Linux header dependency on barrier.h that is unnecessary in most parts. This patch implements the two small defines that are needed from barrier.h. As a bonus, the new implementations are faster than the default ones as they default to sfence and lfence for x86, while we only need a compiler barrier in our case. Just as it is when the same ring access code is compiled in the kernel. Fixes: 1cad07884239 ("libbpf: add support for using AF_XDP sockets") Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to '')
-rw-r--r--tools/lib/bpf/xsk.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
index f264f24f06ac..2377c7a7f1b1 100644
--- a/tools/lib/bpf/xsk.h
+++ b/tools/lib/bpf/xsk.h
@@ -16,6 +16,7 @@
#include <linux/if_xdp.h>
#include "libbpf.h"
+#include "libbpf_util.h"
#ifdef __cplusplus
extern "C" {
@@ -123,7 +124,7 @@ static inline void xsk_ring_prod__submit(struct xsk_ring_prod *prod, size_t nb)
/* Make sure everything has been written to the ring before indicating
* this to the kernel by writing the producer pointer.
*/
- smp_wmb();
+ libbpf_smp_wmb();
*prod->producer += nb;
}
@@ -137,7 +138,7 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons,
/* Make sure we do not speculatively read the data before
* we have received the packet buffers from the ring.
*/
- smp_rmb();
+ libbpf_smp_rmb();
*idx = cons->cached_cons;
cons->cached_cons += entries;
@@ -151,7 +152,7 @@ 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
* with the entries by updating the consumer pointer.
*/
- smp_mb();
+ libbpf_smp_mb();
*cons->consumer += nb;
}