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