[dpdk-dev] [PATCH v2 07/12] app/eventdev: launch pipeline lcores

Pavan Nikhilesh pbhagavatula at caviumnetworks.com
Mon Dec 18 22:44:00 CET 2017


The event master lcore's test termination and the logic to print the mpps
are common for the queue and all types queue test.

Move them as the common function.

Signed-off-by: Pavan Nikhilesh <pbhagavatula at caviumnetworks.com>
---
 app/test-eventdev/test_pipeline_common.c | 64 ++++++++++++++++++++++++++++++++
 app/test-eventdev/test_pipeline_common.h |  2 +
 2 files changed, 66 insertions(+)

diff --git a/app/test-eventdev/test_pipeline_common.c b/app/test-eventdev/test_pipeline_common.c
index df7521453..9a70943b6 100644
--- a/app/test-eventdev/test_pipeline_common.c
+++ b/app/test-eventdev/test_pipeline_common.c
@@ -65,6 +65,70 @@ pipeline_opt_dump(struct evt_options *opt, uint8_t nb_queues)
 	evt_dump_producer_type(opt);
 }
 
+static inline uint64_t
+processed_pkts(struct test_pipeline *t)
+{
+	uint8_t i;
+	uint64_t total = 0;
+
+	rte_smp_rmb();
+	for (i = 0; i < t->nb_workers; i++)
+		total += t->worker[i].processed_pkts;
+
+	return total;
+}
+
+int
+pipeline_launch_lcores(struct evt_test *test, struct evt_options *opt,
+		int (*worker)(void *))
+{
+	int ret, lcore_id;
+	struct test_pipeline *t = evt_test_priv(test);
+
+	int port_idx = 0;
+	/* launch workers */
+	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+		if (!(opt->wlcores[lcore_id]))
+			continue;
+
+		ret = rte_eal_remote_launch(worker,
+				 &t->worker[port_idx], lcore_id);
+		if (ret) {
+			evt_err("failed to launch worker %d", lcore_id);
+			return ret;
+		}
+		port_idx++;
+	}
+
+	uint64_t perf_cycles = rte_get_timer_cycles();
+	const uint64_t perf_sample = rte_get_timer_hz();
+
+	static float total_mpps;
+	static uint64_t samples;
+
+	uint64_t prev_pkts = 0;
+
+	while (t->done == false) {
+		const uint64_t new_cycles = rte_get_timer_cycles();
+
+		if ((new_cycles - perf_cycles) > perf_sample) {
+			const uint64_t curr_pkts = processed_pkts(t);
+
+			float mpps = (float)(curr_pkts - prev_pkts)/1000000;
+
+			prev_pkts = curr_pkts;
+			perf_cycles = new_cycles;
+			total_mpps += mpps;
+			++samples;
+			printf(CLGRN"\r%.3f mpps avg %.3f mpps"CLNRM,
+					mpps, total_mpps/samples);
+			fflush(stdout);
+		}
+	}
+	printf("\n");
+	return 0;
+}
+
 int
 pipeline_opt_check(struct evt_options *opt, uint64_t nb_queues)
 {
diff --git a/app/test-eventdev/test_pipeline_common.h b/app/test-eventdev/test_pipeline_common.h
index 412c6095e..26d265a3d 100644
--- a/app/test-eventdev/test_pipeline_common.h
+++ b/app/test-eventdev/test_pipeline_common.h
@@ -87,6 +87,8 @@ int pipeline_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride,
 int pipeline_mempool_setup(struct evt_test *test, struct evt_options *opt);
 int pipeline_event_port_setup(struct evt_test *test, struct evt_options *opt,
 		uint16_t nb_queues, const struct rte_event_port_conf p_conf);
+int pipeline_launch_lcores(struct evt_test *test, struct evt_options *opt,
+		int (*worker)(void *));
 void pipeline_opt_dump(struct evt_options *opt, uint8_t nb_queues);
 void pipeline_test_destroy(struct evt_test *test, struct evt_options *opt);
 void pipeline_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
-- 
2.14.1



More information about the dev mailing list