New upstream version 18.11-rc1
[deb_dpdk.git] / lib / librte_eal / common / malloc_heap.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef MALLOC_HEAP_H_
6 #define MALLOC_HEAP_H_
7
8 #include <stdbool.h>
9
10 #include <rte_malloc.h>
11 #include <rte_malloc_heap.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 static inline unsigned
18 malloc_get_numa_socket(void)
19 {
20         unsigned socket_id = rte_socket_id();
21
22         if (socket_id == (unsigned)SOCKET_ID_ANY)
23                 return 0;
24
25         return socket_id;
26 }
27
28 void *
29 malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags,
30                 size_t align, size_t bound, bool contig);
31
32 void *
33 malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags,
34                 size_t align, bool contig);
35
36 int
37 malloc_heap_create(struct malloc_heap *heap, const char *heap_name);
38
39 int
40 malloc_heap_destroy(struct malloc_heap *heap);
41
42 int
43 malloc_heap_add_external_memory(struct malloc_heap *heap, void *va_addr,
44                 rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz);
45
46 int
47 malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr,
48                 size_t len);
49
50 int
51 malloc_heap_free(struct malloc_elem *elem);
52
53 int
54 malloc_heap_resize(struct malloc_elem *elem, size_t size);
55
56 int
57 malloc_heap_get_stats(struct malloc_heap *heap,
58                 struct rte_malloc_socket_stats *socket_stats);
59
60 void
61 malloc_heap_dump(struct malloc_heap *heap, FILE *f);
62
63 int
64 malloc_socket_to_heap_id(unsigned int socket_id);
65
66 int
67 rte_eal_malloc_heap_init(void);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* MALLOC_HEAP_H_ */