DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: olivier.matz@6wind.com, thomas@monjalon.net,
	pbhagavatula@caviumnetworks.com
Cc: nipun.gupta@nxp.com, jerin.jacob@caviumnetworks.com,
	santosh.shukla@caviumnetworks.com, dev@dpdk.org,
	Hemant Agrawal <hemant.agrawal@nxp.com>
Subject: [dpdk-dev] [PATCH FIX-OPTION-2 1/2] eal: use named memzone to store user mempool ops name
Date: Fri,  2 Feb 2018 13:33:00 +0530	[thread overview]
Message-ID: <1517558582-27108-1-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1517514427-28843-1-git-send-email-hemant.agrawal@nxp.com>

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

diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile
index dd455e6..f07dace 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -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
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 1622a41..2c33a60 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.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);
diff --git a/lib/librte_eal/common/eal_common_mempool.c b/lib/librte_eal/common/eal_common_mempool.c
new file mode 100644
index 0000000..1d10a75
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_mempool.c
@@ -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;
+}
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 0b28770..76beaff 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -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_ */
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index 82b8910..3c6125b 100644
--- a/lib/librte_eal/common/meson.build
+++ b/lib/librte_eal/common/meson.build
@@ -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',
diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
index 7e5bbe8..83a08b0 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 451fdaf..42a79d1 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.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);
-- 
2.7.4

  parent reply	other threads:[~2018-02-02  8:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 19:47 [dpdk-dev] [PATCH 1/2] Revert "eal: fix default mempool ops" Hemant Agrawal
2018-02-01 19:47 ` [dpdk-dev] [PATCH 2/2] test: use the best mempool ops API to get mbuf pool Hemant Agrawal
2018-02-01 19:56 ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix default mempool ops" Hemant Agrawal
2018-02-01 20:40   ` Pavan Nikhilesh
2018-02-02  5:43     ` Hemant Agrawal
2018-02-02  8:03 ` Hemant Agrawal [this message]
2018-02-02  8:03   ` [dpdk-dev] [PATCH FIX-OPTION-1] mbuf: fix the logic of user mempool ops API Hemant Agrawal
2018-02-02 13:40     ` Olivier Matz
2018-02-02 13:47       ` Hemant Agrawal
2018-02-06  0:05       ` Thomas Monjalon
     [not found]     ` <BY1PR0701MB1895B37B913A223180EED6D3EAFF0@BY1PR0701MB1895.namprd07.prod.outlook.com>
2018-02-04  6:34       ` [dpdk-dev] Fw: " santosh
2018-02-04 10:27         ` [dpdk-dev] " Hemant Agrawal
2018-02-02  8:03   ` [dpdk-dev] [PATCH FIX-OPTION-2 2/2] mbuf: fix user mempool ops get to use only named memzone Hemant Agrawal
2018-02-02  8:03 ` [dpdk-dev] [PATCH] doc: remove eal API for default mempool ops name Hemant Agrawal
2018-02-02  8:31   ` [dpdk-dev] [PATCH v2] " Hemant Agrawal
2018-02-02 14:01     ` Olivier Matz
2018-02-13 11:28       ` Ferruh Yigit
2018-02-14 14:58         ` Thomas Monjalon
2018-02-03 13:28     ` Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517558582-27108-1-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=nipun.gupta@nxp.com \
    --cc=olivier.matz@6wind.com \
    --cc=pbhagavatula@caviumnetworks.com \
    --cc=santosh.shukla@caviumnetworks.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).