eal: do not panic when CPU is not supported
[dpdk.git] / lib / librte_eal / bsdapp / eal / eal.c
index b64bbfc..8ad6157 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -56,6 +56,7 @@
 #include <rte_launch.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
+#include <rte_errno.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
@@ -64,6 +65,7 @@
 #include <rte_string_fns.h>
 #include <rte_cpuflags.h>
 #include <rte_interrupts.h>
+#include <rte_bus.h>
 #include <rte_pci.h>
 #include <rte_dev.h>
 #include <rte_devargs.h>
@@ -486,6 +488,12 @@ rte_eal_iopl_init(void)
        return 0;
 }
 
+static void rte_eal_init_alert(const char *msg)
+{
+       fprintf(stderr, "EAL: FATAL: %s\n", msg);
+       RTE_LOG(ERR, EAL, "%s\n", msg);
+}
+
 /* Launch threads, called at application init(). */
 int
 rte_eal_init(int argc, char **argv)
@@ -496,21 +504,28 @@ rte_eal_init(int argc, char **argv)
        char cpuset[RTE_CPU_AFFINITY_STR_LEN];
        char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
+       /* checks if the machine is adequate */
+       if (!rte_cpu_is_supported()) {
+               rte_eal_init_alert("unsupported cpu type.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
+
        if (!rte_atomic32_test_and_set(&run_once))
                return -1;
 
        thread_id = pthread_self();
 
-       if (rte_eal_log_early_init() < 0)
-               rte_panic("Cannot init early logs\n");
-
        eal_log_level_parse(argc, argv);
 
        /* set log level as early as possible */
        rte_set_log_level(internal_config.log_level);
 
-       if (rte_eal_cpu_init() < 0)
-               rte_panic("Cannot detect lcores\n");
+       if (rte_eal_cpu_init() < 0) {
+               rte_eal_init_alert("Cannot detect lcores.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
 
        fctret = eal_parse_args(argc, argv);
        if (fctret < 0)
@@ -552,9 +567,6 @@ rte_eal_init(int argc, char **argv)
        if (rte_eal_tailqs_init() < 0)
                rte_panic("Cannot init tail queues for objects\n");
 
-/*     if (rte_eal_log_init(argv[0], internal_config.syslog_facility) < 0)
-               rte_panic("Cannot init logs\n");*/
-
        if (rte_eal_alarm_init() < 0)
                rte_panic("Cannot init interrupt-handling thread\n");
 
@@ -569,7 +581,8 @@ rte_eal_init(int argc, char **argv)
 
        eal_check_mem_on_local_socket();
 
-       rte_eal_mcfg_complete();
+       if (eal_plugins_init() < 0)
+               rte_panic("Cannot init plugins\n");
 
        eal_thread_init_master(rte_config.master_lcore);
 
@@ -579,8 +592,8 @@ rte_eal_init(int argc, char **argv)
                rte_config.master_lcore, thread_id, cpuset,
                ret == 0 ? "" : "...");
 
-       if (rte_eal_dev_init() < 0)
-               rte_panic("Cannot init pmd devices\n");
+       if (rte_bus_scan())
+               rte_panic("Cannot scan the buses for devices\n");
 
        RTE_LCORE_FOREACH_SLAVE(i) {
 
@@ -604,7 +617,7 @@ rte_eal_init(int argc, char **argv)
                /* Set thread_name for aid in debugging. */
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
                                "lcore-slave-%d", i);
-               pthread_set_name_np(lcore_config[i].thread_id, thread_name);
+               rte_thread_setname(lcore_config[i].thread_id, thread_name);
        }
 
        /*
@@ -614,10 +627,19 @@ rte_eal_init(int argc, char **argv)
        rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
        rte_eal_mp_wait_lcore();
 
+       /* Probe all the buses and devices/drivers on them */
+       if (rte_bus_probe())
+               rte_panic("Cannot probe devices\n");
+
        /* Probe & Initialize PCI devices */
        if (rte_eal_pci_probe())
                rte_panic("Cannot probe PCI\n");
 
+       if (rte_eal_dev_init() < 0)
+               rte_panic("Cannot init pmd devices\n");
+
+       rte_eal_mcfg_complete();
+
        return fctret;
 }