eal: unify wait for complete init
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 5 Jul 2019 13:10:33 +0000 (14:10 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 6 Jul 2019 08:32:40 +0000 (10:32 +0200)
Currently, mcfg completion function exists in two independent
implementations doing the same thing, which is bug prone.
Unify the two functions and move them into one place.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
lib/librte_eal/common/eal_common_mcfg.c
lib/librte_eal/common/eal_memcfg.h
lib/librte_eal/freebsd/eal/eal.c
lib/librte_eal/linux/eal/eal.c

index 30969c6..dc6665d 100644 (file)
@@ -5,8 +5,22 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_complete(void)
+{
+       struct rte_config *cfg = rte_eal_get_configuration();
+       struct rte_mem_config *mcfg = cfg->mem_config;
+
+       /* ALL shared mem_config related INIT DONE */
+       if (cfg->process_type == RTE_PROC_PRIMARY)
+               mcfg->magic = RTE_MAGIC;
+
+       internal_config.init_complete = 1;
+}
+
 void
 eal_mcfg_wait_complete(void)
 {
index 6c08652..417324a 100644 (file)
@@ -73,4 +73,8 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
index 7840094..4f07c24 100644 (file)
@@ -632,16 +632,6 @@ sync_func(__attribute__((unused)) void *arg)
        return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-       /* ALL shared mem_config related INIT DONE */
-       if (rte_config.process_type == RTE_PROC_PRIMARY)
-               rte_config.mem_config->magic = RTE_MAGIC;
-
-       internal_config.init_complete = 1;
-}
-
 /* return non-zero if hugepages are enabled. */
 int rte_eal_has_hugepages(void)
 {
@@ -925,7 +915,7 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
-       rte_eal_mcfg_complete();
+       eal_mcfg_complete();
 
        /* Call each registered callback, if enabled */
        rte_option_init();
index 03d5e71..ec1cc82 100644 (file)
@@ -934,16 +934,6 @@ sync_func(__attribute__((unused)) void *arg)
        return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-       /* ALL shared mem_config related INIT DONE */
-       if (rte_config.process_type == RTE_PROC_PRIMARY)
-               rte_config.mem_config->magic = RTE_MAGIC;
-
-       internal_config.init_complete = 1;
-}
-
 /*
  * Request iopl privilege for all RPL, returns 0 on success
  * iopl() call is mostly for the i386 architecture. For other architectures,
@@ -1289,7 +1279,7 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
-       rte_eal_mcfg_complete();
+       eal_mcfg_complete();
 
        /* Call each registered callback, if enabled */
        rte_option_init();