DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: configurable number of flows in flowgen
@ 2021-08-19 12:35 Zhihong Wang
  2021-08-23 11:08 ` Li, Xiaoyun
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihong Wang @ 2021-08-19 12:35 UTC (permalink / raw)
  To: dev, ferruh.yigit, xiaoyun.li, aman.deep.singh, irusskikh, cchemparathy
  Cc: Zhihong Wang

Make number of flows in flowgen configurable by setting parameter
--flowgen-flows=N.

Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
---
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-31 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 12:35 [dpdk-dev] [PATCH] app/testpmd: configurable number of flows in flowgen Zhihong Wang
2021-08-23 11:08 ` Li, Xiaoyun
2021-08-31 15:14   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).