build: remove redundant config include
[dpdk.git] / lib / librte_eal / common / eal_common_mcfg.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4
5 #include <rte_eal_memconfig.h>
6 #include <rte_version.h>
7
8 #include "eal_internal_cfg.h"
9 #include "eal_memcfg.h"
10 #include "eal_private.h"
11
12 void
13 eal_mcfg_complete(void)
14 {
15         struct rte_config *cfg = rte_eal_get_configuration();
16         struct rte_mem_config *mcfg = cfg->mem_config;
17
18         /* ALL shared mem_config related INIT DONE */
19         if (cfg->process_type == RTE_PROC_PRIMARY)
20                 mcfg->magic = RTE_MAGIC;
21
22         internal_config.init_complete = 1;
23 }
24
25 void
26 eal_mcfg_wait_complete(void)
27 {
28         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
29
30         /* wait until shared mem_config finish initialising */
31         while (mcfg->magic != RTE_MAGIC)
32                 rte_pause();
33 }
34
35 int
36 eal_mcfg_check_version(void)
37 {
38         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
39
40         /* check if version from memconfig matches compiled in macro */
41         if (mcfg->version != RTE_VERSION)
42                 return -1;
43
44         return 0;
45 }
46
47 void
48 eal_mcfg_update_internal(void)
49 {
50         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
51
52         internal_config.legacy_mem = mcfg->legacy_mem;
53         internal_config.single_file_segments = mcfg->single_file_segments;
54 }
55
56 void
57 eal_mcfg_update_from_internal(void)
58 {
59         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
60
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;
65 }
66
67 void
68 rte_mcfg_mem_read_lock(void)
69 {
70         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
71         rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
72 }
73
74 void
75 rte_mcfg_mem_read_unlock(void)
76 {
77         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
78         rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
79 }
80
81 void
82 rte_mcfg_mem_write_lock(void)
83 {
84         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
85         rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
86 }
87
88 void
89 rte_mcfg_mem_write_unlock(void)
90 {
91         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
92         rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
93 }
94
95 void
96 rte_mcfg_tailq_read_lock(void)
97 {
98         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
99         rte_rwlock_read_lock(&mcfg->qlock);
100 }
101
102 void
103 rte_mcfg_tailq_read_unlock(void)
104 {
105         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
106         rte_rwlock_read_unlock(&mcfg->qlock);
107 }
108
109 void
110 rte_mcfg_tailq_write_lock(void)
111 {
112         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
113         rte_rwlock_write_lock(&mcfg->qlock);
114 }
115
116 void
117 rte_mcfg_tailq_write_unlock(void)
118 {
119         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
120         rte_rwlock_write_unlock(&mcfg->qlock);
121 }
122
123 void
124 rte_mcfg_mempool_read_lock(void)
125 {
126         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
127         rte_rwlock_read_lock(&mcfg->mplock);
128 }
129
130 void
131 rte_mcfg_mempool_read_unlock(void)
132 {
133         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
134         rte_rwlock_read_unlock(&mcfg->mplock);
135 }
136
137 void
138 rte_mcfg_mempool_write_lock(void)
139 {
140         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
141         rte_rwlock_write_lock(&mcfg->mplock);
142 }
143
144 void
145 rte_mcfg_mempool_write_unlock(void)
146 {
147         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
148         rte_rwlock_write_unlock(&mcfg->mplock);
149 }
150
151 void
152 rte_mcfg_timer_lock(void)
153 {
154         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
155         rte_spinlock_lock(&mcfg->tlock);
156 }
157
158 void
159 rte_mcfg_timer_unlock(void)
160 {
161         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
162         rte_spinlock_unlock(&mcfg->tlock);
163 }
164
165 bool
166 rte_mcfg_get_single_file_segments(void)
167 {
168         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
169         return (bool)mcfg->single_file_segments;
170 }