qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Aaron Conole <aconole@redhat.com>,
	Vlad Yasevich <vyasevic@redhat.com>,
	Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PULL 10/13] virtio_net: Bypass backends for MTU feature negotiation
Date: Mon, 29 May 2017 03:18:56 +0300	[thread overview]
Message-ID: <1496017081-24032-11-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1496017081-24032-1-git-send-email-mst@redhat.com>

From: Maxime Coquelin <maxime.coquelin@redhat.com>

This patch adds a new internal "x-mtu-bypass-backend" property
to bypass backends for MTU feature negotiation.

When this property is set, the MTU feature is negotiated as soon
as supported by the guest and a MTU value is set via the host_mtu
parameter. In case the backend advertises the feature (e.g. DPDK's
vhost-user backend), the feature negotiation is propagated down to
the backend.

When this property is not set, the backend has to support the MTU
feature for its negotiation to succeed.

For compatibility purpose, this property is disabled for machine
types v2.9 and older.

Cc: Aaron Conole <aconole@redhat.com>
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Vlad Yasevich <vyasevic@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/compat.h            |  4 ++++
 include/hw/virtio/virtio-net.h |  1 +
 include/hw/virtio/virtio.h     |  1 +
 hw/net/virtio-net.c            | 17 ++++++++++++++++-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 4c53d60..400c64b 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -10,6 +10,10 @@
         .driver   = "intel-iommu",\
         .property = "pt",\
         .value    = "off",\
+    },{\
+        .driver   = "virtio-net-device",\
+        .property = "x-mtu-bypass-backend",\
+        .value    = "off",\
     },
 
 #define HW_COMPAT_2_8 \
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 1eec9a2..602b486 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -97,6 +97,7 @@ typedef struct VirtIONet {
     QEMUTimer *announce_timer;
     int announce_counter;
     bool needs_vnet_hdr_swap;
+    bool mtu_bypass_backend;
 } VirtIONet;
 
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 7b6edba..80c45c3 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -79,6 +79,7 @@ struct VirtIODevice
     uint16_t queue_sel;
     uint64_t guest_features;
     uint64_t host_features;
+    uint64_t backend_features;
     size_t config_len;
     void *config;
     uint16_t config_vector;
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 98bd683..9a3d769 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -589,7 +589,15 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
     if (!get_vhost_net(nc->peer)) {
         return features;
     }
-    return vhost_net_get_features(get_vhost_net(nc->peer), features);
+    features = vhost_net_get_features(get_vhost_net(nc->peer), features);
+    vdev->backend_features = features;
+
+    if (n->mtu_bypass_backend &&
+            (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) {
+        features |= (1ULL << VIRTIO_NET_F_MTU);
+    }
+
+    return features;
 }
 
 static uint64_t virtio_net_bad_features(VirtIODevice *vdev)
@@ -640,6 +648,11 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
     VirtIONet *n = VIRTIO_NET(vdev);
     int i;
 
+    if (n->mtu_bypass_backend &&
+            !virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_MTU)) {
+        features &= ~(1ULL << VIRTIO_NET_F_MTU);
+    }
+
     virtio_net_set_multiqueue(n,
                               virtio_has_feature(features, VIRTIO_NET_F_MQ));
 
@@ -2093,6 +2106,8 @@ static Property virtio_net_properties[] = {
     DEFINE_PROP_UINT16("rx_queue_size", VirtIONet, net_conf.rx_queue_size,
                        VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE),
     DEFINE_PROP_UINT16("host_mtu", VirtIONet, net_conf.mtu, 0),
+    DEFINE_PROP_BOOL("x-mtu-bypass-backend", VirtIONet, mtu_bypass_backend,
+                     true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
MST

  parent reply	other threads:[~2017-05-29  0:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29  0:18 [Qemu-devel] [PULL 00/13] pci, virtio, vhost: fixes Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 01/13] memory: tune last param of iommu_ops.translate() Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 02/13] memory: remove the last param in memory_region_iommu_replay() Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 03/13] x86-iommu: use DeviceClass properties Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 04/13] intel_iommu: renaming context entry helpers Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 05/13] intel_iommu: provide vtd_ce_get_type() Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 06/13] intel_iommu: use IOMMU_ACCESS_FLAG() Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 07/13] intel_iommu: allow dev-iotlb context entry conditionally Michael S. Tsirkin
2017-05-29  0:18 ` [Qemu-devel] [PULL 09/13] intel_iommu: turn off pt before 2.9 Michael S. Tsirkin
2017-05-29  0:18 ` Michael S. Tsirkin [this message]
2017-05-29  0:18 ` [Qemu-devel] [PULL 11/13] vhost-user: pass message as a pointer to process_message_reply() Michael S. Tsirkin
2017-05-29  0:19 ` [Qemu-devel] [PULL 12/13] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry Michael S. Tsirkin
2017-05-29  0:19 ` [Qemu-devel] [PULL 13/13] acpi-test: update expected files Michael S. Tsirkin
2017-05-29  0:19 ` [Qemu-devel] [PULL 08/13] intel_iommu: support passthrough (PT) Michael S. Tsirkin
2017-05-30  9:41 ` [Qemu-devel] [PULL 00/13] pci, virtio, vhost: fixes Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1496017081-24032-11-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=aconole@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vyasevic@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).