avf: allocate descriptor memory from local numa
[vpp.git] / src / vlib / linux / pci.c
index 724bb9d..b99f54f 100644 (file)
@@ -97,6 +97,7 @@ typedef struct
   linux_pci_device_type_t type;
   vlib_pci_dev_handle_t handle;
   vlib_pci_addr_t addr;
+  u32 numa_node;
 
   /* Resource file descriptors. */
   linux_pci_region_t *regions;
@@ -165,6 +166,13 @@ vlib_pci_get_addr (vlib_main_t * vm, vlib_pci_dev_handle_t h)
   return &d->addr;
 }
 
+u32
+vlib_pci_get_numa_node (vlib_main_t * vm, vlib_pci_dev_handle_t h)
+{
+  linux_pci_device_t *d = linux_pci_get_device (h);
+  return d->numa_node;
+}
+
 /* 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. */
@@ -584,7 +592,7 @@ vfio_set_irqs (vlib_main_t * vm, linux_pci_device_t * p, u32 index, u32 start,
   if (efds)
     {
       flags |= VFIO_IRQ_SET_DATA_EVENTFD;
-      clib_memcpy (&irq_set->data, efds, data_len);
+      clib_memcpy_fast (&irq_set->data, efds, data_len);
     }
   else
     flags |= VFIO_IRQ_SET_DATA_NONE;
@@ -1210,6 +1218,11 @@ vlib_pci_device_open (vlib_main_t * vm, vlib_pci_addr_t * addr,
   p->handle = p - lpm->linux_pci_devices;
   p->addr.as_u32 = di->addr.as_u32;
   p->intx_irq.fd = -1;
+  p->numa_node = di->numa_node;
+  /*
+   * pci io bar read/write fd
+   */
+  p->io_fd = -1;
 
   pci_log_debug (vm, p, "open vid:0x%04x did:0x%04x driver:%s iommu_group:%d",
                 di->vendor_id, di->device_id, di->driver_name,
@@ -1253,6 +1266,8 @@ vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h)
       irq = &p->intx_irq;
       clib_file_del_by_index (&file_main, irq->clib_file_index);
       close (p->config_fd);
+      if (p->io_fd != -1)
+       close (p->io_fd);
     }
   else if (p->type == LINUX_PCI_DEVICE_TYPE_VFIO)
     {