CNDP  22.08.0
cne_mmap.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2020-2022 Intel Corporation
3  */
4 
5 #ifndef _MMAP_H_
6 #define _MMAP_H_
7 
15 #include <stddef.h> // for size_t
16 #include <stdint.h> // for uint64_t, uint8_t
17 
18 #include <cne_common.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
27 typedef enum {
33 
34 #define MMAP_HUGEPAGE_DEFAULT MMAP_HUGEPAGE_4KB
35 
39 typedef struct {
40  uint64_t page_sz;
41  uint64_t num_allocated;
42  uint64_t num_freed;
43  uint64_t allocated;
44  uint64_t freed;
45 } mmap_sizes_t;
46 
50 typedef struct {
51  uint8_t inited;
53 } mmap_stats_t;
54 
55 typedef void mmap_t;
69 CNDP_API mmap_t *mmap_alloc(uint32_t bufcnt, uint32_t bufsz, mmap_type_t hugepage);
70 
79 CNDP_API int mmap_free(mmap_t *mmap);
80 
93 CNDP_API void *mmap_addr_at_offset(mmap_t *mm, size_t offset);
94 
103 CNDP_API void *mmap_addr(mmap_t *mm);
104 
117 CNDP_API size_t mmap_size(mmap_t *mm, uint32_t *bufcnt, uint32_t *bufsz);
118 
128 CNDP_API mmap_type_t mmap_type_by_name(const char *htype);
129 
138 CNDP_API const char *mmap_name_by_type(mmap_type_t typ);
139 
146 CNDP_API void mmap_set_default(mmap_type_t htype);
147 
154 CNDP_API void mmap_set_default_by_name(const char *name);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* _MMAP_H_ */
CNDP_API void * mmap_addr(mmap_t *mm)
CNDP_API void mmap_set_default(mmap_type_t htype)
CNDP_API int mmap_free(mmap_t *mmap)
CNDP_API mmap_type_t mmap_type_by_name(const char *htype)
mmap_type_t
Definition: cne_mmap.h:27
@ MMAP_HUGEPAGE_2MB
Definition: cne_mmap.h:29
@ MMAP_HUGEPAGE_1GB
Definition: cne_mmap.h:30
@ MMAP_HUGEPAGE_4KB
Definition: cne_mmap.h:28
@ MMAP_HUGEPAGE_CNT
Definition: cne_mmap.h:31
CNDP_API mmap_t * mmap_alloc(uint32_t bufcnt, uint32_t bufsz, mmap_type_t hugepage)
CNDP_API void mmap_set_default_by_name(const char *name)
CNDP_API size_t mmap_size(mmap_t *mm, uint32_t *bufcnt, uint32_t *bufsz)
CNDP_API const char * mmap_name_by_type(mmap_type_t typ)
void mmap_t
Definition: cne_mmap.h:55
CNDP_API void * mmap_addr_at_offset(mmap_t *mm, size_t offset)
uint64_t freed
Definition: cne_mmap.h:44
uint64_t num_freed
Definition: cne_mmap.h:42
uint64_t num_allocated
Definition: cne_mmap.h:41
uint64_t allocated
Definition: cne_mmap.h:43
uint64_t page_sz
Definition: cne_mmap.h:40
uint8_t inited
Definition: cne_mmap.h:51