return d->numa_node;
}
+u32
+vlib_pci_get_num_msix_interrupts (vlib_main_t * vm, vlib_pci_dev_handle_t h)
+{
+ linux_pci_device_t *d = linux_pci_get_device (h);
+
+ if (d->type == LINUX_PCI_DEVICE_TYPE_VFIO)
+ {
+ struct vfio_irq_info ii = { 0 };
+
+ ii.argsz = sizeof (struct vfio_irq_info);
+ ii.index = VFIO_PCI_MSIX_IRQ_INDEX;
+ if (ioctl (d->fd, VFIO_DEVICE_GET_IRQ_INFO, &ii) < 0)
+ return 0;
+ return ii.count;
+ }
+ return 0;
+}
+
/* Call to allocate/initialize the pci subsystem.
This is not an init function so that users can explicitly enable
pci only when it's needed. */
{
vlib_buffer_pool_t *bp;
/* *INDENT-OFF* */
- vec_foreach (bp, buffer_main.buffer_pools)
+ vec_foreach (bp, vm->buffer_main->buffer_pools)
{
u32 i;
vlib_physmem_map_t *pm;
p->handle = p - lpm->linux_pci_devices;
p->addr.as_u32 = di->addr.as_u32;
p->intx_irq.fd = -1;
+ p->intx_irq.clib_file_index = -1;
p->numa_node = di->numa_node;
/*
* pci io bar read/write fd
if (p->type == LINUX_PCI_DEVICE_TYPE_UIO)
{
irq = &p->intx_irq;
- clib_file_del_by_index (&file_main, irq->clib_file_index);
+ if (irq->clib_file_index != -1)
+ clib_file_del_by_index (&file_main, irq->clib_file_index);
close (p->config_fd);
if (p->io_fd != -1)
close (p->io_fd);
err = vfio_set_irqs (vm, p, VFIO_PCI_INTX_IRQ_INDEX, 0, 0,
VFIO_IRQ_SET_ACTION_TRIGGER, 0);
clib_error_free (err);
- clib_file_del_by_index (&file_main, irq->clib_file_index);
+ if (irq->clib_file_index != -1)
+ clib_file_del_by_index (&file_main, irq->clib_file_index);
close (irq->fd);
}
{
vlib_pci_main_t *pm = &pci_main;
vlib_pci_addr_t *addr = 0, *addrs;
- clib_error_t *error;
pm->vlib_main = vm;
- if ((error = vlib_call_init_function (vm, unix_input_init)))
- return error;
-
ASSERT (sizeof (vlib_pci_addr_t) == sizeof (u32));
addrs = vlib_pci_get_all_dev_addrs ();
}
/* *INDENT-ON* */
- return error;
+ return 0;
}
-VLIB_INIT_FUNCTION (linux_pci_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (linux_pci_init) =
+{
+ .runs_after = VLIB_INITS("unix_input_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON