1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef _RTE_EAL_MEMCONFIG_H_
6 #define _RTE_EAL_MEMCONFIG_H_
8 #include <rte_config.h>
10 #include <rte_memory.h>
11 #include <rte_memzone.h>
12 #include <rte_malloc_heap.h>
13 #include <rte_rwlock.h>
14 #include <rte_pause.h>
15 #include <rte_fbarray.h>
22 * memseg list is a special case as we need to store a bunch of other data
23 * together with the array itself.
25 struct rte_memseg_list {
29 /**< Base virtual address for this memseg list. */
31 /**< Makes sure addr is always 64-bits */
33 int socket_id; /**< Socket ID for all memsegs in this list. */
34 uint64_t page_sz; /**< Page size for all memsegs in this list. */
35 struct rte_fbarray memseg_arr;
39 * the structure for the memory configuration for the RTE.
40 * Used by the rte_config structure. It is separated out, as for multi-process
41 * support, the memory details should be shared across instances
43 struct rte_mem_config {
44 volatile uint32_t magic; /**< Magic number - Sanity check. */
47 uint32_t nchannel; /**< Number of channels (0 if unknown). */
48 uint32_t nrank; /**< Number of ranks (0 if unknown). */
51 * current lock nest order
52 * - qlock->mlock (ring/hash/lpm)
53 * - mplock->qlock->mlock (mempool)
55 * *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
57 rte_rwlock_t mlock; /**< only used by memzone LIB for thread-safe. */
58 rte_rwlock_t qlock; /**< used for tailq operation for thread safe. */
59 rte_rwlock_t mplock; /**< only used by mempool LIB for thread-safe. */
61 uint32_t memzone_cnt; /**< Number of allocated memzones */
63 /* memory segments and zones */
64 struct rte_memzone memzone[RTE_MAX_MEMZONE]; /**< Memzone descriptors. */
66 struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
67 /**< list of dynamic arrays holding memsegs */
69 struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
71 /* Heaps of Malloc per socket */
72 struct malloc_heap malloc_heaps[RTE_MAX_NUMA_NODES];
74 /* address of mem_config in primary process. used to map shared config into
75 * exact same address the primary process maps it.
77 uint64_t mem_cfg_addr;
78 } __attribute__((__packed__));
82 rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
84 /* wait until shared mem_config finish initialising */
85 while(mcfg->magic != RTE_MAGIC)
93 #endif /*__RTE_EAL_MEMCONFIG_H_*/