xref: /dpdk/lib/eal/common/eal_hugepages.h (revision 99a2dd955fba6e4cc23b77d590a033650ced9c45)
1*99a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*99a2dd95SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
3*99a2dd95SBruce Richardson  */
4*99a2dd95SBruce Richardson 
5*99a2dd95SBruce Richardson #ifndef EAL_HUGEPAGES_H
6*99a2dd95SBruce Richardson #define EAL_HUGEPAGES_H
7*99a2dd95SBruce Richardson 
8*99a2dd95SBruce Richardson #include <stddef.h>
9*99a2dd95SBruce Richardson #include <stdint.h>
10*99a2dd95SBruce Richardson #include <limits.h>
11*99a2dd95SBruce Richardson 
12*99a2dd95SBruce Richardson #define MAX_HUGEPAGE_PATH PATH_MAX
13*99a2dd95SBruce Richardson 
14*99a2dd95SBruce Richardson /**
15*99a2dd95SBruce Richardson  * Structure used to store information about hugepages that we mapped
16*99a2dd95SBruce Richardson  * through the files in hugetlbfs.
17*99a2dd95SBruce Richardson  */
18*99a2dd95SBruce Richardson struct hugepage_file {
19*99a2dd95SBruce Richardson 	void *orig_va;      /**< virtual addr of first mmap() */
20*99a2dd95SBruce Richardson 	void *final_va;     /**< virtual addr of 2nd mmap() */
21*99a2dd95SBruce Richardson 	uint64_t physaddr;  /**< physical addr */
22*99a2dd95SBruce Richardson 	size_t size;        /**< the page size */
23*99a2dd95SBruce Richardson 	int socket_id;      /**< NUMA socket ID */
24*99a2dd95SBruce Richardson 	int file_id;        /**< the '%d' in HUGEFILE_FMT */
25*99a2dd95SBruce Richardson 	char filepath[MAX_HUGEPAGE_PATH]; /**< path to backing file on filesystem */
26*99a2dd95SBruce Richardson };
27*99a2dd95SBruce Richardson 
28*99a2dd95SBruce Richardson /**
29*99a2dd95SBruce Richardson  * Read the information on what hugepages are available for the EAL to use,
30*99a2dd95SBruce Richardson  * clearing out any unused ones.
31*99a2dd95SBruce Richardson  */
32*99a2dd95SBruce Richardson int eal_hugepage_info_init(void);
33*99a2dd95SBruce Richardson 
34*99a2dd95SBruce Richardson /**
35*99a2dd95SBruce Richardson  * Read whatever information primary process has shared about hugepages into
36*99a2dd95SBruce Richardson  * secondary process.
37*99a2dd95SBruce Richardson  */
38*99a2dd95SBruce Richardson int eal_hugepage_info_read(void);
39*99a2dd95SBruce Richardson 
40*99a2dd95SBruce Richardson #endif /* EAL_HUGEPAGES_H */
41