From patchwork Tue Apr 28 11:51:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47665 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5FAAF20553 for ; Tue, 28 Apr 2015 11:54:26 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf32145374lbc.1 for ; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=YaMYMqmpvcVd7beYijCBaV7soZPRkIIBy68tujK4FtY=; b=H56e2Ymg3NlEnp8Gsn2xtClkAkv8TFq0/d6dFf2CAVaedpfIF2RcmARrhLE3is+e2L e5+dWD1Ak0ouIAXtcWoMyMknIn9u/KOnGYFG0fNL5mPBwRDDDCSfR+vsZ07OP9Tg/bHo 8w5mmbKI0Wbz3L4cQgqbZiAJe8ir2fATPkZoCZ//MkBFUwjVnPaehXwAo9QT9tC/FNaQ Eayl+sJyxP/udIRuS4ad/FuDTZbLLup3e+Ds4CNaZuAS5F9z//RMZPdfiKESMg0YxRJQ FHtsFaPfRL2yMnns3S6f1tAvteF/Ug2Fh01XWPwc5jRIoA61LzyxZ+VnN6k8P2G2xaJE seBw== X-Gm-Message-State: ALoCoQke9IlPXD/M5BaHgrCIt+jhnMHOenHRqrX9dCTsWV76H7kS5mvFmjCKo4lb/u+SqH7bl5OP X-Received: by 10.194.249.1 with SMTP id yq1mr10103799wjc.2.1430222064539; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.169 with SMTP id l9ls64699lah.52.gmail; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) X-Received: by 10.152.30.100 with SMTP id r4mr7731653lah.107.1430222064375; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id l6si16892367lbd.114.2015.04.28.04.54.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2015 04:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by layy10 with SMTP id y10so102322626lay.0 for ; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) X-Received: by 10.153.8.167 with SMTP id dl7mr14261209lad.86.1430222064082; Tue, 28 Apr 2015 04:54:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1836684lbt; Tue, 28 Apr 2015 04:54:23 -0700 (PDT) X-Received: by 10.140.94.211 with SMTP id g77mr11194887qge.2.1430222062574; Tue, 28 Apr 2015 04:54:22 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n90si18302795qkh.13.2015.04.28.04.54.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 28 Apr 2015 04:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:60840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn45l-0003iN-RN for patch@linaro.org; Tue, 28 Apr 2015 07:54:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn45E-0003Hl-O9 for qemu-devel@nongnu.org; Tue, 28 Apr 2015 07:53:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn42x-0003xV-DN for qemu-devel@nongnu.org; Tue, 28 Apr 2015 07:52:17 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:35280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn42w-0003xP-Ph for qemu-devel@nongnu.org; Tue, 28 Apr 2015 07:51:26 -0400 Received: by pdbqd1 with SMTP id qd1so161774124pdb.2 for ; Tue, 28 Apr 2015 04:51:26 -0700 (PDT) X-Received: by 10.68.217.106 with SMTP id ox10mr30758778pbc.21.1430221885906; Tue, 28 Apr 2015 04:51:25 -0700 (PDT) Received: from localhost ([167.160.116.84]) by mx.google.com with ESMTPSA id l1sm20023793pdp.71.2015.04.28.04.51.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 28 Apr 2015 04:51:24 -0700 (PDT) From: shannon.zhao@linaro.org To: qemu-devel@nongnu.org, peter.maydell@linaro.org, cornelia.huck@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, christoffer.dall@linaro.org Date: Tue, 28 Apr 2015 19:51:12 +0800 Message-Id: <1430221873-5788-2-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430221873-5788-1-git-send-email-shannon.zhao@linaro.org> References: <1430221873-5788-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.179 Cc: hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH v4 1/2] virtio-net: Move DEFINE_VIRTIO_NET_FEATURES to virtio-net X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Shannon Zhao So far virtio-net-device can't expose host features to guest while using virtio-mmio because it doesn't set DEFINE_VIRTIO_NET_FEATURES on backend or transport. So the performance is low. The host features belong to the backend while virtio-net-pci, virtio-net-s390 and virtio-net-ccw set the DEFINE_VIRTIO_NET_FEATURES on transports. But they already have the ability to forward property accesses to the backend child. So if we move the host features to backends, it doesn't break the backwards compatibility for them and make host features work while using virtio-mmio. Here we move DEFINE_VIRTIO_NET_FEATURES to the backend virtio-net. The transports just sync the host features from backend. Meanwhile move virtio_net_set_config_size to virtio-net to make sure the config size is correct and don't expose it. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/net/virtio-net.c | 7 ++++++- hw/s390x/s390-virtio-bus.c | 2 -- hw/s390x/virtio-ccw.c | 2 -- hw/virtio/virtio-pci.c | 2 -- include/hw/virtio/virtio-net.h | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 59f76bc..5c38ac2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -446,6 +446,9 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) VirtIONet *n = VIRTIO_NET(vdev); NetClientState *nc = qemu_get_queue(n->nic); + /* Firstly sync all virtio-net possible supported features */ + features |= n->host_features; + virtio_add_feature(&features, VIRTIO_NET_F_MAC); if (!peer_has_vnet_hdr(n)) { @@ -1552,7 +1555,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, vdev, idx, mask); } -void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) +static void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) { int i, config_size = 0; virtio_add_feature(&host_features, VIRTIO_NET_F_MAC); @@ -1585,6 +1588,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) NetClientState *nc; int i; + virtio_net_set_config_size(n, n->host_features); virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); n->max_queues = MAX(n->nic_conf.peers.queues, 1); @@ -1721,6 +1725,7 @@ static void virtio_net_instance_init(Object *obj) } static Property virtio_net_properties[] = { + DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features), DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf), DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer, TX_TIMER_INTERVAL), diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index 047c963..b893e02 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -145,7 +145,6 @@ static void s390_virtio_net_realize(VirtIOS390Device *s390_dev, Error **errp) DeviceState *vdev = DEVICE(&dev->vdev); Error *err = NULL; - virtio_net_set_config_size(&dev->vdev, s390_dev->host_features); virtio_net_set_netclient_name(&dev->vdev, qdev->id, object_get_typename(OBJECT(qdev))); qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)); @@ -508,7 +507,6 @@ static unsigned virtio_s390_get_features(DeviceState *d) static Property s390_virtio_net_properties[] = { DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features), - DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d32ecaf..1252162 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -779,7 +779,6 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) DeviceState *vdev = DEVICE(&dev->vdev); Error *err = NULL; - virtio_net_set_config_size(&dev->vdev, ccw_dev->host_features[0]); virtio_net_set_netclient_name(&dev->vdev, qdev->id, object_get_typename(OBJECT(qdev))); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); @@ -1403,7 +1402,6 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) static Property virtio_ccw_net_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_NET_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index c7c3f72..c6b99f9 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1360,7 +1360,6 @@ static Property virtio_net_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3), - DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features), DEFINE_PROP_END_OF_LIST(), }; @@ -1370,7 +1369,6 @@ static void virtio_net_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev); DeviceState *vdev = DEVICE(&dev->vdev); - virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features); virtio_net_set_netclient_name(&dev->vdev, qdev->id, object_get_typename(OBJECT(qdev))); qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 4c2fe83..e0dbb41 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -68,6 +68,7 @@ typedef struct VirtIONet { uint32_t has_vnet_hdr; size_t host_hdr_len; size_t guest_hdr_len; + uint32_t host_features; uint8_t has_ufo; int mergeable_rx_bufs; uint8_t promisc; @@ -137,7 +138,6 @@ typedef struct VirtIONet { DEFINE_PROP_INT32("x-txburst", _state, _field.txburst, TX_BURST), \ DEFINE_PROP_STRING("tx", _state, _field.tx) -void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features); void virtio_net_set_netclient_name(VirtIONet *n, const char *name, const char *type);