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 while (mcfg->magic != RTE_MAGIC)
38 eal_mcfg_check_version(void)
40 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
42 /* check if version from memconfig matches compiled in macro */
43 if (mcfg->version != RTE_VERSION)
50 eal_mcfg_update_internal(void)
52 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
53 struct internal_config *internal_conf =
54 eal_get_internal_configuration();
56 internal_conf->legacy_mem = mcfg->legacy_mem;
57 internal_conf->single_file_segments = mcfg->single_file_segments;
61 eal_mcfg_update_from_internal(void)
63 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
64 const struct internal_config *internal_conf =
65 eal_get_internal_configuration();
67 mcfg->legacy_mem = internal_conf->legacy_mem;
68 mcfg->single_file_segments = internal_conf->single_file_segments;
69 /* record current DPDK version */
70 mcfg->version = RTE_VERSION;
74 rte_mcfg_mem_read_lock(void)
76 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
77 rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
81 rte_mcfg_mem_read_unlock(void)
83 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
84 rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
88 rte_mcfg_mem_write_lock(void)
90 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
91 rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
95 rte_mcfg_mem_write_unlock(void)
97 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
98 rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
102 rte_mcfg_tailq_read_lock(void)
104 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
105 rte_rwlock_read_lock(&mcfg->qlock);
109 rte_mcfg_tailq_read_unlock(void)
111 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
112 rte_rwlock_read_unlock(&mcfg->qlock);
116 rte_mcfg_tailq_write_lock(void)
118 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
119 rte_rwlock_write_lock(&mcfg->qlock);
123 rte_mcfg_tailq_write_unlock(void)
125 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
126 rte_rwlock_write_unlock(&mcfg->qlock);
130 rte_mcfg_mempool_read_lock(void)
132 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
133 rte_rwlock_read_lock(&mcfg->mplock);
137 rte_mcfg_mempool_read_unlock(void)
139 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
140 rte_rwlock_read_unlock(&mcfg->mplock);
144 rte_mcfg_mempool_write_lock(void)
146 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
147 rte_rwlock_write_lock(&mcfg->mplock);
151 rte_mcfg_mempool_write_unlock(void)
153 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
154 rte_rwlock_write_unlock(&mcfg->mplock);
158 rte_mcfg_timer_lock(void)
160 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
161 rte_spinlock_lock(&mcfg->tlock);
165 rte_mcfg_timer_unlock(void)
167 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
168 rte_spinlock_unlock(&mcfg->tlock);
172 rte_mcfg_get_single_file_segments(void)
174 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
175 return (bool)mcfg->single_file_segments;