DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vipin Varghese <vipin.varghese@intel.com>
To: marko.kovacevic@intel.com, john.mcnamara@intel.com,
	jerinj@marvell.com, harry.van.haaren@intel.com,
	keith.wiles@intel.com, gage.eads@intel.com, dev@dpdk.org
Cc: sanjay.padubidri@intel.com, narender.vangati@intel.com,
	ilia.kurakin@intel.com, Vipin Varghese <vipin.varghese@intel.com>
Subject: [dpdk-dev] [PATCH v1 2/2] examples/event: add callback handle
Date: Thu,  6 Jun 2019 23:59:57 +0530	[thread overview]
Message-ID: <20190606182957.56596-3-vipin.varghese@intel.com> (raw)
In-Reply-To: <20190606182957.56596-1-vipin.varghese@intel.com>

To add register and unregister for event pre-enqueue and
post-dequeue callback handler.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
 examples/eventdev_pipeline/main.c | 49 +++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index f4e57f541..469951463 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -20,6 +20,37 @@ struct config_data cdata = {
 	.worker_cq_depth = 16
 };
 
+#ifdef RTE_EVENTDEV_ENQDEQ_CALLBACKS
+uint16_t
+dump_flowid_events(uint8_t dev_id, uint8_t port_id,
+		__rte_unused struct rte_event *ev,
+		__rte_unused uint16_t nb_events,
+		__rte_unused void *cb_arg);
+
+uint16_t
+dump_flowid_events(uint8_t dev_id, uint8_t port_id,
+		__rte_unused struct rte_event *ev,
+		__rte_unused uint16_t nb_events,
+		__rte_unused void *cb_arg)
+{
+	if (unlikely(nb_events == 0))
+		return 0;
+
+	for (int i = 0; i < nb_events; i++)
+		printf(" dev_id (%u) port_id (%u)\n "
+				"- ev(%p) nb_events (%u)\n"
+				"- flow_id (%u)\n"
+				"- sub_event_type (%u) event_type (%u)\n",
+				dev_id, port_id,
+				ev, nb_events,
+				ev[i].flow_id,
+				ev[i].sub_event_type,
+				ev[i].event_type);
+
+	return nb_events;
+}
+#endif
+
 static bool
 core_in_use(unsigned int lcore_id) {
 	return (fdata->rx_core[lcore_id] || fdata->sched_core[lcore_id] ||
@@ -398,6 +429,14 @@ signal_handler(int signum)
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		printf("\n\nSignal %d received, preparing to exit...\n",
 				signum);
+
+#ifdef RTE_EVENTDEV_ENQDEQ_CALLBACKS
+		rte_eventdev_preenq_callback_unregister(0, 0,
+				dump_flowid_events, NULL);
+		rte_eventdev_pstdeq_callback_unregister(0, 0,
+				dump_flowid_events, NULL);
+#endif
+
 		if (cdata.dump_dev)
 			rte_event_dev_dump(0, stdout);
 		once = 1;
@@ -559,6 +598,16 @@ main(int argc, char **argv)
 	if (core_in_use(lcore_id))
 		fdata->cap.worker(&worker_data[worker_idx++]);
 
+#ifdef RTE_EVENTDEV_ENQDEQ_CALLBACKS
+	if (rte_eventdev_preenq_callback_register(0, 0,
+			dump_flowid_events, NULL))
+		printf(" Failed to register enq callback\n");
+
+	if (rte_eventdev_pstdeq_callback_register(0, 0,
+			dump_flowid_events, NULL))
+		printf(" Failed to register deq callback\n");
+#endif
+
 	rte_eal_mp_wait_lcore();
 
 	if (!cdata.quiet && (port_stat(dev_id, worker_data[0].port_id) !=
-- 
2.17.1


      parent reply	other threads:[~2019-06-06 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 18:29 [dpdk-dev] [PATCH v1 0/2] event enqueue-dequeue callback handler Vipin Varghese
2019-06-06 18:29 ` [dpdk-dev] [PATCH v1 1/2] lib/event: add callback handlers for event Vipin Varghese
2019-06-06 18:29 ` Vipin Varghese [this message]

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=20190606182957.56596-3-vipin.varghese@intel.com \
    --to=vipin.varghese@intel.com \
    --cc=dev@dpdk.org \
    --cc=gage.eads@intel.com \
    --cc=harry.van.haaren@intel.com \
    --cc=ilia.kurakin@intel.com \
    --cc=jerinj@marvell.com \
    --cc=john.mcnamara@intel.com \
    --cc=keith.wiles@intel.com \
    --cc=marko.kovacevic@intel.com \
    --cc=narender.vangati@intel.com \
    --cc=sanjay.padubidri@intel.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).