1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef __INCLUDE_PIPELINE_COMMON_FE_H__
6 #define __INCLUDE_PIPELINE_COMMON_FE_H__
8 #include <rte_common.h>
9 #include <rte_cycles.h>
10 #include <rte_malloc.h>
11 #include <cmdline_parse.h>
13 #include "pipeline_common_be.h"
17 #ifndef MSG_TIMEOUT_DEFAULT
18 #define MSG_TIMEOUT_DEFAULT 1000
21 static inline struct app_pipeline_data *
22 app_pipeline_data(struct app_params *app, uint32_t id)
24 struct app_pipeline_params *params;
26 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", id, params);
30 return &app->pipeline_data[params - app->pipeline_params];
34 app_pipeline_data_fe(struct app_params *app, uint32_t id, struct pipeline_type *ptype)
36 struct app_pipeline_data *pipeline_data;
38 pipeline_data = app_pipeline_data(app, id);
39 if (pipeline_data == NULL)
42 if (strcmp(pipeline_data->ptype->name, ptype->name) != 0)
45 if (pipeline_data->enabled == 0)
48 return pipeline_data->fe;
51 static inline struct rte_ring *
52 app_pipeline_msgq_in_get(struct app_params *app,
55 struct app_msgq_params *p;
57 APP_PARAM_FIND_BY_ID(app->msgq_params,
64 return app->msgq[p - app->msgq_params];
67 static inline struct rte_ring *
68 app_pipeline_msgq_out_get(struct app_params *app,
71 struct app_msgq_params *p;
73 APP_PARAM_FIND_BY_ID(app->msgq_params,
80 return app->msgq[p - app->msgq_params];
84 app_msg_alloc(__rte_unused struct app_params *app)
86 return rte_malloc(NULL, 2048, RTE_CACHE_LINE_SIZE);
90 app_msg_free(__rte_unused struct app_params *app,
97 app_msg_send(struct app_params *app,
101 struct rte_ring *r = app_pipeline_msgq_in_get(app, pipeline_id);
105 status = rte_ring_sp_enqueue(r, msg);
106 } while (status == -ENOBUFS);
110 app_msg_recv(struct app_params *app,
111 uint32_t pipeline_id)
113 struct rte_ring *r = app_pipeline_msgq_out_get(app, pipeline_id);
115 int status = rte_ring_sc_dequeue(r, &msg);
124 app_msg_send_recv(struct app_params *app,
125 uint32_t pipeline_id,
129 struct rte_ring *r_req = app_pipeline_msgq_in_get(app, pipeline_id);
130 struct rte_ring *r_rsp = app_pipeline_msgq_out_get(app, pipeline_id);
131 uint64_t hz = rte_get_tsc_hz();
138 status = rte_ring_sp_enqueue(r_req, (void *) msg);
139 } while (status == -ENOBUFS);
142 deadline = (timeout_ms) ?
143 (rte_rdtsc() + ((hz * timeout_ms) / 1000)) :
147 if (rte_rdtsc() > deadline)
150 status = rte_ring_sc_dequeue(r_rsp, &msg_recv);
151 } while (status != 0);
156 struct app_link_params *
157 app_pipeline_track_pktq_out_to_link(struct app_params *app,
158 uint32_t pipeline_id,
159 uint32_t pktq_out_id);
162 app_pipeline_track_default(struct pipeline_params *params,
167 app_pipeline_ping(struct app_params *app,
168 uint32_t pipeline_id);
171 app_pipeline_stats_port_in(struct app_params *app,
172 uint32_t pipeline_id,
174 struct rte_pipeline_port_in_stats *stats);
177 app_pipeline_stats_port_out(struct app_params *app,
178 uint32_t pipeline_id,
180 struct rte_pipeline_port_out_stats *stats);
183 app_pipeline_stats_table(struct app_params *app,
184 uint32_t pipeline_id,
186 struct rte_pipeline_table_stats *stats);
189 app_pipeline_port_in_enable(struct app_params *app,
190 uint32_t pipeline_id,
194 app_pipeline_port_in_disable(struct app_params *app,
195 uint32_t pipeline_id,
199 app_link_set_op(struct app_params *app,
201 uint32_t pipeline_id,
206 app_link_config(struct app_params *app,
212 app_link_up(struct app_params *app,
216 app_link_down(struct app_params *app,
220 app_pipeline_common_cmd_push(struct app_params *app);
222 #define CMD_MSG_OUT_OF_MEMORY "Not enough memory\n"
223 #define CMD_MSG_NOT_ENOUGH_ARGS "Not enough arguments for command \"%s\"\n"
224 #define CMD_MSG_TOO_MANY_ARGS "Too many arguments for command \"%s\"\n"
225 #define CMD_MSG_MISMATCH_ARGS "Incorrect set of arguments for command \"%s\"\n"
226 #define CMD_MSG_INVALID_ARG "Invalid value for argument \"%s\"\n"
227 #define CMD_MSG_ARG_NOT_FOUND "Syntax error: \"%s\" not found\n"
228 #define CMD_MSG_FILE_ERR "Error in file \"%s\" at line %u\n"
229 #define CMD_MSG_FAIL "Command \"%s\" failed\n"