1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #include <rte_config.h>
6 #include <rte_eal_memconfig.h>
7 #include <rte_version.h>
9 #include "eal_internal_cfg.h"
10 #include "eal_memcfg.h"
11 #include "eal_private.h"
14 eal_mcfg_complete(void)
16 struct rte_config *cfg = rte_eal_get_configuration();
17 struct rte_mem_config *mcfg = cfg->mem_config;
19 /* ALL shared mem_config related INIT DONE */
20 if (cfg->process_type == RTE_PROC_PRIMARY)
21 mcfg->magic = RTE_MAGIC;
23 internal_config.init_complete = 1;
27 eal_mcfg_wait_complete(void)
29 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
31 /* wait until shared mem_config finish initialising */
32 while (mcfg->magic != RTE_MAGIC)
37 eal_mcfg_check_version(void)
39 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
41 /* check if version from memconfig matches compiled in macro */
42 if (mcfg->version != RTE_VERSION)
49 eal_mcfg_update_internal(void)
51 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
53 internal_config.legacy_mem = mcfg->legacy_mem;
54 internal_config.single_file_segments = mcfg->single_file_segments;
58 eal_mcfg_update_from_internal(void)
60 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
62 mcfg->legacy_mem = internal_config.legacy_mem;
63 mcfg->single_file_segments = internal_config.single_file_segments;
64 /* record current DPDK version */
65 mcfg->version = RTE_VERSION;
69 rte_mcfg_mem_read_lock(void)
71 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
72 rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
76 rte_mcfg_mem_read_unlock(void)
78 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
79 rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
83 rte_mcfg_mem_write_lock(void)
85 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
86 rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
90 rte_mcfg_mem_write_unlock(void)
92 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
93 rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
97 rte_mcfg_tailq_read_lock(void)
99 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
100 rte_rwlock_read_lock(&mcfg->qlock);
104 rte_mcfg_tailq_read_unlock(void)
106 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
107 rte_rwlock_read_unlock(&mcfg->qlock);
111 rte_mcfg_tailq_write_lock(void)
113 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
114 rte_rwlock_write_lock(&mcfg->qlock);
118 rte_mcfg_tailq_write_unlock(void)
120 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
121 rte_rwlock_write_unlock(&mcfg->qlock);
125 rte_mcfg_mempool_read_lock(void)
127 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
128 rte_rwlock_read_lock(&mcfg->mplock);
132 rte_mcfg_mempool_read_unlock(void)
134 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
135 rte_rwlock_read_unlock(&mcfg->mplock);
139 rte_mcfg_mempool_write_lock(void)
141 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
142 rte_rwlock_write_lock(&mcfg->mplock);
146 rte_mcfg_mempool_write_unlock(void)
148 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
149 rte_rwlock_write_unlock(&mcfg->mplock);
153 rte_mcfg_timer_lock(void)
155 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
156 rte_spinlock_lock(&mcfg->tlock);
160 rte_mcfg_timer_unlock(void)
162 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
163 rte_spinlock_unlock(&mcfg->tlock);
167 rte_mcfg_get_single_file_segments(void)
169 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
170 return (bool)mcfg->single_file_segments;