From nobody Tue Feb 10 19:14:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529924963733782.5248870265989; Mon, 25 Jun 2018 04:09:23 -0700 (PDT) Received: from localhost ([::1]:45473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXPN0-0007Vi-Ox for importer@patchew.org; Mon, 25 Jun 2018 07:09:18 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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) +=3D spapr_llan.o obj-$(CONFIG_XILINX_ETHLITE) +=3D xilinx_ethlite.o =20 obj-$(CONFIG_VIRTIO_NET) +=3D virtio-net.o +ifeq ($(CONFIG_BPF),y) + virtio-net.o-cflags :=3D $(CFLAGS_BPF) + virtio-net.o-libs :=3D $(LIBS_BPF) +endif obj-y +=3D vhost_net.o =20 obj-$(CONFIG_ETSEC) +=3D 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" =20 #define VIRTIO_NET_VM_VERSION 11 =20 @@ -1329,6 +1330,9 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) VirtQueueElement *elem; int32_t num_packets =3D 0; int queue_index =3D vq2q(virtio_get_queue_index(q->tx_vq)); + + struct bpf_object *obj =3D NULL; + bpf_object__load(obj); if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return num_packets; } --=20 2.13.6