1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
4 #ifndef __INCLUDE_RTE_SWX_PIPELINE_H__
5 #define __INCLUDE_RTE_SWX_PIPELINE_H__
19 #include <rte_compat.h>
21 #include "rte_swx_port.h"
22 #include "rte_swx_table.h"
23 #include "rte_swx_extern.h"
26 #ifndef RTE_SWX_NAME_SIZE
27 #define RTE_SWX_NAME_SIZE 64
30 /** Instruction size. */
31 #ifndef RTE_SWX_INSTRUCTION_SIZE
32 #define RTE_SWX_INSTRUCTION_SIZE 256
35 /** Instruction tokens. */
36 #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX
37 #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16
41 * Pipeline setup and operation
44 /** Pipeline opaque data structure. */
45 struct rte_swx_pipeline;
51 * Pipeline handle. Must point to valid memory. Contains valid pipeline handle
52 * when the function returns successfully.
53 * @param[in] numa_node
54 * Non-Uniform Memory Access (NUMA) node.
56 * 0 on success or the following error codes otherwise:
57 * -EINVAL: Invalid argument;
58 * -ENOMEM: Not enough space/cannot allocate memory.
62 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
66 * Pipeline input ports
70 * Pipeline input port type register
75 * Input port type name.
77 * Input port type operations.
79 * 0 on success or the following error codes otherwise:
80 * -EINVAL: Invalid argument;
81 * -ENOMEM: Not enough space/cannot allocate memory;
82 * -EEXIST: Input port type with this name already exists.
86 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
88 struct rte_swx_port_in_ops *ops);
91 * Pipeline input port configure
97 * @param[in] port_type_name
98 * Existing input port type name.
100 * Input port creation arguments.
102 * 0 on success or the following error codes otherwise:
103 * -EINVAL: Invalid argument;
104 * -ENOMEM: Not enough space/cannot allocate memory;
105 * -ENODEV: Input port object creation error.
109 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
111 const char *port_type_name,
115 * Pipeline output ports
119 * Pipeline output port type register
124 * Output port type name.
126 * Output port type operations.
128 * 0 on success or the following error codes otherwise:
129 * -EINVAL: Invalid argument;
130 * -ENOMEM: Not enough space/cannot allocate memory;
131 * -EEXIST: Output port type with this name already exists.
135 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
137 struct rte_swx_port_out_ops *ops);
140 * Pipeline output port configure
146 * @param[in] port_type_name
147 * Existing output port type name.
149 * Output port creation arguments.
151 * 0 on success or the following error codes otherwise:
152 * -EINVAL: Invalid argument;
153 * -ENOMEM: Not enough space/cannot allocate memory;
154 * -ENODEV: Output port object creation error.
158 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
160 const char *port_type_name,
166 /** Default number of packet mirroring slots. */
167 #ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
168 #define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
171 /** Default maximum number of packet mirroring sessions. */
172 #ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
173 #define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
176 /** Packet mirroring parameters. */
177 struct rte_swx_pipeline_mirroring_params {
178 /** Number of packet mirroring slots. */
181 /** Maximum number of packet mirroring sessions. */
186 * Packet mirroring configure
191 * Packet mirroring parameters.
193 * 0 on success or the following error codes otherwise:
194 * -EINVAL: Invalid argument;
195 * -ENOMEM: Not enough memory;
196 * -EEXIST: Pipeline was already built successfully.
200 rte_swx_pipeline_mirroring_config(struct rte_swx_pipeline *p,
201 struct rte_swx_pipeline_mirroring_params *params);
204 * Extern objects and functions
208 * Pipeline extern type register
214 * @param[in] mailbox_struct_type_name
215 * Name of existing struct type used to define the mailbox size and layout for
216 * the extern objects that are instances of this type. Each extern object gets
217 * its own mailbox, which is used to pass the input arguments to the member
218 * functions and retrieve the output results.
219 * @param[in] constructor
220 * Function used to create the extern objects that are instances of this type.
221 * @param[in] destructor
222 * Function used to free the extern objects that are instances of this type.
224 * 0 on success or the following error codes otherwise:
225 * -EINVAL: Invalid argument;
226 * -ENOMEM: Not enough space/cannot allocate memory;
227 * -EEXIST: Extern type with this name already exists.
231 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
233 const char *mailbox_struct_type_name,
234 rte_swx_extern_type_constructor_t constructor,
235 rte_swx_extern_type_destructor_t destructor);
238 * Pipeline extern type member function register
242 * @param[in] extern_type_name
243 * Existing extern type name.
245 * Name for the new member function to be added to the extern type.
246 * @param[in] member_func
247 * The new member function.
249 * 0 on success or the following error codes otherwise:
250 * -EINVAL: Invalid argument;
251 * -ENOMEM: Not enough space/cannot allocate memory;
252 * -EEXIST: Member function with this name already exists for this type;
253 * -ENOSPC: Maximum number of member functions reached for this type.
257 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
258 const char *extern_type_name,
260 rte_swx_extern_type_member_func_t member_func);
263 * Pipeline extern object configure
265 * Instantiate a given extern type to create new extern object.
269 * @param[in] extern_type_name
270 * Existing extern type name.
272 * Name for the new object instantiating the extern type.
274 * Extern object constructor arguments.
276 * 0 on success or the following error codes otherwise:
277 * -EINVAL: Invalid argument;
278 * -ENOMEM: Not enough space/cannot allocate memory;
279 * -EEXIST: Extern object with this name already exists;
280 * -ENODEV: Extern object constructor error.
284 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
285 const char *extern_type_name,
290 * Pipeline extern function register
295 * Extern function name.
296 * @param[in] mailbox_struct_type_name
297 * Name of existing struct type used to define the mailbox size and layout for
298 * this extern function. The mailbox is used to pass the input arguments to
299 * the extern function and retrieve the output results.
301 * The extern function.
303 * 0 on success or the following error codes otherwise:
304 * -EINVAL: Invalid argument;
305 * -ENOMEM: Not enough space/cannot allocate memory;
306 * -EEXIST: Extern function with this name already exists.
310 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
312 const char *mailbox_struct_type_name,
313 rte_swx_extern_func_t func);
319 * Hash function prototype
322 * Key to hash. Must be non-NULL.
324 * Key length in bytes.
331 (*rte_swx_hash_func_t)(const void *key,
336 * Pipeline hash function register
341 * Hash function name.
345 * 0 on success or the following error codes otherwise:
346 * -EINVAL: Invalid argument;
347 * -ENOMEM: Not enough space/cannot allocate memory;
348 * -EEXIST: Hash function with this name already exists.
352 rte_swx_pipeline_hash_func_register(struct rte_swx_pipeline *p,
354 rte_swx_hash_func_t func);
357 * Packet headers and meta-data
360 /** Structure (struct) field. */
361 struct rte_swx_field_params {
362 /** Struct field name. */
365 /** Struct field size (in bits).
366 * Restriction: All struct fields must be a multiple of 8 bits.
367 * Restriction: All struct fields must be no greater than 64 bits.
373 * Pipeline struct type register
375 * Structs are used extensively in many part of the pipeline to define the size
376 * and layout of a specific memory piece such as: headers, meta-data, action
377 * data stored in a table entry, mailboxes for extern objects and functions.
378 * Similar to C language structs, they are a well defined sequence of fields,
379 * with each field having a unique name and a constant size.
381 * In order to use structs to express variable size packet headers such as IPv4
382 * with options, it is allowed for the last field of the struct type to have a
383 * variable size between 0 and *n_bits* bits, with the actual size of this field
384 * determined at run-time for each packet. This struct feature is restricted to
385 * just a few selected instructions that deal with packet headers, so a typical
386 * struct generally has a constant size that is fully known when its struct type
394 * The sequence of struct fields.
395 * @param[in] n_fields
396 * The number of struct fields.
397 * @param[in] last_field_has_variable_size
398 * If non-zero (true), then the last field has a variable size between 0 and
399 * *n_bits* bits, with its actual size determined at run-time for each packet.
400 * If zero (false), then the last field has a constant size of *n_bits* bits.
402 * 0 on success or the following error codes otherwise:
403 * -EINVAL: Invalid argument;
404 * -ENOMEM: Not enough space/cannot allocate memory;
405 * -EEXIST: Struct type with this name already exists.
409 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
411 struct rte_swx_field_params *fields,
413 int last_field_has_variable_size);
416 * Pipeline packet header register
422 * @param[in] struct_type_name
423 * The struct type instantiated by this packet header.
425 * 0 on success or the following error codes otherwise:
426 * -EINVAL: Invalid argument;
427 * -ENOMEM: Not enough space/cannot allocate memory;
428 * -EEXIST: Header with this name already exists;
429 * -ENOSPC: Maximum number of headers reached for the pipeline.
433 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
435 const char *struct_type_name);
438 * Pipeline packet meta-data register
442 * @param[in] struct_type_name
443 * The struct type instantiated by the packet meta-data.
445 * 0 on success or the following error codes otherwise:
446 * -EINVAL: Invalid argument.
450 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
451 const char *struct_type_name);
458 * Instruction operands:
460 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
461 *<pre>| | Description | Format | DST | SRC |</pre>
462 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
463 *<pre>| hdr | Header | h.header | | |</pre>
464 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
465 *<pre>| act | Action | ACTION | | |</pre>
466 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
467 *<pre>| tbl | Table | TABLE | | |</pre>
468 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
469 *<pre>| H | Header field | h.header.field | YES | YES |</pre>
470 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
471 *<pre>| M | Meta-data field | m.field | YES | YES |</pre>
472 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
473 *<pre>| E | Extern obj mailbox field | e.ext_obj.field | YES | YES |</pre>
474 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
475 *<pre>| F | Extern func mailbox field | f.ext_func.field | YES | YES |</pre>
476 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
477 *<pre>| T | Table action data field | t.header.field | NO | YES |</pre>
478 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
479 *<pre>| I | Immediate value (64-bit) | h.header.field | NO | YES |</pre>
480 *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
484 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
485 *<pre>| Instr. | Instruction | Instruction | 1st | 2nd |</pre>
486 *<pre>| Name | Description | Format | opnd.| opnd. |</pre>
487 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
488 *<pre>| rx | Receive one pkt | rx m.port_in | M | |</pre>
489 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
490 *<pre>| tx | Transmit one pkt | tx m.port_out | M | |</pre>
491 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
492 *<pre>| extract | Extract one hdr | extract h.hdr | hdr | |</pre>
493 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
494 *<pre>| emit | Emit one hdr | emit h.hdr | hdr | |</pre>
495 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
496 *<pre>| validate | Validate one hdr | validate h.hdr | hdr | |</pre>
497 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
498 *<pre>| invalidate | Invalidate one hdr | invalidate h.hdr | hdr | |</pre>
499 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
500 *<pre>| mov | dst = src | mov dst src | HMEF | HMEFTI |</pre>
501 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
502 *<pre>| add | dst += src | add dst src | HMEF | HMEFTI |</pre>
503 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
504 *<pre>| sub | dst -= src | add dst src | HMEF | HMEFTI |</pre>
505 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
506 *<pre>| ckadd | Checksum add: dst = | add dst src | HMEF | HMEFTI |</pre>
507 *<pre>| | dst '+ src[0:1] '+ | | | or hdr |</pre>
508 *<pre>| | src[2:3] '+ ... | | | |</pre>
509 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
510 *<pre>| cksub | Checksum subtract: | add dst src | HMEF | HMEFTI |</pre>
511 *<pre>| | dst = dst '- src | | | |</pre>
512 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
513 *<pre>| and | dst &= src | and dst src | HMEF | HMEFTI |</pre>
514 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
515 *<pre>| or | dst |= src | or dst src | HMEF | HMEFTI |</pre>
516 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
517 *<pre>| xor | dst ^= src | xor dst src | HMEF | HMEFTI |</pre>
518 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
519 *<pre>| shl | dst <<= src | shl dst src | HMEF | HMEFTI |</pre>
520 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
521 *<pre>| shr | dst >>= src | shr dst src | HMEF | HMEFTI |</pre>
522 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
523 *<pre>| table | Table lookup | table TABLE | tbl | |</pre>
524 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
525 *<pre>| extern | Ext obj member func | extern e.obj.mfunc| ext | |</pre>
526 *<pre>| | call or ext func call| extern f.func | | |</pre>
527 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
528 *<pre>| jmp | Unconditional jump | jmp LABEL | | |</pre>
529 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
530 *<pre>| jmpv | Jump if hdr is valid | jmpv LABEL h.hdr | hdr | |</pre>
531 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
532 *<pre>| jmpnv | Jump if hdr is inval | jmpnv LABEL h.hdr | hdr | |</pre>
533 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
534 *<pre>| jmph | Jump if tbl lkp hit | jmph LABEL | | |</pre>
535 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
536 *<pre>| jmpnh | Jump if tbl lkp miss | jmpnh LABEL | | |</pre>
537 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
538 *<pre>| jmpa | Jump if action run | jmpa LABEL ACTION | act | |</pre>
539 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
540 *<pre>| jmpna | Jump if act not run | jmpna LABEL ACTION| act | |</pre>
541 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
542 *<pre>| jmpeq | Jump if (a == b) | jmpeq LABEL a b | HMEFT| HMEFTI |</pre>
543 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
544 *<pre>| jmpneq | Jump if (a != b) | jmpneq LABEL a b | HMEFT| HMEFTI |</pre>
545 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
546 *<pre>| jmplt | Jump if (a < b) | jmplt LABEL a b | HMEFT| HMEFTI |</pre>
547 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
548 *<pre>| jmpgt | Jump if (a > b) | jmpgt LABEL a b | HMEFT| HMEFTI |</pre>
549 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
550 *<pre>| return | Return from action | return | | |</pre>
551 *<pre>+------------+----------------------+-------------------+------+--------+</pre>
553 * At initialization time, the pipeline and action instructions (including the
554 * symbolic name operands) are translated to internal data structures that are
563 * Pipeline action configure
569 * @param[in] args_struct_type_name
570 * The struct type instantiated by the action data. The action data represent
571 * the action arguments that are stored in the table entry together with the
572 * action ID. Set to NULL when the action does not have any arguments.
573 * @param[in] instructions
574 * Action instructions.
575 * @param[in] n_instructions
576 * Number of action instructions.
578 * 0 on success or the following error codes otherwise:
579 * -EINVAL: Invalid argument;
580 * -ENOMEM: Not enough space/cannot allocate memory;
581 * -EEXIST: Action with this name already exists.
585 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
587 const char *args_struct_type_name,
588 const char **instructions,
589 uint32_t n_instructions);
596 * Pipeline table type register
602 * @param[in] match_type
603 * Match type implemented by the new table type.
605 * Table type operations.
607 * 0 on success or the following error codes otherwise:
608 * -EINVAL: Invalid argument;
609 * -ENOMEM: Not enough space/cannot allocate memory;
610 * -EEXIST: Table type with this name already exists.
614 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
616 enum rte_swx_table_match_type match_type,
617 struct rte_swx_table_ops *ops);
619 /** Match field parameters. */
620 struct rte_swx_match_field_params {
621 /** Match field name. Must be either a field of one of the registered
622 * packet headers ("h.header.field") or a field of the registered
623 * meta-data ("m.field").
627 /** Match type of the field. */
628 enum rte_swx_table_match_type match_type;
631 /** Pipeline table parameters. */
632 struct rte_swx_pipeline_table_params {
633 /** The set of match fields for the current table.
634 * Restriction: All the match fields of the current table need to be
635 * part of the same struct, i.e. either all the match fields are part of
636 * the same header or all the match fields are part of the meta-data.
638 struct rte_swx_match_field_params *fields;
640 /** The number of match fields for the current table. If set to zero, no
641 * "regular" entries (i.e. entries other than the default entry) can be
642 * added to the current table and the match process always results in
647 /** The set of actions for the current table. */
648 const char **action_names;
650 /** Array of *n_actions* flags. For each action, the associated flag
651 * indicates whether the action can be assigned to regular table entries
652 * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
653 * to NULL, it defaults to true for all actions.
655 int *action_is_for_table_entries;
657 /** Array of *n_actions* flags. For each action, the associated flag
658 * indicates whether the action can be assigned to the default table
659 * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
660 * When set to NULL, it defaults to true for all actions.
662 int *action_is_for_default_entry;
664 /** The number of actions for the current table. Must be at least one.
668 /** The default table action that gets executed on lookup miss. Must be
669 * one of the table actions included in the *action_names*.
671 const char *default_action_name;
673 /** Default action arguments. Specified as a string with the format
674 * "ARG0_NAME ARG0_VALUE ...". The number of arguments in this string
675 * must match exactly the number of arguments of the default action.
676 * Must be NULL if the default action does not have any arguments.
678 const char *default_action_args;
680 /** If non-zero (true), then the default action of the current table
681 * cannot be changed. If zero (false), then the default action can be
682 * changed in the future with another action from the *action_names*
685 int default_action_is_const;
689 * Pipeline table configure
697 * @param[in] recommended_table_type_name
698 * Recommended table type. Typically set to NULL. Useful as guidance when
699 * there are multiple table types registered for the match type of the table,
700 * as determined from the table match fields specification. Silently ignored
701 * if the recommended table type does not exist or it serves a different match
704 * Table creation arguments.
706 * Guideline on maximum number of table entries.
708 * 0 on success or the following error codes otherwise:
709 * -EINVAL: Invalid argument;
710 * -ENOMEM: Not enough space/cannot allocate memory;
711 * -EEXIST: Table with this name already exists;
712 * -ENODEV: Table creation error.
716 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
718 struct rte_swx_pipeline_table_params *params,
719 const char *recommended_table_type_name,
723 /** Pipeline selector table parameters. */
724 struct rte_swx_pipeline_selector_params {
725 /** The group ID field. Input into the selection operation.
726 * Restriction: This field must be a meta-data field.
728 const char *group_id_field_name;
730 /** The set of fields used to select (through a hashing scheme) the
731 * member within the current group. Inputs into the selection operation.
732 * Restriction: All the selector fields must be part of the same struct,
733 * i.e. part of the same header or part of the meta-data structure.
735 const char **selector_field_names;
737 /** The number of selector fields. Must be non-zero. */
738 uint32_t n_selector_fields;
740 /** The member ID field. Output from the selection operation.
741 * Restriction: This field must be a meta-data field.
743 const char *member_id_field_name;
745 /** Maximum number of groups. Must be non-zero. */
746 uint32_t n_groups_max;
748 /** Maximum number of members per group. Must be non-zero. */
749 uint32_t n_members_per_group_max;
753 * Pipeline selector table configure
758 * Selector table name.
760 * Selector table parameters.
762 * 0 on success or the following error codes otherwise:
763 * -EINVAL: Invalid argument;
764 * -ENOMEM: Not enough space/cannot allocate memory;
765 * -EEXIST: Selector table with this name already exists;
766 * -ENODEV: Selector table creation error.
770 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
772 struct rte_swx_pipeline_selector_params *params);
774 /** Pipeline learner table parameters. */
775 struct rte_swx_pipeline_learner_params {
776 /** The set of match fields for the current table.
777 * Restriction: All the match fields of the current table need to be
778 * part of the same struct, i.e. either all the match fields are part of
779 * the same header or all the match fields are part of the meta-data.
781 const char **field_names;
783 /** The number of match fields for the current table. Must be non-zero.
787 /** The set of actions for the current table. */
788 const char **action_names;
790 /** Array of *n_actions* flags. For each action, the associated flag
791 * indicates whether the action can be assigned to regular table entries
792 * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
793 * to NULL, it defaults to true for all actions.
795 int *action_is_for_table_entries;
797 /** Array of *n_actions* flags. For each action, the associated flag
798 * indicates whether the action can be assigned to the default table
799 * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
800 * When set to NULL, it defaults to true for all actions.
802 int *action_is_for_default_entry;
804 /** The number of actions for the current table. Must be at least one.
808 /** The default table action that gets executed on lookup miss. Must be
809 * one of the table actions included in the *action_names*.
811 const char *default_action_name;
813 /** Default action arguments. Specified as a string with the format
814 * "ARG0_NAME ARG0_VALUE ...". The number of arguments in this string
815 * must match exactly the number of arguments of the default action.
816 * Must be NULL if the default action does not have any arguments.
818 const char *default_action_args;
820 /** If non-zero (true), then the default action of the current table
821 * cannot be changed. If zero (false), then the default action can be
822 * changed in the future with another action from the *action_names*
825 int default_action_is_const;
829 * Pipeline learner table configure
834 * Learner table name.
836 * Learner table parameters.
838 * The maximum number of table entries. Must be non-zero.
840 * Array of possible table entry timeouts in seconds. Must be non-NULL.
841 * @param[in] n_timeouts
842 * Number of elements in the *timeout* array.
844 * 0 on success or the following error codes otherwise:
845 * -EINVAL: Invalid argument;
846 * -ENOMEM: Not enough space/cannot allocate memory;
847 * -EEXIST: Learner table with this name already exists;
848 * -ENODEV: Learner table creation error.
852 rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
854 struct rte_swx_pipeline_learner_params *params,
857 uint32_t n_timeouts);
860 * Pipeline register array configure
865 * Register array name.
867 * Number of registers in the array. Each register is 64-bit in size.
868 * @param[in] init_val
869 * Initial value for every register in the array. The recommended value is 0.
871 * 0 on success or the following error codes otherwise:
872 * -EINVAL: Invalid argument;
873 * -ENOMEM: Not enough space/cannot allocate memory;
874 * -EEXIST: Register array with this name already exists.
878 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
884 * Pipeline meter array configure
891 * Number of meters in the array. Each meter in the array implements the Two
892 * Rate Three Color Marker (trTCM) algorithm, as specified by RFC 2698.
894 * 0 on success or the following error codes otherwise:
895 * -EINVAL: Invalid argument;
896 * -ENOMEM: Not enough space/cannot allocate memory;
897 * -EEXIST: Meter array with this name already exists.
901 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
906 * Pipeline instructions configure
910 * @param[in] instructions
911 * Pipeline instructions.
912 * @param[in] n_instructions
913 * Number of pipeline instructions.
915 * 0 on success or the following error codes otherwise:
916 * -EINVAL: Invalid argument;
917 * -ENOMEM: Not enough space/cannot allocate memory.
921 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
922 const char **instructions,
923 uint32_t n_instructions);
928 * Once called, the pipeline build operation marks the end of pipeline
929 * configuration. At this point, all the internal data structures needed to run
930 * the pipeline are built.
935 * 0 on success or the following error codes otherwise:
936 * -EINVAL: Invalid argument;
937 * -ENOMEM: Not enough space/cannot allocate memory;
938 * -EEXIST: Pipeline was already built successfully.
942 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
945 * Pipeline build from specification file
950 * Pipeline specification file.
951 * @param[out] err_line
952 * In case of error and non-NULL, the line number within the *spec* file where
953 * the error occurred. The first line number in the file is 1.
954 * @param[out] err_msg
955 * In case of error and non-NULL, the error message.
957 * 0 on success or the following error codes otherwise:
958 * -EINVAL: Invalid argument;
959 * -ENOMEM: Not enough space/cannot allocate memory;
960 * -EEXIST: Resource with the same name already exists;
961 * -ENODEV: Extern object or table creation error.
965 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
968 const char **err_msg);
975 * @param[in] n_instructions
976 * Number of instructions to execute.
980 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
981 uint32_t n_instructions);
986 * Flush all output ports of the pipeline.
993 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
1003 rte_swx_pipeline_free(struct rte_swx_pipeline *p);