[dpdk-dev] [RFC 3/7] testpmd: new parameter to set mbuf pool ops
Olivier Matz
olivier.matz at 6wind.com
Mon Sep 19 15:42:43 CEST 2016
Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
app/test-pmd/parameters.c | 5 +++++
app/test-pmd/testpmd.c | 15 ++++++++++++++-
app/test-pmd/testpmd.h | 1 +
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 6a6a07e..cbd287d 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -131,6 +131,7 @@ usage(char* progname)
printf(" --total-num-mbufs=N: set the number of mbufs to be allocated "
"in mbuf pools.\n");
printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
+ printf(" --mbuf-pool-ops=<handler>: set an alternative mbuf pool handler\n");
#ifdef RTE_LIBRTE_CMDLINE
printf(" --eth-peers-configfile=name: config file with ethernet addresses "
"of peer ports.\n");
@@ -519,6 +520,7 @@ launch_args_parse(int argc, char** argv)
{ "mbuf-size", 1, 0, 0 },
{ "total-num-mbufs", 1, 0, 0 },
{ "max-pkt-len", 1, 0, 0 },
+ { "mbuf-pool-ops", 1, 0, 0 },
{ "pkt-filter-mode", 1, 0, 0 },
{ "pkt-filter-report-hash", 1, 0, 0 },
{ "pkt-filter-size", 1, 0, 0 },
@@ -701,6 +703,9 @@ launch_args_parse(int argc, char** argv)
"Invalid max-pkt-len=%d - should be > %d\n",
n, ETHER_MIN_LEN);
}
+ if (!strcmp(lgopts[opt_idx].name, "mbuf-pool-ops")) {
+ mbuf_pool_ops = strdup(optarg);
+ }
if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
if (!strcmp(optarg, "signature"))
fdir_conf.mode =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index cc3d2d0..669bf97 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -167,6 +167,7 @@ uint32_t burst_tx_retry_num = BURST_TX_RETRIES;
uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */
uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if
* specified on command-line. */
+const char *mbuf_pool_ops = NULL;
/*
* Configuration of packet segments used by the "txonly" processing engine.
@@ -419,6 +420,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
char pool_name[RTE_MEMPOOL_NAMESIZE];
struct rte_mempool *rte_mp = NULL;
uint32_t mb_size;
+ int ret;
mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size;
mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name));
@@ -444,6 +446,17 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
sizeof(struct rte_pktmbuf_pool_private),
socket_id, 0);
+ if (rte_mp != NULL) {
+ ret = rte_mempool_set_ops_byname(rte_mp,
+ mbuf_pool_ops, NULL);
+ if (ret != 0) {
+ RTE_LOG(ERR, MBUF,
+ "cannot set mempool handler\n");
+ rte_mempool_free(rte_mp);
+ rte_mp = NULL;
+ }
+ }
+
if (rte_mempool_populate_anon(rte_mp) == 0) {
rte_mempool_free(rte_mp);
rte_mp = NULL;
@@ -454,7 +467,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
/* wrapper to rte_mempool_create() */
rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
mb_mempool_cache, 0, mbuf_seg_size, socket_id,
- NULL);
+ mbuf_pool_ops);
}
}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2b281cc..c7bab77 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -357,6 +357,7 @@ extern enum dcb_queue_mapping_mode dcb_q_mapping;
extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
extern uint32_t param_total_num_mbufs;
+extern const char *mbuf_pool_ops; /**< mbuf pool handler to use */
extern struct rte_fdir_conf fdir_conf;
--
2.8.1
More information about the dev
mailing list