4 * Copyright(c) 2010-2015 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_READER_IPV4_FRAG,
49 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG,
50 PIPELINE_PORT_IN_SCHED_READER,
51 PIPELINE_PORT_IN_SOURCE,
54 struct pipeline_port_in_params {
55 enum pipeline_port_in_type type;
57 struct rte_port_ethdev_reader_params ethdev;
58 struct rte_port_ring_reader_params ring;
59 struct rte_port_ring_reader_ipv4_frag_params ring_ipv4_frag;
60 struct rte_port_ring_reader_ipv6_frag_params ring_ipv6_frag;
61 struct rte_port_sched_reader_params sched;
62 struct rte_port_source_params source;
68 pipeline_port_in_params_convert(struct pipeline_port_in_params *p)
71 case PIPELINE_PORT_IN_ETHDEV_READER:
72 return (void *) &p->params.ethdev;
73 case PIPELINE_PORT_IN_RING_READER:
74 return (void *) &p->params.ring;
75 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
76 return (void *) &p->params.ring_ipv4_frag;
77 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
78 return (void *) &p->params.ring_ipv6_frag;
79 case PIPELINE_PORT_IN_SCHED_READER:
80 return (void *) &p->params.sched;
81 case PIPELINE_PORT_IN_SOURCE:
82 return (void *) &p->params.source;
88 static inline struct rte_port_in_ops *
89 pipeline_port_in_params_get_ops(struct pipeline_port_in_params *p)
92 case PIPELINE_PORT_IN_ETHDEV_READER:
93 return &rte_port_ethdev_reader_ops;
94 case PIPELINE_PORT_IN_RING_READER:
95 return &rte_port_ring_reader_ops;
96 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
97 return &rte_port_ring_reader_ipv4_frag_ops;
98 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
99 return &rte_port_ring_reader_ipv6_frag_ops;
100 case PIPELINE_PORT_IN_SCHED_READER:
101 return &rte_port_sched_reader_ops;
102 case PIPELINE_PORT_IN_SOURCE:
103 return &rte_port_source_ops;
109 enum pipeline_port_out_type {
110 PIPELINE_PORT_OUT_ETHDEV_WRITER,
111 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP,
112 PIPELINE_PORT_OUT_RING_WRITER,
113 PIPELINE_PORT_OUT_RING_WRITER_NODROP,
114 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS,
115 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS,
116 PIPELINE_PORT_OUT_SCHED_WRITER,
117 PIPELINE_PORT_OUT_SINK,
120 struct pipeline_port_out_params {
121 enum pipeline_port_out_type type;
123 struct rte_port_ethdev_writer_params ethdev;
124 struct rte_port_ethdev_writer_nodrop_params ethdev_nodrop;
125 struct rte_port_ring_writer_params ring;
126 struct rte_port_ring_writer_nodrop_params ring_nodrop;
127 struct rte_port_ring_writer_ipv4_ras_params ring_ipv4_ras;
128 struct rte_port_ring_writer_ipv6_ras_params ring_ipv6_ras;
129 struct rte_port_sched_writer_params sched;
134 pipeline_port_out_params_convert(struct pipeline_port_out_params *p)
137 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
138 return (void *) &p->params.ethdev;
139 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
140 return (void *) &p->params.ethdev_nodrop;
141 case PIPELINE_PORT_OUT_RING_WRITER:
142 return (void *) &p->params.ring;
143 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
144 return (void *) &p->params.ring_nodrop;
145 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
146 return (void *) &p->params.ring_ipv4_ras;
147 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
148 return (void *) &p->params.ring_ipv6_ras;
149 case PIPELINE_PORT_OUT_SCHED_WRITER:
150 return (void *) &p->params.sched;
151 case PIPELINE_PORT_OUT_SINK:
158 pipeline_port_out_params_get_ops(struct pipeline_port_out_params *p)
161 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
162 return &rte_port_ethdev_writer_ops;
163 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
164 return &rte_port_ethdev_writer_nodrop_ops;
165 case PIPELINE_PORT_OUT_RING_WRITER:
166 return &rte_port_ring_writer_ops;
167 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
168 return &rte_port_ring_writer_nodrop_ops;
169 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
170 return &rte_port_ring_writer_ipv4_ras_ops;
171 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
172 return &rte_port_ring_writer_ipv6_ras_ops;
173 case PIPELINE_PORT_OUT_SCHED_WRITER:
174 return &rte_port_sched_writer_ops;
175 case PIPELINE_PORT_OUT_SINK:
176 return &rte_port_sink_ops;
182 #ifndef PIPELINE_NAME_SIZE
183 #define PIPELINE_NAME_SIZE 32
186 #ifndef PIPELINE_MAX_PORT_IN
187 #define PIPELINE_MAX_PORT_IN 16
190 #ifndef PIPELINE_MAX_PORT_OUT
191 #define PIPELINE_MAX_PORT_OUT 16
194 #ifndef PIPELINE_MAX_TABLES
195 #define PIPELINE_MAX_TABLES 16
198 #ifndef PIPELINE_MAX_MSGQ_IN
199 #define PIPELINE_MAX_MSGQ_IN 16
202 #ifndef PIPELINE_MAX_MSGQ_OUT
203 #define PIPELINE_MAX_MSGQ_OUT 16
206 #ifndef PIPELINE_MAX_ARGS
207 #define PIPELINE_MAX_ARGS 32
210 struct pipeline_params {
211 char name[PIPELINE_NAME_SIZE];
213 struct pipeline_port_in_params port_in[PIPELINE_MAX_PORT_IN];
214 struct pipeline_port_out_params port_out[PIPELINE_MAX_PORT_OUT];
215 struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
216 struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
219 uint32_t n_ports_out;
224 char *args_name[PIPELINE_MAX_ARGS];
225 char *args_value[PIPELINE_MAX_ARGS];
232 * Pipeline type back-end operations
235 typedef void* (*pipeline_be_op_init)(struct pipeline_params *params,
238 typedef int (*pipeline_be_op_free)(void *pipeline);
240 typedef int (*pipeline_be_op_run)(void *pipeline);
242 typedef int (*pipeline_be_op_timer)(void *pipeline);
244 typedef int (*pipeline_be_op_track)(void *pipeline,
248 struct pipeline_be_ops {
249 pipeline_be_op_init f_init;
250 pipeline_be_op_free f_free;
251 pipeline_be_op_run f_run;
252 pipeline_be_op_timer f_timer;
253 pipeline_be_op_track f_track;