DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: <dev@dpdk.org>
Cc: <jerin.jacob@caviumnetworks.com>, <olivier.matz@6wind.com>,
	<santosh.shukla@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH v5 3/7] mbuf: add pool ops name selection API helpers
Date: Sat, 20 Jan 2018 11:45:04 +0530	[thread overview]
Message-ID: <1516428908-5430-4-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1516428908-5430-1-git-send-email-hemant.agrawal@nxp.com>

This patch add support for various mempool ops config helper APIs.

1.User defined mempool ops
2.Platform detected HW mempool ops (active).
3.Best selection of mempool ops by looking into user defined,
  platform registered and compile time configured.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 doc/api/doxy-api-index.md            |  1 +
 lib/librte_mbuf/Makefile             |  4 +-
 lib/librte_mbuf/rte_mbuf.c           |  5 +-
 lib/librte_mbuf/rte_mbuf_pool_ops.c  | 96 ++++++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf_pool_ops.h  | 91 ++++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf_version.map | 11 +++++
 6 files changed, 203 insertions(+), 5 deletions(-)
 create mode 100644 lib/librte_mbuf/rte_mbuf_pool_ops.c
 create mode 100644 lib/librte_mbuf/rte_mbuf_pool_ops.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 76d606f..8cbd92a 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -136,6 +136,7 @@ The public API headers are grouped by topics:
 
 - **containers**:
   [mbuf]               (@ref rte_mbuf.h),
+  [mbuf pool ops]      (@ref rte_mbuf_pool_ops.h)
   [ring]               (@ref rte_ring.h),
   [tailq]              (@ref rte_tailq.h),
   [bitmap]             (@ref rte_bitmap.h)
diff --git a/lib/librte_mbuf/Makefile b/lib/librte_mbuf/Makefile
index 398f724..e2e3ec6 100644
--- a/lib/librte_mbuf/Makefile
+++ b/lib/librte_mbuf/Makefile
@@ -14,9 +14,9 @@ EXPORT_MAP := rte_mbuf_version.map
 LIBABIVER := 3
 
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_MBUF) := rte_mbuf.c rte_mbuf_ptype.c
+SRCS-$(CONFIG_RTE_LIBRTE_MBUF) := rte_mbuf.c rte_mbuf_ptype.c rte_mbuf_pool_ops.c
 
 # install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_MBUF)-include := rte_mbuf.h rte_mbuf_ptype.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_MBUF)-include := rte_mbuf.h rte_mbuf_ptype.h rte_mbuf_pool_ops.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index c085c37..0c4d374 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -54,6 +54,7 @@
 #include <rte_branch_prediction.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
+#include <rte_mbuf_pool_ops.h>
 #include <rte_string_fns.h>
 #include <rte_hexdump.h>
 #include <rte_errno.h>
@@ -176,9 +177,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
 	if (mp == NULL)
 		return NULL;
 
-	mp_ops_name = rte_eal_mbuf_default_mempool_ops();
-	if (mp_ops_name == NULL)
-		mp_ops_name = RTE_MBUF_DEFAULT_MEMPOOL_OPS;
+	mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
 		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c
new file mode 100644
index 0000000..9aa1541
--- /dev/null
+++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#include <string.h>
+#include <rte_eal.h>
+#include <rte_mbuf.h>
+#include <rte_errno.h>
+#include <rte_mbuf_pool_ops.h>
+
+int
+rte_mbuf_set_platform_mempool_ops(const char *ops_name)
+{
+	const struct rte_memzone *mz;
+
+	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
+		return -ENAMETOOLONG;
+
+	mz = rte_memzone_lookup("mbuf_platform_pool_ops");
+	if (mz == NULL) {
+		mz = rte_memzone_reserve("mbuf_platform_pool_ops",
+			RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0);
+		if (mz == NULL)
+			return -rte_errno;
+		strncpy(mz->addr, ops_name, strlen(ops_name));
+		return 0;
+	} else if (strcmp(mz->addr, ops_name) == 0) {
+		return 0;
+	}
+
+	RTE_LOG(ERR, MBUF,
+		"%s is already registered as platform mbuf pool ops\n",
+		(char *)mz->addr);
+	return -EEXIST;
+}
+
+const char *
+rte_mbuf_platform_mempool_ops(void)
+{
+	const struct rte_memzone *mz;
+
+	mz = rte_memzone_lookup("mbuf_platform_pool_ops");
+	if (mz == NULL)
+		return NULL;
+	return mz->addr;
+}
+
+int
+rte_mbuf_set_user_mempool_ops(const char *ops_name)
+{
+	const struct rte_memzone *mz;
+
+	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
+		return -ENAMETOOLONG;
+
+	mz = rte_memzone_lookup("mbuf_user_pool_ops");
+	if (mz == NULL) {
+		mz = rte_memzone_reserve("mbuf_user_pool_ops",
+			RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0);
+		if (mz == NULL)
+			return -rte_errno;
+	}
+
+	strncpy(mz->addr, ops_name, strlen(ops_name));
+	return 0;
+
+}
+
+const char *
+rte_mbuf_user_mempool_ops(void)
+{
+	const struct rte_memzone *mz;
+
+	mz = rte_memzone_lookup("mbuf_user_pool_ops");
+	if (mz == NULL)
+		return rte_eal_mbuf_default_mempool_ops();
+	return mz->addr;
+}
+
+/* Return mbuf pool ops name */
+const char *
+rte_mbuf_best_mempool_ops(void)
+{
+	/* User defined mempool ops takes the priority */
+	const char *best_ops = rte_mbuf_user_mempool_ops();
+	if (best_ops)
+		return best_ops;
+
+	/* Next choice is platform configured mempool ops */
+	best_ops = rte_mbuf_platform_mempool_ops();
+	if (best_ops)
+		return best_ops;
+
+	/* Last choice is to use the compile time config pool */
+	return RTE_MBUF_DEFAULT_MEMPOOL_OPS;
+}
diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.h b/lib/librte_mbuf/rte_mbuf_pool_ops.h
new file mode 100644
index 0000000..b4a2d54
--- /dev/null
+++ b/lib/librte_mbuf/rte_mbuf_pool_ops.h
@@ -0,0 +1,91 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef _RTE_MBUF_POOL_OPS_H_
+#define _RTE_MBUF_POOL_OPS_H_
+
+/**
+ * @file
+ * RTE Mbuf Pool Ops
+ *
+ * These APIs are for configuring the mbuf pool ops names to be largely used by
+ * rte_pktmbuf_pool_create(). However, this can also be used to set and inquire
+ * the best mempool ops available.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Set the platform supported pktmbuf HW mempool ops name
+ *
+ * This function allow the HW to register the actively supported HW mempool
+ * ops_name. Only one HW mempool ops can be registered at any point of time.
+ *
+ * @param ops_name
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int
+rte_mbuf_set_platform_mempool_ops(const char *ops_name);
+
+/**
+ * Get configured platform supported pktmbuf HW mempool ops name
+ *
+ * This function returns the platform supported mempool ops name.
+ *
+ * @return
+ *   returns platform pool ops name.
+ */
+const char *
+rte_mbuf_platform_mempool_ops(void);
+
+/**
+ * Set the user preferred pktmbuf mempool ops name
+ *
+ * This function can be used by the user to configure user preferred
+ * mempool ops name.
+ *
+ * @param ops_name
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int
+rte_mbuf_set_user_mempool_ops(const char *ops_name);
+
+/**
+ * Get user preferred pool ops name for mbuf
+ *
+ * This function returns the user configured mempool ops name.
+ *
+ * @return
+ *   returns user pool ops name.
+ */
+const char *
+rte_mbuf_user_mempool_ops(void);
+
+/**
+ * Get the best mempool ops name for pktmbuf.
+ *
+ * This function is used to determine the best options for mempool ops for
+ * pktmbuf allocations. Following are the priority order:
+ * 1. User defined, 2. Platform HW supported, 3. Compile time configured.
+ * This function is also used by the rte_pktmbuf_pool_create to get the best
+ * mempool ops name.
+ *
+ * @return
+ *   returns preferred mbuf pool ops name
+ */
+const char *
+rte_mbuf_best_mempool_ops(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_MBUF_POOL_OPS_H_ */
diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map
index 6e2ea84..0028c08 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -35,3 +35,14 @@ DPDK_16.11 {
 	rte_get_tx_ol_flag_list;
 
 } DPDK_2.1;
+
+DPDK_18.02 {
+	global:
+
+	rte_mbuf_best_mempool_ops;
+	rte_mbuf_platform_mempool_ops;
+	rte_mbuf_set_platform_mempool_ops;
+	rte_mbuf_set_user_mempool_ops;
+	rte_mbuf_user_mempool_ops;
+
+} DPDK_16.11;
-- 
2.7.4

  parent reply	other threads:[~2018-01-20  7:25 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 12:22 [dpdk-dev] [PATCH 0/2] Multiple Pktmbuf mempool support Hemant Agrawal
2017-07-04 12:22 ` [dpdk-dev] [PATCH 1/2] mempool: check the support for the given mempool Hemant Agrawal
2017-07-04 12:22 ` [dpdk-dev] [PATCH 2/2] mbuf: add support for preferred mempool list Hemant Agrawal
2017-09-22  7:13 ` [dpdk-dev] [PATCH 0/2] Multiple Pktmbuf mempool support Hemant Agrawal
2017-09-25 10:24   ` Olivier MATZ
2017-10-10 14:15     ` Thomas Monjalon
2017-10-10 14:21       ` Hemant Agrawal
2017-12-15 10:24 ` [dpdk-dev] [PATCH 0/2] Dynamic HW Mempool Detection Support Hemant Agrawal
2017-12-15 10:24   ` [dpdk-dev] [PATCH 1/2] mbuf: update default Mempool ops with HW active pool Hemant Agrawal
2017-12-15 15:52     ` Stephen Hemminger
2017-12-18  9:26       ` Hemant Agrawal
2017-12-18  8:55     ` Jerin Jacob
2017-12-18  9:36       ` Hemant Agrawal
2017-12-22 14:59         ` Olivier MATZ
2017-12-28 12:07           ` Hemant Agrawal
2018-01-10 12:49             ` Hemant Agrawal
2017-12-22 14:41     ` Olivier MATZ
2017-12-15 10:24   ` [dpdk-dev] [PATCH 2/2] dpaa2: register dpaa2 mempool ops as active mempool Hemant Agrawal
2017-12-18  8:57     ` Jerin Jacob
2017-12-18  9:25       ` Hemant Agrawal
2018-01-15  6:11   ` [dpdk-dev] [PATCH v2 0/5] Dynamic HW Mempool Detection Support Hemant Agrawal
2018-01-15  6:11     ` [dpdk-dev] [PATCH v2 1/5] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-15  6:11     ` [dpdk-dev] [PATCH v2 2/5] eal: add platform mempool ops name in internal config Hemant Agrawal
2018-01-15 12:24       ` Jerin Jacob
2018-01-15 14:31         ` Hemant Agrawal
2018-01-15 16:26           ` Jerin Jacob
2018-01-16 15:04             ` Olivier Matz
2018-01-16 15:08               ` Jerin Jacob
2018-01-15  6:11     ` [dpdk-dev] [PATCH v2 3/5] mbuf: support register mempool Hw ops name APIs Hemant Agrawal
2018-01-15 11:41       ` Jerin Jacob
2018-01-15 14:24         ` Hemant Agrawal
2018-01-15 14:37           ` Jerin Jacob
2018-01-15 12:36       ` Jerin Jacob
2018-01-16 15:09       ` Olivier Matz
2018-01-15  6:11     ` [dpdk-dev] [PATCH v2 4/5] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-15 12:31       ` Jerin Jacob
2018-01-15 14:32         ` Hemant Agrawal
2018-01-15  6:11     ` [dpdk-dev] [PATCH v2 5/5] mbuf: add user command line config mempools ops API Hemant Agrawal
2018-01-15 12:29       ` Jerin Jacob
2018-01-15 14:35         ` Hemant Agrawal
2018-01-15 16:23           ` Jerin Jacob
2018-01-16 15:01     ` [dpdk-dev] [PATCH v2 0/5] Dynamic HW Mempool Detection Support Olivier Matz
2018-01-18 11:47       ` Hemant Agrawal
2018-01-18 13:42         ` Olivier Matz
2018-01-18 13:26     ` [dpdk-dev] [PATCH v3 0/7] " Hemant Agrawal
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 1/7] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-19 10:01         ` Olivier Matz
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 2/7] eal: add API to set user default mbuf mempool ops Hemant Agrawal
2018-01-19 10:01         ` Olivier Matz
2018-01-19 12:31           ` Hemant Agrawal
2018-01-19 12:43             ` Olivier Matz
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 3/7] mbuf: add pool ops name selection API helpers Hemant Agrawal
2018-01-19 10:01         ` Olivier Matz
2018-01-19 12:41           ` Hemant Agrawal
2018-01-19 13:10             ` Olivier Matz
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 4/7] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 5/7] app/testpmd: set preferred mempool as default pktpool Hemant Agrawal
2018-01-19 10:01         ` Olivier Matz
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 6/7] dpaa2: register dpaa2 as platform HW mempool on runtime Hemant Agrawal
2018-01-18 13:26       ` [dpdk-dev] [PATCH v3 7/7] dpaa: register dpaa " Hemant Agrawal
2018-01-19 16:33       ` [dpdk-dev] [PATCH v4 0/7] Dynamic HW Mempool Detection Support Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 1/7] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 2/7] mbuf: maintain user and compile time mempool ops name Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 3/7] mbuf: add pool ops name selection API helpers Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 4/7] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 5/7] app/testpmd: set preferred mempool as default pktpool Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 6/7] dpaa: register dpaa as platform HW mempool on runtime Hemant Agrawal
2018-01-19 16:33         ` [dpdk-dev] [PATCH v4 7/7] dpaa2: register dpaa2 " Hemant Agrawal
2018-01-20  6:15         ` [dpdk-dev] [PATCH v5 0/7] Dynamic HW Mempool Detection Support Hemant Agrawal
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 1/7] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-22 13:23             ` Olivier Matz
2018-01-22 13:24             ` Hemant Agrawal
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 2/7] mbuf: maintain user and compile time mempool ops name Hemant Agrawal
2018-01-22 13:23             ` Olivier Matz
2018-01-20  6:15           ` Hemant Agrawal [this message]
2018-01-22 13:23             ` [dpdk-dev] [PATCH v5 3/7] mbuf: add pool ops name selection API helpers Olivier Matz
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 4/7] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-22 13:24             ` Olivier Matz
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 5/7] app/testpmd: set preferred mempool as default pktpool Hemant Agrawal
2018-01-22 13:25             ` Olivier Matz
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 6/7] dpaa: register dpaa as platform HW mempool on runtime Hemant Agrawal
2018-01-20  6:15           ` [dpdk-dev] [PATCH v5 7/7] dpaa2: register dpaa2 " Hemant Agrawal
2018-01-22 13:51           ` [dpdk-dev] [PATCH v6 0/7] Dynamic HW Mempool Detection Support Hemant Agrawal
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 1/7] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-22 14:43               ` santosh
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 2/7] mbuf: maintain user and compile time mempool ops name Hemant Agrawal
2018-01-22 14:47               ` santosh
2018-01-25 22:02               ` Thomas Monjalon
2018-01-26  5:10                 ` Hemant Agrawal
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 3/7] mbuf: add pool ops name selection API helpers Hemant Agrawal
2018-01-22 14:49               ` santosh
2018-01-25 22:01               ` Thomas Monjalon
2018-01-26  5:10                 ` Hemant Agrawal
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 4/7] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-22 14:51               ` santosh
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 5/7] app/testpmd: set preferred mempool as default pktpool Hemant Agrawal
2018-01-22 14:52               ` santosh
2018-01-25 22:04               ` Thomas Monjalon
2018-01-26  5:11                 ` Hemant Agrawal
2018-01-26  7:43                   ` Thomas Monjalon
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 6/7] dpaa: register dpaa as platform HW mempool on runtime Hemant Agrawal
2018-01-22 13:51             ` [dpdk-dev] [PATCH v6 7/7] dpaa2: register dpaa2 " Hemant Agrawal
2018-01-29  8:10             ` [dpdk-dev] [PATCH v7 0/7] Dynamic HW Mempool Detection Support Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 1/7] eal: prefix mbuf pool ops name with user defined Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 2/7] mbuf: maintain user and compile time mempool ops name Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 3/7] mbuf: add pool ops name selection API helpers Hemant Agrawal
2018-01-29  8:44                 ` Andrew Rybchenko
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 4/7] mbuf: pktmbuf pool create helper for specific mempool ops Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 5/7] app/testpmd: add debug to print preferred " Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 6/7] dpaa: register dpaa as platform HW mempool on runtime Hemant Agrawal
2018-01-29  8:10               ` [dpdk-dev] [PATCH v7 7/7] dpaa2: register dpaa2 " Hemant Agrawal
2018-01-29 18:03               ` [dpdk-dev] [PATCH v7 0/7] Dynamic HW Mempool Detection Support Thomas Monjalon

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=1516428908-5430-4-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=olivier.matz@6wind.com \
    --cc=santosh.shukla@caviumnetworks.com \
    /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).