xref: /dpdk/lib/eal/include/rte_eal_memconfig.h (revision 5fa337858df68f3adedc3ab88322784cedd75e4f)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_EAL_MEMCONFIG_H_
699a2dd95SBruce Richardson #define _RTE_EAL_MEMCONFIG_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson #include <stdbool.h>
999a2dd95SBruce Richardson 
100c156487SDavid Marchand #include <rte_rwlock.h>
110c156487SDavid Marchand #include <rte_spinlock.h>
1299a2dd95SBruce Richardson 
1399a2dd95SBruce Richardson /**
1499a2dd95SBruce Richardson  * @file
1599a2dd95SBruce Richardson  *
1699a2dd95SBruce Richardson  * This API allows access to EAL shared memory configuration through an API.
1799a2dd95SBruce Richardson  */
1899a2dd95SBruce Richardson 
1999a2dd95SBruce Richardson #ifdef __cplusplus
2099a2dd95SBruce Richardson extern "C" {
2199a2dd95SBruce Richardson #endif
2299a2dd95SBruce Richardson 
2399a2dd95SBruce Richardson /**
240c156487SDavid Marchand  * Internal helpers used for lock annotations.
250c156487SDavid Marchand  */
260c156487SDavid Marchand __rte_internal
270c156487SDavid Marchand rte_rwlock_t *
280c156487SDavid Marchand rte_mcfg_mem_get_lock(void);
290c156487SDavid Marchand 
300c156487SDavid Marchand __rte_internal
310c156487SDavid Marchand rte_rwlock_t *
320c156487SDavid Marchand rte_mcfg_tailq_get_lock(void);
330c156487SDavid Marchand 
340c156487SDavid Marchand __rte_internal
350c156487SDavid Marchand rte_rwlock_t *
360c156487SDavid Marchand rte_mcfg_mempool_get_lock(void);
370c156487SDavid Marchand 
380c156487SDavid Marchand __rte_internal
390c156487SDavid Marchand rte_spinlock_t *
400c156487SDavid Marchand rte_mcfg_timer_get_lock(void);
410c156487SDavid Marchand 
42*5fa33785SDavid Marchand __rte_internal
43*5fa33785SDavid Marchand rte_spinlock_t *
44*5fa33785SDavid Marchand rte_mcfg_ethdev_get_lock(void);
45*5fa33785SDavid Marchand 
460c156487SDavid Marchand /**
4799a2dd95SBruce Richardson  * Lock the internal EAL shared memory configuration for shared access.
4899a2dd95SBruce Richardson  */
4999a2dd95SBruce Richardson void
500c156487SDavid Marchand rte_mcfg_mem_read_lock(void)
510c156487SDavid Marchand 	__rte_shared_lock_function(rte_mcfg_mem_get_lock());
5299a2dd95SBruce Richardson 
5399a2dd95SBruce Richardson /**
5499a2dd95SBruce Richardson  * Unlock the internal EAL shared memory configuration for shared access.
5599a2dd95SBruce Richardson  */
5699a2dd95SBruce Richardson void
570c156487SDavid Marchand rte_mcfg_mem_read_unlock(void)
580c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_mem_get_lock());
5999a2dd95SBruce Richardson 
6099a2dd95SBruce Richardson /**
6199a2dd95SBruce Richardson  * Lock the internal EAL shared memory configuration for exclusive access.
6299a2dd95SBruce Richardson  */
6399a2dd95SBruce Richardson void
640c156487SDavid Marchand rte_mcfg_mem_write_lock(void)
650c156487SDavid Marchand 	__rte_exclusive_lock_function(rte_mcfg_mem_get_lock());
6699a2dd95SBruce Richardson 
6799a2dd95SBruce Richardson /**
6899a2dd95SBruce Richardson  * Unlock the internal EAL shared memory configuration for exclusive access.
6999a2dd95SBruce Richardson  */
7099a2dd95SBruce Richardson void
710c156487SDavid Marchand rte_mcfg_mem_write_unlock(void)
720c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_mem_get_lock());
7399a2dd95SBruce Richardson 
7499a2dd95SBruce Richardson /**
7599a2dd95SBruce Richardson  * Lock the internal EAL TAILQ list for shared access.
7699a2dd95SBruce Richardson  */
7799a2dd95SBruce Richardson void
780c156487SDavid Marchand rte_mcfg_tailq_read_lock(void)
790c156487SDavid Marchand 	__rte_shared_lock_function(rte_mcfg_tailq_get_lock());
8099a2dd95SBruce Richardson 
8199a2dd95SBruce Richardson /**
8299a2dd95SBruce Richardson  * Unlock the internal EAL TAILQ list for shared access.
8399a2dd95SBruce Richardson  */
8499a2dd95SBruce Richardson void
850c156487SDavid Marchand rte_mcfg_tailq_read_unlock(void)
860c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_tailq_get_lock());
8799a2dd95SBruce Richardson 
8899a2dd95SBruce Richardson /**
8999a2dd95SBruce Richardson  * Lock the internal EAL TAILQ list for exclusive access.
9099a2dd95SBruce Richardson  */
9199a2dd95SBruce Richardson void
920c156487SDavid Marchand rte_mcfg_tailq_write_lock(void)
930c156487SDavid Marchand 	__rte_exclusive_lock_function(rte_mcfg_tailq_get_lock());
9499a2dd95SBruce Richardson 
9599a2dd95SBruce Richardson /**
9699a2dd95SBruce Richardson  * Unlock the internal EAL TAILQ list for exclusive access.
9799a2dd95SBruce Richardson  */
9899a2dd95SBruce Richardson void
990c156487SDavid Marchand rte_mcfg_tailq_write_unlock(void)
1000c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_tailq_get_lock());
10199a2dd95SBruce Richardson 
10299a2dd95SBruce Richardson /**
10399a2dd95SBruce Richardson  * Lock the internal EAL Mempool list for shared access.
10499a2dd95SBruce Richardson  */
10599a2dd95SBruce Richardson void
1060c156487SDavid Marchand rte_mcfg_mempool_read_lock(void)
1070c156487SDavid Marchand 	__rte_shared_lock_function(rte_mcfg_mempool_get_lock());
10899a2dd95SBruce Richardson 
10999a2dd95SBruce Richardson /**
11099a2dd95SBruce Richardson  * Unlock the internal EAL Mempool list for shared access.
11199a2dd95SBruce Richardson  */
11299a2dd95SBruce Richardson void
1130c156487SDavid Marchand rte_mcfg_mempool_read_unlock(void)
1140c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_mempool_get_lock());
11599a2dd95SBruce Richardson 
11699a2dd95SBruce Richardson /**
11799a2dd95SBruce Richardson  * Lock the internal EAL Mempool list for exclusive access.
11899a2dd95SBruce Richardson  */
11999a2dd95SBruce Richardson void
1200c156487SDavid Marchand rte_mcfg_mempool_write_lock(void)
1210c156487SDavid Marchand 	__rte_exclusive_lock_function(rte_mcfg_mempool_get_lock());
12299a2dd95SBruce Richardson 
12399a2dd95SBruce Richardson /**
12499a2dd95SBruce Richardson  * Unlock the internal EAL Mempool list for exclusive access.
12599a2dd95SBruce Richardson  */
12699a2dd95SBruce Richardson void
1270c156487SDavid Marchand rte_mcfg_mempool_write_unlock(void)
1280c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_mempool_get_lock());
12999a2dd95SBruce Richardson 
13099a2dd95SBruce Richardson /**
13199a2dd95SBruce Richardson  * Lock the internal EAL Timer Library lock for exclusive access.
13299a2dd95SBruce Richardson  */
13399a2dd95SBruce Richardson void
1340c156487SDavid Marchand rte_mcfg_timer_lock(void)
1350c156487SDavid Marchand 	__rte_exclusive_lock_function(rte_mcfg_timer_get_lock());
13699a2dd95SBruce Richardson 
13799a2dd95SBruce Richardson /**
13899a2dd95SBruce Richardson  * Unlock the internal EAL Timer Library lock for exclusive access.
13999a2dd95SBruce Richardson  */
14099a2dd95SBruce Richardson void
1410c156487SDavid Marchand rte_mcfg_timer_unlock(void)
1420c156487SDavid Marchand 	__rte_unlock_function(rte_mcfg_timer_get_lock());
14399a2dd95SBruce Richardson 
14499a2dd95SBruce Richardson /**
14599a2dd95SBruce Richardson  * If true, pages are put in single files (per memseg list),
14699a2dd95SBruce Richardson  * as opposed to creating a file per page.
14799a2dd95SBruce Richardson  */
14899a2dd95SBruce Richardson bool
14999a2dd95SBruce Richardson rte_mcfg_get_single_file_segments(void);
15099a2dd95SBruce Richardson 
15199a2dd95SBruce Richardson #ifdef __cplusplus
15299a2dd95SBruce Richardson }
15399a2dd95SBruce Richardson #endif
15499a2dd95SBruce Richardson 
15599a2dd95SBruce Richardson #endif /*__RTE_EAL_MEMCONFIG_H_*/
156