summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/virtio_pci_modern.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-11-16 16:49:30 +0100
committerBeno�t Ganne <bganne@cisco.com>2020-11-17 16:43:26 +0000
commitb977d3f7c28caee8359098be569b55e770c5c6ec (patch)
tree8ef5cdeea9c772e342622fe46e83da77d3438bfa /src/vnet/devices/virtio/virtio_pci_modern.c
parentb18796092bd1ef23d41b70c83c69d8d9cd2d051a (diff)
virtio: virtio: implement packed queues from virtio 1.1
Type: feature Change-Id: I12703371541298efa029903d6762b1cd1f7322ca Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/virtio_pci_modern.c')
-rw-r--r--src/vnet/devices/virtio/virtio_pci_modern.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/vnet/devices/virtio/virtio_pci_modern.c b/src/vnet/devices/virtio/virtio_pci_modern.c
index 1934f98003d..8e090ffed3a 100644
--- a/src/vnet/devices/virtio/virtio_pci_modern.c
+++ b/src/vnet/devices/virtio/virtio_pci_modern.c
@@ -268,24 +268,39 @@ static u8
virtio_pci_modern_setup_queue (vlib_main_t * vm, virtio_if_t * vif,
u16 queue_id, void *p)
{
- vring_t vr;
+ u64 desc, avail, used;
u16 queue_size = 0;
virtio_pci_modern_set_queue_select (vif, queue_id);
queue_size = virtio_pci_modern_get_queue_size (vm, vif, queue_id);
- vring_init (&vr, queue_size, p, VIRTIO_PCI_VRING_ALIGN);
- u64 desc = vlib_physmem_get_pa (vm, vr.desc);
+ if (vif->is_packed)
+ {
+ virtio_vring_t *vring = (virtio_vring_t *) p;
+
+ desc = vlib_physmem_get_pa (vm, vring->packed_desc);
+ avail = vlib_physmem_get_pa (vm, vring->driver_event);
+ used = vlib_physmem_get_pa (vm, vring->device_event);
+ }
+ else
+ {
+ vring_t vr;
+
+ vring_init (&vr, queue_size, p, VIRTIO_PCI_VRING_ALIGN);
+
+ desc = vlib_physmem_get_pa (vm, vr.desc);
+ avail = vlib_physmem_get_pa (vm, vr.avail);
+ used = vlib_physmem_get_pa (vm, vr.used);
+ }
+
virtio_pci_modern_set_queue_desc (vif, desc);
if (desc != virtio_pci_modern_get_queue_desc (vif))
return 1;
- u64 avail = vlib_physmem_get_pa (vm, vr.avail);
virtio_pci_modern_set_queue_driver (vif, avail);
if (avail != virtio_pci_modern_get_queue_driver (vif))
return 1;
- u64 used = vlib_physmem_get_pa (vm, vr.used);
virtio_pci_modern_set_queue_device (vif, used);
if (used != virtio_pci_modern_get_queue_device (vif))
return 1;