From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDjIW-0001za-5K for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:33:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDjIO-0004Yq-8N for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:32:56 -0500 Received: from mailout1.w2.samsung.com ([211.189.100.11]:60881 helo=usmailout1.samsung.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDjIO-0004Xi-4J for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:32:48 -0500 Received: from uscpsbgex3.samsung.com (u124.gpu85.samsung.co.kr [203.254.195.124]) by mailout1.w2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N0W002IRPEMFI40@mailout1.w2.samsung.com> for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:32:46 -0500 (EST) Message-id: <52FC0494.8000803@samsung.com> Date: Wed, 12 Feb 2014 15:32:36 -0800 From: Mario Smarduch MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit Subject: [Qemu-devel] [PATCH] set virtio-net/virtio-mmio host features to improve, performance List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org, aliguori@amazon.com This patch sets the 'virtio-net/virtio-mmio' VirtIOMMIOProxy host_features to all possible virtio-net features supported. Currently most host_features are turned off including performance related ones, this impacts virtio network performance. Host features update should be done earlier but at the time 'virtio-mmio' is created the device to be plugged in is unknown. Signed-off-by: Mario Smarduch --- hw/virtio/virtio-mmio.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 8829eb0..1d940b7 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -23,6 +23,7 @@ #include "hw/virtio/virtio.h" #include "qemu/host-utils.h" #include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-net.h" /* #define DEBUG_VIRTIO_MMIO */ @@ -92,6 +93,12 @@ typedef struct { static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size, VirtIOMMIOProxy *dev); +/* all possible virtio-net features supported */ +static Property virtio_mmio_net_properties[] = { + DEFINE_VIRTIO_NET_FEATURES(VirtIOMMIOProxy, host_features), + DEFINE_PROP_END_OF_LIST(), +}; + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) { VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; @@ -347,11 +354,33 @@ static void virtio_mmio_reset(DeviceState *d) /* virtio-mmio device */ +/* Walk virtio-net possible supported features and set host_features, this + * should be done earlier when the object is instantiated but at that point + * you don't know what type of device will be plugged in. + */ +static void virtio_mmio_set_net_features(Property *prop, uint32_t *features) +{ + for (; prop && prop->name; prop++) { + if (prop->defval == true) { + *features |= (1 << prop->bitnr); + } else { + *features &= ~(1 << prop->bitnr); + } + } +} + /* This is called by virtio-bus just after the device is plugged. */ static void virtio_mmio_device_plugged(DeviceState *opaque) { VirtIOMMIOProxy *proxy = VIRTIO_MMIO(opaque); + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + Object *obj = OBJECT(vdev); + /* set host features only for virtio-net */ + if (object_dynamic_cast(obj, TYPE_VIRTIO_NET)) { + virtio_mmio_set_net_features(virtio_mmio_net_properties, + &proxy->host_features); + } proxy->host_features |= (0x1 << VIRTIO_F_NOTIFY_ON_EMPTY); proxy->host_features = virtio_bus_get_vdev_features(&proxy->bus, proxy->host_features); -- 1.7.9.5