summaryrefslogtreecommitdiffstats
path: root/src/seastar/dpdk/drivers/mempool/stack
diff options
context:
space:
mode:
Diffstat (limited to 'src/seastar/dpdk/drivers/mempool/stack')
-rw-r--r--src/seastar/dpdk/drivers/mempool/stack/Makefile25
-rw-r--r--src/seastar/dpdk/drivers/mempool/stack/meson.build8
-rw-r--r--src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack.c97
-rw-r--r--src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack_version.map4
4 files changed, 134 insertions, 0 deletions
diff --git a/src/seastar/dpdk/drivers/mempool/stack/Makefile b/src/seastar/dpdk/drivers/mempool/stack/Makefile
new file mode 100644
index 000000000..1681a62bc
--- /dev/null
+++ b/src/seastar/dpdk/drivers/mempool/stack/Makefile
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2017 NXP
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_mempool_stack.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+# Headers
+CFLAGS += -I$(RTE_SDK)/lib/librte_mempool
+LDLIBS += -lrte_eal -lrte_mempool -lrte_stack
+
+EXPORT_MAP := rte_mempool_stack_version.map
+
+LIBABIVER := 1
+
+SRCS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += rte_mempool_stack.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/src/seastar/dpdk/drivers/mempool/stack/meson.build b/src/seastar/dpdk/drivers/mempool/stack/meson.build
new file mode 100644
index 000000000..03e369a41
--- /dev/null
+++ b/src/seastar/dpdk/drivers/mempool/stack/meson.build
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017-2019 Intel Corporation
+
+allow_experimental_apis = true
+
+sources = files('rte_mempool_stack.c')
+
+deps += ['stack']
diff --git a/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack.c b/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack.c
new file mode 100644
index 000000000..7e85c8d6b
--- /dev/null
+++ b/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack.c
@@ -0,0 +1,97 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2019 Intel Corporation
+ */
+
+#include <stdio.h>
+#include <rte_mempool.h>
+#include <rte_stack.h>
+
+static int
+__stack_alloc(struct rte_mempool *mp, uint32_t flags)
+{
+ char name[RTE_STACK_NAMESIZE];
+ struct rte_stack *s;
+ int ret;
+
+ ret = snprintf(name, sizeof(name),
+ RTE_MEMPOOL_MZ_FORMAT, mp->name);
+ if (ret < 0 || ret >= (int)sizeof(name)) {
+ rte_errno = ENAMETOOLONG;
+ return -rte_errno;
+ }
+
+ s = rte_stack_create(name, mp->size, mp->socket_id, flags);
+ if (s == NULL)
+ return -rte_errno;
+
+ mp->pool_data = s;
+
+ return 0;
+}
+
+static int
+stack_alloc(struct rte_mempool *mp)
+{
+ return __stack_alloc(mp, 0);
+}
+
+static int
+lf_stack_alloc(struct rte_mempool *mp)
+{
+ return __stack_alloc(mp, RTE_STACK_F_LF);
+}
+
+static int
+stack_enqueue(struct rte_mempool *mp, void * const *obj_table,
+ unsigned int n)
+{
+ struct rte_stack *s = mp->pool_data;
+
+ return rte_stack_push(s, obj_table, n) == 0 ? -ENOBUFS : 0;
+}
+
+static int
+stack_dequeue(struct rte_mempool *mp, void **obj_table,
+ unsigned int n)
+{
+ struct rte_stack *s = mp->pool_data;
+
+ return rte_stack_pop(s, obj_table, n) == 0 ? -ENOBUFS : 0;
+}
+
+static unsigned
+stack_get_count(const struct rte_mempool *mp)
+{
+ struct rte_stack *s = mp->pool_data;
+
+ return rte_stack_count(s);
+}
+
+static void
+stack_free(struct rte_mempool *mp)
+{
+ struct rte_stack *s = mp->pool_data;
+
+ rte_stack_free(s);
+}
+
+static struct rte_mempool_ops ops_stack = {
+ .name = "stack",
+ .alloc = stack_alloc,
+ .free = stack_free,
+ .enqueue = stack_enqueue,
+ .dequeue = stack_dequeue,
+ .get_count = stack_get_count
+};
+
+static struct rte_mempool_ops ops_lf_stack = {
+ .name = "lf_stack",
+ .alloc = lf_stack_alloc,
+ .free = stack_free,
+ .enqueue = stack_enqueue,
+ .dequeue = stack_dequeue,
+ .get_count = stack_get_count
+};
+
+MEMPOOL_REGISTER_OPS(ops_stack);
+MEMPOOL_REGISTER_OPS(ops_lf_stack);
diff --git a/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack_version.map b/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack_version.map
new file mode 100644
index 000000000..8591cc0b1
--- /dev/null
+++ b/src/seastar/dpdk/drivers/mempool/stack/rte_mempool_stack_version.map
@@ -0,0 +1,4 @@
+DPDK_17.05 {
+
+ local: *;
+};