From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 130514CA6 for ; Tue, 19 Mar 2019 08:17:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 00:17:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,496,1544515200"; d="scan'208";a="329890026" Received: from yexl-server.sh.intel.com ([10.67.110.206]) by fmsmga005.fm.intel.com with ESMTP; 19 Mar 2019 00:17:04 -0700 From: Xiaolong Ye To: dev@dpdk.org Cc: Qi Zhang , Karlsson Magnus , Topel Bjorn , Xiaolong Ye Date: Tue, 19 Mar 2019 15:12:56 +0800 Message-Id: <20190319071256.26302-7-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190319071256.26302-1-xiaolong.ye@intel.com> References: <20190301080947.91086-1-xiaolong.ye@intel.com> <20190319071256.26302-1-xiaolong.ye@intel.com> Subject: [dpdk-dev] [PATCH v2 6/6] app/testpmd: add mempool flags parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2019 07:17:06 -0000 When create rte_mempool, flags can be parsed from command line. Now, it is possible for testpmd to create a af_xdp friendly mempool (which enable zero copy). Signed-off-by: Qi Zhang Signed-off-by: Xiaolong Ye --- app/test-pmd/parameters.c | 12 ++++++++++++ app/test-pmd/testpmd.c | 17 ++++++++++------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 38b419767..9d5be0007 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -61,6 +61,7 @@ usage(char* progname) "--tx-first | --stats-period=PERIOD | " "--coremask=COREMASK --portmask=PORTMASK --numa " "--mbuf-size= | --total-num-mbufs= | " + "--mp-flags= | " "--nb-cores= | --nb-ports= | " #ifdef RTE_LIBRTE_CMDLINE "--eth-peers-configfile= | " @@ -105,6 +106,7 @@ usage(char* progname) printf(" --socket-num=N: set socket from which all memory is allocated " "in NUMA mode.\n"); printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n"); + printf(" --mp-flags=N: set the flags when create mbuf memory pool.\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"); @@ -585,6 +587,7 @@ launch_args_parse(int argc, char** argv) { "ring-numa-config", 1, 0, 0 }, { "socket-num", 1, 0, 0 }, { "mbuf-size", 1, 0, 0 }, + { "mp-flags", 1, 0, 0 }, { "total-num-mbufs", 1, 0, 0 }, { "max-pkt-len", 1, 0, 0 }, { "pkt-filter-mode", 1, 0, 0 }, @@ -811,6 +814,15 @@ 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, "mp-flags")) { + n = atoi(optarg); + if (n > 0 && n <= 0xFFFF) + mp_flags = (uint16_t)n; + else + rte_exit(EXIT_FAILURE, + "mp-flags should be > 0 and < 65536\n"); + } + if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { n = atoi(optarg); if (n > 1024) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d9d0c16d4..eb46dfa53 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -195,6 +195,7 @@ uint32_t burst_tx_delay_time = BURST_TX_WAIT_US; uint32_t burst_tx_retry_num = BURST_TX_RETRIES; uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */ +uint16_t mp_flags = 0; /**< flags parsed when create mempool */ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period; /**< Period to show statistics (disabled by default) */ @@ -834,6 +835,7 @@ setup_extmem(uint32_t nb_mbufs, uint32_t mbuf_sz, bool huge) */ static void mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, + unsigned int flags, unsigned int socket_id) { char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -853,8 +855,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, /* wrapper to rte_mempool_create() */ TESTPMD_LOG(INFO, "preferred mempool ops selected: %s\n", rte_mbuf_best_mempool_ops()); - rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf, - mb_mempool_cache, 0, mbuf_seg_size, socket_id); + rte_mp = rte_pktmbuf_pool_create_with_flags(pool_name, nb_mbuf, + mb_mempool_cache, 0, mbuf_seg_size, flags, socket_id); break; } case MP_ALLOC_ANON: @@ -891,8 +893,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, TESTPMD_LOG(INFO, "preferred mempool ops selected: %s\n", rte_mbuf_best_mempool_ops()); - rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf, - mb_mempool_cache, 0, mbuf_seg_size, + rte_mp = rte_pktmbuf_pool_create_with_flags(pool_name, nb_mbuf, + mb_mempool_cache, 0, mbuf_seg_size, flags, heap_socket); break; } @@ -1128,13 +1130,14 @@ init_config(void) for (i = 0; i < num_sockets; i++) mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, - socket_ids[i]); + mp_flags, socket_ids[i]); } else { if (socket_num == UMA_NO_CONFIG) - mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0); + mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, + mp_flags, 0); else mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, - socket_num); + mp_flags, socket_num); } init_port_config(); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index fa4887853..3ddb70e3e 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -408,6 +408,7 @@ extern uint8_t dcb_config; extern uint8_t dcb_test; extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ +extern uint16_t mp_flags; /**< flags for mempool creation. */ extern uint32_t param_total_num_mbufs; extern uint16_t stats_period; diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 4495ed038..bafb9c493 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -392,6 +392,10 @@ The commandline options are: * xmemhuge: create and populate mempool using externally and anonymously allocated hugepage area +* ``--mp-flag=`` + + Select mempool allocation flag. + * ``--noisy-tx-sw-buffer-size`` Set the number of maximum elements of the FIFO queue to be created -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 25F87A05FE for ; Tue, 19 Mar 2019 08:17:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77D7D4F90; Tue, 19 Mar 2019 08:17:16 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 130514CA6 for ; Tue, 19 Mar 2019 08:17:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 00:17:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,496,1544515200"; d="scan'208";a="329890026" Received: from yexl-server.sh.intel.com ([10.67.110.206]) by fmsmga005.fm.intel.com with ESMTP; 19 Mar 2019 00:17:04 -0700 From: Xiaolong Ye To: dev@dpdk.org Cc: Qi Zhang , Karlsson Magnus , Topel Bjorn , Xiaolong Ye Date: Tue, 19 Mar 2019 15:12:56 +0800 Message-Id: <20190319071256.26302-7-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190319071256.26302-1-xiaolong.ye@intel.com> References: <20190301080947.91086-1-xiaolong.ye@intel.com> <20190319071256.26302-1-xiaolong.ye@intel.com> Subject: [dpdk-dev] [PATCH v2 6/6] app/testpmd: add mempool flags parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190319071256.jXWObASRx8z3Aealye2-d2GV7_26lUKPPYzTaBdtYfw@z> When create rte_mempool, flags can be parsed from command line. Now, it is possible for testpmd to create a af_xdp friendly mempool (which enable zero copy). Signed-off-by: Qi Zhang Signed-off-by: Xiaolong Ye --- app/test-pmd/parameters.c | 12 ++++++++++++ app/test-pmd/testpmd.c | 17 ++++++++++------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 38b419767..9d5be0007 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -61,6 +61,7 @@ usage(char* progname) "--tx-first | --stats-period=PERIOD | " "--coremask=COREMASK --portmask=PORTMASK --numa " "--mbuf-size= | --total-num-mbufs= | " + "--mp-flags= | " "--nb-cores= | --nb-ports= | " #ifdef RTE_LIBRTE_CMDLINE "--eth-peers-configfile= | " @@ -105,6 +106,7 @@ usage(char* progname) printf(" --socket-num=N: set socket from which all memory is allocated " "in NUMA mode.\n"); printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n"); + printf(" --mp-flags=N: set the flags when create mbuf memory pool.\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"); @@ -585,6 +587,7 @@ launch_args_parse(int argc, char** argv) { "ring-numa-config", 1, 0, 0 }, { "socket-num", 1, 0, 0 }, { "mbuf-size", 1, 0, 0 }, + { "mp-flags", 1, 0, 0 }, { "total-num-mbufs", 1, 0, 0 }, { "max-pkt-len", 1, 0, 0 }, { "pkt-filter-mode", 1, 0, 0 }, @@ -811,6 +814,15 @@ 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, "mp-flags")) { + n = atoi(optarg); + if (n > 0 && n <= 0xFFFF) + mp_flags = (uint16_t)n; + else + rte_exit(EXIT_FAILURE, + "mp-flags should be > 0 and < 65536\n"); + } + if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { n = atoi(optarg); if (n > 1024) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d9d0c16d4..eb46dfa53 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -195,6 +195,7 @@ uint32_t burst_tx_delay_time = BURST_TX_WAIT_US; uint32_t burst_tx_retry_num = BURST_TX_RETRIES; uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */ +uint16_t mp_flags = 0; /**< flags parsed when create mempool */ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period; /**< Period to show statistics (disabled by default) */ @@ -834,6 +835,7 @@ setup_extmem(uint32_t nb_mbufs, uint32_t mbuf_sz, bool huge) */ static void mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, + unsigned int flags, unsigned int socket_id) { char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -853,8 +855,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, /* wrapper to rte_mempool_create() */ TESTPMD_LOG(INFO, "preferred mempool ops selected: %s\n", rte_mbuf_best_mempool_ops()); - rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf, - mb_mempool_cache, 0, mbuf_seg_size, socket_id); + rte_mp = rte_pktmbuf_pool_create_with_flags(pool_name, nb_mbuf, + mb_mempool_cache, 0, mbuf_seg_size, flags, socket_id); break; } case MP_ALLOC_ANON: @@ -891,8 +893,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, TESTPMD_LOG(INFO, "preferred mempool ops selected: %s\n", rte_mbuf_best_mempool_ops()); - rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf, - mb_mempool_cache, 0, mbuf_seg_size, + rte_mp = rte_pktmbuf_pool_create_with_flags(pool_name, nb_mbuf, + mb_mempool_cache, 0, mbuf_seg_size, flags, heap_socket); break; } @@ -1128,13 +1130,14 @@ init_config(void) for (i = 0; i < num_sockets; i++) mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, - socket_ids[i]); + mp_flags, socket_ids[i]); } else { if (socket_num == UMA_NO_CONFIG) - mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0); + mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, + mp_flags, 0); else mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, - socket_num); + mp_flags, socket_num); } init_port_config(); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index fa4887853..3ddb70e3e 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -408,6 +408,7 @@ extern uint8_t dcb_config; extern uint8_t dcb_test; extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ +extern uint16_t mp_flags; /**< flags for mempool creation. */ extern uint32_t param_total_num_mbufs; extern uint16_t stats_period; diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 4495ed038..bafb9c493 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -392,6 +392,10 @@ The commandline options are: * xmemhuge: create and populate mempool using externally and anonymously allocated hugepage area +* ``--mp-flag=`` + + Select mempool allocation flag. + * ``--noisy-tx-sw-buffer-size`` Set the number of maximum elements of the FIFO queue to be created -- 2.17.1