1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #include <rte_eal_memconfig.h>
6 #include <rte_version.h>
8 #include "eal_internal_cfg.h"
9 #include "eal_memcfg.h"
10 #include "eal_private.h"
13 eal_mcfg_complete(void)
15 struct rte_config *cfg = rte_eal_get_configuration();
16 struct rte_mem_config *mcfg = cfg->mem_config;
17 struct internal_config *internal_conf =
18 eal_get_internal_configuration();
20 /* ALL shared mem_config related INIT DONE */
21 if (cfg->process_type == RTE_PROC_PRIMARY)
22 mcfg->magic = RTE_MAGIC;
24 internal_conf->init_complete = 1;
28 eal_mcfg_wait_complete(void)
30 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
32 /* wait until shared mem_config finish initialising */
33 rte_wait_until_equal_32(&mcfg->magic, RTE_MAGIC, __ATOMIC_RELAXED);
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;
52 struct internal_config *internal_conf =
53 eal_get_internal_configuration();
55 internal_conf->legacy_mem = mcfg->legacy_mem;
56 internal_conf->single_file_segments = mcfg->single_file_segments;
60 eal_mcfg_update_from_internal(void)
62 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
63 const struct internal_config *internal_conf =
64 eal_get_internal_configuration();
66 mcfg->legacy_mem = internal_conf->legacy_mem;
67 mcfg->single_file_segments = internal_conf->single_file_segments;
68 /* record current DPDK version */
69 mcfg->version = RTE_VERSION;
73 rte_mcfg_mem_read_lock(void)
75 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
76 rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
80 rte_mcfg_mem_read_unlock(void)
82 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
83 rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
87 rte_mcfg_mem_write_lock(void)
89 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
90 rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
94 rte_mcfg_mem_write_unlock(void)
96 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
97 rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
101 rte_mcfg_tailq_read_lock(void)
103 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
104 rte_rwlock_read_lock(&mcfg->qlock);
108 rte_mcfg_tailq_read_unlock(void)
110 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
111 rte_rwlock_read_unlock(&mcfg->qlock);
115 rte_mcfg_tailq_write_lock(void)
117 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
118 rte_rwlock_write_lock(&mcfg->qlock);
122 rte_mcfg_tailq_write_unlock(void)
124 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
125 rte_rwlock_write_unlock(&mcfg->qlock);
129 rte_mcfg_mempool_read_lock(void)
131 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
132 rte_rwlock_read_lock(&mcfg->mplock);
136 rte_mcfg_mempool_read_unlock(void)
138 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
139 rte_rwlock_read_unlock(&mcfg->mplock);
143 rte_mcfg_mempool_write_lock(void)
145 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
146 rte_rwlock_write_lock(&mcfg->mplock);
150 rte_mcfg_mempool_write_unlock(void)
152 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
153 rte_rwlock_write_unlock(&mcfg->mplock);
157 rte_mcfg_timer_lock(void)
159 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
160 rte_spinlock_lock(&mcfg->tlock);
164 rte_mcfg_timer_unlock(void)
166 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
167 rte_spinlock_unlock(&mcfg->tlock);
171 rte_mcfg_get_single_file_segments(void)
173 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
174 return (bool)mcfg->single_file_segments;