1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 #include <rte_malloc.h>
12 #include <rte_spinlock.h>
14 /* Number of free lists per heap, grouped by size. */
15 #define RTE_HEAP_NUM_FREELISTS 13
16 #define RTE_HEAP_NAME_MAX_LEN 32
18 /* dummy definition, for pointers */
22 * Structure to hold malloc heap
26 LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS];
27 struct malloc_elem *volatile first;
28 struct malloc_elem *volatile last;
30 unsigned int alloc_count;
31 unsigned int socket_id;
33 char name[RTE_HEAP_NAME_MAX_LEN];
34 } __rte_cache_aligned;
37 malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags,
38 size_t align, size_t bound, bool contig);
41 malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags,
42 size_t align, bool contig);
45 malloc_heap_create(struct malloc_heap *heap, const char *heap_name);
48 malloc_heap_destroy(struct malloc_heap *heap);
50 struct rte_memseg_list *
51 malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[],
52 unsigned int n_pages, size_t page_sz, const char *seg_name,
53 unsigned int socket_id);
55 struct rte_memseg_list *
56 malloc_heap_find_external_seg(void *va_addr, size_t len);
59 malloc_heap_destroy_external_seg(struct rte_memseg_list *msl);
62 malloc_heap_add_external_memory(struct malloc_heap *heap,
63 struct rte_memseg_list *msl);
66 malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr,
70 malloc_heap_free(struct malloc_elem *elem);
73 malloc_heap_resize(struct malloc_elem *elem, size_t size);
76 malloc_heap_get_stats(struct malloc_heap *heap,
77 struct rte_malloc_socket_stats *socket_stats);
80 malloc_heap_dump(struct malloc_heap *heap, FILE *f);
83 malloc_socket_to_heap_id(unsigned int socket_id);
86 rte_eal_malloc_heap_init(void);
89 rte_eal_malloc_heap_cleanup(void);
91 #endif /* MALLOC_HEAP_H_ */