diff mbox

[RFC,v2,2/2] virtio-net: Example Patch for using BPF

Message ID 20180625110706.23332-3-sameeh@daynix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sameeh Jubran June 25, 2018, 11:07 a.m. UTC
From: Sameeh Jubran <sjubran@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 <sjubran@redhat.com>
---
 hw/net/Makefile.objs | 4 ++++
 hw/net/virtio-net.c  | 4 ++++
 2 files changed, 8 insertions(+)

Comments

Daniel P. Berrangé June 25, 2018, 11:22 a.m. UTC | #1
On Mon, Jun 25, 2018 at 02:07:06PM +0300, Sameeh Jubran wrote:
> From: Sameeh Jubran <sjubran@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 <sjubran@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);

This really doesn't tell us anything useful about how this will be
used and integrated in qemu. I'd expect this patch to actually
be doing a real feature complete impl of RSS for virtio-net.

Regards,
Daniel
Sameeh Jubran June 25, 2018, 3:29 p.m. UTC | #2
On Mon, Jun 25, 2018 at 2:22 PM, Daniel P. Berrangé <berrange@redhat.com>
wrote:

> On Mon, Jun 25, 2018 at 02:07:06PM +0300, Sameeh Jubran wrote:
> > From: Sameeh Jubran <sjubran@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 <sjubran@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);
>
> This really doesn't tell us anything useful about how this will be
> used and integrated in qemu. I'd expect this patch to actually
> be doing a real feature complete impl of RSS for virtio-net.
>
No problem, I'll be sending the full series ASAP,
Thanks :)

>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/
> dberrange :|
> |: https://libvirt.org         -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/
> dberrange :|
>
diff mbox

Patch

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;
     }