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 <stdbool.h> 9 10 #include <rte_rwlock.h> 11 #include <rte_spinlock.h> 12 13 /** 14 * @file 15 * 16 * This API allows access to EAL shared memory configuration through an API. 17 */ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * Internal helpers used for lock annotations. 25 */ 26 __rte_internal 27 rte_rwlock_t * 28 rte_mcfg_mem_get_lock(void); 29 30 __rte_internal 31 rte_rwlock_t * 32 rte_mcfg_tailq_get_lock(void); 33 34 __rte_internal 35 rte_rwlock_t * 36 rte_mcfg_mempool_get_lock(void); 37 38 __rte_internal 39 rte_spinlock_t * 40 rte_mcfg_timer_get_lock(void); 41 42 __rte_internal 43 rte_spinlock_t * 44 rte_mcfg_ethdev_get_lock(void); 45 46 /** 47 * Lock the internal EAL shared memory configuration for shared access. 48 */ 49 void 50 rte_mcfg_mem_read_lock(void) 51 __rte_shared_lock_function(rte_mcfg_mem_get_lock()); 52 53 /** 54 * Unlock the internal EAL shared memory configuration for shared access. 55 */ 56 void 57 rte_mcfg_mem_read_unlock(void) 58 __rte_unlock_function(rte_mcfg_mem_get_lock()); 59 60 /** 61 * Lock the internal EAL shared memory configuration for exclusive access. 62 */ 63 void 64 rte_mcfg_mem_write_lock(void) 65 __rte_exclusive_lock_function(rte_mcfg_mem_get_lock()); 66 67 /** 68 * Unlock the internal EAL shared memory configuration for exclusive access. 69 */ 70 void 71 rte_mcfg_mem_write_unlock(void) 72 __rte_unlock_function(rte_mcfg_mem_get_lock()); 73 74 /** 75 * Lock the internal EAL TAILQ list for shared access. 76 */ 77 void 78 rte_mcfg_tailq_read_lock(void) 79 __rte_shared_lock_function(rte_mcfg_tailq_get_lock()); 80 81 /** 82 * Unlock the internal EAL TAILQ list for shared access. 83 */ 84 void 85 rte_mcfg_tailq_read_unlock(void) 86 __rte_unlock_function(rte_mcfg_tailq_get_lock()); 87 88 /** 89 * Lock the internal EAL TAILQ list for exclusive access. 90 */ 91 void 92 rte_mcfg_tailq_write_lock(void) 93 __rte_exclusive_lock_function(rte_mcfg_tailq_get_lock()); 94 95 /** 96 * Unlock the internal EAL TAILQ list for exclusive access. 97 */ 98 void 99 rte_mcfg_tailq_write_unlock(void) 100 __rte_unlock_function(rte_mcfg_tailq_get_lock()); 101 102 /** 103 * Lock the internal EAL Mempool list for shared access. 104 */ 105 void 106 rte_mcfg_mempool_read_lock(void) 107 __rte_shared_lock_function(rte_mcfg_mempool_get_lock()); 108 109 /** 110 * Unlock the internal EAL Mempool list for shared access. 111 */ 112 void 113 rte_mcfg_mempool_read_unlock(void) 114 __rte_unlock_function(rte_mcfg_mempool_get_lock()); 115 116 /** 117 * Lock the internal EAL Mempool list for exclusive access. 118 */ 119 void 120 rte_mcfg_mempool_write_lock(void) 121 __rte_exclusive_lock_function(rte_mcfg_mempool_get_lock()); 122 123 /** 124 * Unlock the internal EAL Mempool list for exclusive access. 125 */ 126 void 127 rte_mcfg_mempool_write_unlock(void) 128 __rte_unlock_function(rte_mcfg_mempool_get_lock()); 129 130 /** 131 * Lock the internal EAL Timer Library lock for exclusive access. 132 */ 133 void 134 rte_mcfg_timer_lock(void) 135 __rte_exclusive_lock_function(rte_mcfg_timer_get_lock()); 136 137 /** 138 * Unlock the internal EAL Timer Library lock for exclusive access. 139 */ 140 void 141 rte_mcfg_timer_unlock(void) 142 __rte_unlock_function(rte_mcfg_timer_get_lock()); 143 144 /** 145 * If true, pages are put in single files (per memseg list), 146 * as opposed to creating a file per page. 147 */ 148 bool 149 rte_mcfg_get_single_file_segments(void); 150 151 #ifdef __cplusplus 152 } 153 #endif 154 155 #endif /*__RTE_EAL_MEMCONFIG_H_*/ 156