1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017-2018 Intel Corporation
10 #include <rte_memory.h>
11 #include <rte_eal_memconfig.h>
14 * Allocate segment of specified page size.
17 eal_memalloc_alloc_seg(size_t page_sz, int socket);
20 * Allocate `n_segs` segments.
22 * Note: `ms` can be NULL.
24 * Note: it is possible to request best-effort allocation by setting `exact` to
25 * `false`, in which case allocator will return however many pages it managed to
26 * allocate successfully.
29 eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,
30 int socket, bool exact);
36 eal_memalloc_free_seg(struct rte_memseg *ms);
39 * Deallocate `n_segs` segments. Returns 0 on successful deallocation of all
40 * segments, returns -1 on error. Any segments that could have been deallocated,
41 * will be deallocated even in case of error.
44 eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs);
47 * Check if memory pointed to by `start` and of `length` that resides in
48 * memseg list `msl` is IOVA-contiguous.
51 eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,
54 /* synchronize local memory map to primary process */
56 eal_memalloc_sync_with_primary(void);
59 eal_memalloc_mem_event_callback_register(const char *name,
60 rte_mem_event_callback_t clb, void *arg);
63 eal_memalloc_mem_event_callback_unregister(const char *name, void *arg);
66 eal_memalloc_mem_event_notify(enum rte_mem_event event, const void *start,
70 eal_memalloc_mem_alloc_validator_register(const char *name,
71 rte_mem_alloc_validator_t clb, int socket_id, size_t limit);
74 eal_memalloc_mem_alloc_validator_unregister(const char *name, int socket_id);
77 eal_memalloc_mem_alloc_validate(int socket_id, size_t new_len);
79 /* returns fd or -errno */
81 eal_memalloc_get_seg_fd(int list_idx, int seg_idx);
83 /* returns 0 or -errno */
85 eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd);
87 /* returns 0 or -errno */
89 eal_memalloc_set_seg_list_fd(int list_idx, int fd);
92 eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset);
95 eal_memalloc_init(void);
97 #endif /* EAL_MEMALLOC_H */