doc: update firmware/driver mapping table for i40e
[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 #include <stdio.h>
19
20 #include <rte_compat.h>
21
22 #include "rte_swx_port.h"
23 #include "rte_swx_table.h"
24 #include "rte_swx_extern.h"
25
26 /** Name size. */
27 #ifndef RTE_SWX_NAME_SIZE
28 #define RTE_SWX_NAME_SIZE 64
29 #endif
30
31 /** Instruction size. */
32 #ifndef RTE_SWX_INSTRUCTION_SIZE
33 #define RTE_SWX_INSTRUCTION_SIZE 256
34 #endif
35
36 /** Instruction tokens. */
37 #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX
38 #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16
39 #endif
40
41 /*
42  * Pipeline setup and operation
43  */
44
45 /** Pipeline opaque data structure. */
46 struct rte_swx_pipeline;
47
48 /**
49  * Pipeline configure
50  *
51  * @param[out] p
52  *   Pipeline handle. Must point to valid memory. Contains valid pipeline handle
53  *   when the function returns successfully.
54  * @param[in] numa_node
55  *   Non-Uniform Memory Access (NUMA) node.
56  * @return
57  *   0 on success or the following error codes otherwise:
58  *   -EINVAL: Invalid argument;
59  *   -ENOMEM: Not enough space/cannot allocate memory.
60  */
61 __rte_experimental
62 int
63 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
64                         int numa_node);
65
66 /*
67  * Pipeline input ports
68  */
69
70 /**
71  * Pipeline input port type register
72  *
73  * @param[in] p
74  *   Pipeline handle.
75  * @param[in] name
76  *   Input port type name.
77  * @param[in] ops
78  *   Input port type operations.
79  * @return
80  *   0 on success or the following error codes otherwise:
81  *   -EINVAL: Invalid argument;
82  *   -ENOMEM: Not enough space/cannot allocate memory;
83  *   -EEXIST: Input port type with this name already exists.
84  */
85 __rte_experimental
86 int
87 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
88                                        const char *name,
89                                        struct rte_swx_port_in_ops *ops);
90
91 /**
92  * Pipeline input port configure
93  *
94  * @param[in] p
95  *   Pipeline handle.
96  * @param[in] port_id
97  *   Input port ID.
98  * @param[in] port_type_name
99  *   Existing input port type name.
100  * @param[in] args
101  *   Input port creation arguments.
102  * @return
103  *   0 on success or the following error codes otherwise:
104  *   -EINVAL: Invalid argument;
105  *   -ENOMEM: Not enough space/cannot allocate memory;
106  *   -ENODEV: Input port object creation error.
107  */
108 __rte_experimental
109 int
110 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
111                                 uint32_t port_id,
112                                 const char *port_type_name,
113                                 void *args);
114
115 /*
116  * Pipeline output ports
117  */
118
119 /**
120  * Pipeline output port type register
121  *
122  * @param[in] p
123  *   Pipeline handle.
124  * @param[in] name
125  *   Output port type name.
126  * @param[in] ops
127  *   Output port type operations.
128  * @return
129  *   0 on success or the following error codes otherwise:
130  *   -EINVAL: Invalid argument;
131  *   -ENOMEM: Not enough space/cannot allocate memory;
132  *   -EEXIST: Output port type with this name already exists.
133  */
134 __rte_experimental
135 int
136 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
137                                         const char *name,
138                                         struct rte_swx_port_out_ops *ops);
139
140 /**
141  * Pipeline output port configure
142  *
143  * @param[in] p
144  *   Pipeline handle.
145  * @param[in] port_id
146  *   Output port ID.
147  * @param[in] port_type_name
148  *   Existing output port type name.
149  * @param[in] args
150  *   Output port creation arguments.
151  * @return
152  *   0 on success or the following error codes otherwise:
153  *   -EINVAL: Invalid argument;
154  *   -ENOMEM: Not enough space/cannot allocate memory;
155  *   -ENODEV: Output port object creation error.
156  */
157 __rte_experimental
158 int
159 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
160                                  uint32_t port_id,
161                                  const char *port_type_name,
162                                  void *args);
163
164 /*
165  * Extern objects and functions
166  */
167
168 /**
169  * Pipeline extern type register
170  *
171  * @param[in] p
172  *   Pipeline handle.
173  * @param[in] name
174  *   Extern type name.
175  * @param[in] mailbox_struct_type_name
176  *   Name of existing struct type used to define the mailbox size and layout for
177  *   the extern objects that are instances of this type. Each extern object gets
178  *   its own mailbox, which is used to pass the input arguments to the member
179  *   functions and retrieve the output results.
180  * @param[in] constructor
181  *   Function used to create the extern objects that are instances of this type.
182  * @param[in] destructor
183  *   Function used to free the extern objects that are instances of  this type.
184  * @return
185  *   0 on success or the following error codes otherwise:
186  *   -EINVAL: Invalid argument;
187  *   -ENOMEM: Not enough space/cannot allocate memory;
188  *   -EEXIST: Extern type with this name already exists.
189  */
190 __rte_experimental
191 int
192 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
193         const char *name,
194         const char *mailbox_struct_type_name,
195         rte_swx_extern_type_constructor_t constructor,
196         rte_swx_extern_type_destructor_t destructor);
197
198 /**
199  * Pipeline extern type member function register
200  *
201  * @param[in] p
202  *   Pipeline handle.
203  * @param[in] extern_type_name
204  *   Existing extern type name.
205  * @param[in] name
206  *   Name for the new member function to be added to the extern type.
207  * @param[in] member_func
208  *   The new member function.
209  * @return
210  *   0 on success or the following error codes otherwise:
211  *   -EINVAL: Invalid argument;
212  *   -ENOMEM: Not enough space/cannot allocate memory;
213  *   -EEXIST: Member function with this name already exists for this type;
214  *   -ENOSPC: Maximum number of member functions reached for this type.
215  */
216 __rte_experimental
217 int
218 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
219         const char *extern_type_name,
220         const char *name,
221         rte_swx_extern_type_member_func_t member_func);
222
223 /**
224  * Pipeline extern object configure
225  *
226  * Instantiate a given extern type to create new extern object.
227  *
228  * @param[in] p
229  *   Pipeline handle.
230  * @param[in] extern_type_name
231  *   Existing extern type name.
232  * @param[in] name
233  *   Name for the new object instantiating the extern type.
234  * @param[in] args
235  *   Extern object constructor arguments.
236  * @return
237  *   0 on success or the following error codes otherwise:
238  *   -EINVAL: Invalid argument;
239  *   -ENOMEM: Not enough space/cannot allocate memory;
240  *   -EEXIST: Extern object with this name already exists;
241  *   -ENODEV: Extern object constructor error.
242  */
243 __rte_experimental
244 int
245 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
246                                       const char *extern_type_name,
247                                       const char *name,
248                                       const char *args);
249
250 /**
251  * Pipeline extern function register
252  *
253  * @param[in] p
254  *   Pipeline handle.
255  * @param[in] name
256  *   Extern function name.
257  * @param[in] mailbox_struct_type_name
258  *   Name of existing struct type used to define the mailbox size and layout for
259  *   this extern function. The mailbox is used to pass the input arguments to
260  *   the extern function and retrieve the output results.
261  * @param[in] func
262  *   The extern function.
263  * @return
264  *   0 on success or the following error codes otherwise:
265  *   -EINVAL: Invalid argument;
266  *   -ENOMEM: Not enough space/cannot allocate memory;
267  *   -EEXIST: Extern function with this name already exists.
268  */
269 __rte_experimental
270 int
271 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
272                                       const char *name,
273                                       const char *mailbox_struct_type_name,
274                                       rte_swx_extern_func_t func);
275
276 /*
277  * Packet headers and meta-data
278  */
279
280 /** Structure (struct) field. */
281 struct rte_swx_field_params {
282         /** Struct field name. */
283         const char *name;
284
285         /** Struct field size (in bits).
286          * Restriction: All struct fields must be a multiple of 8 bits.
287          * Restriction: All struct fields must be no greater than 64 bits.
288          */
289         uint32_t n_bits;
290 };
291
292 /**
293  * Pipeline struct type register
294  *
295  * Structs are used extensively in many part of the pipeline to define the size
296  * and layout of a specific memory piece such as: headers, meta-data, action
297  * data stored in a table entry, mailboxes for extern objects and functions.
298  * Similar to C language structs, they are a well defined sequence of fields,
299  * with each field having a unique name and a constant size.
300  *
301  * @param[in] p
302  *   Pipeline handle.
303  * @param[in] name
304  *   Struct type name.
305  * @param[in] fields
306  *   The sequence of struct fields.
307  * @param[in] n_fields
308  *   The number of struct fields.
309  * @return
310  *   0 on success or the following error codes otherwise:
311  *   -EINVAL: Invalid argument;
312  *   -ENOMEM: Not enough space/cannot allocate memory;
313  *   -EEXIST: Struct type with this name already exists.
314  */
315 __rte_experimental
316 int
317 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
318                                       const char *name,
319                                       struct rte_swx_field_params *fields,
320                                       uint32_t n_fields);
321
322 /**
323  * Pipeline packet header register
324  *
325  * @param[in] p
326  *   Pipeline handle.
327  * @param[in] name
328  *   Header name.
329  * @param[in] struct_type_name
330  *   The struct type instantiated by this packet header.
331  * @return
332  *   0 on success or the following error codes otherwise:
333  *   -EINVAL: Invalid argument;
334  *   -ENOMEM: Not enough space/cannot allocate memory;
335  *   -EEXIST: Header with this name already exists;
336  *   -ENOSPC: Maximum number of headers reached for the pipeline.
337  */
338 __rte_experimental
339 int
340 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
341                                         const char *name,
342                                         const char *struct_type_name);
343
344 /**
345  * Pipeline packet meta-data register
346  *
347  * @param[in] p
348  *   Pipeline handle.
349  * @param[in] struct_type_name
350  *   The struct type instantiated by the packet meta-data.
351  * @return
352  *   0 on success or the following error codes otherwise:
353  *   -EINVAL: Invalid argument.
354  */
355 __rte_experimental
356 int
357 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
358                                           const char *struct_type_name);
359
360 /*
361  * Instructions
362  */
363
364 /**
365  * Instruction operands:
366  *
367  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
368  *<pre>|     | Description               | Format           | DST | SRC |</pre>
369  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
370  *<pre>| hdr | Header                    | h.header         |     |     |</pre>
371  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
372  *<pre>| act | Action                    | ACTION           |     |     |</pre>
373  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
374  *<pre>| tbl | Table                     | TABLE            |     |     |</pre>
375  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
376  *<pre>| H   | Header field              | h.header.field   | YES | YES |</pre>
377  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
378  *<pre>| M   | Meta-data field           | m.field          | YES | YES |</pre>
379  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
380  *<pre>| E   | Extern obj mailbox field  | e.ext_obj.field  | YES | YES |</pre>
381  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
382  *<pre>| F   | Extern func mailbox field | f.ext_func.field | YES | YES |</pre>
383  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
384  *<pre>| T   | Table action data field   | t.header.field   | NO  | YES |</pre>
385  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
386  *<pre>| I   | Immediate value (64-bit)  | h.header.field   | NO  | YES |</pre>
387  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
388  *
389  * Instruction set:
390  *
391  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
392  *<pre>| Instr.     | Instruction          | Instruction       | 1st  | 2nd    |</pre>
393  *<pre>| Name       | Description          | Format            | opnd.| opnd.  |</pre>
394  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
395  *<pre>| rx         | Receive one pkt      | rx m.port_in      | M    |        |</pre>
396  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
397  *<pre>| tx         | Transmit one pkt     | tx m.port_out     | M    |        |</pre>
398  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
399  *<pre>| extract    | Extract one hdr      | extract h.hdr     | hdr  |        |</pre>
400  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
401  *<pre>| emit       | Emit one hdr         | emit h.hdr        | hdr  |        |</pre>
402  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
403  *<pre>| validate   | Validate one hdr     | validate h.hdr    | hdr  |        |</pre>
404  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
405  *<pre>| invalidate | Invalidate one hdr   | invalidate h.hdr  | hdr  |        |</pre>
406  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
407  *<pre>| mov        | dst = src            | mov dst src       | HMEF | HMEFTI |</pre>
408  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
409  *<pre>| dma        | memcpy(h.hdr,        | dma h.hdr t.field | hdr  | T      |</pre>
410  *<pre>|            |    &t.field,         |                   |      |        |</pre>
411  *<pre>|            |    sizeof(h.hdr)     |                   |      |        |</pre>
412  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
413  *<pre>| add        | dst += src           | add dst src       | HMEF | HMEFTI |</pre>
414  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
415  *<pre>| sub        | dst -= src           | add dst src       | HMEF | HMEFTI |</pre>
416  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
417  *<pre>| ckadd      | Checksum add: dst =  | add dst src       | HMEF | HMEFTI |</pre>
418  *<pre>|            | dst '+ src[0:1] '+   |                   |      | or hdr |</pre>
419  *<pre>|            | src[2:3] '+ ...      |                   |      |        |</pre>
420  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
421  *<pre>| cksub      | Checksum subtract:   | add dst src       | HMEF | HMEFTI |</pre>
422  *<pre>|            | dst = dst '- src     |                   |      |        |</pre>
423  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
424  *<pre>| and        | dst &= src           | and dst src       | HMEF | HMEFTI |</pre>
425  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
426  *<pre>| or         | dst |= src           | or  dst src       | HMEF | HMEFTI |</pre>
427  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
428  *<pre>| xor        | dst ^= src           | xor dst src       | HMEF | HMEFTI |</pre>
429  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
430  *<pre>| shl        | dst <<= src          | shl dst src       | HMEF | HMEFTI |</pre>
431  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
432  *<pre>| shr        | dst >>= src          | shr dst src       | HMEF | HMEFTI |</pre>
433  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
434  *<pre>| table      | Table lookup         | table TABLE       | tbl  |        |</pre>
435  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
436  *<pre>| extern     | Ext obj member func  | extern e.obj.mfunc| ext  |        |</pre>
437  *<pre>|            | call or ext func call| extern f.func     |      |        |</pre>
438  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
439  *<pre>| jmp        | Unconditional jump   | jmp LABEL         |      |        |</pre>
440  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
441  *<pre>| jmpv       | Jump if hdr is valid | jmpv LABEL h.hdr  | hdr  |        |</pre>
442  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
443  *<pre>| jmpnv      | Jump if hdr is inval | jmpnv LABEL h.hdr | hdr  |        |</pre>
444  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
445  *<pre>| jmph       | Jump if tbl lkp hit  | jmph LABEL        |      |        |</pre>
446  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
447  *<pre>| jmpnh      | Jump if tbl lkp miss | jmpnh LABEL       |      |        |</pre>
448  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
449  *<pre>| jmpa       | Jump if action run   | jmpa LABEL ACTION | act  |        |</pre>
450  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
451  *<pre>| jmpna      | Jump if act not run  | jmpna LABEL ACTION| act  |        |</pre>
452  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
453  *<pre>| jmpeq      | Jump if (a == b)     | jmpeq LABEL a b   | HMEFT| HMEFTI |</pre>
454  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
455  *<pre>| jmpneq     | Jump if (a != b)     | jmpneq LABEL a b  | HMEFT| HMEFTI |</pre>
456  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
457  *<pre>| jmplt      | Jump if (a < b)      | jmplt LABEL a b   | HMEFT| HMEFTI |</pre>
458  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
459  *<pre>| jmpgt      | Jump if (a > b)      | jmpgt LABEL a b   | HMEFT| HMEFTI |</pre>
460  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
461  *<pre>| return     | Return from action   | return            |      |        |</pre>
462  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
463  *
464  * At initialization time, the pipeline and action instructions (including the
465  * symbolic name operands) are translated to internal data structures that are
466  * used at run-time.
467  */
468
469 /*
470  * Pipeline action
471  */
472
473 /**
474  * Pipeline action configure
475  *
476  * @param[in] p
477  *   Pipeline handle.
478  * @param[in] name
479  *   Action name.
480  * @param[in] args_struct_type_name
481  *   The struct type instantiated by the action data. The action data represent
482  *   the action arguments that are stored in the table entry together with the
483  *   action ID. Set to NULL when the action does not have any arguments.
484  * @param[in] instructions
485  *   Action instructions.
486  * @param[in] n_instructions
487  *   Number of action instructions.
488  * @return
489  *   0 on success or the following error codes otherwise:
490  *   -EINVAL: Invalid argument;
491  *   -ENOMEM: Not enough space/cannot allocate memory;
492  *   -EEXIST: Action with this name already exists.
493  */
494 __rte_experimental
495 int
496 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
497                                const char *name,
498                                const char *args_struct_type_name,
499                                const char **instructions,
500                                uint32_t n_instructions);
501
502 /*
503  * Pipeline table
504  */
505
506 /**
507  * Pipeline table type register
508  *
509  * @param[in] p
510  *   Pipeline handle.
511  * @param[in] name
512  *   Table type name.
513  * @param[in] match_type
514  *   Match type implemented by the new table type.
515  * @param[in] ops
516  *   Table type operations.
517  * @return
518  *   0 on success or the following error codes otherwise:
519  *   -EINVAL: Invalid argument;
520  *   -ENOMEM: Not enough space/cannot allocate memory;
521  *   -EEXIST: Table type with this name already exists.
522  */
523 __rte_experimental
524 int
525 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
526                                      const char *name,
527                                      enum rte_swx_table_match_type match_type,
528                                      struct rte_swx_table_ops *ops);
529
530 /** Match field parameters. */
531 struct rte_swx_match_field_params {
532         /** Match field name. Must be either a field of one of the registered
533          * packet headers ("h.header.field") or a field of the registered
534          * meta-data ("m.field").
535          */
536         const char *name;
537
538         /** Match type of the field. */
539         enum rte_swx_table_match_type match_type;
540 };
541
542 /** Pipeline table parameters. */
543 struct rte_swx_pipeline_table_params {
544         /** The set of match fields for the current table.
545          * Restriction: All the match fields of the current table need to be
546          * part of the same struct, i.e. either all the match fields are part of
547          * the same header or all the match fields are part of the meta-data.
548          */
549         struct rte_swx_match_field_params *fields;
550
551         /** The number of match fields for the current table. If set to zero, no
552          * "regular" entries (i.e. entries other than the default entry) can be
553          * added to the current table and the match process always results in
554          * lookup miss.
555          */
556         uint32_t n_fields;
557
558         /** The set of actions for the current table. */
559         const char **action_names;
560
561         /** The number of actions for the current table. Must be at least one.
562          */
563         uint32_t n_actions;
564
565         /** The default table action that gets executed on lookup miss. Must be
566          * one of the table actions included in the *action_names*.
567          */
568         const char *default_action_name;
569
570         /** Default action data. The size of this array is the action data size
571          * of the default action. Must be NULL if the default action data size
572          * is zero.
573          */
574         uint8_t *default_action_data;
575
576         /** If non-zero (true), then the default action of the current table
577          * cannot be changed. If zero (false), then the default action can be
578          * changed in the future with another action from the *action_names*
579          * list.
580          */
581         int default_action_is_const;
582 };
583
584 /**
585  * Pipeline table configure
586  *
587  * @param[out] p
588  *   Pipeline handle.
589  * @param[in] name
590  *   Table name.
591  * @param[in] params
592  *   Table parameters.
593  * @param[in] recommended_table_type_name
594  *   Recommended table type. Typically set to NULL. Useful as guidance when
595  *   there are multiple table types registered for the match type of the table,
596  *   as determined from the table match fields specification. Silently ignored
597  *   if the recommended table type does not exist or it serves a different match
598  *   type.
599  * @param[in] args
600  *   Table creation arguments.
601  * @param[in] size
602  *   Guideline on maximum number of table entries.
603  * @return
604  *   0 on success or the following error codes otherwise:
605  *   -EINVAL: Invalid argument;
606  *   -ENOMEM: Not enough space/cannot allocate memory;
607  *   -EEXIST: Table with this name already exists;
608  *   -ENODEV: Table creation error.
609  */
610 __rte_experimental
611 int
612 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
613                               const char *name,
614                               struct rte_swx_pipeline_table_params *params,
615                               const char *recommended_table_type_name,
616                               const char *args,
617                               uint32_t size);
618
619 /**
620  * Pipeline register array configure
621  *
622  * @param[in] p
623  *   Pipeline handle.
624  * @param[in] name
625  *   Register array name.
626  * @param[in] size
627  *   Number of registers in the array. Each register is 64-bit in size.
628  * @param[in] init_val
629  *   Initial value for every register in the array. The recommended value is 0.
630  * @return
631  *   0 on success or the following error codes otherwise:
632  *   -EINVAL: Invalid argument;
633  *   -ENOMEM: Not enough space/cannot allocate memory;
634  *   -EEXIST: Register array with this name already exists.
635  */
636 __rte_experimental
637 int
638 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
639                                  const char *name,
640                                  uint32_t size,
641                                  uint64_t init_val);
642
643 /**
644  * Pipeline meter array configure
645  *
646  * @param[in] p
647  *   Pipeline handle.
648  * @param[in] name
649  *   Meter array name.
650  * @param[in] size
651  *   Number of meters in the array. Each meter in the array implements the Two
652  *   Rate Three Color Marker (trTCM) algorithm, as specified by RFC 2698.
653  * @return
654  *   0 on success or the following error codes otherwise:
655  *   -EINVAL: Invalid argument;
656  *   -ENOMEM: Not enough space/cannot allocate memory;
657  *   -EEXIST: Meter array with this name already exists.
658  */
659 __rte_experimental
660 int
661 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
662                                  const char *name,
663                                  uint32_t size);
664
665 /**
666  * Pipeline instructions configure
667  *
668  * @param[in] p
669  *   Pipeline handle.
670  * @param[in] instructions
671  *   Pipeline instructions.
672  * @param[in] n_instructions
673  *   Number of pipeline instructions.
674  * @return
675  *   0 on success or the following error codes otherwise:
676  *   -EINVAL: Invalid argument;
677  *   -ENOMEM: Not enough space/cannot allocate memory.
678  */
679 __rte_experimental
680 int
681 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
682                                      const char **instructions,
683                                      uint32_t n_instructions);
684
685 /**
686  * Pipeline build
687  *
688  * Once called, the pipeline build operation marks the end of pipeline
689  * configuration. At this point, all the internal data structures needed to run
690  * the pipeline are built.
691  *
692  * @param[in] p
693  *   Pipeline handle.
694  * @return
695  *   0 on success or the following error codes otherwise:
696  *   -EINVAL: Invalid argument;
697  *   -ENOMEM: Not enough space/cannot allocate memory;
698  *   -EEXIST: Pipeline was already built successfully.
699  */
700 __rte_experimental
701 int
702 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
703
704 /**
705  * Pipeline build from specification file
706  *
707  * @param[in] p
708  *   Pipeline handle.
709  * @param[in] spec
710  *   Pipeline specification file.
711  * @param[out] err_line
712  *   In case of error and non-NULL, the line number within the *spec* file where
713  *   the error occurred. The first line number in the file is 1.
714  * @param[out] err_msg
715  *   In case of error and non-NULL, the error message.
716  * @return
717  *   0 on success or the following error codes otherwise:
718  *   -EINVAL: Invalid argument;
719  *   -ENOMEM: Not enough space/cannot allocate memory;
720  *   -EEXIST: Resource with the same name already exists;
721  *   -ENODEV: Extern object or table creation error.
722  */
723 __rte_experimental
724 int
725 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
726                                  FILE *spec,
727                                  uint32_t *err_line,
728                                  const char **err_msg);
729
730 /**
731  * Pipeline run
732  *
733  * @param[in] p
734  *   Pipeline handle.
735  * @param[in] n_instructions
736  *   Number of instructions to execute.
737  */
738 __rte_experimental
739 void
740 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
741                      uint32_t n_instructions);
742
743 /**
744  * Pipeline flush
745  *
746  * Flush all output ports of the pipeline.
747  *
748  * @param[in] p
749  *   Pipeline handle.
750  */
751 __rte_experimental
752 void
753 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
754
755 /**
756  * Pipeline free
757  *
758  * @param[in] p
759  *   Pipeline handle.
760  */
761 __rte_experimental
762 void
763 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
764
765 #ifdef __cplusplus
766 }
767 #endif
768
769 #endif