4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <rte_common.h>
35 #include <rte_cycles.h>
36 #include <rte_pipeline.h>
38 #include "pipeline_common_be.h"
41 int app_thread(void *arg)
43 struct app_params *app = (struct app_params *) arg;
44 uint32_t core_id = rte_lcore_id(), i, j;
45 struct app_thread_data *t = &app->thread_data[core_id];
46 uint32_t n_regular = RTE_MIN(t->n_regular, RTE_DIM(t->regular));
47 uint32_t n_custom = RTE_MIN(t->n_custom, RTE_DIM(t->custom));
50 /* Run regular pipelines */
51 for (j = 0; j < n_regular; j++) {
52 struct app_thread_pipeline_data *data = &t->regular[j];
53 struct pipeline *p = data->be;
55 rte_pipeline_run(p->p);
58 /* Run custom pipelines */
59 for (j = 0; j < n_custom; j++) {
60 struct app_thread_pipeline_data *data = &t->custom[j];
62 data->f_run(data->be);
67 uint64_t time = rte_get_tsc_cycles();
68 uint64_t t_deadline = UINT64_MAX;
70 if (time < t->deadline)
73 /* Timer for regular pipelines */
74 for (j = 0; j < n_regular; j++) {
75 struct app_thread_pipeline_data *data =
77 uint64_t p_deadline = data->deadline;
79 if (p_deadline <= time) {
80 data->f_timer(data->be);
81 p_deadline = time + data->timer_period;
82 data->deadline = p_deadline;
85 if (p_deadline < t_deadline)
86 t_deadline = p_deadline;
89 /* Timer for custom pipelines */
90 for (j = 0; j < n_custom; j++) {
91 struct app_thread_pipeline_data *data =
93 uint64_t p_deadline = data->deadline;
95 if (p_deadline <= time) {
96 data->f_timer(data->be);
97 p_deadline = time + data->timer_period;
98 data->deadline = p_deadline;
101 if (p_deadline < t_deadline)
102 t_deadline = p_deadline;
105 t->deadline = t_deadline;