4 * Copyright(c) 2010-2016 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 #ifndef __INCLUDE_PIPELINE_BE_H__
35 #define __INCLUDE_PIPELINE_BE_H__
37 #include <rte_port_ethdev.h>
38 #include <rte_port_ring.h>
39 #include <rte_port_frag.h>
40 #include <rte_port_ras.h>
41 #include <rte_port_sched.h>
42 #include <rte_port_source_sink.h>
43 #include <rte_pipeline.h>
45 enum pipeline_port_in_type {
46 PIPELINE_PORT_IN_ETHDEV_READER,
47 PIPELINE_PORT_IN_RING_READER,
48 PIPELINE_PORT_IN_RING_MULTI_READER,
49 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG,
50 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG,
51 PIPELINE_PORT_IN_SCHED_READER,
52 PIPELINE_PORT_IN_SOURCE,
55 struct pipeline_port_in_params {
56 enum pipeline_port_in_type type;
58 struct rte_port_ethdev_reader_params ethdev;
59 struct rte_port_ring_reader_params ring;
60 struct rte_port_ring_multi_reader_params ring_multi;
61 struct rte_port_ring_reader_ipv4_frag_params ring_ipv4_frag;
62 struct rte_port_ring_reader_ipv6_frag_params ring_ipv6_frag;
63 struct rte_port_sched_reader_params sched;
64 struct rte_port_source_params source;
70 pipeline_port_in_params_convert(struct pipeline_port_in_params *p)
73 case PIPELINE_PORT_IN_ETHDEV_READER:
74 return (void *) &p->params.ethdev;
75 case PIPELINE_PORT_IN_RING_READER:
76 return (void *) &p->params.ring;
77 case PIPELINE_PORT_IN_RING_MULTI_READER:
78 return (void *) &p->params.ring_multi;
79 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
80 return (void *) &p->params.ring_ipv4_frag;
81 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
82 return (void *) &p->params.ring_ipv6_frag;
83 case PIPELINE_PORT_IN_SCHED_READER:
84 return (void *) &p->params.sched;
85 case PIPELINE_PORT_IN_SOURCE:
86 return (void *) &p->params.source;
92 static inline struct rte_port_in_ops *
93 pipeline_port_in_params_get_ops(struct pipeline_port_in_params *p)
96 case PIPELINE_PORT_IN_ETHDEV_READER:
97 return &rte_port_ethdev_reader_ops;
98 case PIPELINE_PORT_IN_RING_READER:
99 return &rte_port_ring_reader_ops;
100 case PIPELINE_PORT_IN_RING_MULTI_READER:
101 return &rte_port_ring_multi_reader_ops;
102 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
103 return &rte_port_ring_reader_ipv4_frag_ops;
104 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
105 return &rte_port_ring_reader_ipv6_frag_ops;
106 case PIPELINE_PORT_IN_SCHED_READER:
107 return &rte_port_sched_reader_ops;
108 case PIPELINE_PORT_IN_SOURCE:
109 return &rte_port_source_ops;
115 enum pipeline_port_out_type {
116 PIPELINE_PORT_OUT_ETHDEV_WRITER,
117 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP,
118 PIPELINE_PORT_OUT_RING_WRITER,
119 PIPELINE_PORT_OUT_RING_MULTI_WRITER,
120 PIPELINE_PORT_OUT_RING_WRITER_NODROP,
121 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP,
122 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS,
123 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS,
124 PIPELINE_PORT_OUT_SCHED_WRITER,
125 PIPELINE_PORT_OUT_SINK,
128 struct pipeline_port_out_params {
129 enum pipeline_port_out_type type;
131 struct rte_port_ethdev_writer_params ethdev;
132 struct rte_port_ethdev_writer_nodrop_params ethdev_nodrop;
133 struct rte_port_ring_writer_params ring;
134 struct rte_port_ring_multi_writer_params ring_multi;
135 struct rte_port_ring_writer_nodrop_params ring_nodrop;
136 struct rte_port_ring_multi_writer_nodrop_params ring_multi_nodrop;
137 struct rte_port_ring_writer_ipv4_ras_params ring_ipv4_ras;
138 struct rte_port_ring_writer_ipv6_ras_params ring_ipv6_ras;
139 struct rte_port_sched_writer_params sched;
140 struct rte_port_sink_params sink;
145 pipeline_port_out_params_convert(struct pipeline_port_out_params *p)
148 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
149 return (void *) &p->params.ethdev;
150 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
151 return (void *) &p->params.ethdev_nodrop;
152 case PIPELINE_PORT_OUT_RING_WRITER:
153 return (void *) &p->params.ring;
154 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
155 return (void *) &p->params.ring_multi;
156 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
157 return (void *) &p->params.ring_nodrop;
158 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
159 return (void *) &p->params.ring_multi_nodrop;
160 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
161 return (void *) &p->params.ring_ipv4_ras;
162 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
163 return (void *) &p->params.ring_ipv6_ras;
164 case PIPELINE_PORT_OUT_SCHED_WRITER:
165 return (void *) &p->params.sched;
166 case PIPELINE_PORT_OUT_SINK:
167 return (void *) &p->params.sink;
174 pipeline_port_out_params_get_ops(struct pipeline_port_out_params *p)
177 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
178 return &rte_port_ethdev_writer_ops;
179 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
180 return &rte_port_ethdev_writer_nodrop_ops;
181 case PIPELINE_PORT_OUT_RING_WRITER:
182 return &rte_port_ring_writer_ops;
183 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
184 return &rte_port_ring_multi_writer_ops;
185 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
186 return &rte_port_ring_writer_nodrop_ops;
187 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
188 return &rte_port_ring_multi_writer_nodrop_ops;
189 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
190 return &rte_port_ring_writer_ipv4_ras_ops;
191 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
192 return &rte_port_ring_writer_ipv6_ras_ops;
193 case PIPELINE_PORT_OUT_SCHED_WRITER:
194 return &rte_port_sched_writer_ops;
195 case PIPELINE_PORT_OUT_SINK:
196 return &rte_port_sink_ops;
202 #ifndef PIPELINE_NAME_SIZE
203 #define PIPELINE_NAME_SIZE 32
206 #ifndef PIPELINE_MAX_PORT_IN
207 #define PIPELINE_MAX_PORT_IN 16
210 #ifndef PIPELINE_MAX_PORT_OUT
211 #define PIPELINE_MAX_PORT_OUT 16
214 #ifndef PIPELINE_MAX_TABLES
215 #define PIPELINE_MAX_TABLES 16
218 #ifndef PIPELINE_MAX_MSGQ_IN
219 #define PIPELINE_MAX_MSGQ_IN 16
222 #ifndef PIPELINE_MAX_MSGQ_OUT
223 #define PIPELINE_MAX_MSGQ_OUT 16
226 #ifndef PIPELINE_MAX_ARGS
227 #define PIPELINE_MAX_ARGS 32
230 struct pipeline_params {
231 char name[PIPELINE_NAME_SIZE];
233 struct pipeline_port_in_params port_in[PIPELINE_MAX_PORT_IN];
234 struct pipeline_port_out_params port_out[PIPELINE_MAX_PORT_OUT];
235 struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
236 struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
239 uint32_t n_ports_out;
244 char *args_name[PIPELINE_MAX_ARGS];
245 char *args_value[PIPELINE_MAX_ARGS];
252 * Pipeline type back-end operations
255 typedef void* (*pipeline_be_op_init)(struct pipeline_params *params,
258 typedef int (*pipeline_be_op_free)(void *pipeline);
260 typedef int (*pipeline_be_op_run)(void *pipeline);
262 typedef int (*pipeline_be_op_timer)(void *pipeline);
264 typedef int (*pipeline_be_op_track)(void *pipeline,
268 struct pipeline_be_ops {
269 pipeline_be_op_init f_init;
270 pipeline_be_op_free f_free;
271 pipeline_be_op_run f_run;
272 pipeline_be_op_timer f_timer;
273 pipeline_be_op_track f_track;
276 /* Pipeline specific config parse error messages */
277 #define PIPELINE_ARG_CHECK(exp, fmt, ...) \
280 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
285 #define PIPELINE_PARSE_ERR_INV_VAL(exp, section, entry, val) \
286 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
287 "has invalid value (\"%s\")", section, entry, val)
289 #define PIPELINE_PARSE_ERR_OUT_RNG(exp, section, entry, val) \
290 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
291 "value is out of range (\"%s\")", section, entry, val)
293 #define PIPELINE_PARSE_ERR_DUPLICATE(exp, section, entry) \
294 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": duplicated " \
295 "entry \"%s\"", section, entry)
297 #define PIPELINE_PARSE_ERR_INV_ENT(exp, section, entry) \
298 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": invalid entry " \
299 "\"%s\"", section, entry)
301 #define PIPELINE_PARSE_ERR_MANDATORY(exp, section, entry) \
302 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": mandatory " \
303 "entry \"%s\" is missing", section, entry)