aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2019-11-07 17:54:58 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2019-12-05 14:41:07 +1100
commit1aeb125770c4c161394b851b0eff982292702c23 (patch)
tree4d618d9b02b01e7a090bd43c0be75c913cc01021 /lib
parent300384f3dc68588a051f5737aee3b5eab4dd19e4 (diff)
downloadSLOF-1aeb125770c4c161394b851b0eff982292702c23.zip
SLOF-1aeb125770c4c161394b851b0eff982292702c23.tar.gz
SLOF-1aeb125770c4c161394b851b0eff982292702c23.tar.bz2
virtio-net: Init queues after features negotiation
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 <aik@ozlabs.ru> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvirtio/virtio-net.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c
index 2290b2d..ae67883 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);