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_fd.h>
43 #include <rte_port_source_sink.h>
45 #include <rte_port_kni.h>
47 #include <rte_pipeline.h>
49 enum pipeline_port_in_type
{
50 PIPELINE_PORT_IN_ETHDEV_READER
,
51 PIPELINE_PORT_IN_RING_READER
,
52 PIPELINE_PORT_IN_RING_MULTI_READER
,
53 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG
,
54 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG
,
55 PIPELINE_PORT_IN_SCHED_READER
,
56 PIPELINE_PORT_IN_FD_READER
,
57 PIPELINE_PORT_IN_KNI_READER
,
58 PIPELINE_PORT_IN_SOURCE
,
61 struct pipeline_port_in_params
{
62 enum pipeline_port_in_type type
;
64 struct rte_port_ethdev_reader_params ethdev
;
65 struct rte_port_ring_reader_params ring
;
66 struct rte_port_ring_multi_reader_params ring_multi
;
67 struct rte_port_ring_reader_ipv4_frag_params ring_ipv4_frag
;
68 struct rte_port_ring_reader_ipv6_frag_params ring_ipv6_frag
;
69 struct rte_port_sched_reader_params sched
;
70 struct rte_port_fd_reader_params fd
;
72 struct rte_port_kni_reader_params kni
;
74 struct rte_port_source_params source
;
80 pipeline_port_in_params_convert(struct pipeline_port_in_params
*p
)
83 case PIPELINE_PORT_IN_ETHDEV_READER
:
84 return (void *) &p
->params
.ethdev
;
85 case PIPELINE_PORT_IN_RING_READER
:
86 return (void *) &p
->params
.ring
;
87 case PIPELINE_PORT_IN_RING_MULTI_READER
:
88 return (void *) &p
->params
.ring_multi
;
89 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG
:
90 return (void *) &p
->params
.ring_ipv4_frag
;
91 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG
:
92 return (void *) &p
->params
.ring_ipv6_frag
;
93 case PIPELINE_PORT_IN_SCHED_READER
:
94 return (void *) &p
->params
.sched
;
95 case PIPELINE_PORT_IN_FD_READER
:
96 return (void *) &p
->params
.fd
;
98 case PIPELINE_PORT_IN_KNI_READER
:
99 return (void *) &p
->params
.kni
;
101 case PIPELINE_PORT_IN_SOURCE
:
102 return (void *) &p
->params
.source
;
108 static inline struct rte_port_in_ops
*
109 pipeline_port_in_params_get_ops(struct pipeline_port_in_params
*p
)
112 case PIPELINE_PORT_IN_ETHDEV_READER
:
113 return &rte_port_ethdev_reader_ops
;
114 case PIPELINE_PORT_IN_RING_READER
:
115 return &rte_port_ring_reader_ops
;
116 case PIPELINE_PORT_IN_RING_MULTI_READER
:
117 return &rte_port_ring_multi_reader_ops
;
118 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG
:
119 return &rte_port_ring_reader_ipv4_frag_ops
;
120 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG
:
121 return &rte_port_ring_reader_ipv6_frag_ops
;
122 case PIPELINE_PORT_IN_SCHED_READER
:
123 return &rte_port_sched_reader_ops
;
124 case PIPELINE_PORT_IN_FD_READER
:
125 return &rte_port_fd_reader_ops
;
126 #ifdef RTE_LIBRTE_KNI
127 case PIPELINE_PORT_IN_KNI_READER
:
128 return &rte_port_kni_reader_ops
;
130 case PIPELINE_PORT_IN_SOURCE
:
131 return &rte_port_source_ops
;
137 enum pipeline_port_out_type
{
138 PIPELINE_PORT_OUT_ETHDEV_WRITER
,
139 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP
,
140 PIPELINE_PORT_OUT_RING_WRITER
,
141 PIPELINE_PORT_OUT_RING_MULTI_WRITER
,
142 PIPELINE_PORT_OUT_RING_WRITER_NODROP
,
143 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP
,
144 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS
,
145 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS
,
146 PIPELINE_PORT_OUT_SCHED_WRITER
,
147 PIPELINE_PORT_OUT_FD_WRITER
,
148 PIPELINE_PORT_OUT_KNI_WRITER
,
149 PIPELINE_PORT_OUT_KNI_WRITER_NODROP
,
150 PIPELINE_PORT_OUT_SINK
,
153 struct pipeline_port_out_params
{
154 enum pipeline_port_out_type type
;
156 struct rte_port_ethdev_writer_params ethdev
;
157 struct rte_port_ethdev_writer_nodrop_params ethdev_nodrop
;
158 struct rte_port_ring_writer_params ring
;
159 struct rte_port_ring_multi_writer_params ring_multi
;
160 struct rte_port_ring_writer_nodrop_params ring_nodrop
;
161 struct rte_port_ring_multi_writer_nodrop_params ring_multi_nodrop
;
162 struct rte_port_ring_writer_ipv4_ras_params ring_ipv4_ras
;
163 struct rte_port_ring_writer_ipv6_ras_params ring_ipv6_ras
;
164 struct rte_port_sched_writer_params sched
;
165 struct rte_port_fd_writer_params fd
;
166 #ifdef RTE_LIBRTE_KNI
167 struct rte_port_kni_writer_params kni
;
168 struct rte_port_kni_writer_nodrop_params kni_nodrop
;
170 struct rte_port_sink_params sink
;
175 pipeline_port_out_params_convert(struct pipeline_port_out_params
*p
)
178 case PIPELINE_PORT_OUT_ETHDEV_WRITER
:
179 return (void *) &p
->params
.ethdev
;
180 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP
:
181 return (void *) &p
->params
.ethdev_nodrop
;
182 case PIPELINE_PORT_OUT_RING_WRITER
:
183 return (void *) &p
->params
.ring
;
184 case PIPELINE_PORT_OUT_RING_MULTI_WRITER
:
185 return (void *) &p
->params
.ring_multi
;
186 case PIPELINE_PORT_OUT_RING_WRITER_NODROP
:
187 return (void *) &p
->params
.ring_nodrop
;
188 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP
:
189 return (void *) &p
->params
.ring_multi_nodrop
;
190 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS
:
191 return (void *) &p
->params
.ring_ipv4_ras
;
192 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS
:
193 return (void *) &p
->params
.ring_ipv6_ras
;
194 case PIPELINE_PORT_OUT_SCHED_WRITER
:
195 return (void *) &p
->params
.sched
;
196 case PIPELINE_PORT_OUT_FD_WRITER
:
197 return (void *) &p
->params
.fd
;
198 #ifdef RTE_LIBRTE_KNI
199 case PIPELINE_PORT_OUT_KNI_WRITER
:
200 return (void *) &p
->params
.kni
;
201 case PIPELINE_PORT_OUT_KNI_WRITER_NODROP
:
202 return (void *) &p
->params
.kni_nodrop
;
204 case PIPELINE_PORT_OUT_SINK
:
205 return (void *) &p
->params
.sink
;
212 pipeline_port_out_params_get_ops(struct pipeline_port_out_params
*p
)
215 case PIPELINE_PORT_OUT_ETHDEV_WRITER
:
216 return &rte_port_ethdev_writer_ops
;
217 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP
:
218 return &rte_port_ethdev_writer_nodrop_ops
;
219 case PIPELINE_PORT_OUT_RING_WRITER
:
220 return &rte_port_ring_writer_ops
;
221 case PIPELINE_PORT_OUT_RING_MULTI_WRITER
:
222 return &rte_port_ring_multi_writer_ops
;
223 case PIPELINE_PORT_OUT_RING_WRITER_NODROP
:
224 return &rte_port_ring_writer_nodrop_ops
;
225 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP
:
226 return &rte_port_ring_multi_writer_nodrop_ops
;
227 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS
:
228 return &rte_port_ring_writer_ipv4_ras_ops
;
229 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS
:
230 return &rte_port_ring_writer_ipv6_ras_ops
;
231 case PIPELINE_PORT_OUT_SCHED_WRITER
:
232 return &rte_port_sched_writer_ops
;
233 case PIPELINE_PORT_OUT_FD_WRITER
:
234 return &rte_port_fd_writer_ops
;
235 #ifdef RTE_LIBRTE_KNI
236 case PIPELINE_PORT_OUT_KNI_WRITER
:
237 return &rte_port_kni_writer_ops
;
238 case PIPELINE_PORT_OUT_KNI_WRITER_NODROP
:
239 return &rte_port_kni_writer_nodrop_ops
;
241 case PIPELINE_PORT_OUT_SINK
:
242 return &rte_port_sink_ops
;
248 #ifndef PIPELINE_NAME_SIZE
249 #define PIPELINE_NAME_SIZE 64
252 #ifndef PIPELINE_TYPE_SIZE
253 #define PIPELINE_TYPE_SIZE 64
256 #ifndef PIPELINE_MAX_PORT_IN
257 #define PIPELINE_MAX_PORT_IN 64
260 #ifndef PIPELINE_MAX_PORT_OUT
261 #define PIPELINE_MAX_PORT_OUT 64
264 #ifndef PIPELINE_MAX_TABLES
265 #define PIPELINE_MAX_TABLES 16
268 #ifndef PIPELINE_MAX_MSGQ_IN
269 #define PIPELINE_MAX_MSGQ_IN 16
272 #ifndef PIPELINE_MAX_MSGQ_OUT
273 #define PIPELINE_MAX_MSGQ_OUT 16
276 #ifndef PIPELINE_MAX_ARGS
277 #define PIPELINE_MAX_ARGS 64
280 struct pipeline_params
{
281 char name
[PIPELINE_NAME_SIZE
];
282 char type
[PIPELINE_TYPE_SIZE
];
284 struct pipeline_port_in_params port_in
[PIPELINE_MAX_PORT_IN
];
285 struct pipeline_port_out_params port_out
[PIPELINE_MAX_PORT_OUT
];
286 struct rte_ring
*msgq_in
[PIPELINE_MAX_MSGQ_IN
];
287 struct rte_ring
*msgq_out
[PIPELINE_MAX_MSGQ_OUT
];
290 uint32_t n_ports_out
;
295 char *args_name
[PIPELINE_MAX_ARGS
];
296 char *args_value
[PIPELINE_MAX_ARGS
];
303 * Pipeline type back-end operations
306 typedef void* (*pipeline_be_op_init
)(struct pipeline_params
*params
,
309 typedef int (*pipeline_be_op_free
)(void *pipeline
);
311 typedef int (*pipeline_be_op_run
)(void *pipeline
);
313 typedef int (*pipeline_be_op_timer
)(void *pipeline
);
315 struct pipeline_be_ops
{
316 pipeline_be_op_init f_init
;
317 pipeline_be_op_free f_free
;
318 pipeline_be_op_run f_run
;
319 pipeline_be_op_timer f_timer
;
322 /* Pipeline specific config parse error messages */
323 #define PIPELINE_ARG_CHECK(exp, fmt, ...) \
326 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
331 #define PIPELINE_PARSE_ERR_INV_VAL(exp, section, entry, val) \
332 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
333 "has invalid value (\"%s\")", section, entry, val)
335 #define PIPELINE_PARSE_ERR_OUT_RNG(exp, section, entry, val) \
336 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
337 "value is out of range (\"%s\")", section, entry, val)
339 #define PIPELINE_PARSE_ERR_DUPLICATE(exp, section, entry) \
340 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": duplicated " \
341 "entry \"%s\"", section, entry)
343 #define PIPELINE_PARSE_ERR_INV_ENT(exp, section, entry) \
344 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": invalid entry " \
345 "\"%s\"", section, entry)
347 #define PIPELINE_PARSE_ERR_MANDATORY(exp, section, entry) \
348 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": mandatory " \
349 "entry \"%s\" is missing", section, entry)