]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/lib/librte_eal/common/eal_common_mcfg.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / eal_common_mcfg.c
CommitLineData
f67539c2
TL
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
12void
13eal_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
25void
26eal_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
35int
36eal_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
47void
48eal_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
56void
57eal_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
67void
68rte_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
74void
75rte_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
81void
82rte_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
88void
89rte_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
95void
96rte_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
102void
103rte_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
109void
110rte_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
116void
117rte_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
123void
124rte_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
130void
131rte_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
137void
138rte_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
144void
145rte_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
151void
152rte_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
158void
159rte_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
165bool
166rte_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}