[dpdk-dev] [PATCH v2 12/14] eal: unify and move mcfg complete function

Anatoly Burakov anatoly.burakov at intel.com
Tue Jun 25 18:05:24 CEST 2019


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 at intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  5 +++++
 lib/librte_eal/freebsd/eal/eal.c        | 12 +-----------
 lib/librte_eal/linux/eal/eal.c          | 12 +-----------
 4 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 30969c6bf..dc6665d6a 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -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)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 7319d9f7a..6e2d3abc9 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -72,4 +72,9 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
+
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index b3c96b5cd..e43e01042 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -597,16 +597,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)
 {
@@ -883,7 +873,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();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 9168a3e47..4b5deaa70 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -897,16 +897,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,
@@ -1229,7 +1219,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();
-- 
2.17.1


More information about the dev mailing list