DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 06/11] ip_pipeline: added application thread
Date: Thu, 25 Jun 2015 13:15:09 +0200	[thread overview]
Message-ID: <1435230914-8174-7-git-send-email-maciejx.t.gajdzica@intel.com> (raw)
In-Reply-To: <1435230914-8174-1-git-send-email-maciejx.t.gajdzica@intel.com>

Application thread runs pipelines on assigned cores.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 examples/ip_pipeline/Makefile |    1 +
 examples/ip_pipeline/main.c   |    6 +++
 examples/ip_pipeline/thread.c |  105 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 examples/ip_pipeline/thread.c

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 9ce80a8..f255338 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c
diff --git a/examples/ip_pipeline/main.c b/examples/ip_pipeline/main.c
index ef68c86..862e2f2 100644
--- a/examples/ip_pipeline/main.c
+++ b/examples/ip_pipeline/main.c
@@ -52,5 +52,11 @@ main(int argc, char **argv)
 	/* Init */
 	app_init(&app);
 
+	/* Run-time */
+	rte_eal_mp_remote_launch(
+		app_thread,
+		(void *) &app,
+		CALL_MASTER);
+
 	return 0;
 }
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
new file mode 100644
index 0000000..66b2a2b
--- /dev/null
+++ b/examples/ip_pipeline/thread.c
@@ -0,0 +1,105 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <rte_cycles.h>
+#include <rte_pipeline.h>
+
+#include "pipeline_common_be.h"
+#include "app.h"
+
+int app_thread(void *arg)
+{
+	struct app_params *app = (struct app_params *) arg;
+	uint32_t core_id = rte_lcore_id(), i, j;
+	struct app_thread_data *t = &app->thread_data[core_id];
+
+	for (i = 0; ; i++) {
+		/* Run regular pipelines */
+		for (j = 0; j < t->n_regular; j++){
+			struct app_thread_pipeline_data *data = &t->regular[j];
+			struct pipeline *p = data->be;
+
+			rte_pipeline_run(p->p);
+		}
+
+		/* Run custom pipelines */
+		for (j = 0; j < t->n_custom; j++){
+			struct app_thread_pipeline_data *data = &t->custom[j];
+
+			data->f_run(data->be);
+		}
+
+		/* Timer */
+		if ((i & 0xF) == 0) {
+			uint64_t time = rte_get_tsc_cycles();
+			uint64_t t_deadline = UINT64_MAX;
+			
+			if (time < t->deadline)
+				continue;
+
+			/* Timer for regular pipelines */
+			for (j = 0; j < t->n_regular; j++){
+				struct app_thread_pipeline_data *data = &t->regular[j];
+				uint64_t p_deadline = data->deadline;
+
+				if (p_deadline <= time) {
+					data->f_timer(data->be);
+					p_deadline = time + data->timer_period;
+					data->deadline = p_deadline;
+				}
+
+				if (p_deadline < t_deadline)
+					t_deadline = p_deadline;
+			}
+
+			/* Timer for custom pipelines */
+			for (j = 0; j < t->n_custom; j++){
+				struct app_thread_pipeline_data *data = &t->custom[j];
+				uint64_t p_deadline = data->deadline;
+
+				if (p_deadline <= time) {
+					data->f_timer(data->be);
+					p_deadline = time + data->timer_period;
+					data->deadline = p_deadline;
+				}
+
+				if (p_deadline < t_deadline)
+					t_deadline = p_deadline;
+			}
+
+			t->deadline = t_deadline;
+		}
+	}
+
+	return 0;
+}
-- 
1.7.9.5

  parent reply	other threads:[~2015-06-25 11:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 11:15 [dpdk-dev] [PATCH v2 00/11] ip_pipeline: ip_pipeline application enhancements Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 01/11] ip_pipeline: add parsing for config files with new syntax Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 02/11] ip_pipeline: added config checks Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 03/11] ip_pipeline: modified init to match new params struct Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 04/11] ip_pipeline: moved pipelines to separate folder Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 05/11] ip_pipeline: added master pipeline Maciej Gajdzica
2015-06-25 11:15 ` Maciej Gajdzica [this message]
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 07/11] ip_pipeline: moved config files to separate folder Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 08/11] ip_pipeline: added new implementation of passthrough pipeline Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 09/11] ip_pipeline: added new implementation of firewall pipeline Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 10/11] ip_pipeline: added new implementation of routing pipeline Maciej Gajdzica
2015-06-25 11:15 ` [dpdk-dev] [PATCH v2 11/11] ip_pipeline: added new implementation of flow classification pipeline Maciej Gajdzica
2015-06-25 12:19 ` [dpdk-dev] [PATCH v2 00/11] ip_pipeline: ip_pipeline application enhancements Dumitrescu, Cristian

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=1435230914-8174-7-git-send-email-maciejx.t.gajdzica@intel.com \
    --to=maciejx.t.gajdzica@intel.com \
    --cc=dev@dpdk.org \
    /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).