doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_eal / windows / eal.c
index addac62..28c787c 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
+#include <stdarg.h>
+
 #include <fcntl.h>
 #include <io.h>
 #include <share.h>
 #include <eal_filesystem.h>
 #include <eal_options.h>
 #include <eal_private.h>
+#include <rte_service_component.h>
 #include <rte_vfio.h>
 
 #include "eal_hugepages.h"
 #include "eal_trace.h"
+#include "eal_log.h"
 #include "eal_windows.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
@@ -66,6 +70,12 @@ eal_proc_type_detect(void)
        return ptype;
 }
 
+bool
+rte_mp_disable(void)
+{
+       return true;
+}
+
 /* display usage */
 static void
 eal_usage(const char *prgname)
@@ -142,6 +152,10 @@ eal_parse_args(int argc, char **argv)
                        return -1;
                }
 
+               /* eal_log_level_parse() already handled this option */
+               if (opt == OPT_LOG_LEVEL_NUM)
+                       continue;
+
                ret = eal_parse_common_option(opt, optarg, internal_conf);
                /* common parser is not happy */
                if (ret < 0) {
@@ -244,7 +258,8 @@ rte_eal_cleanup(void)
 {
        struct internal_config *internal_conf =
                eal_get_internal_configuration();
-
+       /* after this point, any DPDK pointers will become dangling */
+       rte_eal_memory_detach();
        eal_cleanup_config(internal_conf);
        return 0;
 }
@@ -257,8 +272,9 @@ rte_eal_init(int argc, char **argv)
        const struct rte_config *config = rte_eal_get_configuration();
        struct internal_config *internal_conf =
                eal_get_internal_configuration();
+       int ret;
 
-       rte_eal_log_init(NULL, 0);
+       eal_log_init(NULL, 0);
 
        eal_log_level_parse(argc, argv);
 
@@ -278,11 +294,17 @@ rte_eal_init(int argc, char **argv)
        if (fctret < 0)
                exit(1);
 
+       if (eal_option_device_parse()) {
+               rte_errno = ENODEV;
+               return -1;
+       }
+
        /* Prevent creation of shared memory files. */
        if (internal_conf->in_memory == 0) {
                RTE_LOG(WARNING, EAL, "Multi-process support is requested, "
                        "but not available.\n");
                internal_conf->in_memory = 1;
+               internal_conf->no_shconf = 1;
        }
 
        if (!internal_conf->no_hugetlbfs && (eal_hugepage_info_init() < 0)) {
@@ -332,14 +354,19 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
+       if (rte_eal_intr_init() < 0) {
+               rte_eal_init_alert("Cannot init interrupt-handling thread");
+               return -1;
+       }
+
        if (rte_eal_timer_init() < 0) {
                rte_eal_init_alert("Cannot init TSC timer");
                rte_errno = EFAULT;
                return -1;
        }
 
-       __rte_thread_init(config->master_lcore,
-               &lcore_config[config->master_lcore].cpuset);
+       __rte_thread_init(config->main_lcore,
+               &lcore_config[config->main_lcore].cpuset);
 
        bscan = rte_bus_scan();
        if (bscan < 0) {
@@ -348,16 +375,16 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
-       RTE_LCORE_FOREACH_SLAVE(i) {
+       RTE_LCORE_FOREACH_WORKER(i) {
 
                /*
-                * create communication pipes between master thread
+                * create communication pipes between main thread
                 * and children
                 */
-               if (_pipe(lcore_config[i].pipe_master2slave,
+               if (_pipe(lcore_config[i].pipe_main2worker,
                        sizeof(char), _O_BINARY) < 0)
                        rte_panic("Cannot create pipe\n");
-               if (_pipe(lcore_config[i].pipe_slave2master,
+               if (_pipe(lcore_config[i].pipe_worker2main,
                        sizeof(char), _O_BINARY) < 0)
                        rte_panic("Cannot create pipe\n");
 
@@ -368,15 +395,57 @@ rte_eal_init(int argc, char **argv)
                        rte_panic("Cannot create thread\n");
        }
 
+       /* Initialize services so drivers can register services during probe. */
+       ret = rte_service_init();
+       if (ret) {
+               rte_eal_init_alert("rte_service_init() failed");
+               rte_errno = -ret;
+               return -1;
+       }
+
+       if (rte_bus_probe()) {
+               rte_eal_init_alert("Cannot probe devices");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
+
        /*
-        * Launch a dummy function on all slave lcores, so that master lcore
+        * Launch a dummy function on all worker lcores, so that main lcore
         * knows they are all ready when this function returns.
         */
-       rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
+       rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MAIN);
        rte_eal_mp_wait_lcore();
        return fctret;
 }
 
+/* Don't use MinGW asprintf() to have identical code with all toolchains. */
+int
+eal_asprintf(char **buffer, const char *format, ...)
+{
+       int size, ret;
+       va_list arg;
+
+       va_start(arg, format);
+       size = vsnprintf(NULL, 0, format, arg);
+       va_end(arg);
+       if (size < 0)
+               return -1;
+       size++;
+
+       *buffer = malloc(size);
+       if (*buffer == NULL)
+               return -1;
+
+       va_start(arg, format);
+       ret = vsnprintf(*buffer, size, format, arg);
+       va_end(arg);
+       if (ret != size - 1) {
+               free(*buffer);
+               return -1;
+       }
+       return ret;
+}
+
 int
 rte_vfio_container_dma_map(__rte_unused int container_fd,
                        __rte_unused uint64_t vaddr,