DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Jerin Jacob <jerinj@marvell.com>,
	Nikhil Rao <nikhil.rao@intel.com>,
	"Erik Gabriel Carrillo" <erik.g.carrillo@intel.com>,
	Abhinandan Gujjar <abhinandan.gujjar@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: "Anoob Joseph" <anoobj@marvell.com>,
	"Narayana Prasad" <pathreya@marvell.com>,
	dev@dpdk.org, "Lukasz Bartosik" <lbartosik@marvell.com>,
	"Pavan Nikhilesh" <pbhagavatula@marvell.com>,
	"Hemant Agrawal" <hemant.agrawal@nxp.com>,
	"Nipun Gupta" <nipun.gupta@nxp.com>,
	"Harry van Haaren" <harry.van.haaren@intel.com>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
	"Liang Ma" <liang.j.ma@intel.com>
Subject: [dpdk-dev] [PATCH 39/39] examples/l2fwd-event: add eventmode worker
Date: Mon, 3 Jun 2019 23:02:39 +0530	[thread overview]
Message-ID: <1559583160-13944-40-git-send-email-anoobj@marvell.com> (raw)
In-Reply-To: <1559583160-13944-1-git-send-email-anoobj@marvell.com>

Adding burst Tx internal port eventmode worker.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Lukasz Bartosik <lbartosik@marvell.com>
---
 examples/l2fwd-event/l2fwd_worker.c | 200 +++++++++++++++++++++++++++++++++++-
 1 file changed, 199 insertions(+), 1 deletion(-)

diff --git a/examples/l2fwd-event/l2fwd_worker.c b/examples/l2fwd-event/l2fwd_worker.c
index 251c546..1e38210 100644
--- a/examples/l2fwd-event/l2fwd_worker.c
+++ b/examples/l2fwd-event/l2fwd_worker.c
@@ -315,7 +315,7 @@ l2fwd_poll_mode_worker(void)
  */
 
 /* Workers registered */
-#define L2FWD_EVENTMODE_WORKERS		3
+#define L2FWD_EVENTMODE_WORKERS		4
 
 /*
  * Event mode worker
@@ -847,6 +847,195 @@ l2fwd_eventmode_burst_no_internal_port(void *args)
 		rte_free(links);
 }
 
+/*
+ * Event mode worker
+ * Operating mode : burst tx internal port
+ */
+static void
+l2fwd_eventmode_burst_tx_internal_port(void *args)
+{
+	struct rte_event ev[MAX_PKT_BURST];
+	struct rte_mbuf *pkt;
+	struct rte_eventmode_helper_conf *mode_conf;
+	struct rte_eventmode_helper_event_link_info *links = NULL;
+	unsigned int lcore_nb_link = 0;
+	uint32_t lcore_id;
+	unsigned int i, j, left, nb_rx = 0;
+	unsigned int portid;
+	struct lcore_queue_conf *qconf;
+	int is_master_core;
+	struct rte_event_port_conf event_port_conf;
+	uint16_t deq_len = 0, enq_len = 0;
+	struct tsc_tracker tsc = {0};
+
+	/* Get core ID */
+	lcore_id = rte_lcore_id();
+
+	RTE_LOG(INFO, L2FWD,
+		"Launching event mode burst worker internal port "
+		"lcore %d\n", lcore_id);
+
+	/* Set the flag if master core */
+	is_master_core = (lcore_id == rte_get_master_lcore()) ? 1 : 0;
+
+	/* Get qconf for this core */
+	qconf = &lcore_queue_conf[lcore_id];
+
+	/* Set drain tsc */
+	tsc.drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
+			US_PER_S * BURST_TX_DRAIN_US;
+
+	/* Mode conf will be passed as args */
+	mode_conf = (struct rte_eventmode_helper_conf *)args;
+
+	/* Get the links configured for this lcore */
+	lcore_nb_link = rte_eventmode_helper_get_event_lcore_links(lcore_id,
+			mode_conf, &links);
+
+	/* Check if we have links registered for this lcore */
+	if (lcore_nb_link == 0) {
+		/* No links registered. The core could do periodic drains */
+		l2fwd_drain_loop(qconf, &tsc, is_master_core);
+		goto clean_and_exit;
+	}
+
+	/* We have valid links */
+
+	/* Reset stats before proceeding */
+	reset_eth_stats(is_master_core);
+
+	/* Get the burst size of the event device */
+
+	/* Get the default conf of the first link */
+	rte_event_port_default_conf_get(links[0].eventdev_id,
+			links[0].event_portid,
+			&event_port_conf);
+
+	/* Save the burst size */
+	deq_len = event_port_conf.dequeue_depth;
+	enq_len = event_port_conf.enqueue_depth;
+
+	/* Dequeue and enqueue length should not exceed MAX_PKT_BURST */
+	if (deq_len > MAX_PKT_BURST)
+		deq_len = MAX_PKT_BURST;
+	if (enq_len > MAX_PKT_BURST)
+		enq_len = MAX_PKT_BURST;
+
+	/* See if it's single link */
+	if (lcore_nb_link == 1)
+		goto single_link_loop;
+	else
+		goto multi_link_loop;
+
+single_link_loop:
+
+	RTE_LOG(INFO, L2FWD, " -- lcoreid=%u event_port_id=%u\n", lcore_id,
+		links[0].event_portid);
+
+	while (!force_quit) {
+
+		/* Do periodic operations (buffer drain & stats monitor) */
+		l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core);
+
+		/* Read packet from event queues */
+		nb_rx = rte_event_dequeue_burst(links[0].eventdev_id,
+				links[0].event_portid,
+				ev,             /* events */
+				deq_len,        /* nb_events */
+				0               /* timeout_ticks */);
+
+		if (nb_rx == 0)
+			continue;
+
+		for (j = 0; j < nb_rx; j++) {
+
+			portid = ev[j].queue_id;
+			port_statistics[portid].rx++;
+			pkt = ev[j].mbuf;
+
+			rte_prefetch0(rte_pktmbuf_mtod(pkt, void *));
+
+			/* Process packet */
+			l2fwd_event_pre_forward(&(ev[j]), portid);
+		}
+
+		/*
+		 * Since tx internal port is available, events can be
+		 * directly enqueued to the adapter and it would be
+		 * internally submitted to the eth device.
+		 */
+		for (j = 0, left = nb_rx;
+			j < (nb_rx + enq_len - 1)/enq_len; j++) {
+
+			left -= rte_event_eth_tx_adapter_enqueue(
+					links[0].eventdev_id,
+					links[0].event_portid,
+					&ev[j*enq_len],	/* events */
+					left > enq_len ?
+					enq_len : left /* nb_events */);
+		}
+	}
+	goto clean_and_exit;
+
+multi_link_loop:
+
+	for (i = 0; i < lcore_nb_link; i++) {
+		RTE_LOG(INFO, L2FWD, " -- lcoreid=%u event_port_id=%u\n",
+			lcore_id, links[i].event_portid);
+	}
+
+	while (!force_quit) {
+
+		/* Do periodic operations (buffer drain & stats monitor) */
+		l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core);
+
+		for (i = 0; i < lcore_nb_link; i++) {
+			/* Read packet from event queues */
+			nb_rx = rte_event_dequeue_burst(links[i].eventdev_id,
+					links[i].event_portid,
+					ev,             /* events */
+					deq_len,        /* nb_events */
+					0               /* timeout_ticks */);
+
+			if (nb_rx == 0)
+				continue;
+
+			for (j = 0; j < nb_rx; j++) {
+
+				portid = ev[j].queue_id;
+				port_statistics[portid].rx++;
+				pkt = ev[j].mbuf;
+
+				rte_prefetch0(rte_pktmbuf_mtod(pkt, void *));
+
+				/* Process packet */
+				l2fwd_event_pre_forward(&(ev[j]), portid);
+			}
+
+			/*
+			 * Since tx internal port is available, events can be
+			 * directly enqueued to the adapter and it would be
+			 * internally submitted to the eth device.
+			 */
+			for (j = 0, left = nb_rx;
+				j < (nb_rx + enq_len - 1)/enq_len; j++) {
+
+				left -= rte_event_eth_tx_adapter_enqueue(
+					links[i].eventdev_id,
+					links[i].event_portid,
+					&ev[j*enq_len],	/* events */
+					left > enq_len ?
+					enq_len : left /* nb_events */);
+			}
+		}
+	}
+	goto clean_and_exit;
+
+clean_and_exit:
+	if (links != NULL)
+		rte_free(links);
+}
+
 static uint8_t
 l2fwd_eventmode_populate_wrkr_params(
 		struct rte_eventmode_helper_app_worker_params *wrkrs)
@@ -882,6 +1071,15 @@ l2fwd_eventmode_populate_wrkr_params(
 	wrkr->worker_thread = l2fwd_eventmode_burst_no_internal_port;
 
 	nb_wrkr_param++;
+	wrkr++;
+
+	/* Burst tx internal port */
+	wrkr->cap.burst = RTE_EVENTMODE_HELPER_RX_TYPE_BURST;
+	wrkr->cap.tx_internal_port =
+			RTE_EVENTMODE_HELPER_TX_TYPE_INTERNAL_PORT;
+	wrkr->worker_thread = l2fwd_eventmode_burst_tx_internal_port;
+
+	nb_wrkr_param++;
 	return nb_wrkr_param;
 }
 
-- 
2.7.4


  parent reply	other threads:[~2019-06-03 17:41 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 17:32 [dpdk-dev] [PATCH 00/39] adding eventmode helper library Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 01/39] examples/l2fwd-event: create copy of l2fwd Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 02/39] examples/l2fwd-event: move macros to common header Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 03/39] examples/l2fwd-event: move structures " Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 04/39] examples/l2fwd-event: move global vars " Anoob Joseph
2019-06-07 10:02   ` Jerin Jacob Kollanukkaran
2019-06-07 10:45     ` Anoob Joseph
2019-06-07 12:47       ` Jerin Jacob Kollanukkaran
2019-06-03 17:32 ` [dpdk-dev] [PATCH 05/39] examples/l2fwd-event: move dataplane code to new file Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 06/39] examples/l2fwd-event: remove unused header includes Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 07/39] examples/l2fwd-event: move drain buffers to new function Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 08/39] examples/l2fwd-event: optimize check for master core Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 09/39] examples/l2fwd-event: move periodic tasks to new func Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 10/39] examples/l2fwd-event: do timer updates only on master Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 11/39] examples/l2fwd-event: move pkt send code to a new func Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 12/39] examples/l2fwd-event: use fprintf in usage print Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 13/39] examples/l2fwd-event: improvements to the " Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 14/39] eventdev: add files for eventmode helper Anoob Joseph
2019-06-10 10:10   ` Jerin Jacob Kollanukkaran
2019-06-03 17:32 ` [dpdk-dev] [PATCH 15/39] eventdev: add routines for logging " Anoob Joseph
2019-06-10 10:12   ` Jerin Jacob Kollanukkaran
2019-06-17  9:09     ` Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 16/39] eventdev: add eventmode CL options framework Anoob Joseph
2019-06-10 10:19   ` Jerin Jacob Kollanukkaran
2019-06-17 10:14     ` Anoob Joseph
2019-06-11  8:58   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2019-06-03 17:32 ` [dpdk-dev] [PATCH 17/39] eventdev: allow application to set ethernet portmask Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 18/39] eventdev: add framework for eventmode conf Anoob Joseph
2019-06-10 10:06   ` Jerin Jacob Kollanukkaran
2019-06-20  7:26     ` Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 19/39] eventdev: add common initialize routine for eventmode devs Anoob Joseph
2019-06-10 10:23   ` Jerin Jacob Kollanukkaran
2019-06-17 10:22     ` Anoob Joseph
2019-06-11  8:58   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2019-06-03 17:32 ` [dpdk-dev] [PATCH 20/39] eventdev: add eventdevice init for eventmode Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 21/39] eventdev: add eventdev port-lcore link Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 22/39] eventdev: add option to specify schedule mode for app stage Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 23/39] eventdev: add placeholder for ethdev init Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 24/39] eventdev: add Rx adapter init in eventmode Anoob Joseph
2019-06-10 14:56   ` Carrillo, Erik G
2019-06-11  3:45     ` [dpdk-dev] [EXT] " Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 25/39] eventdev: add routine to validate conf Anoob Joseph
2019-06-10 10:25   ` Jerin Jacob Kollanukkaran
2019-06-17 10:23     ` Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 26/39] eventdev: add default conf for event devs field in conf Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 27/39] eventdev: add default conf for Rx adapter conf Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 28/39] eventdev: add default conf for event port-lcore link Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 29/39] eventdev: add routines to display the eventmode conf Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 30/39] eventdev: add routine to access eventmode link info Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 31/39] eventdev: add routine to access event queue for eth Tx Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 32/39] eventdev: add routine to launch eventmode workers Anoob Joseph
2019-06-10 14:31   ` Carrillo, Erik G
2019-06-17 10:34     ` [dpdk-dev] [EXT] " Anoob Joseph
2019-06-10 14:46   ` [dpdk-dev] " Carrillo, Erik G
2019-06-27  5:50     ` Anoob Joseph
2019-06-11  8:58   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2019-06-03 17:32 ` [dpdk-dev] [PATCH 33/39] eventdev: add Tx adapter support Anoob Joseph
2019-06-11  8:58   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2019-06-03 17:32 ` [dpdk-dev] [PATCH 34/39] eventdev: add support for internal ports Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 35/39] eventdev: display Tx adapter conf Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 36/39] examples/l2fwd-event: add eventmode for l2fwd Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 37/39] examples/l2fwd-event: add eventmode worker Anoob Joseph
2019-06-03 17:32 ` [dpdk-dev] [PATCH 38/39] " Anoob Joseph
2019-06-03 17:32 ` Anoob Joseph [this message]
2019-06-07  9:48 ` [dpdk-dev] [PATCH 00/39] adding eventmode helper library Jerin Jacob Kollanukkaran
2019-06-11 10:44   ` Mattias Rönnblom
2019-06-14  9:18     ` [dpdk-dev] [EXT] " Anoob Joseph
2019-06-17 13:23       ` Mattias Rönnblom
2019-06-20  3:44         ` Anoob Joseph
     [not found] <1559580584-5728-1-git-send-email-anoobj@marvell.com>
2019-06-03 16:49 ` [dpdk-dev] [PATCH 39/39] examples/l2fwd-event: add eventmode worker Anoob Joseph

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1559583160-13944-40-git-send-email-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=abhinandan.gujjar@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=erik.g.carrillo@intel.com \
    --cc=harry.van.haaren@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=lbartosik@marvell.com \
    --cc=liang.j.ma@intel.com \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=nikhil.rao@intel.com \
    --cc=nipun.gupta@nxp.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=pathreya@marvell.com \
    --cc=pbhagavatula@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).