2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

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>
This commit is contained in:
Daniele Di Proietto
2014-07-16 17:10:59 -07:00
committed by Pravin B Shelar
parent a413195ece
commit 033e9df25f

View 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);