9ae3a8
From 01ebac2f7d54e80a690c855680d35574d118b072 Mon Sep 17 00:00:00 2001
9ae3a8
From: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Date: Wed, 12 Mar 2014 06:52:43 +0100
9ae3a8
Subject: [PATCH 06/16] virtio-net: add feature bit for any header s/g
9ae3a8
9ae3a8
Message-id: <1394169006-8402-1-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 58046
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.0] virtio-net: add feature bit for any header s/g
9ae3a8
Bugzilla: 990989
9ae3a8
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
Old qemu versions required that 1st s/g entry is the header.
9ae3a8
9ae3a8
Since QEMU 1.5, patchset titled "virtio-net: iovec handling cleanup"
9ae3a8
removed this limitation but a feature bit is needed so guests know it's
9ae3a8
safe to lay out header differently.
9ae3a8
9ae3a8
This patch applies on top and adds such a feature bit to QEMU.
9ae3a8
It is set by default for virtio-net.
9ae3a8
virtio net header inline with the data is beneficial
9ae3a8
for latency and small packet bandwidth - guest driver
9ae3a8
code utilizing this feature has been acked but missed 3.11
9ae3a8
by a narrow margin, it's pending for 3.12.
9ae3a8
9ae3a8
This feature bit is cleared by default when compatibility with old
9ae3a8
machine types is requested.
9ae3a8
9ae3a8
Other performance-sensitive devices (blk and scsi)
9ae3a8
don't yet support arbitrary s/g layouts, so
9ae3a8
we only set this bit for virtio-net for now.
9ae3a8
There are plans to allow arbitrary layouts there, but
9ae3a8
no code has been posted yet.
9ae3a8
9ae3a8
Cc: Rusty Russell <rusty@rustcorp.com.au>
9ae3a8
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
(cherry picked from commit 488f069bd1f3aeb6ee748acb02b7581831bcb3f8)
9ae3a8
9ae3a8
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7155286
9ae3a8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=990989
9ae3a8
Tested: on developer's box
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	include/hw/i386/pc.h
9ae3a8
---
9ae3a8
9ae3a8
Oops, the patch got lost somehow.
9ae3a8
I was sure our last rebase included it but no ...
9ae3a8
Pls review ASAP and we'll discuss setting blocker for this one
9ae3a8
separately.
9ae3a8
9ae3a8
Impossible to fix in zstream since it would affect
9ae3a8
migration.
9ae3a8
9ae3a8
 include/hw/i386/pc.h           | 4 ++++
9ae3a8
 include/hw/virtio/virtio-net.h | 1 +
9ae3a8
 include/hw/virtio/virtio.h     | 2 ++
9ae3a8
 hw/i386/pc_piix.c              | 4 ++++
9ae3a8
 4 files changed, 11 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c              |    4 ++++
9ae3a8
 include/hw/i386/pc.h           |    4 ++++
9ae3a8
 include/hw/virtio/virtio-net.h |    1 +
9ae3a8
 include/hw/virtio/virtio.h     |    2 ++
9ae3a8
 4 files changed, 11 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
9ae3a8
index 697f12f..98a5253 100644
9ae3a8
--- a/hw/i386/pc_piix.c
9ae3a8
+++ b/hw/i386/pc_piix.c
9ae3a8
@@ -904,6 +904,10 @@ static QEMUMachine pc_machine_rhel700 = {
9ae3a8
         .driver   = TYPE_USB_DEVICE,\
9ae3a8
         .property = "msos-desc",\
9ae3a8
         .value    = "no",\
9ae3a8
+    },{\
9ae3a8
+        .driver   = "virtio-net-pci",\
9ae3a8
+        .property = "any_layout",\
9ae3a8
+        .value    = "off",\
9ae3a8
     }
9ae3a8
 
9ae3a8
 static void pc_compat_rhel650(QEMUMachineInitArgs *args)
9ae3a8
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
9ae3a8
index f56e9ea..8a69347 100644
9ae3a8
--- a/include/hw/i386/pc.h
9ae3a8
+++ b/include/hw/i386/pc.h
9ae3a8
@@ -274,6 +274,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
9ae3a8
             .driver = TYPE_X86_CPU,\
9ae3a8
             .property = "pmu",\
9ae3a8
             .value = "on",\
9ae3a8
+        },{\
9ae3a8
+            .driver   = "virtio-net-pci",\
9ae3a8
+            .property = "any_layout",\
9ae3a8
+            .value    = "off",\
9ae3a8
         }
9ae3a8
 
9ae3a8
 #define PC_COMPAT_1_4 \
9ae3a8
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
9ae3a8
index beeead7..75723a8 100644
9ae3a8
--- a/include/hw/virtio/virtio-net.h
9ae3a8
+++ b/include/hw/virtio/virtio-net.h
9ae3a8
@@ -231,6 +231,7 @@ struct virtio_net_ctrl_mq {
9ae3a8
 
9ae3a8
 #define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \
9ae3a8
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
9ae3a8
+        DEFINE_PROP_BIT("any_layout", _state, _field, VIRTIO_F_ANY_LAYOUT, true), \
9ae3a8
         DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \
9ae3a8
         DEFINE_PROP_BIT("guest_csum", _state, _field, VIRTIO_NET_F_GUEST_CSUM, true), \
9ae3a8
         DEFINE_PROP_BIT("gso", _state, _field, VIRTIO_NET_F_GSO, true), \
9ae3a8
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
9ae3a8
index cd886c3..9e22865 100644
9ae3a8
--- a/include/hw/virtio/virtio.h
9ae3a8
+++ b/include/hw/virtio/virtio.h
9ae3a8
@@ -43,6 +43,8 @@
9ae3a8
 /* We notify when the ring is completely used, even if the guest is suppressing
9ae3a8
  * callbacks */
9ae3a8
 #define VIRTIO_F_NOTIFY_ON_EMPTY        24
9ae3a8
+/* Can the device handle any descriptor layout? */
9ae3a8
+#define VIRTIO_F_ANY_LAYOUT             27
9ae3a8
 /* We support indirect buffer descriptors */
9ae3a8
 #define VIRTIO_RING_F_INDIRECT_DESC     28
9ae3a8
 /* The Guest publishes the used index for which it expects an interrupt
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8