From: Sameeh Jubran <sjub...@redhat.com> This commit is a sample only for using the libbpf in the code and shouldn't be committed.
Signed-off-by: Sameeh Jubran <sjub...@redhat.com> --- hw/net/Makefile.objs | 4 ++++ hw/net/virtio-net.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs index fa461d4463..0fb271436d 100644 --- a/hw/net/Makefile.objs +++ b/hw/net/Makefile.objs @@ -37,6 +37,10 @@ obj-$(CONFIG_PSERIES) += spapr_llan.o obj-$(CONFIG_XILINX_ETHLITE) += xilinx_ethlite.o obj-$(CONFIG_VIRTIO_NET) += virtio-net.o +ifeq ($(CONFIG_BPF),y) + virtio-net.o-cflags := $(CFLAGS_BPF) + virtio-net.o-libs := $(LIBS_BPF) +endif obj-y += vhost_net.o obj-$(CONFIG_ETSEC) += fsl_etsec/etsec.o fsl_etsec/registers.o \ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 90502fca7c..b4840838c1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -27,6 +27,7 @@ #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" +#include "standard-headers/linux/libbpf.h" #define VIRTIO_NET_VM_VERSION 11 @@ -1329,6 +1330,9 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) VirtQueueElement *elem; int32_t num_packets = 0; int queue_index = vq2q(virtio_get_queue_index(q->tx_vq)); + + struct bpf_object *obj = NULL; + bpf_object__load(obj); if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return num_packets; } -- 2.13.6