From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 168422716 for ; Mon, 19 Sep 2016 15:43:00 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 7E75928D69; Mon, 19 Sep 2016 15:42:59 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, david.hunt@intel.com Date: Mon, 19 Sep 2016 15:42:43 +0200 Message-Id: <1474292567-21912-4-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1474292567-21912-1-git-send-email-olivier.matz@6wind.com> References: <1474292567-21912-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [RFC 3/7] testpmd: new parameter to set mbuf pool ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 13:43:00 -0000 Signed-off-by: Olivier Matz --- 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=: 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