From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXPL5-0006Wr-AQ for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXPL3-0003QM-4D for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:07:19 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:38634) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXPL2-0003Q8-T3 for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:07:17 -0400 Received: by mail-wm0-x244.google.com with SMTP id 69-v6so9494908wmf.3 for ; Mon, 25 Jun 2018 04:07:16 -0700 (PDT) From: Sameeh Jubran Date: Mon, 25 Jun 2018 14:07:06 +0300 Message-Id: <20180625110706.23332-3-sameeh@daynix.com> In-Reply-To: <20180625110706.23332-1-sameeh@daynix.com> References: <20180625110706.23332-1-sameeh@daynix.com> Subject: [Qemu-devel] [RFC v2 2/2] virtio-net: Example Patch for using BPF List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Yan Vugenfirer , Jason Wang , "Michael S . Tsirkin" , Amnon Ilan From: Sameeh Jubran This commit is a sample only for using the libbpf in the code and shouldn't be committed. Signed-off-by: Sameeh Jubran --- 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