DPDK  18.02.2
rte_memory.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_MEMORY_H_
6 #define _RTE_MEMORY_H_
7 
14 #include <stdint.h>
15 #include <stddef.h>
16 #include <stdio.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include <rte_common.h>
23 #include <rte_config.h>
24 
25 __extension__
26 enum rte_page_sizes {
27  RTE_PGSIZE_4K = 1ULL << 12,
28  RTE_PGSIZE_64K = 1ULL << 16,
29  RTE_PGSIZE_256K = 1ULL << 18,
30  RTE_PGSIZE_2M = 1ULL << 21,
31  RTE_PGSIZE_16M = 1ULL << 24,
32  RTE_PGSIZE_256M = 1ULL << 28,
33  RTE_PGSIZE_512M = 1ULL << 29,
34  RTE_PGSIZE_1G = 1ULL << 30,
35  RTE_PGSIZE_4G = 1ULL << 32,
36  RTE_PGSIZE_16G = 1ULL << 34,
37 };
38 
39 #define SOCKET_ID_ANY -1
40 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
42 #define RTE_CACHE_LINE_ROUNDUP(size) \
43  (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE))
44 
47 #if RTE_CACHE_LINE_SIZE == 64
48 #define RTE_CACHE_LINE_SIZE_LOG2 6
49 #elif RTE_CACHE_LINE_SIZE == 128
50 #define RTE_CACHE_LINE_SIZE_LOG2 7
51 #else
52 #error "Unsupported cache line size"
53 #endif
54 
55 #define RTE_CACHE_LINE_MIN_SIZE 64
60 #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
61 
65 #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
66 
67 typedef uint64_t phys_addr_t;
68 #define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1)
69 
76 typedef uint64_t rte_iova_t;
77 #define RTE_BAD_IOVA ((rte_iova_t)-1)
78 
82 struct rte_memseg {
84  union {
85  phys_addr_t phys_addr;
86  rte_iova_t iova;
87  };
89  union {
90  void *addr;
91  uint64_t addr_64;
92  };
93  size_t len;
94  uint64_t hugepage_sz;
95  int32_t socket_id;
96  uint32_t nchannel;
97  uint32_t nrank;
99 
108 int rte_mem_lock_page(const void *virt);
109 
120 phys_addr_t rte_mem_virt2phy(const void *virt);
121 
130 rte_iova_t rte_mem_virt2iova(const void *virt);
131 
147 const struct rte_memseg *rte_eal_get_physmem_layout(void);
148 
155 void rte_dump_physmem_layout(FILE *f);
156 
163 uint64_t rte_eal_get_physmem_size(void);
164 
172 unsigned rte_memory_get_nchannel(void);
173 
181 unsigned rte_memory_get_nrank(void);
182 
192 int rte_eal_using_phys_addrs(void);
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* _RTE_MEMORY_H_ */