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>
44 #include <rte_port_kni.h>
46 #include <rte_pipeline.h>
48 enum pipeline_port_in_type {
49 PIPELINE_PORT_IN_ETHDEV_READER,
50 PIPELINE_PORT_IN_RING_READER,
51 PIPELINE_PORT_IN_RING_MULTI_READER,
52 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG,
53 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG,
54 PIPELINE_PORT_IN_SCHED_READER,
55 PIPELINE_PORT_IN_KNI_READER,
56 PIPELINE_PORT_IN_SOURCE,
59 struct pipeline_port_in_params {
60 enum pipeline_port_in_type type;
62 struct rte_port_ethdev_reader_params ethdev;
63 struct rte_port_ring_reader_params ring;
64 struct rte_port_ring_multi_reader_params ring_multi;
65 struct rte_port_ring_reader_ipv4_frag_params ring_ipv4_frag;
66 struct rte_port_ring_reader_ipv6_frag_params ring_ipv6_frag;
67 struct rte_port_sched_reader_params sched;
69 struct rte_port_kni_reader_params kni;
71 struct rte_port_source_params source;
77 pipeline_port_in_params_convert(struct pipeline_port_in_params *p)
80 case PIPELINE_PORT_IN_ETHDEV_READER:
81 return (void *) &p->params.ethdev;
82 case PIPELINE_PORT_IN_RING_READER:
83 return (void *) &p->params.ring;
84 case PIPELINE_PORT_IN_RING_MULTI_READER:
85 return (void *) &p->params.ring_multi;
86 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
87 return (void *) &p->params.ring_ipv4_frag;
88 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
89 return (void *) &p->params.ring_ipv6_frag;
90 case PIPELINE_PORT_IN_SCHED_READER:
91 return (void *) &p->params.sched;
93 case PIPELINE_PORT_IN_KNI_READER:
94 return (void *) &p->params.kni;
96 case PIPELINE_PORT_IN_SOURCE:
97 return (void *) &p->params.source;
103 static inline struct rte_port_in_ops *
104 pipeline_port_in_params_get_ops(struct pipeline_port_in_params *p)
107 case PIPELINE_PORT_IN_ETHDEV_READER:
108 return &rte_port_ethdev_reader_ops;
109 case PIPELINE_PORT_IN_RING_READER:
110 return &rte_port_ring_reader_ops;
111 case PIPELINE_PORT_IN_RING_MULTI_READER:
112 return &rte_port_ring_multi_reader_ops;
113 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
114 return &rte_port_ring_reader_ipv4_frag_ops;
115 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
116 return &rte_port_ring_reader_ipv6_frag_ops;
117 case PIPELINE_PORT_IN_SCHED_READER:
118 return &rte_port_sched_reader_ops;
119 #ifdef RTE_LIBRTE_KNI
120 case PIPELINE_PORT_IN_KNI_READER:
121 return &rte_port_kni_reader_ops;
123 case PIPELINE_PORT_IN_SOURCE:
124 return &rte_port_source_ops;
130 enum pipeline_port_out_type {
131 PIPELINE_PORT_OUT_ETHDEV_WRITER,
132 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP,
133 PIPELINE_PORT_OUT_RING_WRITER,
134 PIPELINE_PORT_OUT_RING_MULTI_WRITER,
135 PIPELINE_PORT_OUT_RING_WRITER_NODROP,
136 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP,
137 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS,
138 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS,
139 PIPELINE_PORT_OUT_SCHED_WRITER,
140 PIPELINE_PORT_OUT_KNI_WRITER,
141 PIPELINE_PORT_OUT_KNI_WRITER_NODROP,
142 PIPELINE_PORT_OUT_SINK,
145 struct pipeline_port_out_params {
146 enum pipeline_port_out_type type;
148 struct rte_port_ethdev_writer_params ethdev;
149 struct rte_port_ethdev_writer_nodrop_params ethdev_nodrop;
150 struct rte_port_ring_writer_params ring;
151 struct rte_port_ring_multi_writer_params ring_multi;
152 struct rte_port_ring_writer_nodrop_params ring_nodrop;
153 struct rte_port_ring_multi_writer_nodrop_params ring_multi_nodrop;
154 struct rte_port_ring_writer_ipv4_ras_params ring_ipv4_ras;
155 struct rte_port_ring_writer_ipv6_ras_params ring_ipv6_ras;
156 struct rte_port_sched_writer_params sched;
157 #ifdef RTE_LIBRTE_KNI
158 struct rte_port_kni_writer_params kni;
159 struct rte_port_kni_writer_nodrop_params kni_nodrop;
161 struct rte_port_sink_params sink;
166 pipeline_port_out_params_convert(struct pipeline_port_out_params *p)
169 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
170 return (void *) &p->params.ethdev;
171 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
172 return (void *) &p->params.ethdev_nodrop;
173 case PIPELINE_PORT_OUT_RING_WRITER:
174 return (void *) &p->params.ring;
175 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
176 return (void *) &p->params.ring_multi;
177 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
178 return (void *) &p->params.ring_nodrop;
179 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
180 return (void *) &p->params.ring_multi_nodrop;
181 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
182 return (void *) &p->params.ring_ipv4_ras;
183 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
184 return (void *) &p->params.ring_ipv6_ras;
185 case PIPELINE_PORT_OUT_SCHED_WRITER:
186 return (void *) &p->params.sched;
187 #ifdef RTE_LIBRTE_KNI
188 case PIPELINE_PORT_OUT_KNI_WRITER:
189 return (void *) &p->params.kni;
190 case PIPELINE_PORT_OUT_KNI_WRITER_NODROP:
191 return (void *) &p->params.kni_nodrop;
193 case PIPELINE_PORT_OUT_SINK:
194 return (void *) &p->params.sink;
201 pipeline_port_out_params_get_ops(struct pipeline_port_out_params *p)
204 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
205 return &rte_port_ethdev_writer_ops;
206 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
207 return &rte_port_ethdev_writer_nodrop_ops;
208 case PIPELINE_PORT_OUT_RING_WRITER:
209 return &rte_port_ring_writer_ops;
210 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
211 return &rte_port_ring_multi_writer_ops;
212 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
213 return &rte_port_ring_writer_nodrop_ops;
214 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
215 return &rte_port_ring_multi_writer_nodrop_ops;
216 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
217 return &rte_port_ring_writer_ipv4_ras_ops;
218 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
219 return &rte_port_ring_writer_ipv6_ras_ops;
220 case PIPELINE_PORT_OUT_SCHED_WRITER:
221 return &rte_port_sched_writer_ops;
222 #ifdef RTE_LIBRTE_KNI
223 case PIPELINE_PORT_OUT_KNI_WRITER:
224 return &rte_port_kni_writer_ops;
225 case PIPELINE_PORT_OUT_KNI_WRITER_NODROP:
226 return &rte_port_kni_writer_nodrop_ops;
228 case PIPELINE_PORT_OUT_SINK:
229 return &rte_port_sink_ops;
235 #ifndef PIPELINE_NAME_SIZE
236 #define PIPELINE_NAME_SIZE 64
239 #ifndef PIPELINE_TYPE_SIZE
240 #define PIPELINE_TYPE_SIZE 64
243 #ifndef PIPELINE_MAX_PORT_IN
244 #define PIPELINE_MAX_PORT_IN 64
247 #ifndef PIPELINE_MAX_PORT_OUT
248 #define PIPELINE_MAX_PORT_OUT 64
251 #ifndef PIPELINE_MAX_TABLES
252 #define PIPELINE_MAX_TABLES 16
255 #ifndef PIPELINE_MAX_MSGQ_IN
256 #define PIPELINE_MAX_MSGQ_IN 16
259 #ifndef PIPELINE_MAX_MSGQ_OUT
260 #define PIPELINE_MAX_MSGQ_OUT 16
263 #ifndef PIPELINE_MAX_ARGS
264 #define PIPELINE_MAX_ARGS 64
267 struct pipeline_params {
268 char name[PIPELINE_NAME_SIZE];
269 char type[PIPELINE_TYPE_SIZE];
271 struct pipeline_port_in_params port_in[PIPELINE_MAX_PORT_IN];
272 struct pipeline_port_out_params port_out[PIPELINE_MAX_PORT_OUT];
273 struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
274 struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
277 uint32_t n_ports_out;
282 char *args_name[PIPELINE_MAX_ARGS];
283 char *args_value[PIPELINE_MAX_ARGS];
290 * Pipeline type back-end operations
293 typedef void* (*pipeline_be_op_init)(struct pipeline_params *params,
296 typedef int (*pipeline_be_op_free)(void *pipeline);
298 typedef int (*pipeline_be_op_run)(void *pipeline);
300 typedef int (*pipeline_be_op_timer)(void *pipeline);
302 struct pipeline_be_ops {
303 pipeline_be_op_init f_init;
304 pipeline_be_op_free f_free;
305 pipeline_be_op_run f_run;
306 pipeline_be_op_timer f_timer;
309 /* Pipeline specific config parse error messages */
310 #define PIPELINE_ARG_CHECK(exp, fmt, ...) \
313 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
318 #define PIPELINE_PARSE_ERR_INV_VAL(exp, section, entry, val) \
319 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
320 "has invalid value (\"%s\")", section, entry, val)
322 #define PIPELINE_PARSE_ERR_OUT_RNG(exp, section, entry, val) \
323 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
324 "value is out of range (\"%s\")", section, entry, val)
326 #define PIPELINE_PARSE_ERR_DUPLICATE(exp, section, entry) \
327 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": duplicated " \
328 "entry \"%s\"", section, entry)
330 #define PIPELINE_PARSE_ERR_INV_ENT(exp, section, entry) \
331 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": invalid entry " \
332 "\"%s\"", section, entry)
334 #define PIPELINE_PARSE_ERR_MANDATORY(exp, section, entry) \
335 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": mandatory " \
336 "entry \"%s\" is missing", section, entry)