1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
4 #ifndef __INCLUDE_RTE_SWX_CTL_H__
5 #define __INCLUDE_RTE_SWX_CTL_H__
13 * RTE SWX Pipeline Control
19 #include <rte_compat.h>
20 #include <rte_meter.h>
22 #include "rte_swx_port.h"
23 #include "rte_swx_table.h"
25 struct rte_swx_pipeline;
28 #ifndef RTE_SWX_CTL_NAME_SIZE
29 #define RTE_SWX_CTL_NAME_SIZE 64
37 struct rte_swx_ctl_pipeline_info {
38 /** Number of input ports. */
41 /** Number of input ports. */
44 /** Number of packet mirroring slots. */
45 uint32_t n_mirroring_slots;
47 /** Number of packet mirroring sessions. */
48 uint32_t n_mirroring_sessions;
50 /** Number of actions. */
53 /** Number of tables. */
56 /** Number of selector tables. */
59 /** Number of learner tables. */
62 /** Number of register arrays. */
65 /** Number of meter arrays. */
74 * @param[out] pipeline
77 * 0 on success or the following error codes otherwise:
78 * -EINVAL: Invalid argument.
82 rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
83 struct rte_swx_ctl_pipeline_info *pipeline);
86 * Pipeline NUMA node get
90 * @param[out] numa_node
93 * 0 on success or the following error codes otherwise:
94 * -EINVAL: Invalid argument.
98 rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
106 * Input port statistics counters read
111 * Port ID (0 .. *n_ports_in* - 1).
115 * 0 on success or the following error codes otherwise:
116 * -EINVAL: Invalid argument.
120 rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
122 struct rte_swx_port_in_stats *stats);
125 * Output port statistics counters read
130 * Port ID (0 .. *n_ports_out* - 1).
134 * 0 on success or the following error codes otherwise:
135 * -EINVAL: Invalid argument.
139 rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
141 struct rte_swx_port_out_stats *stats);
148 struct rte_swx_ctl_action_info {
150 char name[RTE_SWX_CTL_NAME_SIZE];
152 /** Number of action arguments. */
161 * @param[in] action_id
162 * Action ID (0 .. *n_actions* - 1).
166 * 0 on success or the following error codes otherwise:
167 * -EINVAL: Invalid argument.
171 rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
173 struct rte_swx_ctl_action_info *action);
175 /** Action argument info. */
176 struct rte_swx_ctl_action_arg_info {
177 /** Action argument name. */
178 char name[RTE_SWX_CTL_NAME_SIZE];
180 /** Action argument size (in bits). */
183 /** Non-zero (true) when this action argument must be stored in the
184 * table in network byte order (NBO), zero when it must be stored in
185 * host byte order (HBO).
187 int is_network_byte_order;
191 * Action argument info get
195 * @param[in] action_id
196 * Action ID (0 .. *n_actions* - 1).
197 * @param[in] action_arg_id
198 * Action ID (0 .. *n_args* - 1).
199 * @param[out] action_arg
200 * Action argument info.
202 * 0 on success or the following error codes otherwise:
203 * -EINVAL: Invalid argument.
207 rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
209 uint32_t action_arg_id,
210 struct rte_swx_ctl_action_arg_info *action_arg);
217 struct rte_swx_ctl_table_info {
219 char name[RTE_SWX_CTL_NAME_SIZE];
221 /** Table creation arguments. */
222 char args[RTE_SWX_CTL_NAME_SIZE];
224 /** Number of match fields. */
225 uint32_t n_match_fields;
227 /** Number of actions. */
230 /** Non-zero (true) when the default action is constant, therefore it
231 * cannot be changed; zero (false) when the default action not constant,
232 * therefore it can be changed.
234 int default_action_is_const;
236 /** Table size parameter. */
245 * @param[in] table_id
246 * Table ID (0 .. *n_tables* - 1).
250 * 0 on success or the following error codes otherwise:
251 * -EINVAL: Invalid argument.
255 rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
257 struct rte_swx_ctl_table_info *table);
259 /** Table match field info.
261 * If (n_bits, offset) are known for all the match fields of the table, then the
262 * table (key_offset, key_size, key_mask0) can be computed.
264 struct rte_swx_ctl_table_match_field_info {
265 /** Match type of the current match field. */
266 enum rte_swx_table_match_type match_type;
268 /** Non-zero (true) when the current match field is part of a registered
269 * header, zero (false) when it is part of the registered meta-data.
273 /** Match field size (in bits). */
276 /** Match field offset within its parent struct (one of the headers or
283 * Table match field info get
287 * @param[in] table_id
288 * Table ID (0 .. *n_tables*).
289 * @param[in] match_field_id
290 * Match field ID (0 .. *n_match_fields* - 1).
291 * @param[out] match_field
292 * Table match field info.
294 * 0 on success or the following error codes otherwise:
295 * -EINVAL: Invalid argument.
299 rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
301 uint32_t match_field_id,
302 struct rte_swx_ctl_table_match_field_info *match_field);
304 /** Table action info. */
305 struct rte_swx_ctl_table_action_info {
309 /** When non-zero (true), the action can be assigned to regular table entries. */
310 int action_is_for_table_entries;
312 /** When non-zero (true), the action can be assigned to the table default entry. */
313 int action_is_for_default_entry;
317 * Table action info get
321 * @param[in] table_id
322 * Table ID (0 .. *n_tables*).
323 * @param[in] table_action_id
324 * Action index within the set of table actions (0 .. table n_actions - 1).
325 * Not to be confused with the action ID, which works at the pipeline level
326 * (0 .. pipeline n_actions - 1), which is precisely what this function
327 * returns as part of *table_action*.
328 * @param[out] table_action
331 * 0 on success or the following error codes otherwise:
332 * -EINVAL: Invalid argument.
336 rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
338 uint32_t table_action_id,
339 struct rte_swx_ctl_table_action_info *table_action);
342 * Table operations get
346 * @param[in] table_id
347 * Table ID (0 .. *n_tables*).
348 * @param[out] table_ops
349 * Table operations. Only valid when function returns success and *is_stub* is
351 * @param[out] is_stub
352 * A stub table is a table with no match fields. No "regular" table entries
353 * (i.e. entries other than the default entry) can be added to such a table,
354 * therefore the lookup operation always results in lookup miss. Non-zero
355 * (true) when the current table is a stub table, zero (false) otherwise.
357 * 0 on success or the following error codes otherwise:
358 * -EINVAL: Invalid argument.
362 rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
364 struct rte_swx_table_ops *table_ops,
367 /** Table statistics. */
368 struct rte_swx_table_stats {
369 /** Number of packets with lookup hit. */
372 /** Number of packets with lookup miss. */
373 uint64_t n_pkts_miss;
375 /** Number of packets (with either lookup hit or miss) per pipeline
376 * action. Array of pipeline *n_actions* elements indexed by the
377 * pipeline-level *action_id*, therefore this array has the same size
378 * for all the tables within the same pipeline.
380 uint64_t *n_pkts_action;
384 * Table statistics counters read
388 * @param[in] table_name
391 * Table stats. Must point to a pre-allocated structure. The *n_pkts_action*
392 * field also needs to be pre-allocated as array of pipeline *n_actions*
393 * elements. The pipeline actions that are not valid for the current table
394 * have their associated *n_pkts_action* element always set to zero.
396 * 0 on success or the following error codes otherwise:
397 * -EINVAL: Invalid argument.
401 rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
402 const char *table_name,
403 struct rte_swx_table_stats *stats);
406 * Selector Table Query API.
409 /** Selector info. */
410 struct rte_swx_ctl_selector_info {
411 /** Selector table name. */
412 char name[RTE_SWX_CTL_NAME_SIZE];
414 /** Number of selector fields. */
415 uint32_t n_selector_fields;
417 /** Maximum number of groups. */
418 uint32_t n_groups_max;
420 /** Maximum number of members per group. */
421 uint32_t n_members_per_group_max;
425 * Selector table info get
429 * @param[in] selector_id
430 * Selector table ID (0 .. *n_selectors* - 1).
431 * @param[out] selector
432 * Selector table info.
434 * 0 on success or the following error codes otherwise:
435 * -EINVAL: Invalid argument.
439 rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p,
440 uint32_t selector_id,
441 struct rte_swx_ctl_selector_info *selector);
444 * Selector table "group ID" field info get
448 * @param[in] selector_id
449 * Selector table ID (0 .. *n_selectors*).
451 * Selector table "group ID" field info.
453 * 0 on success or the following error codes otherwise:
454 * -EINVAL: Invalid argument.
458 rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p,
459 uint32_t selector_id,
460 struct rte_swx_ctl_table_match_field_info *field);
463 * Sselector table selector field info get
467 * @param[in] selector_id
468 * Selector table ID (0 .. *n_selectors*).
469 * @param[in] selector_field_id
470 * Selector table selector field ID (0 .. *n_selector_fields* - 1).
472 * Selector table selector field info.
474 * 0 on success or the following error codes otherwise:
475 * -EINVAL: Invalid argument.
479 rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p,
480 uint32_t selector_id,
481 uint32_t selector_field_id,
482 struct rte_swx_ctl_table_match_field_info *field);
485 * Selector table "member ID" field info get
489 * @param[in] selector_id
490 * Selector table ID (0 .. *n_selectors*).
492 * Selector table "member ID" field info.
494 * 0 on success or the following error codes otherwise:
495 * -EINVAL: Invalid argument.
499 rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p,
500 uint32_t selector_id,
501 struct rte_swx_ctl_table_match_field_info *field);
503 /** Selector table statistics. */
504 struct rte_swx_pipeline_selector_stats {
505 /** Number of packets. */
510 * Selector table statistics counters read
514 * @param[in] selector_name
515 * Selector table name.
517 * Selector table stats. Must point to a pre-allocated structure.
519 * 0 on success or the following error codes otherwise:
520 * -EINVAL: Invalid argument.
524 rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p,
525 const char *selector_name,
526 struct rte_swx_pipeline_selector_stats *stats);
529 * Learner Table Query API.
532 /** Learner table info. */
533 struct rte_swx_ctl_learner_info {
534 /** Learner table name. */
535 char name[RTE_SWX_CTL_NAME_SIZE];
537 /** Number of match fields. */
538 uint32_t n_match_fields;
540 /** Number of actions. */
543 /** Non-zero (true) when the default action is constant, therefore it
544 * cannot be changed; zero (false) when the default action not constant,
545 * therefore it can be changed.
547 int default_action_is_const;
549 /** Learner table size parameter. */
552 /** Number of possible key timeout values. */
553 uint32_t n_key_timeouts;
557 * Learner table info get
561 * @param[in] learner_id
562 * Learner table ID (0 .. *n_learners* - 1).
563 * @param[out] learner
564 * Learner table info.
566 * 0 on success or the following error codes otherwise:
567 * -EINVAL: Invalid argument.
571 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
573 struct rte_swx_ctl_learner_info *learner);
576 * Learner table match field info get
580 * @param[in] learner_id
581 * Learner table ID (0 .. *n_learners* - 1).
582 * @param[in] match_field_id
583 * Match field ID (0 .. *n_match_fields* - 1).
584 * @param[out] match_field
585 * Learner table match field info.
587 * 0 on success or the following error codes otherwise:
588 * -EINVAL: Invalid argument.
592 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
594 uint32_t match_field_id,
595 struct rte_swx_ctl_table_match_field_info *match_field);
598 * Learner table action info get
602 * @param[in] learner_id
603 * Learner table ID (0 .. *n_learners* - 1).
604 * @param[in] learner_action_id
605 * Action index within the set of learner table actions (0 .. learner table n_actions - 1). Not
606 * to be confused with the pipeline-leve action ID (0 .. pipeline n_actions - 1), which is
607 * precisely what this function returns as part of the *learner_action*.
608 * @param[out] learner_action
609 * Learner action info.
611 * 0 on success or the following error codes otherwise:
612 * -EINVAL: Invalid argument.
616 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
618 uint32_t learner_action_id,
619 struct rte_swx_ctl_table_action_info *learner_action);
622 * Learner table timeout get
626 * @param[in] learner_id
627 * Learner table ID (0 .. *n_learners* - 1).
628 * @param[in] timeout_id
630 * @param[out] timeout
631 * Timeout value measured in seconds. Must be non-NULL.
633 * 0 on success or the following error codes otherwise:
634 * -EINVAL: Invalid argument.
638 rte_swx_ctl_pipeline_learner_timeout_get(struct rte_swx_pipeline *p,
644 * Learner table timeout set
648 * @param[in] learner_id
649 * Learner table ID (0 .. *n_learners* - 1).
650 * @param[in] timeout_id
653 * Timeout value measured in seconds.
655 * 0 on success or the following error codes otherwise:
656 * -EINVAL: Invalid argument.
660 rte_swx_ctl_pipeline_learner_timeout_set(struct rte_swx_pipeline *p,
665 /** Learner table statistics. */
666 struct rte_swx_learner_stats {
667 /** Number of packets with lookup hit. */
670 /** Number of packets with lookup miss. */
671 uint64_t n_pkts_miss;
673 /** Number of packets with successful learning. */
674 uint64_t n_pkts_learn_ok;
676 /** Number of packets with learning error. */
677 uint64_t n_pkts_learn_err;
679 /** Number of packets with rearm event. */
680 uint64_t n_pkts_rearm;
682 /** Number of packets with forget event. */
683 uint64_t n_pkts_forget;
685 /** Number of packets (with either lookup hit or miss) per pipeline action. Array of
686 * pipeline *n_actions* elements indexed by the pipeline-level *action_id*, therefore this
687 * array has the same size for all the tables within the same pipeline.
689 uint64_t *n_pkts_action;
693 * Learner table statistics counters read
697 * @param[in] learner_name
698 * Learner table name.
700 * Learner table stats. Must point to a pre-allocated structure. The *n_pkts_action* field also
701 * needs to be pre-allocated as array of pipeline *n_actions* elements. The pipeline actions that
702 * are not valid for the current learner table have their associated *n_pkts_action* element
703 * always set to zero.
705 * 0 on success or the following error codes otherwise:
706 * -EINVAL: Invalid argument.
710 rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
711 const char *learner_name,
712 struct rte_swx_learner_stats *stats);
715 * Packet mirroring API.
718 /** Packet mirroring session parameters. */
719 struct rte_swx_pipeline_mirroring_session_params {
720 /** Output port ID. */
723 /** Fast clone flag. */
726 /** Truncation packet length (in bytes). Zero means no truncation. */
727 uint32_t truncation_length;
731 * Packet mirroring session set
735 * @param[in] session_id
736 * Packet mirroring session ID.
738 * Packet mirroring session parameters.
740 * 0 on success or the following error codes otherwise:
741 * -EINVAL: Invalid argument;
742 * -EEXIST: Pipeline was already built successfully.
746 rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p,
748 struct rte_swx_pipeline_mirroring_session_params *params);
755 struct rte_swx_table_state {
759 /** Action ID of the table default action. */
760 uint64_t default_action_id;
762 /** Action data of the table default action. Ignored when the action
763 * data size is zero; otherwise, action data size bytes are meaningful.
765 uint8_t *default_action_data;
769 * Pipeline table state get
773 * @param[out] table_state
774 * After successful execution, the *table_state* contains the pointer to the
775 * current pipeline table state, which is an array of *n_tables* elements,
776 * with array element i containing the state of the i-th pipeline table. The
777 * pipeline continues to own all the data structures directly or indirectly
778 * referenced by the *table_state* until the subsequent successful invocation
779 * of function *rte_swx_pipeline_table_state_set*.
781 * 0 on success or the following error codes otherwise:
782 * -EINVAL: Invalid argument.
786 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
787 struct rte_swx_table_state **table_state);
790 * Pipeline table state set
794 * @param[out] table_state
795 * After successful execution, the pipeline table state is updated to this
796 * *table_state*. The ownership of all the data structures directly or
797 * indirectly referenced by this *table_state* is passed from the caller to
800 * 0 on success or the following error codes otherwise:
801 * -EINVAL: Invalid argument.
805 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
806 struct rte_swx_table_state *table_state);
809 * High Level Reference Table Update API.
812 /** Pipeline control opaque data structure. */
813 struct rte_swx_ctl_pipeline;
816 * Pipeline control create
821 * Pipeline control handle, on success, or NULL, on error.
824 struct rte_swx_ctl_pipeline *
825 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
828 * Pipeline table entry add
830 * Schedule entry for addition to table or update as part of the next commit
834 * Pipeline control handle.
835 * @param[in] table_name
838 * Entry to be added to the table.
840 * 0 on success or the following error codes otherwise:
841 * -EINVAL: Invalid argument.
845 rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
846 const char *table_name,
847 struct rte_swx_table_entry *entry);
850 * Pipeline table default entry add
852 * Schedule table default entry update as part of the next commit operation.
855 * Pipeline control handle.
856 * @param[in] table_name
859 * The new table default entry. The *key* and *key_mask* entry fields are
862 * 0 on success or the following error codes otherwise:
863 * -EINVAL: Invalid argument.
867 rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
868 const char *table_name,
869 struct rte_swx_table_entry *entry);
872 * Pipeline table entry delete
874 * Schedule entry for deletion from table as part of the next commit operation.
875 * Request is silently discarded if no such entry exists.
878 * Pipeline control handle.
879 * @param[in] table_name
882 * Entry to be deleted from the table. The *action_id* and *action_data* entry
883 * fields are ignored.
885 * 0 on success or the following error codes otherwise:
886 * -EINVAL: Invalid argument.
890 rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
891 const char *table_name,
892 struct rte_swx_table_entry *entry);
895 * Pipeline selector table group add
897 * Add a new group to a selector table. This operation is executed before this
898 * function returns and its result is independent of the result of the next
902 * Pipeline control handle.
903 * @param[in] selector_name
904 * Selector table name.
905 * @param[out] group_id
906 * The ID of the new group. Only valid when the function call is successful.
907 * This group is initially empty, i.e. it does not contain any members.
909 * 0 on success or the following error codes otherwise:
910 * -EINVAL: Invalid argument;
911 * -ENOSPC: All groups are currently in use, no group available.
915 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
916 const char *selector_name,
920 * Pipeline selector table group delete
922 * Schedule a group for deletion as part of the next commit operation. The group
923 * to be deleted can be empty or non-empty.
926 * Pipeline control handle.
927 * @param[in] selector_name
928 * Selector table name.
929 * @param[in] group_id
930 * Group to be deleted from the selector table.
932 * 0 on success or the following error codes otherwise:
933 * -EINVAL: Invalid argument;
934 * -ENOMEM: Not enough memory.
938 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
939 const char *selector_name,
943 * Pipeline selector table member add to group
945 * Schedule the operation to add a new member to an existing group as part of
946 * the next commit operation. If this member is already in this group, the
947 * member weight is updated to the new value. A weight of zero means this member
948 * is to be deleted from the group.
951 * Pipeline control handle.
952 * @param[in] selector_name
953 * Selector table name.
954 * @param[in] group_id
956 * @param[in] member_id
957 * The member to be added to the group.
958 * @param[in] member_weight
961 * 0 on success or the following error codes otherwise:
962 * -EINVAL: Invalid argument;
963 * -ENOMEM: Not enough memory;
964 * -ENOSPC: The group is full.
968 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
969 const char *selector_name,
972 uint32_t member_weight);
975 * Pipeline selector table member delete from group
977 * Schedule the operation to delete a member from an existing group as part of
978 * the next commit operation.
981 * Pipeline control handle.
982 * @param[in] selector_name
983 * Selector table name.
984 * @param[in] group_id
985 * The group ID. Must be valid.
986 * @param[in] member_id
987 * The member to be added to the group. Must be valid.
989 * 0 on success or the following error codes otherwise:
990 * -EINVAL: Invalid argument.
994 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
995 const char *selector_name,
1000 * Pipeline learner table default entry add
1002 * Schedule learner table default entry update as part of the next commit operation.
1005 * Pipeline control handle.
1006 * @param[in] learner_name
1007 * Learner table name.
1009 * The new table default entry. The *key* and *key_mask* entry fields are ignored.
1011 * 0 on success or the following error codes otherwise:
1012 * -EINVAL: Invalid argument.
1016 rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
1017 const char *learner_name,
1018 struct rte_swx_table_entry *entry);
1023 * Perform all the scheduled table work.
1026 * Pipeline control handle.
1027 * @param[in] abort_on_fail
1028 * When non-zero (false), all the scheduled work is discarded after a failed
1029 * commit. Otherwise, the scheduled work is still kept pending for the next
1032 * 0 on success or the following error codes otherwise:
1033 * -EINVAL: Invalid argument.
1037 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
1043 * Discard all the scheduled table work.
1046 * Pipeline control handle.
1050 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
1053 * Pipeline table entry read
1055 * Read table entry from string.
1058 * Pipeline control handle.
1059 * @param[in] table_name
1062 * String containing the table entry.
1063 * @param[out] is_blank_or_comment
1064 * On error, this argument provides an indication of whether *string* contains
1065 * an invalid table entry (set to zero) or a blank or comment line that should
1066 * typically be ignored (set to a non-zero value).
1068 * 0 on success or the following error codes otherwise:
1069 * -EINVAL: Invalid argument.
1072 struct rte_swx_table_entry *
1073 rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
1074 const char *table_name,
1076 int *is_blank_or_comment);
1079 * Pipeline learner table default entry read
1081 * Read learner table default entry from string.
1084 * Pipeline control handle.
1085 * @param[in] learner_name
1086 * Learner table name.
1088 * String containing the learner table default entry.
1089 * @param[out] is_blank_or_comment
1090 * On error, this argument provides an indication of whether *string* contains
1091 * an invalid table entry (set to zero) or a blank or comment line that should
1092 * typically be ignored (set to a non-zero value).
1094 * 0 on success or the following error codes otherwise:
1095 * -EINVAL: Invalid argument.
1098 struct rte_swx_table_entry *
1099 rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
1100 const char *learner_name,
1102 int *is_blank_or_comment);
1105 * Pipeline table print to file
1107 * Print all the table entries to file.
1112 * Pipeline control handle.
1113 * @param[in] table_name
1116 * 0 on success or the following error codes otherwise:
1117 * -EINVAL: Invalid argument.
1121 rte_swx_ctl_pipeline_table_fprintf(FILE *f,
1122 struct rte_swx_ctl_pipeline *ctl,
1123 const char *table_name);
1126 * Pipeline selector print to file
1128 * Print all the selector entries to file.
1133 * Pipeline control handle.
1134 * @param[in] selector_name
1135 * Selector table name.
1137 * 0 on success or the following error codes otherwise:
1138 * -EINVAL: Invalid argument.
1142 rte_swx_ctl_pipeline_selector_fprintf(FILE *f,
1143 struct rte_swx_ctl_pipeline *ctl,
1144 const char *selector_name);
1147 * Register Array Query API.
1150 /** Register array info. */
1151 struct rte_swx_ctl_regarray_info {
1152 /** Register array name. */
1153 char name[RTE_SWX_CTL_NAME_SIZE];
1155 /** Register array size. */
1160 * Register array info get
1164 * @param[in] regarray_id
1165 * Register array ID (0 .. *n_regarrays* - 1).
1166 * @param[out] regarray
1167 * Register array info.
1169 * 0 on success or the following error codes otherwise:
1170 * -EINVAL: Invalid argument.
1174 rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
1175 uint32_t regarray_id,
1176 struct rte_swx_ctl_regarray_info *regarray);
1183 * @param[in] regarray_name
1184 * Register array name.
1185 * @param[in] regarray_index
1186 * Register index within the array (0 .. *size* - 1).
1188 * Current register value.
1190 * 0 on success or the following error codes otherwise:
1191 * -EINVAL: Invalid argument.
1195 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1196 const char *regarray_name,
1197 uint32_t regarray_index,
1205 * @param[in] regarray_name
1206 * Register array name.
1207 * @param[in] regarray_index
1208 * Register index within the array (0 .. *size* - 1).
1210 * Value to be written to the register.
1212 * 0 on success or the following error codes otherwise:
1213 * -EINVAL: Invalid argument.
1217 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1218 const char *regarray_name,
1219 uint32_t regarray_index,
1223 * Meter Array Query and Configuration API.
1226 /** Meter array info. */
1227 struct rte_swx_ctl_metarray_info {
1228 /** Meter array name. */
1229 char name[RTE_SWX_CTL_NAME_SIZE];
1231 /** Meter array size. */
1236 * Meter array info get
1240 * @param[in] metarray_id
1241 * Meter array ID (0 .. *n_metarrays* - 1).
1242 * @param[out] metarray
1245 * 0 on success or the following error codes otherwise:
1246 * -EINVAL: Invalid argument.
1250 rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
1251 uint32_t metarray_id,
1252 struct rte_swx_ctl_metarray_info *metarray);
1260 * Meter profile name.
1262 * Meter profile parameters.
1264 * 0 on success or the following error codes otherwise:
1265 * -EINVAL: Invalid argument;
1266 * -ENOMEM: Not enough space/cannot allocate memory;
1267 * -EEXIST: Meter profile with this name already exists.
1271 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1273 struct rte_meter_trtcm_params *params);
1276 * Meter profile delete
1281 * Meter profile name.
1283 * 0 on success or the following error codes otherwise:
1284 * -EINVAL: Invalid argument;
1285 * -EBUSY: Meter profile is currently in use.
1289 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1295 * Reset a meter within a given meter array to use the default profile that
1296 * causes all the input packets to be colored as green. It is the responsibility
1297 * of the control plane to make sure this meter is not used by the data plane
1298 * pipeline before calling this function.
1302 * @param[in] metarray_name
1304 * @param[in] metarray_index
1305 * Meter index within the meter array.
1307 * 0 on success or the following error codes otherwise:
1308 * -EINVAL: Invalid argument.
1312 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1313 const char *metarray_name,
1314 uint32_t metarray_index);
1319 * Set a meter within a given meter array to use a specific profile. It is the
1320 * responsibility of the control plane to make sure this meter is not used by
1321 * the data plane pipeline before calling this function.
1325 * @param[in] metarray_name
1327 * @param[in] metarray_index
1328 * Meter index within the meter array.
1329 * @param[in] profile_name
1330 * Existing meter profile name.
1332 * 0 on success or the following error codes otherwise:
1333 * -EINVAL: Invalid argument.
1337 rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
1338 const char *metarray_name,
1339 uint32_t metarray_index,
1340 const char *profile_name);
1342 /** Meter statistics counters. */
1343 struct rte_swx_ctl_meter_stats {
1344 /** Number of packets tagged by the meter for each color. */
1345 uint64_t n_pkts[RTE_COLORS];
1347 /** Number of bytes tagged by the meter for each color. */
1348 uint64_t n_bytes[RTE_COLORS];
1352 * Meter statistics counters read
1356 * @param[in] metarray_name
1358 * @param[in] metarray_index
1359 * Meter index within the meter array.
1361 * Meter statistics counters.
1363 * 0 on success or the following error codes otherwise:
1364 * -EINVAL: Invalid argument.
1368 rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
1369 const char *metarray_name,
1370 uint32_t metarray_index,
1371 struct rte_swx_ctl_meter_stats *stats);
1374 * Pipeline control free
1377 * Pipeline control handle.
1381 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);