1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2019 Intel Corporation
6 #include <rte_mempool.h>
10 stack_alloc(struct rte_mempool *mp)
12 char name[RTE_STACK_NAMESIZE];
16 ret = snprintf(name, sizeof(name),
17 RTE_MEMPOOL_MZ_FORMAT, mp->name);
18 if (ret < 0 || ret >= (int)sizeof(name)) {
19 rte_errno = ENAMETOOLONG;
23 s = rte_stack_create(name, mp->size, mp->socket_id, 0);
33 stack_enqueue(struct rte_mempool *mp, void * const *obj_table,
36 struct rte_stack *s = mp->pool_data;
38 return rte_stack_push(s, obj_table, n) == 0 ? -ENOBUFS : 0;
42 stack_dequeue(struct rte_mempool *mp, void **obj_table,
45 struct rte_stack *s = mp->pool_data;
47 return rte_stack_pop(s, obj_table, n) == 0 ? -ENOBUFS : 0;
51 stack_get_count(const struct rte_mempool *mp)
53 struct rte_stack *s = mp->pool_data;
55 return rte_stack_count(s);
59 stack_free(struct rte_mempool *mp)
61 struct rte_stack *s = mp->pool_data;
66 static struct rte_mempool_ops ops_stack = {
70 .enqueue = stack_enqueue,
71 .dequeue = stack_dequeue,
72 .get_count = stack_get_count
75 MEMPOOL_REGISTER_OPS(ops_stack);