summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Di Proietto <ddiproietto@vmware.com>2014-07-16 17:10:59 -0700
committerPravin B Shelar <pshelar@nicira.com>2014-07-17 11:16:32 -0700
commit033e9df25fd3828959e332caf086706e91111a55 (patch)
tree1d7b7d1f932ebdaae4beb1bcaebf4e7681dcab9d
parenta413195ecede139380166065bf42699b3c002acd (diff)
downloadopenvswitch-033e9df25fd3828959e332caf086706e91111a55.tar.gz
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 <ddiproietto@vmware.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
-rw-r--r--lib/netdev-dpdk.c40
1 files 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,33 +1188,14 @@ 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);