ikev2: fix udp encap
[vpp.git] / src / plugins / dpdk / main.c
index 5437e2f..ef93a22 100644 (file)
@@ -58,7 +58,8 @@ rte_delay_us_override (unsigned us)
          /* Only suspend for the admin_down_process */
          vlib_process_t *proc = vlib_get_current_process (vm);
          if (!(proc->flags & VLIB_PROCESS_IS_RUNNING) ||
-             (proc->node_runtime.function != admin_up_down_process))
+             (proc->node_runtime.node_index !=
+              admin_up_down_process_node.index))
            return 0;
 
          f64 delay = 1e-6 * us;
@@ -84,19 +85,21 @@ static clib_error_t * dpdk_main_init (vlib_main_t * vm)
   dm->vlib_main = vm;
   dm->vnet_main = vnet_get_main ();
 
-  if ((error = vlib_call_init_function (vm, dpdk_init)))
-    return error;
-
   /* register custom delay function */
   rte_delay_us_callback_register (rte_delay_us_override_cb);
 
   return error;
 }
 
-VLIB_INIT_FUNCTION (dpdk_main_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (dpdk_main_init) =
+{
+    .runs_after = VLIB_INITS("dpdk_init"),
+};
+/* *INDENT-ON* */
 
 
-clib_error_t *
+__clib_export clib_error_t *
 dpdk_early_init (vlib_main_t *vm)
 {
   int fd = -1;
@@ -106,19 +109,33 @@ dpdk_early_init (vlib_main_t *vm)
   /* check if pagemap is accessible - if we get zero result
      dpdk will not be able to get physical memory address and game is over
      unless we have IOMMU */
-  pt = clib_mem_vm_get_paddr (&pt, min_log2 (sysconf (_SC_PAGESIZE)), 1);
+  pt = clib_mem_vm_get_paddr (&pt, CLIB_MEM_PAGE_SZ_DEFAULT, 1);
   if (pt && pt[0])
-    goto done;
+    goto check_hugetlb;
 
-  if ((fd = open ("/dev/vfio/vfio", O_RDWR) == -1))
+  if ((fd = open ("/dev/vfio/vfio", O_RDWR)) == -1)
       goto error;
 
   if (ioctl (fd, VFIO_GET_API_VERSION) != VFIO_API_VERSION)
       goto error;
 
   /* if we have type 1 IOMMU page map is not needed */
-  if (ioctl (fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) == 1)
-    goto done;
+  if (ioctl (fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) != 1)
+    goto error;
+
+check_hugetlb:
+  fd = clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT_HUGE,
+                             "dpdk early init");
+
+  if (fd != -1)
+    {
+      u8 *page = clib_mem_vm_map_shared (0, 1, fd, 0, "dpdk_early_init");
+      if (page != CLIB_MEM_VM_MAP_FAILED)
+       {
+         clib_mem_vm_unmap (page);
+         goto done;
+       }
+    }
 
 error:
   err = clib_error_return (0, "access to physical devices is not allowed");