From c87988187fdb35cfc7ee1624159ee273e587ac9d Mon Sep 17 00:00:00 2001 From: Intel Date: Thu, 20 Dec 2012 00:00:00 +0100 Subject: [PATCH] app/testpmd: add --total-num-mbufs option Signed-off-by: Intel --- app/test-pmd/parameters.c | 12 ++++++++++++ app/test-pmd/testpmd.c | 17 +++++++++++++---- app/test-pmd/testpmd.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index a478ce6a81..dfdd6739f6 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -82,6 +82,7 @@ usage(char* progname) { printf("usage: %s [--interactive|-i] [--help|-h] | [" "--coremask=COREMASK --portmask=PORTMASK --numa " + "--mbuf-size= | --total-num-mbufs= | " "--eth-peers-configfile= | " "--eth-peer=X,M:M:M:M:M:M | --nb-cores= | --nb-ports= | " "--pkt-filter-mode= |" @@ -107,6 +108,8 @@ usage(char* progname) printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " " RX memory buffers (mbufs)\n"); printf(" --mbuf-size=N set the data size of mbuf to N bytes\n"); + 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(" --pkt-filter-mode=N: set Flow director mode " "( N: none (default mode) or signature or perfect)\n"); @@ -329,6 +332,7 @@ launch_args_parse(int argc, char** argv) { "portmask", 1, 0, 0 }, { "numa", 0, 0, 0 }, { "mbuf-size", 1, 0, 0 }, + { "total-num-mbufs", 1, 0, 0 }, { "max-pkt-len", 1, 0, 0 }, { "pkt-filter-mode", 1, 0, 0 }, { "pkt-filter-report-hash", 1, 0, 0 }, @@ -440,6 +444,14 @@ launch_args_parse(int argc, char** argv) rte_exit(EXIT_FAILURE, "mbuf-size should be > 0 and < 65536\n"); } + if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { + n = atoi(optarg); + if (n > 1024) + param_total_num_mbufs = (unsigned)n; + else + rte_exit(EXIT_FAILURE, + "total-num-mbufs should be > 1024\n"); + } if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { n = atoi(optarg); if (n >= ETHER_MIN_LEN) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 919b395caa..2365a5d193 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -142,6 +142,8 @@ struct fwd_config cur_fwd_config; struct fwd_engine *cur_fwd_eng = &io_fwd_engine; /**< IO mode by default. */ 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. */ /* * Configuration of packet segments used by the "txonly" processing engine. @@ -430,15 +432,22 @@ init_config(void) * If NUMA support is disabled, create a single pool of mbuf in * socket 0 memory. * Otherwise, create a pool of mbuf in the memory of sockets 0 and 1. + * + * Use the maximum value of nb_rxd and nb_txd here, then nb_rxd and + * nb_txd can be configured at run time. */ - nb_mbuf_per_pool = nb_rxd + (nb_lcores * mb_mempool_cache) + - nb_txd + MAX_PKT_BURST; + if (param_total_num_mbufs) + nb_mbuf_per_pool = param_total_num_mbufs; + else { + nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + (nb_lcores * mb_mempool_cache) + + RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST; + nb_mbuf_per_pool = (nb_mbuf_per_pool * nb_ports); + } if (numa_support) { - nb_mbuf_per_pool = nb_mbuf_per_pool * (nb_ports >> 1); + nb_mbuf_per_pool /= 2; mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0); mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 1); } else { - nb_mbuf_per_pool = (nb_mbuf_per_pool * nb_ports); mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0); } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index abb31f5e44..937a1663e4 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -257,6 +257,7 @@ extern uint16_t tx_free_thresh; extern uint16_t tx_rs_thresh; extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ +extern uint32_t param_total_num_mbufs; extern struct rte_fdir_conf fdir_conf; -- 2.20.1