112a9d9c8Sopenharmony_ci// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq --rust-target 1.40 212a9d9c8Sopenharmony_citypedef unsigned char uint8_t; 312a9d9c8Sopenharmony_citypedef unsigned short uint16_t; 412a9d9c8Sopenharmony_citypedef unsigned int uint32_t; 512a9d9c8Sopenharmony_citypedef unsigned long long uint64_t; 612a9d9c8Sopenharmony_ci 712a9d9c8Sopenharmony_citypedef long long size_t; 812a9d9c8Sopenharmony_ci 912a9d9c8Sopenharmony_ci#define RTE_CACHE_LINE_SIZE 64 1012a9d9c8Sopenharmony_ci 1112a9d9c8Sopenharmony_ci/** 1212a9d9c8Sopenharmony_ci * Force alignment 1312a9d9c8Sopenharmony_ci */ 1412a9d9c8Sopenharmony_ci#define __rte_aligned(a) __attribute__((__aligned__(a))) 1512a9d9c8Sopenharmony_ci 1612a9d9c8Sopenharmony_ci/** 1712a9d9c8Sopenharmony_ci * Force alignment to cache line. 1812a9d9c8Sopenharmony_ci */ 1912a9d9c8Sopenharmony_ci#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) 2012a9d9c8Sopenharmony_ci 2112a9d9c8Sopenharmony_ci#define RTE_MEMPOOL_OPS_NAMESIZE 32 /**< Max length of ops struct name. */ 2212a9d9c8Sopenharmony_ci 2312a9d9c8Sopenharmony_ci/** 2412a9d9c8Sopenharmony_ci * Prototype for implementation specific data provisioning function. 2512a9d9c8Sopenharmony_ci * 2612a9d9c8Sopenharmony_ci * The function should provide the implementation specific memory for 2712a9d9c8Sopenharmony_ci * for use by the other mempool ops functions in a given mempool ops struct. 2812a9d9c8Sopenharmony_ci * E.g. the default ops provides an instance of the rte_ring for this purpose. 2912a9d9c8Sopenharmony_ci * it will most likely point to a different type of data structure, and 3012a9d9c8Sopenharmony_ci * will be transparent to the application programmer. 3112a9d9c8Sopenharmony_ci * This function should set mp->pool_data. 3212a9d9c8Sopenharmony_ci */ 3312a9d9c8Sopenharmony_citypedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp); 3412a9d9c8Sopenharmony_ci 3512a9d9c8Sopenharmony_ci/** 3612a9d9c8Sopenharmony_ci * Free the opaque private data pointed to by mp->pool_data pointer. 3712a9d9c8Sopenharmony_ci */ 3812a9d9c8Sopenharmony_citypedef void (*rte_mempool_free_t)(struct rte_mempool *mp); 3912a9d9c8Sopenharmony_ci 4012a9d9c8Sopenharmony_ci/** 4112a9d9c8Sopenharmony_ci * Enqueue an object into the external pool. 4212a9d9c8Sopenharmony_ci */ 4312a9d9c8Sopenharmony_citypedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp, 4412a9d9c8Sopenharmony_ci void * const *obj_table, unsigned int n); 4512a9d9c8Sopenharmony_ci 4612a9d9c8Sopenharmony_ci/** 4712a9d9c8Sopenharmony_ci * Dequeue an object from the external pool. 4812a9d9c8Sopenharmony_ci */ 4912a9d9c8Sopenharmony_citypedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, 5012a9d9c8Sopenharmony_ci void **obj_table, unsigned int n); 5112a9d9c8Sopenharmony_ci 5212a9d9c8Sopenharmony_ci/** 5312a9d9c8Sopenharmony_ci * Return the number of available objects in the external pool. 5412a9d9c8Sopenharmony_ci */ 5512a9d9c8Sopenharmony_citypedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); 5612a9d9c8Sopenharmony_ci/** Structure defining mempool operations structure */ 5712a9d9c8Sopenharmony_cistruct rte_mempool_ops { 5812a9d9c8Sopenharmony_ci char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ 5912a9d9c8Sopenharmony_ci rte_mempool_alloc_t alloc; /**< Allocate private data. */ 6012a9d9c8Sopenharmony_ci rte_mempool_free_t free; /**< Free the external pool. */ 6112a9d9c8Sopenharmony_ci rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ 6212a9d9c8Sopenharmony_ci rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ 6312a9d9c8Sopenharmony_ci rte_mempool_get_count get_count; /**< Get qty of available objs. */ 6412a9d9c8Sopenharmony_ci} __rte_cache_aligned; 6512a9d9c8Sopenharmony_ci 6612a9d9c8Sopenharmony_ci#define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ 6712a9d9c8Sopenharmony_ci 6812a9d9c8Sopenharmony_ci/** 6912a9d9c8Sopenharmony_ci * The rte_spinlock_t type. 7012a9d9c8Sopenharmony_ci */ 7112a9d9c8Sopenharmony_citypedef struct { 7212a9d9c8Sopenharmony_ci volatile int locked; /**< lock status 0 = unlocked, 1 = locked */ 7312a9d9c8Sopenharmony_ci} rte_spinlock_t; 7412a9d9c8Sopenharmony_ci 7512a9d9c8Sopenharmony_ci/** 7612a9d9c8Sopenharmony_ci * Structure storing the table of registered ops structs, each of which contain 7712a9d9c8Sopenharmony_ci * the function pointers for the mempool ops functions. 7812a9d9c8Sopenharmony_ci * Each process has its own storage for this ops struct array so that 7912a9d9c8Sopenharmony_ci * the mempools can be shared across primary and secondary processes. 8012a9d9c8Sopenharmony_ci * The indices used to access the array are valid across processes, whereas 8112a9d9c8Sopenharmony_ci * any function pointers stored directly in the mempool struct would not be. 8212a9d9c8Sopenharmony_ci * This results in us simply having "ops_index" in the mempool struct. 8312a9d9c8Sopenharmony_ci */ 8412a9d9c8Sopenharmony_cistruct rte_mempool_ops_table { 8512a9d9c8Sopenharmony_ci rte_spinlock_t sl; /**< Spinlock for add/delete. */ 8612a9d9c8Sopenharmony_ci uint32_t num_ops; /**< Number of used ops structs in the table. */ 8712a9d9c8Sopenharmony_ci /** 8812a9d9c8Sopenharmony_ci * Storage for all possible ops structs. 8912a9d9c8Sopenharmony_ci */ 9012a9d9c8Sopenharmony_ci struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX]; 9112a9d9c8Sopenharmony_ci} __rte_cache_aligned; 9212a9d9c8Sopenharmony_ci 9312a9d9c8Sopenharmony_ci 9412a9d9c8Sopenharmony_ci/* Number of free lists per heap, grouped by size. */ 9512a9d9c8Sopenharmony_ci#define RTE_HEAP_NUM_FREELISTS 13 9612a9d9c8Sopenharmony_ci 9712a9d9c8Sopenharmony_ci#define LIST_HEAD(name, type) \ 9812a9d9c8Sopenharmony_cistruct name { \ 9912a9d9c8Sopenharmony_ci struct type *lh_first; /* first element */ \ 10012a9d9c8Sopenharmony_ci} 10112a9d9c8Sopenharmony_ci 10212a9d9c8Sopenharmony_ci/** 10312a9d9c8Sopenharmony_ci * Structure to hold malloc heap 10412a9d9c8Sopenharmony_ci */ 10512a9d9c8Sopenharmony_cistruct malloc_heap { 10612a9d9c8Sopenharmony_ci rte_spinlock_t lock; 10712a9d9c8Sopenharmony_ci LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS]; 10812a9d9c8Sopenharmony_ci unsigned alloc_count; 10912a9d9c8Sopenharmony_ci size_t total_size; 11012a9d9c8Sopenharmony_ci} __rte_cache_aligned; 111