1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017-2018 Intel Corporation
10 #include <rte_memory.h>
13 * Allocate segment of specified page size.
16 eal_memalloc_alloc_seg(size_t page_sz, int socket);
19 * Allocate `n_segs` segments.
21 * Note: `ms` can be NULL.
23 * Note: it is possible to request best-effort allocation by setting `exact` to
24 * `false`, in which case allocator will return however many pages it managed to
25 * allocate successfully.
28 eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,
29 int socket, bool exact);
35 eal_memalloc_free_seg(struct rte_memseg *ms);
38 * Deallocate `n_segs` segments. Returns 0 on successful deallocation of all
39 * segments, returns -1 on error. Any segments that could have been deallocated,
40 * will be deallocated even in case of error.
43 eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs);
46 * Check if memory pointed to by `start` and of `length` that resides in
47 * memseg list `msl` is IOVA-contiguous.
50 eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,
53 /* synchronize local memory map to primary process */
55 eal_memalloc_sync_with_primary(void);
58 eal_memalloc_mem_event_callback_register(const char *name,
59 rte_mem_event_callback_t clb, void *arg);
62 eal_memalloc_mem_event_callback_unregister(const char *name, void *arg);
65 eal_memalloc_mem_event_notify(enum rte_mem_event event, const void *start,
69 eal_memalloc_mem_alloc_validator_register(const char *name,
70 rte_mem_alloc_validator_t clb, int socket_id, size_t limit);
73 eal_memalloc_mem_alloc_validator_unregister(const char *name, int socket_id);
76 eal_memalloc_mem_alloc_validate(int socket_id, size_t new_len);
78 /* returns fd or -errno */
80 eal_memalloc_get_seg_fd(int list_idx, int seg_idx);
82 /* returns 0 or -errno */
84 eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd);
86 /* returns 0 or -errno */
88 eal_memalloc_set_seg_list_fd(int list_idx, int fd);
91 eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset);
94 eal_memalloc_init(void);
97 eal_memalloc_cleanup(void);
99 #endif /* EAL_MEMALLOC_H */