[dpdk-dev] [PATCH v2 07/15] examples/eventdev: modify work cycles

Pavan Nikhilesh pbhagavatula at caviumnetworks.com
Wed Jan 10 12:10:05 CET 2018


The current work cycles function exchanges source and destination mac
address and also pauses the core for the given cycles.
This patch splits the function into two parts i.e. exchange mac and
pause the cores. The pause cores function is invoked at every stage
where as exchange mac is invoked when packet is transmitted.

Signed-off-by: Pavan Nikhilesh <pbhagavatula at caviumnetworks.com>
---
 examples/eventdev_pipeline_sw_pmd/pipeline_common.h         | 11 +++++------
 examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c |  7 +++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/examples/eventdev_pipeline_sw_pmd/pipeline_common.h b/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
index 9e1f5e9f0..d58059b78 100644
--- a/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
+++ b/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
@@ -99,21 +99,20 @@ struct fastpath_data *fdata;
 struct config_data cdata;
 
 static __rte_always_inline void
-work(struct rte_mbuf *m)
+exchange_mac(struct rte_mbuf *m)
 {
 	struct ether_hdr *eth;
 	struct ether_addr addr;
 
 	/* change mac addresses on packet (to use mbuf data) */
-	/*
-	 * FIXME Swap mac address properly and also handle the
-	 * case for both odd and even number of stages that the
-	 * addresses end up the same at the end of the pipeline
-	 */
 	eth = rte_pktmbuf_mtod(m, struct ether_hdr *);
 	ether_addr_copy(&eth->d_addr, &addr);
 	ether_addr_copy(&addr, &eth->d_addr);
+}
 
+static __rte_always_inline void
+work(void)
+{
 	/* do a number of cycles of work per packet */
 	volatile uint64_t start_tsc = rte_rdtsc();
 	while (rte_rdtsc() < start_tsc + cdata.worker_cycles)
diff --git a/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c b/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c
index f4523902b..90f87709c 100644
--- a/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c
+++ b/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c
@@ -45,7 +45,7 @@ worker_generic(void *arg)
 		ev.op = RTE_EVENT_OP_FORWARD;
 		ev.sched_type = cdata.queue_type;
 
-		work(ev.mbuf);
+		work();
 
 		while (rte_event_enqueue_burst(dev_id, port_id, &ev, 1) != 1)
 			rte_pause();
@@ -101,7 +101,7 @@ worker_generic_burst(void *arg)
 			events[i].op = RTE_EVENT_OP_FORWARD;
 			events[i].sched_type = cdata.queue_type;
 
-			work(events[i].mbuf);
+			work();
 		}
 		uint16_t nb_tx = rte_event_enqueue_burst(dev_id, port_id,
 				events, nb_rx);
@@ -148,6 +148,7 @@ consumer(void)
 		received++;
 		uint8_t outport = packet.mbuf->port;
 
+		exchange_mac(packet.mbuf);
 		rte_eth_tx_buffer(outport, 0, fdata->tx_buf[outport],
 				packet.mbuf);
 
@@ -212,6 +213,8 @@ consumer_burst(void)
 		received += n;
 		for (i = 0; i < n; i++) {
 			uint8_t outport = packets[i].mbuf->port;
+
+			exchange_mac(packets[i].mbuf);
 			rte_eth_tx_buffer(outport, 0, fdata->tx_buf[outport],
 					packets[i].mbuf);
 
-- 
2.15.1



More information about the dev mailing list