From patchwork Thu Jun 27 11:39:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 55497 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A8F481B9C3; Thu, 27 Jun 2019 13:39:44 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 667F91B9AA for ; Thu, 27 Jun 2019 13:39:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 04:39:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,423,1557212400"; d="scan'208";a="245785857" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.125]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2019 04:39:34 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Bruce Richardson , david.marchand@redhat.com, thomas@monjalon.net, stephen@networkplumber.org Date: Thu, 27 Jun 2019 12:39:07 +0100 Message-Id: <5015e26e6bb6ff5e24e7c8ef399222ddeda6d50f.1561635481.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 v3 12/14] eal: unify and move mcfg complete function 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, 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 --- lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++ lib/librte_eal/common/eal_memcfg.h | 4 ++++ lib/librte_eal/freebsd/eal/eal.c | 12 +----------- lib/librte_eal/linux/eal/eal.c | 12 +----------- 4 files changed, 20 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 #include +#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..a2434417e 100644 --- a/lib/librte_eal/common/eal_memcfg.h +++ b/lib/librte_eal/common/eal_memcfg.h @@ -72,4 +72,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 */ diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index c102847d1..13e230fc8 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -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) { @@ -921,7 +911,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 6a06628b1..4fd18b15f 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -933,16 +933,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, @@ -1268,7 +1258,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();