virtio: fix modern device queue notify
QUEUE_SELECT and QUEUE_NOTIFY_OFF registers are shared between all
workers operating on the same device and operations are not atomic
Type: fix
Change-Id: Ie017b1bfc7e3b6b4e59029f45db78eeffd9f3aeb
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index 71d813a..9b68b1c 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -486,7 +486,11 @@
virtio_log_debug (vif, "control-queue: number %u, size %u", queue_num,
queue_size);
vif->virtio_pci_func->setup_queue (vm, vif, queue_num, ptr);
- vring->kick_fd = -1;
+ vring->queue_notify_offset =
+ vif->notify_off_multiplier *
+ vif->virtio_pci_func->get_queue_notify_off (vm, vif, queue_num);
+ virtio_log_debug (vif, "queue-notify-offset: number %u, offset %u",
+ queue_num, vring->queue_notify_offset);
return error;
}
@@ -562,7 +566,11 @@
if (vif->virtio_pci_func->setup_queue (vm, vif, queue_num, ptr))
return clib_error_return (0, "error in queue address setup");
- vring->kick_fd = -1;
+ vring->queue_notify_offset =
+ vif->notify_off_multiplier *
+ vif->virtio_pci_func->get_queue_notify_off (vm, vif, queue_num);
+ virtio_log_debug (vif, "queue-notify-offset: number %u, offset %u",
+ queue_num, vring->queue_notify_offset);
return error;
}
@@ -775,6 +783,7 @@
if (common_cfg == 0 || notify == 0 || dev_cfg == 0 || isr == 0)
{
vif->virtio_pci_func = &virtio_pci_legacy_func;
+ vif->notify_off_multiplier = 0;
virtio_log_debug (vif, "legacy virtio pci device found");
return error;
}
@@ -783,9 +792,14 @@
vif->virtio_pci_func = &virtio_pci_modern_func;
if (!pci_cfg)
- virtio_log_debug (vif, "modern virtio pci device found");
+ {
+ virtio_log_debug (vif, "modern virtio pci device found");
+ }
+ else
+ {
+ virtio_log_debug (vif, "transitional virtio pci device found");
+ }
- virtio_log_debug (vif, "transitional virtio pci device found");
return error;
}
@@ -1244,8 +1258,6 @@
vec_foreach_index (i, vif->rxq_vrings)
{
virtio_vring_t *vring = vec_elt_at_index (vif->rxq_vrings, i);
- if (vring->kick_fd != -1)
- close (vring->kick_fd);
if (vring->used)
{
virtio_free_rx_buffers (vm, vring);
@@ -1257,8 +1269,6 @@
vec_foreach_index (i, vif->txq_vrings)
{
virtio_vring_t *vring = vec_elt_at_index (vif->txq_vrings, i);
- if (vring->kick_fd != -1)
- close (vring->kick_fd);
if (vring->used)
{
virtio_free_used_desc (vm, vring);