From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A295A0C4C; Thu, 19 Aug 2021 14:35:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25FEF4067E; Thu, 19 Aug 2021 14:35:51 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 2F13240141 for ; Thu, 19 Aug 2021 14:35:50 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id t13so5352190pfl.6 for ; Thu, 19 Aug 2021 05:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mnK2K3I/G9/8gnEPwffE+E4ePMfx0Kxk4OxJ2hyh8y8=; b=hQ2TmqXGs6U5GdO1jOGaPaOZtAdxlkwrEQySbPKsDjZYp7cZ+lRgNKjKhRvZjGgknC XPsi3pFft2YZZ5DgkuFj3r0VFVFGWPeM11PIy6speM3cvLIYPDt2eCgojS++juBb6hhH EjRcLxyJ/KH2vP2WcdjIaSj8UVGb6cpsJSCJGbThiE4x7oyA5y8KNL6VVniR3Z4s1OvZ Q6T9kLrshtBDval8QYFyBVeNBqL9A38CobNdLex1nSKjlA4Hob5Ep+qUDaFUhZlhc6nu dU9RExulMaYxRjF5A69o56PjElofh1vwUAzftIOLDFZe91T0zB6mbdOt2+lyo7T2TytK kjmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mnK2K3I/G9/8gnEPwffE+E4ePMfx0Kxk4OxJ2hyh8y8=; b=LouDtfha45649L8pSklTGxm4tnBPvLIRYcDwxFmprXoZ3iZ5GJw1urFQlFcoNpz/xV GJ5Kpd5KkZ/7vflzmD7r+Bns4zs+yFmFGHxerRQ1qLZLSznR6YofxoSyg77y0Sr0DbwE umV5VfyMuj4LvI/CbSITTlO9eloJbx3mkN2thxwh6niXXpgwDKuAa4ndyxO9tQNWqSat HRzIE7b9anj1SQzLNPx7NPukZdAByszKnhC8vu9Vt3UIVXYsJJ4WV8USKktq8JdLI06k s8EkD1F22Stl38MMyuAlheLlWtm9wmX+fBfBbR7TeGr8OC4ZZAHG+Ep0bfZdjKlNAuqg N/1w== X-Gm-Message-State: AOAM533652J65h1TiyOI2eHdso0mMoRrOI1s+9rRE/yrKZnwfrDOAmqh rwyDobheqazgsVZGB24kPT3EyOQqywARpg== X-Google-Smtp-Source: ABdhPJxaXQfQEfp4WZD3ib+cHYkRsVH5seJQrqC+4LNHGfgnCrVy4oJ/U1Uop7H5jdydAMx19BR9Og== X-Received: by 2002:a65:5845:: with SMTP id s5mr11135277pgr.227.1629376547779; Thu, 19 Aug 2021 05:35:47 -0700 (PDT) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id y64sm3891741pgy.32.2021.08.19.05.35.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Aug 2021 05:35:47 -0700 (PDT) From: Zhihong Wang To: dev@dpdk.org, ferruh.yigit@intel.com, xiaoyun.li@intel.com, aman.deep.singh@intel.com, irusskikh@marvell.com, cchemparathy@tilera.com Cc: Zhihong Wang Date: Thu, 19 Aug 2021 20:35:41 +0800 Message-Id: <20210819123541.16308-1-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] app/testpmd: configurable number of flows in flowgen X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Make number of flows in flowgen configurable by setting parameter --flowgen-flows=N. Signed-off-by: Zhihong Wang --- Depends-on: series-18277 ("app/testpmd: flowgen fixes and improvements") app/test-pmd/flowgen.c | 22 ++++++++++++++-------- app/test-pmd/parameters.c | 10 ++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/run_app.rst | 5 +++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 9348618d0f..9910a4dc53 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -40,8 +40,6 @@ #include "testpmd.h" -/* hardcoded configuration (for now) */ -static unsigned cfg_n_flows = 1024; static uint32_t cfg_ip_src = RTE_IPV4(10, 254, 0, 0); static uint32_t cfg_ip_dst = RTE_IPV4(10, 253, 0, 0); static uint16_t cfg_udp_src = 1000; @@ -76,6 +74,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) uint64_t ol_flags = 0; uint16_t nb_rx; uint16_t nb_tx; + uint16_t nb_dropped; uint16_t nb_pkt; uint16_t nb_clones = nb_pkt_flowgen_clones; uint16_t i; @@ -165,7 +164,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) } pkts_burst[nb_pkt] = pkt; - if (++next_flow >= (int)cfg_n_flows) + if (++next_flow >= nb_flows_flowgen) next_flow = 0; } @@ -184,13 +183,14 @@ pkt_burst_flow_gen(struct fwd_stream *fs) fs->tx_packets += nb_tx; inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_pkt)) { + nb_dropped = nb_pkt - nb_tx; + if (unlikely(nb_dropped > 0)) { /* Back out the flow counter. */ - next_flow -= (nb_pkt - nb_tx); + next_flow -= nb_dropped; while (next_flow < 0) - next_flow += cfg_n_flows; + next_flow += nb_flows_flowgen; - fs->fwd_dropped += nb_pkt - nb_tx; + fs->fwd_dropped += nb_dropped; do { rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_pkt); @@ -201,9 +201,15 @@ pkt_burst_flow_gen(struct fwd_stream *fs) get_end_cycles(fs, start_tsc); } +static void +flowgen_begin(portid_t pi) +{ + printf("nb flows from port %u: %d\n", pi, nb_flows_flowgen); +} + struct fwd_engine flow_gen_engine = { .fwd_mode_name = "flowgen", - .port_fwd_begin = NULL, + .port_fwd_begin = flowgen_begin, .port_fwd_end = NULL, .packet_fwd = pkt_burst_flow_gen, }; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 7c13210f04..825275e683 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -143,6 +143,7 @@ usage(char* progname) "N.\n"); printf(" --burst=N: set the number of packets per burst to N.\n"); printf(" --flowgen-clones=N: set the number of single packet clones to send in flowgen mode. Should be less than burst value.\n"); + printf(" --flowgen-flows=N: set the number of flows in flowgen mode to N (1 <= N <= 2147483647).\n"); printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n"); printf(" --rxpt=N: set prefetch threshold register of RX rings to N.\n"); printf(" --rxht=N: set the host threshold register of RX rings to N.\n"); @@ -586,6 +587,7 @@ launch_args_parse(int argc, char** argv) { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "flowgen-clones", 1, 0, 0 }, + { "flowgen-flows", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 }, { "txht", 1, 0, 0 }, @@ -1122,6 +1124,14 @@ launch_args_parse(int argc, char** argv) rte_exit(EXIT_FAILURE, "clones must be >= 0 and <= current burst\n"); } + if (!strcmp(lgopts[opt_idx].name, "flowgen-flows")) { + n = atoi(optarg); + if (n > 0) + nb_flows_flowgen = (int) n; + else + rte_exit(EXIT_FAILURE, + "flows must be >= 1\n"); + } if (!strcmp(lgopts[opt_idx].name, "mbcache")) { n = atoi(optarg); if ((n >= 0) && diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6cbe9ba3c8..9061cbf637 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -246,6 +246,7 @@ uint32_t tx_pkt_times_intra; uint16_t nb_pkt_per_burst = DEF_PKT_BURST; /**< Number of packets per burst. */ uint16_t nb_pkt_flowgen_clones; /**< Number of Tx packet clones to send in flowgen mode. */ +int nb_flows_flowgen = 1024; /**< Number of flows in flowgen mode. */ uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */ /* current configuration is in DCB or not,0 means it is not in DCB mode */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 16a3598e48..635b572ef7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -479,6 +479,7 @@ extern uint8_t txonly_multi_flow; extern uint16_t nb_pkt_per_burst; extern uint16_t nb_pkt_flowgen_clones; +extern int nb_flows_flowgen; extern uint16_t mb_mempool_cache; extern int8_t rx_pthresh; extern int8_t rx_hthresh; diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 6061674239..3e2d048653 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -306,6 +306,11 @@ The command line options are: in testing extreme speeds or maxing out Tx packet performance. N should be not zero, but less than 'burst' parameter. +* ``--flowgen-flows=N`` + + Set the number of flows to be generated in `flowgen` mode, where + 1 <= N <= 2147483647. + * ``--mbcache=N`` Set the cache of mbuf memory pools to N, where 0 <= N <= 512. -- 2.11.0