pipeline: add SWX pipeline output port
[dpdk.git] / lib / librte_pipeline / rte_swx_pipeline.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 #ifndef __INCLUDE_RTE_SWX_PIPELINE_H__
5 #define __INCLUDE_RTE_SWX_PIPELINE_H__
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /**
12  * @file
13  * RTE SWX Pipeline
14  */
15
16 #include <stddef.h>
17 #include <stdint.h>
18
19 #include <rte_compat.h>
20
21 #include "rte_swx_port.h"
22
23 /** Name size. */
24 #ifndef RTE_SWX_NAME_SIZE
25 #define RTE_SWX_NAME_SIZE 64
26 #endif
27 /*
28  * Pipeline setup and operation
29  */
30
31 /** Pipeline opaque data structure. */
32 struct rte_swx_pipeline;
33
34 /**
35  * Pipeline configure
36  *
37  * @param[out] p
38  *   Pipeline handle. Must point to valid memory. Contains valid pipeline handle
39  *   when the function returns successfully.
40  * @param[in] numa_node
41  *   Non-Uniform Memory Access (NUMA) node.
42  * @return
43  *   0 on success or the following error codes otherwise:
44  *   -EINVAL: Invalid argument;
45  *   -ENOMEM: Not enough space/cannot allocate memory.
46  */
47 __rte_experimental
48 int
49 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
50                         int numa_node);
51
52 /*
53  * Pipeline input ports
54  */
55
56 /**
57  * Pipeline input port type register
58  *
59  * @param[in] p
60  *   Pipeline handle.
61  * @param[in] name
62  *   Input port type name.
63  * @param[in] ops
64  *   Input port type operations.
65  * @return
66  *   0 on success or the following error codes otherwise:
67  *   -EINVAL: Invalid argument;
68  *   -ENOMEM: Not enough space/cannot allocate memory;
69  *   -EEXIST: Input port type with this name already exists.
70  */
71 __rte_experimental
72 int
73 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
74                                        const char *name,
75                                        struct rte_swx_port_in_ops *ops);
76
77 /**
78  * Pipeline input port configure
79  *
80  * @param[in] p
81  *   Pipeline handle.
82  * @param[in] port_id
83  *   Input port ID.
84  * @param[in] port_type_name
85  *   Existing input port type name.
86  * @param[in] args
87  *   Input port creation arguments.
88  * @return
89  *   0 on success or the following error codes otherwise:
90  *   -EINVAL: Invalid argument;
91  *   -ENOMEM: Not enough space/cannot allocate memory;
92  *   -ENODEV: Input port object creation error.
93  */
94 __rte_experimental
95 int
96 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
97                                 uint32_t port_id,
98                                 const char *port_type_name,
99                                 void *args);
100
101 /*
102  * Pipeline output ports
103  */
104
105 /**
106  * Pipeline output port type register
107  *
108  * @param[in] p
109  *   Pipeline handle.
110  * @param[in] name
111  *   Output port type name.
112  * @param[in] ops
113  *   Output port type operations.
114  * @return
115  *   0 on success or the following error codes otherwise:
116  *   -EINVAL: Invalid argument;
117  *   -ENOMEM: Not enough space/cannot allocate memory;
118  *   -EEXIST: Output port type with this name already exists.
119  */
120 __rte_experimental
121 int
122 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
123                                         const char *name,
124                                         struct rte_swx_port_out_ops *ops);
125
126 /**
127  * Pipeline output port configure
128  *
129  * @param[in] p
130  *   Pipeline handle.
131  * @param[in] port_id
132  *   Output port ID.
133  * @param[in] port_type_name
134  *   Existing output port type name.
135  * @param[in] args
136  *   Output port creation arguments.
137  * @return
138  *   0 on success or the following error codes otherwise:
139  *   -EINVAL: Invalid argument;
140  *   -ENOMEM: Not enough space/cannot allocate memory;
141  *   -ENODEV: Output port object creation error.
142  */
143 __rte_experimental
144 int
145 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
146                                  uint32_t port_id,
147                                  const char *port_type_name,
148                                  void *args);
149
150 /**
151  * Pipeline build
152  *
153  * Once called, the pipeline build operation marks the end of pipeline
154  * configuration. At this point, all the internal data structures needed to run
155  * the pipeline are built.
156  *
157  * @param[in] p
158  *   Pipeline handle.
159  * @return
160  *   0 on success or the following error codes otherwise:
161  *   -EINVAL: Invalid argument;
162  *   -ENOMEM: Not enough space/cannot allocate memory;
163  *   -EEXIST: Pipeline was already built successfully.
164  */
165 __rte_experimental
166 int
167 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
168
169 /**
170  * Pipeline free
171  *
172  * @param[in] p
173  *   Pipeline handle.
174  */
175 __rte_experimental
176 void
177 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
178
179 #ifdef __cplusplus
180 }
181 #endif
182
183 #endif