From patchwork Thu Jun 6 18:33:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Varghese, Vipin" X-Patchwork-Id: 54522 X-Patchwork-Delegate: thomas@monjalon.net 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 CB1201B9AC; Thu, 6 Jun 2019 20:33:25 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 669A51B9A7 for ; Thu, 6 Jun 2019 20:33:24 +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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 11:33:24 -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:33:21 -0700 From: Vipin Varghese To: olivier.matz@6wind.com, reshma.pattan@intel.com, keith.wiles@intel.com, dev@dpdk.org Cc: sanjay.padubidri@intel.com, Vipin Varghese Date: Fri, 7 Jun 2019 00:03:55 +0530 Message-Id: <20190606183355.56734-2-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190606183355.56734-1-vipin.varghese@intel.com> References: <20190606183355.56734-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v1 2/2] examples/packet_ordering: add ring callback 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" update example with ring register-unregister for enqueue-dequeue callabck. Signed-off-by: Vipin Varghese --- examples/packet_ordering/Makefile | 1 + examples/packet_ordering/main.c | 40 ++++++++++++++++++++++++++++ examples/packet_ordering/meson.build | 1 + 3 files changed, 42 insertions(+) diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile index 2c3187a41..3322b4024 100644 --- a/examples/packet_ordering/Makefile +++ b/examples/packet_ordering/Makefile @@ -50,6 +50,7 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API include $(RTE_SDK)/mk/rte.extapp.mk endif diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index ca312029e..98d4a7a77 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -71,6 +71,28 @@ volatile struct app_stats { } tx __rte_cache_aligned; } app_stats; +#ifdef RTE_RING_ENQDEQ_CALLBACKS +unsigned int dump_ring(__rte_unused struct rte_ring *r, + __rte_unused void *obj_table, + __rte_unused unsigned int n, + __rte_unused void *cb_arg); + +unsigned int dump_ring(__rte_unused struct rte_ring *r, + __rte_unused void *obj_table, + __rte_unused unsigned int n, + __rte_unused void *cb_arg) +{ + +#if 0 + if (likely(n)) + printf(" ring (%p) obj (%p) n (%u)\n", + r, obj_table, n); +#endif + + return n; +} +#endif + /** * Get the last enabled lcore ID * @@ -699,6 +721,15 @@ main(int argc, char **argv) worker_args.ring_in = rx_to_workers; worker_args.ring_out = workers_to_tx; +#ifdef RTE_RING_ENQDEQ_CALLBACKS + if (rte_ring_preenq_callback_register(rte_ring_lookup("rx_to_workers"), + dump_ring, NULL)) + printf("failed preenq_callback_register - rx_to_workers\n"); + if (rte_ring_pstdeq_callback_register(rte_ring_lookup("workers_to_tx"), + dump_ring, NULL)) + printf("failed pstdeq_callback_register - rx_to_workers\n"); +#endif + /* Start worker_thread() on all the available slave cores but the last 1 */ for (lcore_id = 0; lcore_id <= get_previous_lcore_id(last_lcore_id); lcore_id++) if (rte_lcore_is_enabled(lcore_id) && lcore_id != master_lcore_id) @@ -724,6 +755,15 @@ main(int argc, char **argv) return -1; } +#ifdef RTE_RING_ENQDEQ_CALLBACKS + if (rte_ring_preenq_callback_unregister( + rte_ring_lookup("rx_to_workers"), dump_ring, NULL)) + printf("failed preenq_callback_unregister - rx_to_workers\n"); + if (rte_ring_pstdeq_callback_unregister( + rte_ring_lookup("workers_to_tx"), dump_ring, NULL)) + printf("failed pstdeq_callback_unregister - rx_to_workers\n"); +#endif + print_stats(); return 0; } diff --git a/examples/packet_ordering/meson.build b/examples/packet_ordering/meson.build index 6c2fccdcb..a3776946f 100644 --- a/examples/packet_ordering/meson.build +++ b/examples/packet_ordering/meson.build @@ -7,6 +7,7 @@ # DPDK instance, use 'make' deps += 'reorder' +allow_experimental_apis = true sources = files( 'main.c' )