From patchwork Thu Jun 6 18:29:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Varghese, Vipin" X-Patchwork-Id: 54519 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AD6BB1B99D; Thu, 6 Jun 2019 20:29:34 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C3E011B99C for ; Thu, 6 Jun 2019 20:29:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 11:29:32 -0700 X-ExtLoop1: 1 Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by orsmga005.jf.intel.com with ESMTP; 06 Jun 2019 11:29:29 -0700 From: Vipin Varghese 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 Date: Thu, 6 Jun 2019 23:59:57 +0530 Message-Id: <20190606182957.56596-3-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190606182957.56596-1-vipin.varghese@intel.com> References: <20190606182957.56596-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v1 2/2] examples/event: add callback handle X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" To add register and unregister for event pre-enqueue and post-dequeue callback handler. Signed-off-by: Vipin Varghese --- 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) !=