lib: use SPDX tag for Intel copyright files
[dpdk.git] / lib / librte_eal / common / include / rte_eal_memconfig.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _RTE_EAL_MEMCONFIG_H_
6 #define _RTE_EAL_MEMCONFIG_H_
7
8 #include <rte_tailq.h>
9 #include <rte_memory.h>
10 #include <rte_memzone.h>
11 #include <rte_malloc_heap.h>
12 #include <rte_rwlock.h>
13 #include <rte_pause.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 /**
20  * the structure for the memory configuration for the RTE.
21  * Used by the rte_config structure. It is separated out, as for multi-process
22  * support, the memory details should be shared across instances
23  */
24 struct rte_mem_config {
25         volatile uint32_t magic;   /**< Magic number - Sanity check. */
26
27         /* memory topology */
28         uint32_t nchannel;    /**< Number of channels (0 if unknown). */
29         uint32_t nrank;       /**< Number of ranks (0 if unknown). */
30
31         /**
32          * current lock nest order
33          *  - qlock->mlock (ring/hash/lpm)
34          *  - mplock->qlock->mlock (mempool)
35          * Notice:
36          *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
37          */
38         rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
39         rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
40         rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
41
42         uint32_t memzone_cnt; /**< Number of allocated memzones */
43
44         /* memory segments and zones */
45         struct rte_memseg memseg[RTE_MAX_MEMSEG];    /**< Physmem descriptors. */
46         struct rte_memzone memzone[RTE_MAX_MEMZONE]; /**< Memzone descriptors. */
47
48         struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
49
50         /* Heaps of Malloc per socket */
51         struct malloc_heap malloc_heaps[RTE_MAX_NUMA_NODES];
52
53         /* address of mem_config in primary process. used to map shared config into
54          * exact same address the primary process maps it.
55          */
56         uint64_t mem_cfg_addr;
57 } __attribute__((__packed__));
58
59
60 inline static void
61 rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
62 {
63         /* wait until shared mem_config finish initialising */
64         while(mcfg->magic != RTE_MAGIC)
65                 rte_pause();
66 }
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif /*__RTE_EAL_MEMCONFIG_H_*/