dpdk: Be wary of the return value from rte_eth_dev_socket_id
[vpp.git] / src / plugins / dpdk / device / init.c
index 23a26a4..ad38694 100644 (file)
@@ -205,8 +205,12 @@ dpdk_find_startup_config (struct rte_eth_dev_info *di)
   if ((vmbus_dev = dpdk_get_vmbus_device (di)))
     {
       unformat_input_t input_vmbus;
-      unformat_init_string (&input_vmbus, di->device->name,
-                           strlen (di->device->name));
+#if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0)
+      const char *dev_name = rte_dev_name (di->device);
+#else
+      const char *dev_name = di->device->name;
+#endif
+      unformat_init_string (&input_vmbus, dev_name, strlen (dev_name));
       if (unformat (&input_vmbus, "%U", unformat_vlib_vmbus_addr, &vmbus_addr))
        p = mhash_get (&dm->conf->device_config_index_by_vmbus_addr,
                       &vmbus_addr);
@@ -264,6 +268,7 @@ dpdk_lib_init (dpdk_main_t * dm)
       dpdk_device_config_t *devconf = 0;
       vnet_eth_interface_registration_t eir = {};
       dpdk_driver_t *dr;
+      i8 numa_node;
 
       if (!rte_eth_dev_is_valid_port (port_id))
        continue;
@@ -444,11 +449,19 @@ dpdk_lib_init (dpdk_main_t * dm)
       eir.cb.set_max_frame_size = dpdk_set_max_frame_size;
       xd->hw_if_index = vnet_eth_register_interface (vnm, &eir);
       hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
-      hi->numa_node = xd->cpu_socket = (i8) rte_eth_dev_socket_id (port_id);
+      numa_node = (i8) rte_eth_dev_socket_id (port_id);
+      if (numa_node == SOCKET_ID_ANY)
+       /* numa_node is not set, default to 0 */
+       hi->numa_node = xd->cpu_socket = 0;
+      else
+       hi->numa_node = xd->cpu_socket = numa_node;
       sw = vnet_get_hw_sw_interface (vnm, xd->hw_if_index);
       xd->sw_if_index = sw->sw_if_index;
       dpdk_log_debug ("[%u] interface %s created", port_id, hi->name);
 
+      if (devconf->tag)
+       vnet_set_sw_interface_tag (vnm, devconf->tag, sw->sw_if_index);
+
       ethernet_set_flags (vnm, xd->hw_if_index,
                          ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
 
@@ -626,7 +639,8 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf)
             d->device_class == PCI_CLASS_PROCESSOR_CO &&
             (d->device_id == 0x0443 || d->device_id == 0x18a1 ||
              d->device_id == 0x19e3 || d->device_id == 0x37c9 ||
-             d->device_id == 0x6f55 || d->device_id == 0x4941))
+             d->device_id == 0x6f55 || d->device_id == 0x18ef ||
+             d->device_id == 0x4941))
       ;
     /* Cisco VIC */
     else if (d->vendor_id == 0x1137 &&
@@ -672,6 +686,9 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf)
         d->device_id == 0x1614 || d->device_id == 0x1606 ||
         d->device_id == 0x1609 || d->device_id == 0x1614)))
       ;
+    /* Google vNIC */
+    else if (d->vendor_id == 0x1ae0 && d->device_id == 0x0042)
+      ;
     else
       {
         dpdk_log_warn ("Unsupported PCI device 0x%04x:0x%04x found "
@@ -680,7 +697,8 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf)
         continue;
       }
 
-    error = vlib_pci_bind_to_uio (vm, addr, (char *) conf->uio_driver_name);
+    error = vlib_pci_bind_to_uio (vm, addr, (char *) conf->uio_driver_name,
+                                 conf->uio_bind_force);
 
     if (error)
       {
@@ -875,6 +893,8 @@ dpdk_device_config (dpdk_config_main_t *conf, void *addr,
        ;
       else if (unformat (input, "name %v", &devconf->name))
        ;
+      else if (unformat (input, "tag %s", &devconf->tag))
+       ;
       else if (unformat (input, "workers %U", unformat_bitmap_list,
                         &devconf->workers))
        ;
@@ -987,7 +1007,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
   int eal_no_hugetlb = 0;
   u8 no_pci = 0;
   u8 no_vmbus = 0;
-  u8 no_dsa = 0;
   u8 file_prefix = 0;
   u8 *socket_mem = 0;
   u8 *huge_dir_path = 0;
@@ -1088,6 +1107,8 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
        }
       else if (unformat (input, "uio-driver %s", &conf->uio_driver_name))
        ;
+      else if (unformat (input, "uio-bind-force"))
+       conf->uio_bind_force = 1;
       else if (unformat (input, "socket-mem %s", &socket_mem))
        ;
       else if (unformat (input, "no-pci"))
@@ -1096,8 +1117,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
          tmp = format (0, "--no-pci%c", 0);
          vec_add1 (conf->eal_init_args, tmp);
        }
-      else if (unformat (input, "no-dsa"))
-       no_dsa = 1;
       else if (unformat (input, "blacklist %U", unformat_vlib_vmbus_addr,
                         &vmbus_addr))
        {
@@ -1307,13 +1326,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
 
   vm = vlib_get_main ();
 
-  if (no_dsa)
-    {
-      struct rte_bus *bus;
-      bus = rte_bus_find_by_name ("dsa");
-      if (bus)
-       rte_bus_unregister (bus);
-    }
   /* make copy of args as rte_eal_init tends to mess up with arg array */
   for (i = 1; i < vec_len (conf->eal_init_args); i++)
     conf->eal_init_args_str = format (conf->eal_init_args_str, "%s ",
@@ -1441,6 +1453,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
   dpdk_device_t *xd;
   vlib_thread_main_t *tm = vlib_get_thread_main ();
 
+  vlib_worker_thread_barrier_sync (vm);
   error = dpdk_lib_init (dm);
 
   if (error)
@@ -1457,6 +1470,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
        }
     }
 
+  vlib_worker_thread_barrier_release (vm);
   tm->worker_thread_release = 1;
 
   f64 now = vlib_time_now (vm);