DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test-eventdev: add burst enqueue support in perf_queue test
@ 2021-10-12 21:05 Rashmi Shetty
  2021-10-13 20:16 ` [dpdk-dev] [PATCH v2] app/test-eventdev: add burst enqueue support Rashmi Shetty
  0 siblings, 1 reply; 3+ messages in thread
From: Rashmi Shetty @ 2021-10-12 21:05 UTC (permalink / raw)
  To: dev; +Cc: jerinj, harry.van.haaren, pravin.pathak, Rashmi Shetty

A new command line option prod_enq_burst_sz is introduced to set burst size
for eventdev enqueue at producer in perf_queue test. The newly added function
perf_producer_burst is called when prod_enq_burst_sz is greater than 1.

Signed-off-by: Rashmi Shetty <rashmi.shetty@intel.com>
---
 app/test-eventdev/evt_common.h       |  1 +
 app/test-eventdev/evt_main.c         |  2 +-
 app/test-eventdev/evt_options.c      | 14 +++++
 app/test-eventdev/evt_options.h      |  1 +
 app/test-eventdev/test_perf_common.c | 80 +++++++++++++++++++++++++++-
 app/test-eventdev/test_perf_common.h |  1 +
 6 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index 28afb114b3..f466434459 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -64,6 +64,7 @@ struct evt_options {
 	uint32_t nb_flows;
 	uint32_t tx_first;
 	uint32_t max_pkt_sz;
+	uint32_t prod_enq_burst_sz;
 	uint32_t deq_tmo_nsec;
 	uint32_t q_priority:1;
 	uint32_t fwd_latency:1;
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index a8d304bab3..3534aabca7 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -95,7 +95,7 @@ main(int argc, char **argv)
 	/* Parse the command line arguments */
 	ret = evt_options_parse(&opt, argc, argv);
 	if (ret) {
-		evt_err("parsing on or more user options failed");
+		evt_err("parsing one or more user options failed");
 		goto error;
 	}
 
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index b0bcbc6c96..753a7dbd7d 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -26,6 +26,7 @@ evt_options_default(struct evt_options *opt)
 	opt->nb_flows = 1024;
 	opt->socket_id = SOCKET_ID_ANY;
 	opt->pool_sz = 16 * 1024;
+	opt->prod_enq_burst_sz = 1;
 	opt->wkr_deq_dep = 16;
 	opt->nb_pkts = (1ULL << 26); /* do ~64M packets */
 	opt->nb_timers = 1E8;
@@ -304,6 +305,16 @@ evt_parse_per_port_pool(struct evt_options *opt, const char *arg __rte_unused)
 	return 0;
 }
 
+static int
+evt_parse_prod_enq_burst_sz(struct evt_options *opt, const char *arg)
+{
+	int ret;
+
+	ret = parser_read_uint32(&(opt->prod_enq_burst_sz), arg);
+
+	return ret;
+}
+
 static void
 usage(char *program)
 {
@@ -336,6 +347,7 @@ usage(char *program)
 		"\t--expiry_nsec      : event timer expiry ns.\n"
 		"\t--mbuf_sz          : packet mbuf size.\n"
 		"\t--max_pkt_sz       : max packet size.\n"
+		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
 		"\t--nb_eth_queues    : number of ethernet Rx queues.\n"
 		"\t--enable_vector    : enable event vectorization.\n"
 		"\t--vector_size      : Max vector size.\n"
@@ -412,6 +424,7 @@ static struct option lgopts[] = {
 	{ EVT_EXPIRY_NSEC,         1, 0, 0 },
 	{ EVT_MBUF_SZ,             1, 0, 0 },
 	{ EVT_MAX_PKT_SZ,          1, 0, 0 },
+	{ EVT_PROD_ENQ_BURST_SZ,   1, 0, 0 },
 	{ EVT_NB_ETH_QUEUES,       1, 0, 0 },
 	{ EVT_ENA_VECTOR,          0, 0, 0 },
 	{ EVT_VECTOR_SZ,           1, 0, 0 },
@@ -451,6 +464,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
 		{ EVT_EXPIRY_NSEC, evt_parse_expiry_nsec},
 		{ EVT_MBUF_SZ, evt_parse_mbuf_sz},
 		{ EVT_MAX_PKT_SZ, evt_parse_max_pkt_sz},
+		{ EVT_PROD_ENQ_BURST_SZ, evt_parse_prod_enq_burst_sz},
 		{ EVT_NB_ETH_QUEUES, evt_parse_eth_queues},
 		{ EVT_ENA_VECTOR, evt_parse_ena_vector},
 		{ EVT_VECTOR_SZ, evt_parse_vector_size},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 6436200b40..413d7092f0 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -42,6 +42,7 @@
 #define EVT_EXPIRY_NSEC          ("expiry_nsec")
 #define EVT_MBUF_SZ              ("mbuf_sz")
 #define EVT_MAX_PKT_SZ           ("max_pkt_sz")
+#define EVT_PROD_ENQ_BURST_SZ    ("prod_enq_burst_sz")
 #define EVT_NB_ETH_QUEUES        ("nb_eth_queues")
 #define EVT_ENA_VECTOR           ("enable_vector")
 #define EVT_VECTOR_SZ            ("vector_size")
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index cc100650c2..c1749b9a88 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -77,6 +77,70 @@ perf_producer(void *arg)
 	return 0;
 }
 
+static inline int
+perf_producer_burst(void *arg)
+{
+	uint32_t i;
+	uint64_t timestamp;
+	struct rte_event_dev_info dev_info;
+	struct prod_data *p  = arg;
+	struct test_perf *t = p->t;
+	struct evt_options *opt = t->opt;
+	const uint8_t dev_id = p->dev_id;
+	const uint8_t port = p->port_id;
+	struct rte_mempool *pool = t->pool;
+	const uint64_t nb_pkts = t->nb_pkts;
+	const uint32_t nb_flows = t->nb_flows;
+	uint32_t flow_counter = 0;
+	uint16_t enq = 0;
+	uint64_t count = 0;
+	struct perf_elt *m[MAX_PROD_ENQ_BURST_SIZE + 1] = {NULL};
+	struct rte_event ev[MAX_PROD_ENQ_BURST_SIZE + 1];
+	uint32_t burst_size = opt->prod_enq_burst_sz;
+
+	rte_event_dev_info_get(dev_id, &dev_info);
+	if (dev_info.max_event_port_enqueue_depth < burst_size)
+		burst_size = dev_info.max_event_port_enqueue_depth;
+
+	if (opt->verbose_level > 1)
+		printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__,
+				rte_lcore_id(), dev_id, port, p->queue_id);
+
+	for (i = 0; i < burst_size; i++) {
+		ev[i].op = RTE_EVENT_OP_NEW;
+		ev[i].queue_id = p->queue_id;
+		ev[i].sched_type = t->opt->sched_type_list[0];
+		ev[i].priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+		ev[i].event_type =  RTE_EVENT_TYPE_CPU;
+		ev[i].sub_event_type = 0; /* stage 0 */
+	}
+
+	while (count < nb_pkts && t->done == false) {
+		if (rte_mempool_get_bulk(pool, (void **)m, burst_size) < 0)
+			continue;
+		timestamp = rte_get_timer_cycles();
+		for (i = 0; i < burst_size; i++) {
+			ev[i].flow_id = flow_counter++ % nb_flows;
+			ev[i].event_ptr = m[i];
+			m[i]->timestamp = timestamp;
+		}
+                enq = rte_event_enqueue_burst(dev_id, port, ev, burst_size);
+                while (enq < burst_size) {
+                        enq += rte_event_enqueue_burst(dev_id, port,
+                                                        ev + enq,
+							burst_size - enq);
+                        if (t->done)
+                                break;
+			rte_pause();
+			timestamp = rte_get_timer_cycles();
+			for (i = enq; i < burst_size; i++)
+				m[i]->timestamp = timestamp;
+                }
+		count += burst_size;
+	}
+	return 0;
+}
+
 static inline int
 perf_event_timer_producer(void *arg)
 {
@@ -212,9 +276,20 @@ perf_producer_wrapper(void *arg)
 {
 	struct prod_data *p  = arg;
 	struct test_perf *t = p->t;
-	/* Launch the producer function only in case of synthetic producer. */
-	if (t->opt->prod_type == EVT_PROD_TYPE_SYNT)
+	bool burst = evt_has_burst_mode(p->dev_id);
+
+	/* In case of synthetic producer, launch perf_producer or
+	 * perf_producer_burst depending on producer enqueue burst size. */
+	if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
+			t->opt->prod_enq_burst_sz == 1)
 		return perf_producer(arg);
+	else if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
+			t->opt->prod_enq_burst_sz > 1) {
+		if (!burst)
+			evt_err("This event device does not support burst mode");
+		else
+			return perf_producer_burst(arg);
+	}
 	else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
 			!t->opt->timdev_use_burst)
 		return perf_event_timer_producer(arg);
@@ -635,6 +710,7 @@ perf_opt_dump(struct evt_options *opt, uint8_t nb_queues)
 	evt_dump_queue_priority(opt);
 	evt_dump_sched_type_list(opt);
 	evt_dump_producer_type(opt);
+	evt_dump("prod_enq_burst_sz", "%d", opt->prod_enq_burst_sz);
 }
 
 void
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 9785dc3e23..14dcf80429 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -71,6 +71,7 @@ struct perf_elt {
 } __rte_cache_aligned;
 
 #define BURST_SIZE 16
+#define MAX_PROD_ENQ_BURST_SIZE 128
 
 #define PERF_WORKER_INIT\
 	struct worker_data *w  = arg;\
-- 
2.25.1


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

end of thread, other threads:[~2021-10-14  6:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 21:05 [dpdk-dev] [PATCH] app/test-eventdev: add burst enqueue support in perf_queue test Rashmi Shetty
2021-10-13 20:16 ` [dpdk-dev] [PATCH v2] app/test-eventdev: add burst enqueue support Rashmi Shetty
2021-10-14  6:30   ` Jerin Jacob

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).