From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E48C2A046B for ; Tue, 25 Jun 2019 18:08:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EEC651BB74; Tue, 25 Jun 2019 18:06:15 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 8062C1BAB5 for ; Tue, 25 Jun 2019 18:05:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 09:05:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="336894858" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.125]) by orsmga005.jf.intel.com with ESMTP; 25 Jun 2019 09:05:54 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Bruce Richardson , david.marchand@redhat.com, thomas@monjalon.net, stephen@networkplumber.org Date: Tue, 25 Jun 2019 17:05:25 +0100 Message-Id: <53ac95842cf06c1c708abf78d8c3ab6c521cee30.1561478388.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 13/14] eal: unify internal config initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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(-) 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 6e2d3abc9..908542e18 100644 --- a/lib/librte_eal/common/eal_memcfg.h +++ b/lib/librte_eal/common/eal_memcfg.h @@ -68,6 +68,14 @@ struct rte_mem_config { uint8_t dma_maskbits; }; +/* 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 e43e01042..81eb44670 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -350,11 +350,13 @@ rte_config_init(void) switch (rte_config.process_type){ case RTE_PROC_PRIMARY: rte_eal_config_create(); + eal_mcfg_update_internal(); break; case RTE_PROC_SECONDARY: rte_eal_config_attach(); eal_mcfg_wait_complete(); rte_eal_config_reattach(); + eal_mcfg_update_from_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 4b5deaa70..e2be87e23 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -443,24 +443,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 void rte_config_init(void) @@ -470,13 +452,13 @@ rte_config_init(void) switch (rte_config.process_type){ case RTE_PROC_PRIMARY: rte_eal_config_create(); - eal_update_mem_config(); + eal_mcfg_update_from_internal(); break; case RTE_PROC_SECONDARY: rte_eal_config_attach(); eal_mcfg_wait_complete(); rte_eal_config_reattach(); - eal_update_internal_config(); + eal_mcfg_update_internal(); break; case RTE_PROC_AUTO: case RTE_PROC_INVALID: -- 2.17.1