From patchwork Wed Dec 4 03:21:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1203962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47SPKJ6f96z9sPL for ; Wed, 4 Dec 2019 14:21:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47SPKJ45yrzDqSj for ; Wed, 4 Dec 2019 14:21:56 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from ozlabs.ru (unknown [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 47SPKD3lXkzDqSJ for ; Wed, 4 Dec 2019 14:21:51 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 8DEECAE801F8; Tue, 3 Dec 2019 22:20:43 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 4 Dec 2019 14:21:36 +1100 Message-Id: <20191204032138.127624-4-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191204032138.127624-1-aik@ozlabs.ru> References: <20191204032138.127624-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof v4 3/5] virtio-net: Init queues after features negotiation X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Every virtio device negotiates virtio protocol features before setting up internal queue descriptors with one exception which is virtio-net. This moves virtio_queue_init_vq() later to have feature negotiation happened sooner. This is going to be used for IOMMU setup later. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Michael Roth --- lib/libvirtio/virtio-net.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c index 2290b2d74765..ae67883020ef 100644 --- a/lib/libvirtio/virtio-net.c +++ b/lib/libvirtio/virtio-net.c @@ -84,18 +84,6 @@ static int virtionet_init_pci(struct virtio_net *vnet, struct virtio_device *dev /* Reset device */ virtio_reset_device(vdev); - /* The queue information can be retrieved via the virtio header that - * can be found in the I/O BAR. First queue is the receive queue, - * second the transmit queue, and the forth is the control queue for - * networking options. - * We are only interested in the receive and transmit queue here. */ - if (!virtio_queue_init_vq(vdev, VQ_RX) || - !virtio_queue_init_vq(vdev, VQ_TX)) { - virtio_set_status(vdev, VIRTIO_STAT_ACKNOWLEDGE|VIRTIO_STAT_DRIVER - |VIRTIO_STAT_FAILED); - return -1; - } - /* Acknowledge device. */ virtio_set_status(vdev, VIRTIO_STAT_ACKNOWLEDGE); @@ -113,7 +101,7 @@ static int virtionet_init(struct virtio_net *vnet) int status = VIRTIO_STAT_ACKNOWLEDGE | VIRTIO_STAT_DRIVER; struct virtio_device *vdev = &vnet->vdev; net_driver_t *driver = &vnet->driver; - struct vqs *vq_tx = &vdev->vq[VQ_TX], *vq_rx = &vdev->vq[VQ_RX]; + struct vqs *vq_tx, *vq_rx; dprintf("virtionet_init(%02x:%02x:%02x:%02x:%02x:%02x)\n", driver->mac_addr[0], driver->mac_addr[1], @@ -137,6 +125,19 @@ static int virtionet_init(struct virtio_net *vnet) virtio_set_guest_features(vdev, 0); } + /* The queue information can be retrieved via the virtio header that + * can be found in the I/O BAR. First queue is the receive queue, + * second the transmit queue, and the forth is the control queue for + * networking options. + * We are only interested in the receive and transmit queue here. */ + vq_rx = virtio_queue_init_vq(vdev, VQ_RX); + vq_tx = virtio_queue_init_vq(vdev, VQ_TX); + if (!vq_rx || !vq_tx) { + virtio_set_status(vdev, VIRTIO_STAT_ACKNOWLEDGE|VIRTIO_STAT_DRIVER + |VIRTIO_STAT_FAILED); + return -1; + } + /* Allocate memory for one transmit an multiple receive buffers */ vq_rx->buf_mem = SLOF_alloc_mem((BUFFER_ENTRY_SIZE+net_hdr_size) * RX_QUEUE_SIZE);