eal: unify wait for complete init
[dpdk.git] / lib / librte_eal / common / eal_memcfg.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4
5 #ifndef EAL_MEMCFG_H
6 #define EAL_MEMCFG_H
7
8 #include <rte_config.h>
9 #include <rte_eal_memconfig.h>
10 #include <rte_malloc_heap.h>
11 #include <rte_memory.h>
12 #include <rte_memzone.h>
13 #include <rte_pause.h>
14 #include <rte_rwlock.h>
15 #include <rte_tailq.h>
16
17 /**
18  * Memory configuration shared across multiple processes.
19  */
20 struct rte_mem_config {
21         volatile uint32_t magic;   /**< Magic number - sanity check. */
22
23         /* memory topology */
24         uint32_t nchannel;    /**< Number of channels (0 if unknown). */
25         uint32_t nrank;       /**< Number of ranks (0 if unknown). */
26
27         /**
28          * current lock nest order
29          *  - qlock->mlock (ring/hash/lpm)
30          *  - mplock->qlock->mlock (mempool)
31          * Notice:
32          *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
33          */
34         rte_rwlock_t mlock;   /**< used by memzones for thread safety. */
35         rte_rwlock_t qlock;   /**< used by tailqs for thread safety. */
36         rte_rwlock_t mplock;  /**< used by mempool library for thread safety. */
37
38         rte_rwlock_t memory_hotplug_lock;
39         /**< Indicates whether memory hotplug request is in progress. */
40
41         /* memory segments and zones */
42         struct rte_fbarray memzones; /**< Memzone descriptors. */
43
44         struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
45         /**< List of dynamic arrays holding memsegs */
46
47         struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
48         /**< Tailqs for objects */
49
50         struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
51         /**< DPDK malloc heaps */
52
53         int next_socket_id; /**< Next socket ID for external malloc heap */
54
55         /* rte_mem_config has to be mapped at the exact same address in all
56          * processes, so we need to store it.
57          */
58         uint64_t mem_cfg_addr; /**< Address of this structure in memory. */
59
60         /* Primary and secondary processes cannot run with different legacy or
61          * single file segments options, so to avoid having to specify these
62          * options to all processes, store them in shared config and update the
63          * internal config at init time.
64          */
65         uint32_t legacy_mem; /**< stored legacy mem parameter. */
66         uint32_t single_file_segments;
67         /**< stored single file segments parameter. */
68
69         uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
70 };
71
72 /* wait until primary process initialization is complete */
73 void
74 eal_mcfg_wait_complete(void);
75
76 /* set mem config as complete */
77 void
78 eal_mcfg_complete(void);
79
80 #endif /* EAL_MEMCFG_H */