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"
13 eal_mcfg_complete(void)
15 struct rte_config *cfg = rte_eal_get_configuration();
16 struct rte_mem_config *mcfg = cfg->mem_config;
18 /* ALL shared mem_config related INIT DONE */
19 if (cfg->process_type == RTE_PROC_PRIMARY)
20 mcfg->magic = RTE_MAGIC;
22 internal_config.init_complete = 1;
26 eal_mcfg_wait_complete(void)
28 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
30 /* wait until shared mem_config finish initialising */
31 while (mcfg->magic != RTE_MAGIC)
36 eal_mcfg_check_version(void)
38 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
40 /* check if version from memconfig matches compiled in macro */
41 if (mcfg->version != RTE_VERSION)
48 eal_mcfg_update_internal(void)
50 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
52 internal_config.legacy_mem = mcfg->legacy_mem;
53 internal_config.single_file_segments = mcfg->single_file_segments;
57 eal_mcfg_update_from_internal(void)
59 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
61 mcfg->legacy_mem = internal_config.legacy_mem;
62 mcfg->single_file_segments = internal_config.single_file_segments;
63 /* record current DPDK version */
64 mcfg->version = RTE_VERSION;
68 rte_mcfg_mem_read_lock(void)
70 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
71 rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
75 rte_mcfg_mem_read_unlock(void)
77 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
78 rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
82 rte_mcfg_mem_write_lock(void)
84 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
85 rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
89 rte_mcfg_mem_write_unlock(void)
91 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
92 rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
96 rte_mcfg_tailq_read_lock(void)
98 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
99 rte_rwlock_read_lock(&mcfg->qlock);
103 rte_mcfg_tailq_read_unlock(void)
105 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
106 rte_rwlock_read_unlock(&mcfg->qlock);
110 rte_mcfg_tailq_write_lock(void)
112 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
113 rte_rwlock_write_lock(&mcfg->qlock);
117 rte_mcfg_tailq_write_unlock(void)
119 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
120 rte_rwlock_write_unlock(&mcfg->qlock);
124 rte_mcfg_mempool_read_lock(void)
126 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
127 rte_rwlock_read_lock(&mcfg->mplock);
131 rte_mcfg_mempool_read_unlock(void)
133 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
134 rte_rwlock_read_unlock(&mcfg->mplock);
138 rte_mcfg_mempool_write_lock(void)
140 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
141 rte_rwlock_write_lock(&mcfg->mplock);
145 rte_mcfg_mempool_write_unlock(void)
147 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
148 rte_rwlock_write_unlock(&mcfg->mplock);
152 rte_mcfg_timer_lock(void)
154 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
155 rte_spinlock_lock(&mcfg->tlock);
159 rte_mcfg_timer_unlock(void)
161 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
162 rte_spinlock_unlock(&mcfg->tlock);