[dpdk-dev] [PATCH v4 1/2] eal: allow user to override default pool handle
Santosh Shukla
santosh.shukla at caviumnetworks.com
Mon Sep 11 17:18:36 CEST 2017
DPDK has support for both sw and hw mempool and
currently user is limited to use ring_mp_mc pool.
In case user want to use other pool handle,
need to update config RTE_MEMPOOL_OPS_DEFAULT, then
build and run with desired pool handle.
Introducing eal option to override default pool handle.
Now user can override the RTE_MEMPOOL_OPS_DEFAULT by passing
pool handle to eal `--mbuf-pool-ops=""`.
Signed-off-by: Santosh Shukla <santosh.shukla at caviumnetworks.com>
Acked-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
v3 --> v4:
- Removed RTE_MBUF_XX_POOL_NAMESIZE macro. (Suggested by Olivier)
- Replaced char * with const char * for 'mbuf_pool_name' var. (Olivier)
- Added eal arg info in release guide.
doc/guides/freebsd_gsg/build_sample_apps.rst | 3 +++
doc/guides/linux_gsg/build_sample_apps.rst | 3 +++
doc/guides/testpmd_app_ug/run_app.rst | 4 ++++
lib/librte_eal/bsdapp/eal/eal.c | 10 ++++++++++
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 +++++++
lib/librte_eal/common/eal_common_options.c | 3 +++
lib/librte_eal/common/eal_internal_cfg.h | 2 +-
lib/librte_eal/common/eal_options.h | 2 ++
lib/librte_eal/common/include/rte_eal.h | 9 +++++++++
lib/librte_eal/linuxapp/eal/eal.c | 11 +++++++++++
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 +++++++
lib/librte_mbuf/rte_mbuf.c | 5 +++--
12 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/doc/guides/freebsd_gsg/build_sample_apps.rst b/doc/guides/freebsd_gsg/build_sample_apps.rst
index 9faa0e6e5..bd69aa9f5 100644
--- a/doc/guides/freebsd_gsg/build_sample_apps.rst
+++ b/doc/guides/freebsd_gsg/build_sample_apps.rst
@@ -163,6 +163,9 @@ Other options, specific to Linux and are not supported under FreeBSD are as foll
* ``--huge-dir``:
The directory where hugetlbfs is mounted.
+* ``mbuf-pool-ops``:
+ Pool ops name for mbuf to use.
+
* ``--file-prefix``:
The prefix text used for hugepage filenames.
diff --git a/doc/guides/linux_gsg/build_sample_apps.rst b/doc/guides/linux_gsg/build_sample_apps.rst
index 0cc5fd173..7cba22e2a 100644
--- a/doc/guides/linux_gsg/build_sample_apps.rst
+++ b/doc/guides/linux_gsg/build_sample_apps.rst
@@ -157,6 +157,9 @@ The EAL options are as follows:
* ``--huge-dir``:
The directory where hugetlbfs is mounted.
+* ``mbuf-pool-ops``:
+ Pool ops name for mbuf to use.
+
* ``--file-prefix``:
The prefix text used for hugepage filenames.
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index e8303f3ba..61138957c 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -110,6 +110,10 @@ See the DPDK Getting Started Guides for more information on these options.
Specify the directory where the hugetlbfs is mounted.
+* ``mbuf-pool-ops``:
+
+ Pool ops name for mbuf to use.
+
* ``--proc-type``
Set the type of the current process.
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 5fa598842..150d3ccc4 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -112,6 +112,13 @@ struct internal_config internal_config;
/* used by rte_rdtsc() */
int rte_cycles_vmware_tsc_map;
+/* Return mbuf pool name */
+const char *
+rte_eal_mbuf_default_mempool_ops(void)
+{
+ return internal_config.mbuf_pool_name;
+}
+
/* Return a pointer to the configuration structure */
struct rte_config *
rte_eal_get_configuration(void)
@@ -385,6 +392,9 @@ eal_parse_args(int argc, char **argv)
continue;
switch (opt) {
+ case OPT_MBUF_POOL_OPS_NUM:
+ internal_config.mbuf_pool_name = optarg;
+ break;
case 'h':
eal_usage(prgname);
exit(EXIT_SUCCESS);
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index aac6fd776..172a28bbf 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -237,3 +237,10 @@ EXPERIMENTAL {
rte_service_unregister;
} DPDK_17.08;
+
+DPDK_17.11 {
+ global:
+
+ rte_eal_mbuf_default_mempool_ops;
+
+} DPDK_17.08;
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 1da185e59..cf49db990 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -98,6 +98,7 @@ eal_long_options[] = {
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
{OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
{OPT_XEN_DOM0, 0, NULL, OPT_XEN_DOM0_NUM },
+ {OPT_MBUF_POOL_OPS, 1, NULL, OPT_MBUF_POOL_OPS_NUM},
{0, 0, NULL, 0 }
};
@@ -220,6 +221,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
#endif
internal_cfg->vmware_tsc_map = 0;
internal_cfg->create_uio_dev = 0;
+ internal_cfg->mbuf_pool_name = RTE_MBUF_DEFAULT_MEMPOOL_OPS;
}
static int
@@ -1309,5 +1311,6 @@ eal_common_usage(void)
" --"OPT_NO_PCI" Disable PCI\n"
" --"OPT_NO_HPET" Disable HPET\n"
" --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
+ " --"OPT_MBUF_POOL_OPS" Pool ops name for mbuf to use\n"
"\n", RTE_MAX_LCORE);
}
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index 7b7e8c887..00c3bd227 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -82,7 +82,7 @@ struct internal_config {
volatile enum rte_intr_mode vfio_intr_mode;
const char *hugefile_prefix; /**< the base filename of hugetlbfs files */
const char *hugepage_dir; /**< specific hugetlbfs directory to use */
-
+ const char *mbuf_pool_name; /**< mbuf pool name */
unsigned num_hugepage_sizes; /**< how many sizes on this system */
struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES];
};
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 439a26104..9c893aa2d 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -83,6 +83,8 @@ enum {
OPT_VMWARE_TSC_MAP_NUM,
#define OPT_XEN_DOM0 "xen-dom0"
OPT_XEN_DOM0_NUM,
+#define OPT_MBUF_POOL_OPS "mbuf-pool-ops"
+ OPT_MBUF_POOL_OPS_NUM,
OPT_LONG_MAX_NUM
};
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 0e7363d77..1a719cc6b 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -287,6 +287,15 @@ static inline int rte_gettid(void)
return RTE_PER_LCORE(_thread_id);
}
+/**
+ * Get default pool name for mbuf
+ *
+ * @return
+ * returns default pool name.
+ */
+const char *
+rte_eal_mbuf_default_mempool_ops(void);
+
#define RTE_INIT(func) \
static void __attribute__((constructor, used)) func(void)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 48f12f44c..a44454129 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -121,6 +121,13 @@ struct internal_config internal_config;
/* used by rte_rdtsc() */
int rte_cycles_vmware_tsc_map;
+/* Return mbuf pool name */
+const char *
+rte_eal_mbuf_default_mempool_ops(void)
+{
+ return internal_config.mbuf_pool_name;
+}
+
/* Return a pointer to the configuration structure */
struct rte_config *
rte_eal_get_configuration(void)
@@ -610,6 +617,10 @@ eal_parse_args(int argc, char **argv)
internal_config.create_uio_dev = 1;
break;
+ case OPT_MBUF_POOL_OPS_NUM:
+ internal_config.mbuf_pool_name = optarg;
+ break;
+
default:
if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
RTE_LOG(ERR, EAL, "Option %c is not supported "
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 3a8f15406..5b48fcd37 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -242,3 +242,10 @@ EXPERIMENTAL {
rte_service_unregister;
} DPDK_17.08;
+
+DPDK_17.11 {
+ global:
+
+ rte_eal_mbuf_default_mempool_ops;
+
+} DPDK_17.08;
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 26a62b8e1..e1fc90ef3 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -157,6 +157,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
{
struct rte_mempool *mp;
struct rte_pktmbuf_pool_private mbp_priv;
+ const char *mp_name;
unsigned elt_size;
int ret;
@@ -176,8 +177,8 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
if (mp == NULL)
return NULL;
- ret = rte_mempool_set_ops_byname(mp,
- RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
+ mp_name = rte_eal_mbuf_default_mempool_ops();
+ ret = rte_mempool_set_ops_byname(mp, mp_name, NULL);
if (ret != 0) {
RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
rte_mempool_free(mp);
--
2.14.1
More information about the dev
mailing list