From patchwork Mon Jun 25 11:07:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10485565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1984604D3 for ; Mon, 25 Jun 2018 11:08:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B05C3284F1 for ; Mon, 25 Jun 2018 11:08:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4C4228500; Mon, 25 Jun 2018 11:08:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4AEC1284F1 for ; Mon, 25 Jun 2018 11:08:48 +0000 (UTC) Received: from localhost ([::1]:45473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXPMV-0007Vi-7j for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Jun 2018 07:08:47 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5pk0CuI/Cef9S/ieR/kd4TL7tU+HoaaDP7sM6c050Gc=; b=mWsv8Vpsapxb4yikjsnPIMMx4QViZ3dnNDfq3deYjZjLe6YKk/8zmUJkzELte41HcQ 3t/hxHFEPrxyn7ZwLEyDOiLB4pWBJXP/q9PMQ2XFySieHJxRwG/DfMdIMboGrtPr1WRn LJjm1HBPLk4uKjML/meavwMIqiHIYcWQ2O9YRCtQWSmxH1cBf0ttFA5ATx7A3fmUwiEP +0hfnqCGF3sM/ZDqEhF3wk1t4CJsWRski2n3kdUnXuVeQ/hYohzzeh37R13uZde68U/L ymKxnkjK4Q2sqFtpPkeCQ0Vr88n5QjDNYS35kj2KGq+aSKbvTVNG576eyF1Qy7OB6K09 boQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5pk0CuI/Cef9S/ieR/kd4TL7tU+HoaaDP7sM6c050Gc=; b=goS48vW6FA+S/HYqPQkBn3BNyy3mPAqV9ehLbphjJz00ItS37VQBYBUvu5NEUQyyqS VngQAvHUllYTZorhNP0HKalk4OK8iQh5Vo1KBkWw3K5OENVBHmU3MCL3laajXibQENLn cGIji5H8uTQVtR3X6oCqp2Vvvc2F+uiAa0ILZT8Zpqby/mx27hhifJ0kCJruottPrTSB k/CFexfZx+SgPIPyiEMKyj+Pt3g5VEV/qKe0ksrQYJGSc49B2C+D+CfXl5i8lsbV31Ic y6SS6T27Bv3qd7F2Q+XIzTxyE//bJTIC9/X8JZw21nhZe4bGikWtE4mOspzu5kOk88eW vgNg== X-Gm-Message-State: APt69E3siNhtkC2fFZDYBHz+HRZ5PhzcFWo8bKwsFrgUWkPPIv1yEc36 niGfFgOrW7MdEhwgZIkgXFWB7xH0 X-Google-Smtp-Source: AAOMgpe0KNIxMUmNQ8b3RY7z6sJe9SF9azCoHKEqse30ZvW8HjBgRJuU0rJJkGt8uRQBaxVaVWwvQg== X-Received: by 2002:a1c:1143:: with SMTP id 64-v6mr642299wmr.100.1529924835812; Mon, 25 Jun 2018 04:07:15 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id o1-v6sm1400725wrm.41.2018.06.25.04.07.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 04:07:15 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org Date: Mon, 25 Jun 2018 14:07:06 +0300 Message-Id: <20180625110706.23332-3-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180625110706.23332-1-sameeh@daynix.com> References: <20180625110706.23332-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [RFC v2 2/2] virtio-net: Example Patch for using BPF X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Jason Wang , Amnon Ilan , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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; }