1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
8 #include <rte_config.h>
9 #include <rte_malloc_heap.h>
10 #include <rte_memory.h>
11 #include <rte_memzone.h>
12 #include <rte_pause.h>
13 #include <rte_spinlock.h>
14 #include <rte_rwlock.h>
15 #include <rte_tailq.h>
18 * Memory configuration shared across multiple processes.
20 struct rte_mem_config {
21 volatile uint32_t magic; /**< Magic number - sanity check. */
23 /**< Prevent secondary processes using different DPDK versions. */
26 uint32_t nchannel; /**< Number of channels (0 if unknown). */
27 uint32_t nrank; /**< Number of ranks (0 if unknown). */
30 * current lock nest order
31 * - qlock->mlock (ring/hash/lpm)
32 * - mplock->qlock->mlock (mempool)
34 * *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
36 rte_rwlock_t mlock; /**< used by memzones for thread safety. */
37 rte_rwlock_t qlock; /**< used by tailqs for thread safety. */
38 rte_rwlock_t mplock; /**< used by mempool library for thread safety. */
39 rte_spinlock_t tlock; /**< used by timer library for thread safety. */
41 rte_rwlock_t memory_hotplug_lock;
42 /**< Indicates whether memory hotplug request is in progress. */
44 /* memory segments and zones */
45 struct rte_fbarray memzones; /**< Memzone descriptors. */
47 struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
48 /**< List of dynamic arrays holding memsegs */
50 struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
51 /**< Tailqs for objects */
53 struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
54 /**< DPDK malloc heaps */
56 int next_socket_id; /**< Next socket ID for external malloc heap */
58 /* rte_mem_config has to be mapped at the exact same address in all
59 * processes, so we need to store it.
61 uint64_t mem_cfg_addr; /**< Address of this structure in memory. */
63 /* Primary and secondary processes cannot run with different legacy or
64 * single file segments options, so to avoid having to specify these
65 * options to all processes, store them in shared config and update the
66 * internal config at init time.
68 uint32_t legacy_mem; /**< stored legacy mem parameter. */
69 uint32_t single_file_segments;
70 /**< stored single file segments parameter. */
72 uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
75 /* update internal config from shared mem config */
77 eal_mcfg_update_internal(void);
79 /* update shared mem config from internal config */
81 eal_mcfg_update_from_internal(void);
83 /* wait until primary process initialization is complete */
85 eal_mcfg_wait_complete(void);
87 /* check if DPDK version of current process matches one stored in the config */
89 eal_mcfg_check_version(void);
91 /* set mem config as complete */
93 eal_mcfg_complete(void);
95 #endif /* EAL_MEMCFG_H */