netdev-dpdk: Refactor dpdk_class_init()
authorDaniele Di Proietto <ddiproietto@vmware.com>
Thu, 17 Jul 2014 00:10:59 +0000 (17:10 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Thu, 17 Jul 2014 18:16:32 +0000 (11:16 -0700)
The following changes were made:

- Since we have two dpdk classes, we should split the initial operations needed
  by both classes from the initialization needed by each class.
- The dpdk_ring class does not need an initialization function: it has been
  removed. This also prevents many testcase from failing, because
  dpdk_ring_class_init() was printing an unexpected log message
  (OVS_VSWITCHD_START at tests/ofproto-macros.at:54 check for a specific set of
  startup log messages)
- If the user doesn't pass the --dpdk option we do not register the dpdk*
  classes
- Do not call VLOG_ERR if there are 0 dpdk ethernet device. OVS can now be used
  with dpdk_ring devices.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
lib/netdev-dpdk.c

index 6de1b2b..b925dd2 100644 (file)
@@ -1161,15 +1161,21 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, int argc,
     unixctl_command_reply(conn, "OK");
 }
 
+static void
+dpdk_common_init(void)
+{
+    unixctl_command_register("netdev-dpdk/set-admin-state",
+                             "[netdev] up|down", 1, 2,
+                             netdev_dpdk_set_admin_state, NULL);
+
+    ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
+}
+
 static int
 dpdk_class_init(void)
 {
     int result;
 
-    if (rte_eal_init_ret) {
-        return 0;
-    }
-
     result = rte_pmd_init_all();
     if (result) {
         VLOG_ERR("Cannot init PMD");
@@ -1182,32 +1188,13 @@ dpdk_class_init(void)
         return -result;
     }
 
-    if (rte_eth_dev_count() < 1) {
-        VLOG_ERR("No Ethernet devices found. Try assigning ports to UIO.");
-    }
-
     VLOG_INFO("Ethernet Device Count: %d", (int)rte_eth_dev_count());
 
-    list_init(&dpdk_list);
-    list_init(&dpdk_mp_list);
-
-    unixctl_command_register("netdev-dpdk/set-admin-state",
-                             "[netdev] up|down", 1, 2,
-                             netdev_dpdk_set_admin_state, NULL);
-
-    ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
     return 0;
 }
 
 /* Client Rings */
 
-static int
-dpdk_ring_class_init(void)
-{
-    VLOG_INFO("Initialized dpdk client handlers:\n");
-    return 0;
-}
-
 static int
 dpdk_ring_create(const char dev_name[], unsigned int port_no,
                  unsigned int *eth_port_id)
@@ -1409,7 +1396,7 @@ const struct netdev_class dpdk_class =
 const struct netdev_class dpdk_ring_class =
     NETDEV_DPDK_CLASS(
         "dpdkr",
-        dpdk_ring_class_init,
+        NULL,
         netdev_dpdk_ring_construct);
 
 void
@@ -1417,7 +1404,12 @@ netdev_dpdk_register(void)
 {
     static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
 
+    if (rte_eal_init_ret) {
+        return;
+    }
+
     if (ovsthread_once_start(&once)) {
+        dpdk_common_init();
         netdev_register_provider(&dpdk_class);
         netdev_register_provider(&dpdk_ring_class);
         ovsthread_once_done(&once);