1// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq --rust-target 1.40
2typedef unsigned char uint8_t;
3typedef unsigned short uint16_t;
4typedef unsigned int uint32_t;
5typedef unsigned long long uint64_t;
6
7typedef long long size_t;
8
9#define RTE_CACHE_LINE_SIZE 64
10
11/**
12 * Force alignment
13 */
14#define __rte_aligned(a) __attribute__((__aligned__(a)))
15
16/**
17 * Force alignment to cache line.
18 */
19#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
20
21#define RTE_MEMPOOL_OPS_NAMESIZE 32 /**< Max length of ops struct name. */
22
23/**
24 * Prototype for implementation specific data provisioning function.
25 *
26 * The function should provide the implementation specific memory for
27 * for use by the other mempool ops functions in a given mempool ops struct.
28 * E.g. the default ops provides an instance of the rte_ring for this purpose.
29 * it will most likely point to a different type of data structure, and
30 * will be transparent to the application programmer.
31 * This function should set mp->pool_data.
32 */
33typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
34
35/**
36 * Free the opaque private data pointed to by mp->pool_data pointer.
37 */
38typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
39
40/**
41 * Enqueue an object into the external pool.
42 */
43typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
44		void * const *obj_table, unsigned int n);
45
46/**
47 * Dequeue an object from the external pool.
48 */
49typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
50		void **obj_table, unsigned int n);
51
52/**
53 * Return the number of available objects in the external pool.
54 */
55typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
56/** Structure defining mempool operations structure */
57struct rte_mempool_ops {
58	char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */
59	rte_mempool_alloc_t alloc;       /**< Allocate private data. */
60	rte_mempool_free_t free;         /**< Free the external pool. */
61	rte_mempool_enqueue_t enqueue;   /**< Enqueue an object. */
62	rte_mempool_dequeue_t dequeue;   /**< Dequeue an object. */
63	rte_mempool_get_count get_count; /**< Get qty of available objs. */
64} __rte_cache_aligned;
65
66#define RTE_MEMPOOL_MAX_OPS_IDX 16  /**< Max registered ops structs */
67
68/**
69 * The rte_spinlock_t type.
70 */
71typedef struct {
72	volatile int locked; /**< lock status 0 = unlocked, 1 = locked */
73} rte_spinlock_t;
74
75/**
76 * Structure storing the table of registered ops structs, each of which contain
77 * the function pointers for the mempool ops functions.
78 * Each process has its own storage for this ops struct array so that
79 * the mempools can be shared across primary and secondary processes.
80 * The indices used to access the array are valid across processes, whereas
81 * any function pointers stored directly in the mempool struct would not be.
82 * This results in us simply having "ops_index" in the mempool struct.
83 */
84struct rte_mempool_ops_table {
85	rte_spinlock_t sl;     /**< Spinlock for add/delete. */
86	uint32_t num_ops;      /**< Number of used ops structs in the table. */
87	/**
88	 * Storage for all possible ops structs.
89	 */
90	struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX];
91} __rte_cache_aligned;
92
93
94/* Number of free lists per heap, grouped by size. */
95#define RTE_HEAP_NUM_FREELISTS  13
96
97#define LIST_HEAD(name, type)                                           \
98struct name {                                                           \
99		struct type *lh_first;  /* first element */                     \
100}
101
102/**
103 * Structure to hold malloc heap
104 */
105struct malloc_heap {
106	rte_spinlock_t lock;
107	LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS];
108	unsigned alloc_count;
109	size_t total_size;
110} __rte_cache_aligned;
111