From patchwork Sun Feb 3 22:22:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 217812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A47FD2C0292 for ; Mon, 4 Feb 2013 09:18:47 +1100 (EST) Received: from localhost ([::1]:45414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27td-0001fl-3z for incoming@patchwork.ozlabs.org; Sun, 03 Feb 2013 17:18:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27tQ-0001V0-Nu for qemu-devel@nongnu.org; Sun, 03 Feb 2013 17:18:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U27tO-0000Vy-0J for qemu-devel@nongnu.org; Sun, 03 Feb 2013 17:18:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27tN-0000Vr-Od for qemu-devel@nongnu.org; Sun, 03 Feb 2013 17:18:29 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r13MISsD031767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 3 Feb 2013 17:18:28 -0500 Received: from redhat.com (vpn-200-77.tlv.redhat.com [10.35.200.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r13MIPJx021363; Sun, 3 Feb 2013 17:18:26 -0500 Date: Mon, 4 Feb 2013 00:22:46 +0200 From: "Michael S. Tsirkin" To: Anthony Liguori Message-ID: <20130203222246.GA21229@redhat.com> References: <510C25F2.8000406@msgid.tls.msk.ru> <87fw1fbwk7.fsf@codemonkey.ws> <510C28BD.7050701@msgid.tls.msk.ru> <87zjznagbd.fsf@codemonkey.ws> <510D09C2.6050905@redhat.com> <1359835708.1968.3.camel@localhost> <87halu1fic.fsf@codemonkey.ws> <401C01B3-F93C-4804-8208-D1D6F62285AC@redhat.com> <510E8BD4.9000505@msgid.tls.msk.ru> <87vca9gl4c.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87vca9gl4c.fsf@codemonkey.ws> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Rusty Russell , Jason Wang , Yan Vugenfirer , Michael Tokarev , qemu-devel , Vadim Rozenfeld Subject: Re: [Qemu-devel] Headsup: windows virtio networking does not work on current git 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Sun, Feb 03, 2013 at 03:09:39PM -0600, Anthony Liguori wrote: > Michael Tokarev writes: > > > 03.02.2013 17:23, Yan Vugenfirer wrote: > > > >>> If it helps, mq changes the config size from 8 to 16 bytes. If the > >>> driver was making an assumption about an 8-byte config size, that's > >>> likely what the problem is. > >>> > >> That's exactly the problem. > > > > So what do we do? It isn't nice to break existing setups. > > Maybe mq can be disabled by default (together with Antony's > > patch) until fixed drivers will be more widely available? > > I've got a patch that does exactly like this. It's pretty ugly though > because of the relationship between virtio-pci and virtio-net. I'm > going to try to see if I can find a cleaner way to do it on Monday. > > I'm also contemplating just disabling mq by default. Since a special > command line is needed to enable it anyway (on the backend), having to > specify mq=on for the device doesn't seem so bad. It's after midnight here so didn't test yet, but wouldn't the following achieve this in a way that is a bit cleaner? Signed-off-by: Michael S. Tsirkin diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 5699f5e..3342a76 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -346,6 +346,10 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 << VIRTIO_NET_F_MAC); + if (n->max_queues <= 1) { + features &= ~(0x1 << VIRTIO_NET_F_MQ); + } + if (!peer_has_vnet_hdr(n)) { features &= ~(0x1 << VIRTIO_NET_F_CSUM); features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4); @@ -1284,7 +1288,9 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf, int i; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, - sizeof(struct virtio_net_config), + conf->queues > 1 ? + sizeof(struct virtio_net_config) : + sizeof(struct virtio_net_config_compat), sizeof(VirtIONet)); n->vdev.get_config = virtio_net_get_config; diff --git a/hw/virtio-net.h b/hw/virtio-net.h index 1d5c721..95ad54f 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -69,6 +69,15 @@ typedef struct virtio_net_conf /* Maximum packet size we can receive from tap device: header + 64k */ #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10)) + +struct virtio_net_config_compat +{ + /* The config defining mac address ($ETH_ALEN bytes) */ + uint8_t mac[ETH_ALEN]; + /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ + uint16_t status; +} QEMU_PACKED; + struct virtio_net_config { /* The config defining mac address ($ETH_ALEN bytes) */