Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
mempool_private.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2019-2022 Intel Corporation.
3
* Copyright (c) 2016 6WIND S.A.
4
*/
5
6
#ifndef _MEMPOOL_PRIVATE_H_
7
#define _MEMPOOL_PRIVATE_H_
8
15
16
#include <stdio.h>
17
#include <stdlib.h>
18
#include <stdint.h>
19
#include <inttypes.h>
20
21
#include <
cne_branch_prediction.h
>
22
#include <
cne_common.h
>
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
28
#define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
29
30
#ifndef CNE_MEMPOOL_ALIGN
31
#define CNE_MEMPOOL_ALIGN CNE_CACHE_LINE_SIZE
32
#endif
33
34
#define CNE_MEMPOOL_ALIGN_MASK (CNE_MEMPOOL_ALIGN - 1)
35
39
struct
mempool_stats
{
40
uint64_t
put_bulk
;
41
uint64_t
put_objs
;
42
uint64_t
get_success_bulk
;
43
uint64_t
get_success_objs
;
44
uint64_t
get_fail_bulk
;
45
uint64_t
get_fail_objs
;
46
}
__cne_cache_aligned
;
47
52
53
struct
mempool_cache
{
54
uint32_t
size
;
55
uint32_t
flushthresh
;
56
uint32_t
len
;
57
/*
58
* Cache is allocated to this size to allow it to overflow in certain
59
* cases to avoid needless emptying of cache.
60
*/
61
void
*
objs
[MEMPOOL_CACHE_MAX_SIZE * 3];
62
}
__cne_cache_aligned
;
63
64
struct
cne_mempool {
65
void
*objring;
66
void
*objmem;
67
ssize_t objmem_sz;
68
uint32_t obj_cnt;
69
uint32_t obj_sz;
70
uint32_t cache_sz;
71
uint32_t populated_sz;
72
uint32_t free_objmem;
73
struct
mempool_cache
*cache;
74
struct
mempool_stats
*stats;
75
}
__cne_cache_aligned
;
76
77
// clang-format off
78
#define __MEMPOOL_STAT_ADD(mp, name, n) do { \
79
int __uid = cne_id(); \
80
mp->stats[__uid].name##_objs += n; \
81
mp->stats[__uid].name##_bulk += 1; \
82
} while(0)
83
// clang-format on
84
85
#ifdef __cplusplus
86
}
87
#endif
88
89
#endif
/* _MEMPOOL_PRIVATE_H_ */
cne_branch_prediction.h
cne_common.h
__cne_cache_aligned
#define __cne_cache_aligned
Definition
cne_common.h:379
mempool_cache
Definition
mempool_private.h:53
mempool_cache::flushthresh
uint32_t flushthresh
Definition
mempool_private.h:55
mempool_cache::objs
void * objs[MEMPOOL_CACHE_MAX_SIZE *3]
Definition
mempool_private.h:61
mempool_cache::len
uint32_t len
Definition
mempool_private.h:56
mempool_cache::size
uint32_t size
Definition
mempool_private.h:54
mempool_stats
Definition
mempool_private.h:39
mempool_stats::get_success_objs
uint64_t get_success_objs
Definition
mempool_private.h:43
mempool_stats::put_objs
uint64_t put_objs
Definition
mempool_private.h:41
mempool_stats::get_success_bulk
uint64_t get_success_bulk
Definition
mempool_private.h:42
mempool_stats::put_bulk
uint64_t put_bulk
Definition
mempool_private.h:40
mempool_stats::get_fail_objs
uint64_t get_fail_objs
Definition
mempool_private.h:45
mempool_stats::get_fail_bulk
uint64_t get_fail_bulk
Definition
mempool_private.h:44
lib
core
mempool
mempool_private.h
Generated by
1.18.0