aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2019-01-28 19:30:21 +0000
committerDamjan Marion <dmarion@me.com>2019-01-29 16:37:36 +0000
commit22c0ece25c72238cde7d7a3d98931795edae4785 (patch)
treea855ea8bad7f4a15036f6f82fdf32cde8a3790fe /src/vnet/devices
parent0ef8ef2b474473b13de2cee0165b424e79e4e363 (diff)
virtio: Support legacy and transitional virtio devices
Change-Id: Ib1316482dd7b1ae3c27c7eeb55839ed8af9ca162 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/virtio/pci.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index e615827ccd4..0ff453eb204 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -586,7 +586,7 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
clib_error_t *error = 0;
virtio_main_t *vim = &virtio_main;
struct virtio_pci_cap cap;
- u8 pos, common_cfg = 0, notify_base = 0, dev_cfg = 0, isr = 0;
+ u8 pos, common_cfg = 0, notify_base = 0, dev_cfg = 0, isr = 0, pci_cfg = 0;
vlib_pci_dev_handle_t h = vif->pci_dev_handle;
if ((error = vlib_pci_read_config_u8 (vm, h, PCI_CAPABILITY_LIST, &pos)))
@@ -637,18 +637,25 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
case VIRTIO_PCI_CAP_ISR_CFG:
isr = 1;
break;
+ case VIRTIO_PCI_CAP_PCI_CFG:
+ if (cap.bar == 0)
+ pci_cfg = 1;
+ break;
}
next:
pos = cap.cap_next;
}
+ if (!pci_cfg)
+ clib_error_return (error, "modern virtio pci device found");
+
if (common_cfg == 0 || notify_base == 0 || dev_cfg == 0 || isr == 0)
{
virtio_log_debug (vim, vif, "legacy virtio pci device found");
return error;
}
- virtio_log_debug (vim, vif, "modern virtio pci device found");
+ virtio_log_debug (vim, vif, "transitional virtio pci device found");
return error;
}
@@ -659,7 +666,8 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
clib_error_t *error = 0;
u8 status = 0;
- virtio_pci_read_caps (vm, vif);
+ if ((error = virtio_pci_read_caps (vm, vif)))
+ clib_error_return (error, "Device not supported");
if (virtio_pci_reset_device (vm, vif) < 0)
clib_error_return (error, "Failed to reset the device");