[v4,8/8] eal: unify internal config initialization

Message ID 4d42544cf722666e493a236d5a1065c57726e8fa.1562332112.git.anatoly.burakov@intel.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • Make shared memory config non-public
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Burakov, Anatoly July 5, 2019, 1:10 p.m.
Currently, each EAL will update internal/shared config in their
own way at init, resulting in needless duplication of code and
OS-dependent behavior. Move the functions to a common file and
add missing FreeBSD steps.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
 lib/librte_eal/freebsd/eal/eal.c        |  2 ++
 lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

Patch

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index dc6665d6a..fe8d2b726 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -31,6 +31,24 @@  eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+void
+eal_mcfg_update_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	internal_config.legacy_mem = mcfg->legacy_mem;
+	internal_config.single_file_segments = mcfg->single_file_segments;
+}
+
+void
+eal_mcfg_update_from_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	mcfg->legacy_mem = internal_config.legacy_mem;
+	mcfg->single_file_segments = internal_config.single_file_segments;
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 417324aab..573233896 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -69,6 +69,14 @@  struct rte_mem_config {
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
 };
 
+/* update internal config from shared mem config */
+void
+eal_mcfg_update_internal(void);
+
+/* update shared mem config from internal config */
+void
+eal_mcfg_update_from_internal(void);
+
 /* wait until primary process initialization is complete */
 void
 eal_mcfg_wait_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 340f7dd6c..ec1650c43 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -379,6 +379,7 @@  rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -386,6 +387,7 @@  rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index e15eacffc..445d72f0c 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -473,24 +473,6 @@  eal_proc_type_detect(void)
 	return ptype;
 }
 
-/* copies data from internal config to shared config */
-static void
-eal_update_mem_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	mcfg->legacy_mem = internal_config.legacy_mem;
-	mcfg->single_file_segments = internal_config.single_file_segments;
-}
-
-/* copies data from shared config to internal config */
-static void
-eal_update_internal_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	internal_config.legacy_mem = mcfg->legacy_mem;
-	internal_config.single_file_segments = mcfg->single_file_segments;
-}
-
 /* Sets up rte_config structure with the pointer to shared memory config.*/
 static int
 rte_config_init(void)
@@ -501,7 +483,7 @@  rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
-		eal_update_mem_config();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -509,7 +491,7 @@  rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
-		eal_update_internal_config();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID: