From 033e9df25fd3828959e332caf086706e91111a55 Mon Sep 17 00:00:00 2001 From: Daniele Di Proietto Date: Wed, 16 Jul 2014 17:10:59 -0700 Subject: [PATCH] netdev-dpdk: Refactor dpdk_class_init() 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 Acked-by: Pravin B Shelar --- lib/netdev-dpdk.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 6de1b2b22..b925dd28b 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -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); -- 2.20.1