2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef __INCLUDE_PIPELINE_COMMON_FE_H__
18 #define __INCLUDE_PIPELINE_COMMON_FE_H__
20 #include <rte_common.h>
21 #include <rte_cycles.h>
22 #include <rte_malloc.h>
23 #include <cmdline_parse.h>
25 #include "pipeline_common_be.h"
29 #ifndef MSG_TIMEOUT_DEFAULT
30 #define MSG_TIMEOUT_DEFAULT 1000
32 struct app_link_params mylink[APP_MAX_LINKS];
33 static inline struct app_pipeline_data *
34 app_pipeline_data(struct app_params *app, uint32_t id)
36 struct app_pipeline_params *params;
38 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", id, params);
42 return &app->pipeline_data[params - app->pipeline_params];
46 app_pipeline_data_fe(struct app_params *app, uint32_t id, struct pipeline_type *ptype)
48 struct app_pipeline_data *pipeline_data;
50 pipeline_data = app_pipeline_data(app, id);
51 if (pipeline_data == NULL)
54 if (strcmp(pipeline_data->ptype->name, ptype->name) != 0)
57 if (pipeline_data->enabled == 0)
60 return pipeline_data->fe;
63 static inline struct rte_ring *
64 app_pipeline_msgq_in_get(struct app_params *app,
67 struct app_msgq_params *p;
69 APP_PARAM_FIND_BY_ID(app->msgq_params,
76 return app->msgq[p - app->msgq_params];
79 static inline struct rte_ring *
80 app_pipeline_msgq_out_get(struct app_params *app,
83 struct app_msgq_params *p;
85 APP_PARAM_FIND_BY_ID(app->msgq_params,
92 return app->msgq[p - app->msgq_params];
96 app_msg_alloc(__rte_unused struct app_params *app)
98 return rte_malloc(NULL, 2048, RTE_CACHE_LINE_SIZE);
102 app_msg_free(__rte_unused struct app_params *app,
109 app_msg_send(struct app_params *app,
110 uint32_t pipeline_id,
113 struct rte_ring *r = app_pipeline_msgq_in_get(app, pipeline_id);
117 status = rte_ring_sp_enqueue(r, msg);
118 } while (status == -ENOBUFS);
122 app_msg_recv(struct app_params *app,
123 uint32_t pipeline_id)
125 struct rte_ring *r = app_pipeline_msgq_out_get(app, pipeline_id);
127 int status = rte_ring_sc_dequeue(r, &msg);
136 app_msg_send_recv(struct app_params *app,
137 uint32_t pipeline_id,
141 struct rte_ring *r_req = app_pipeline_msgq_in_get(app, pipeline_id);
142 struct rte_ring *r_rsp = app_pipeline_msgq_out_get(app, pipeline_id);
143 uint64_t hz = rte_get_tsc_hz();
144 void *msg_recv = NULL;
151 status = rte_ring_sp_enqueue(r_req, (void *) msg);
152 } while (status == -ENOBUFS);
155 deadline = (timeout_ms) ?
156 (rte_rdtsc() + ((hz * timeout_ms) / 1000)) :
160 if (rte_rdtsc() > deadline)
163 status = rte_ring_sc_dequeue(r_rsp, &msg_recv);
164 } while (status != 0);
170 app_pipeline_ping(struct app_params *app,
171 uint32_t pipeline_id);
174 app_pipeline_stats_port_in(struct app_params *app,
175 uint32_t pipeline_id,
177 struct rte_pipeline_port_in_stats *stats);
180 app_pipeline_stats_port_out(struct app_params *app,
181 uint32_t pipeline_id,
183 struct rte_pipeline_port_out_stats *stats);
186 app_pipeline_stats_table(struct app_params *app,
187 uint32_t pipeline_id,
189 struct rte_pipeline_table_stats *stats);
192 app_pipeline_port_in_enable(struct app_params *app,
193 uint32_t pipeline_id,
197 app_pipeline_port_in_disable(struct app_params *app,
198 uint32_t pipeline_id,
202 app_link_config(struct app_params *app,
208 app_link_up(struct app_params *app,
212 app_link_down(struct app_params *app,
216 app_pipeline_common_cmd_push(struct app_params *app);
219 void convert_prefixlen_to_netmask_ipv6(uint32_t depth, uint8_t netmask_ipv6[]);
222 get_host_portion_ipv6(uint8_t ipv6[], uint8_t netmask[], uint8_t host_ipv6[]);
225 get_bcast_portion_ipv6(uint8_t host[], uint8_t netmask[], uint8_t bcast_ipv6[]);
228 app_link_config_ipv6(struct app_params *app,
229 uint32_t link_id, uint8_t ipv6[], uint32_t depth);
231 int app_routeadd_config_ipv4( __attribute__((unused)) struct app_params *app,
232 uint32_t port_id, uint32_t ip, uint32_t mask);
234 int app_routeadd_config_ipv6( __attribute__((unused)) struct app_params *app,
235 uint32_t port_id, uint8_t ipv6[], uint32_t depth);