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_BE_H__
18 #define __INCLUDE_PIPELINE_BE_H__
20 #include <rte_port_ethdev.h>
21 #include <rte_port_ring.h>
22 #include <rte_port_frag.h>
23 #include <rte_port_ras.h>
24 #include <rte_port_sched.h>
25 #include <rte_port_source_sink.h>
26 #include <rte_pipeline.h>
28 enum pipeline_port_in_type {
29 PIPELINE_PORT_IN_ETHDEV_READER,
30 PIPELINE_PORT_IN_RING_READER,
31 PIPELINE_PORT_IN_RING_MULTI_READER,
32 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG,
33 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG,
34 PIPELINE_PORT_IN_SCHED_READER,
35 PIPELINE_PORT_IN_SOURCE,
38 struct pipeline_port_in_params {
39 enum pipeline_port_in_type type;
41 struct rte_port_ethdev_reader_params ethdev;
42 struct rte_port_ring_reader_params ring;
43 struct rte_port_ring_multi_reader_params ring_multi;
44 struct rte_port_ring_reader_ipv4_frag_params ring_ipv4_frag;
45 struct rte_port_ring_reader_ipv6_frag_params ring_ipv6_frag;
46 struct rte_port_sched_reader_params sched;
47 struct rte_port_source_params source;
53 pipeline_port_in_params_convert(struct pipeline_port_in_params *p)
56 case PIPELINE_PORT_IN_ETHDEV_READER:
57 return (void *) &p->params.ethdev;
58 case PIPELINE_PORT_IN_RING_READER:
59 return (void *) &p->params.ring;
60 case PIPELINE_PORT_IN_RING_MULTI_READER:
61 return (void *) &p->params.ring_multi;
62 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
63 return (void *) &p->params.ring_ipv4_frag;
64 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
65 return (void *) &p->params.ring_ipv6_frag;
66 case PIPELINE_PORT_IN_SCHED_READER:
67 return (void *) &p->params.sched;
68 case PIPELINE_PORT_IN_SOURCE:
69 return (void *) &p->params.source;
75 static inline struct rte_port_in_ops *
76 pipeline_port_in_params_get_ops(struct pipeline_port_in_params *p)
79 case PIPELINE_PORT_IN_ETHDEV_READER:
80 return &rte_port_ethdev_reader_ops;
81 case PIPELINE_PORT_IN_RING_READER:
82 return &rte_port_ring_reader_ops;
83 case PIPELINE_PORT_IN_RING_MULTI_READER:
84 return &rte_port_ring_multi_reader_ops;
85 case PIPELINE_PORT_IN_RING_READER_IPV4_FRAG:
86 return &rte_port_ring_reader_ipv4_frag_ops;
87 case PIPELINE_PORT_IN_RING_READER_IPV6_FRAG:
88 return &rte_port_ring_reader_ipv6_frag_ops;
89 case PIPELINE_PORT_IN_SCHED_READER:
90 return &rte_port_sched_reader_ops;
91 case PIPELINE_PORT_IN_SOURCE:
92 return &rte_port_source_ops;
98 enum pipeline_port_out_type {
99 PIPELINE_PORT_OUT_ETHDEV_WRITER,
100 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP,
101 PIPELINE_PORT_OUT_RING_WRITER,
102 PIPELINE_PORT_OUT_RING_MULTI_WRITER,
103 PIPELINE_PORT_OUT_RING_WRITER_NODROP,
104 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP,
105 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS,
106 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS,
107 PIPELINE_PORT_OUT_SCHED_WRITER,
108 PIPELINE_PORT_OUT_SINK,
111 struct pipeline_port_out_params {
112 enum pipeline_port_out_type type;
114 struct rte_port_ethdev_writer_params ethdev;
115 struct rte_port_ethdev_writer_nodrop_params ethdev_nodrop;
116 struct rte_port_ring_writer_params ring;
117 struct rte_port_ring_multi_writer_params ring_multi;
118 struct rte_port_ring_writer_nodrop_params ring_nodrop;
119 struct rte_port_ring_multi_writer_nodrop_params ring_multi_nodrop;
120 struct rte_port_ring_writer_ipv4_ras_params ring_ipv4_ras;
121 struct rte_port_ring_writer_ipv6_ras_params ring_ipv6_ras;
122 struct rte_port_sched_writer_params sched;
123 struct rte_port_sink_params sink;
128 pipeline_port_out_params_convert(struct pipeline_port_out_params *p)
131 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
132 return (void *) &p->params.ethdev;
133 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
134 return (void *) &p->params.ethdev_nodrop;
135 case PIPELINE_PORT_OUT_RING_WRITER:
136 return (void *) &p->params.ring;
137 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
138 return (void *) &p->params.ring_multi;
139 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
140 return (void *) &p->params.ring_nodrop;
141 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
142 return (void *) &p->params.ring_multi_nodrop;
143 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
144 return (void *) &p->params.ring_ipv4_ras;
145 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
146 return (void *) &p->params.ring_ipv6_ras;
147 case PIPELINE_PORT_OUT_SCHED_WRITER:
148 return (void *) &p->params.sched;
149 case PIPELINE_PORT_OUT_SINK:
150 return (void *) &p->params.sink;
157 pipeline_port_out_params_get_ops(struct pipeline_port_out_params *p)
160 case PIPELINE_PORT_OUT_ETHDEV_WRITER:
161 return &rte_port_ethdev_writer_ops;
162 case PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP:
163 return &rte_port_ethdev_writer_nodrop_ops;
164 case PIPELINE_PORT_OUT_RING_WRITER:
165 return &rte_port_ring_writer_ops;
166 case PIPELINE_PORT_OUT_RING_MULTI_WRITER:
167 return &rte_port_ring_multi_writer_ops;
168 case PIPELINE_PORT_OUT_RING_WRITER_NODROP:
169 return &rte_port_ring_writer_nodrop_ops;
170 case PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP:
171 return &rte_port_ring_multi_writer_nodrop_ops;
172 case PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS:
173 return &rte_port_ring_writer_ipv4_ras_ops;
174 case PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS:
175 return &rte_port_ring_writer_ipv6_ras_ops;
176 case PIPELINE_PORT_OUT_SCHED_WRITER:
177 return &rte_port_sched_writer_ops;
178 case PIPELINE_PORT_OUT_SINK:
179 return &rte_port_sink_ops;
185 #ifndef PIPELINE_NAME_SIZE
186 #define PIPELINE_NAME_SIZE 64
189 #ifndef PIPELINE_MAX_PORT_IN
190 #define PIPELINE_MAX_PORT_IN 64
193 #ifndef PIPELINE_MAX_PORT_OUT
194 #define PIPELINE_MAX_PORT_OUT 64
197 #ifndef PIPELINE_MAX_TABLES
198 #define PIPELINE_MAX_TABLES 64
201 #ifndef PIPELINE_MAX_MSGQ_IN
202 #define PIPELINE_MAX_MSGQ_IN 64
205 #ifndef PIPELINE_MAX_MSGQ_OUT
206 #define PIPELINE_MAX_MSGQ_OUT 64
209 #ifndef PIPELINE_MAX_ARGS
210 #define PIPELINE_MAX_ARGS 64
213 struct pipeline_params {
214 char name[PIPELINE_NAME_SIZE];
216 struct pipeline_port_in_params port_in[PIPELINE_MAX_PORT_IN];
217 struct pipeline_port_out_params port_out[PIPELINE_MAX_PORT_OUT];
218 struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
219 struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
222 uint32_t n_ports_out;
227 char *args_name[PIPELINE_MAX_ARGS];
228 char *args_value[PIPELINE_MAX_ARGS];
235 * Pipeline type back-end operations
238 typedef void* (*pipeline_be_op_init)(struct pipeline_params *params,
241 typedef int (*pipeline_be_op_free)(void *pipeline);
243 typedef int (*pipeline_be_op_run)(void *pipeline);
245 typedef int (*pipeline_be_op_timer)(void *pipeline);
247 typedef int (*pipeline_be_op_track)(void *pipeline,
251 struct pipeline_be_ops {
252 pipeline_be_op_init f_init;
253 pipeline_be_op_free f_free;
254 pipeline_be_op_run f_run;
255 pipeline_be_op_timer f_timer;
256 pipeline_be_op_track f_track;
259 /* Pipeline specific config parse error messages */
260 #define PIPELINE_ARG_CHECK(exp, fmt, ...) \
263 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
268 #define PIPELINE_PARSE_ERR_INV_VAL(exp, section, entry, val) \
269 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
270 "has invalid value (\"%s\")", section, entry, val)
272 #define PIPELINE_PARSE_ERR_OUT_RNG(exp, section, entry, val) \
273 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": entry \"%s\" " \
274 "value is out of range (\"%s\")", section, entry, val)
276 #define PIPELINE_PARSE_ERR_DUPLICATE(exp, section, entry) \
277 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": duplicated " \
278 "entry \"%s\"", section, entry)
280 #define PIPELINE_PARSE_ERR_INV_ENT(exp, section, entry) \
281 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": invalid entry " \
282 "\"%s\"", section, entry)
284 #define PIPELINE_PARSE_ERR_MANDATORY(exp, section, entry) \
285 PIPELINE_ARG_CHECK(exp, "Parse error in section \"%s\": mandatory " \
286 "entry \"%s\" is missing", section, entry)