@@ -38,6 +38,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_alarm.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_lcore.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_mempool.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
@@ -621,6 +621,11 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_eal_mempool_ops_config() < 0) {
+ rte_eal_init_alert("Cannot config user Mempool Ops\n");
+ return -1;
+ }
+
eal_check_mem_on_local_socket();
eal_thread_init_master(rte_config.master_lcore);
new file mode 100644
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/queue.h>
+
+#include <rte_memory.h>
+#include <rte_eal.h>
+#include <rte_log.h>
+#include <rte_errno.h>
+#include <rte_memzone.h>
+
+#include "eal_private.h"
+#include "eal_internal_cfg.h"
+
+/* init mempool ops */
+int
+rte_eal_mempool_ops_config(void)
+{
+ RTE_LOG(DEBUG, EAL, "Configuring user mempool ops name...\n");
+
+ /* secondary processes don't need to initialise anything */
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+ return 0;
+
+ if (internal_config.user_mbuf_pool_ops_name) {
+ const struct rte_memzone *mz;
+
+ mz = rte_memzone_lookup("mbuf_user_pool_ops");
+ if (mz == NULL) {
+ mz = rte_memzone_reserve("mbuf_user_pool_ops",
+ 32, SOCKET_ID_ANY, 0);
+ if (mz == NULL)
+ return -rte_errno;
+ }
+
+ strncpy(mz->addr, internal_config.user_mbuf_pool_ops_name,
+ strlen(internal_config.user_mbuf_pool_ops_name));
+ }
+
+ return 0;
+}
@@ -205,4 +205,16 @@ struct rte_bus *rte_bus_find_by_device_name(const char *str);
int rte_mp_channel_init(void);
+/**
+ * Mempool ops configuration
+ *
+ * This function is private to EAL.
+ *
+ * Set the user defined mempool ops in the named memzone area.
+ *
+ * @return
+ * 0 on success, negative on error
+ */
+int rte_eal_mempool_ops_config(void);
+
#endif /* _EAL_PRIVATE_H_ */
@@ -16,6 +16,7 @@ common_sources = files(
'eal_common_lcore.c',
'eal_common_log.c',
'eal_common_memory.c',
+ 'eal_common_mempool.c',
'eal_common_memzone.c',
'eal_common_options.c',
'eal_common_proc.c',
@@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_alarm.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_lcore.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_mempool.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
@@ -877,6 +877,11 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_eal_mempool_ops_config() < 0) {
+ rte_eal_init_alert("Cannot config user Mempool Ops\n");
+ return -1;
+ }
+
eal_check_mem_on_local_socket();
eal_thread_init_master(rte_config.master_lcore);
The new mbuf pool ops name API uses the named memzone to store different types of configured mempool ops name. It is better to also save the user configured mempool ops name in named memzone. This way the best mempool ops name can easily get the user configured mempool ops name for it's decisions. This will also avoid the need to maintain a eal api for default mempool ops name. Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 5 +++ lib/librte_eal/common/eal_common_mempool.c | 50 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 12 +++++++ lib/librte_eal/common/meson.build | 1 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal.c | 5 +++ 7 files changed, 75 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_mempool.c -- 2.7.4