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. */
554 * Learner table info get
558 * @param[in] learner_id
559 * Learner table ID (0 .. *n_learners* - 1).
560 * @param[out] learner
561 * Learner table info.
563 * 0 on success or the following error codes otherwise:
564 * -EINVAL: Invalid argument.
568 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
570 struct rte_swx_ctl_learner_info *learner);
573 * Learner table match field info get
577 * @param[in] learner_id
578 * Learner table ID (0 .. *n_learners* - 1).
579 * @param[in] match_field_id
580 * Match field ID (0 .. *n_match_fields* - 1).
581 * @param[out] match_field
582 * Learner table match field info.
584 * 0 on success or the following error codes otherwise:
585 * -EINVAL: Invalid argument.
589 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
591 uint32_t match_field_id,
592 struct rte_swx_ctl_table_match_field_info *match_field);
595 * Learner table action info get
599 * @param[in] learner_id
600 * Learner table ID (0 .. *n_learners* - 1).
601 * @param[in] learner_action_id
602 * Action index within the set of learner table actions (0 .. learner table n_actions - 1). Not
603 * to be confused with the pipeline-leve action ID (0 .. pipeline n_actions - 1), which is
604 * precisely what this function returns as part of the *learner_action*.
605 * @param[out] learner_action
606 * Learner action info.
608 * 0 on success or the following error codes otherwise:
609 * -EINVAL: Invalid argument.
613 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
615 uint32_t learner_action_id,
616 struct rte_swx_ctl_table_action_info *learner_action);
618 /** Learner table statistics. */
619 struct rte_swx_learner_stats {
620 /** Number of packets with lookup hit. */
623 /** Number of packets with lookup miss. */
624 uint64_t n_pkts_miss;
626 /** Number of packets with successful learning. */
627 uint64_t n_pkts_learn_ok;
629 /** Number of packets with learning error. */
630 uint64_t n_pkts_learn_err;
632 /** Number of packets with forget event. */
633 uint64_t n_pkts_forget;
635 /** Number of packets (with either lookup hit or miss) per pipeline action. Array of
636 * pipeline *n_actions* elements indexed by the pipeline-level *action_id*, therefore this
637 * array has the same size for all the tables within the same pipeline.
639 uint64_t *n_pkts_action;
643 * Learner table statistics counters read
647 * @param[in] learner_name
648 * Learner table name.
650 * Learner table stats. Must point to a pre-allocated structure. The *n_pkts_action* field also
651 * needs to be pre-allocated as array of pipeline *n_actions* elements. The pipeline actions that
652 * are not valid for the current learner table have their associated *n_pkts_action* element
653 * always set to zero.
655 * 0 on success or the following error codes otherwise:
656 * -EINVAL: Invalid argument.
660 rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
661 const char *learner_name,
662 struct rte_swx_learner_stats *stats);
665 * Packet mirroring API.
668 /** Packet mirroring session parameters. */
669 struct rte_swx_pipeline_mirroring_session_params {
670 /** Output port ID. */
673 /** Fast clone flag. */
676 /** Truncation packet length (in bytes). Zero means no truncation. */
677 uint32_t truncation_length;
681 * Packet mirroring session set
685 * @param[in] session_id
686 * Packet mirroring session ID.
688 * Packet mirroring session parameters.
690 * 0 on success or the following error codes otherwise:
691 * -EINVAL: Invalid argument;
692 * -EEXIST: Pipeline was already built successfully.
696 rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p,
698 struct rte_swx_pipeline_mirroring_session_params *params);
705 struct rte_swx_table_state {
709 /** Action ID of the table default action. */
710 uint64_t default_action_id;
712 /** Action data of the table default action. Ignored when the action
713 * data size is zero; otherwise, action data size bytes are meaningful.
715 uint8_t *default_action_data;
719 * Pipeline table state get
723 * @param[out] table_state
724 * After successful execution, the *table_state* contains the pointer to the
725 * current pipeline table state, which is an array of *n_tables* elements,
726 * with array element i containing the state of the i-th pipeline table. The
727 * pipeline continues to own all the data structures directly or indirectly
728 * referenced by the *table_state* until the subsequent successful invocation
729 * of function *rte_swx_pipeline_table_state_set*.
731 * 0 on success or the following error codes otherwise:
732 * -EINVAL: Invalid argument.
736 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
737 struct rte_swx_table_state **table_state);
740 * Pipeline table state set
744 * @param[out] table_state
745 * After successful execution, the pipeline table state is updated to this
746 * *table_state*. The ownership of all the data structures directly or
747 * indirectly referenced by this *table_state* is passed from the caller to
750 * 0 on success or the following error codes otherwise:
751 * -EINVAL: Invalid argument.
755 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
756 struct rte_swx_table_state *table_state);
759 * High Level Reference Table Update API.
762 /** Pipeline control opaque data structure. */
763 struct rte_swx_ctl_pipeline;
766 * Pipeline control create
771 * Pipeline control handle, on success, or NULL, on error.
774 struct rte_swx_ctl_pipeline *
775 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
778 * Pipeline table entry add
780 * Schedule entry for addition to table or update as part of the next commit
784 * Pipeline control handle.
785 * @param[in] table_name
788 * Entry to be added to the table.
790 * 0 on success or the following error codes otherwise:
791 * -EINVAL: Invalid argument.
795 rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
796 const char *table_name,
797 struct rte_swx_table_entry *entry);
800 * Pipeline table default entry add
802 * Schedule table default entry update as part of the next commit operation.
805 * Pipeline control handle.
806 * @param[in] table_name
809 * The new table default entry. The *key* and *key_mask* entry fields are
812 * 0 on success or the following error codes otherwise:
813 * -EINVAL: Invalid argument.
817 rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
818 const char *table_name,
819 struct rte_swx_table_entry *entry);
822 * Pipeline table entry delete
824 * Schedule entry for deletion from table as part of the next commit operation.
825 * Request is silently discarded if no such entry exists.
828 * Pipeline control handle.
829 * @param[in] table_name
832 * Entry to be deleted from the table. The *action_id* and *action_data* entry
833 * fields are ignored.
835 * 0 on success or the following error codes otherwise:
836 * -EINVAL: Invalid argument.
840 rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
841 const char *table_name,
842 struct rte_swx_table_entry *entry);
845 * Pipeline selector table group add
847 * Add a new group to a selector table. This operation is executed before this
848 * function returns and its result is independent of the result of the next
852 * Pipeline control handle.
853 * @param[in] selector_name
854 * Selector table name.
855 * @param[out] group_id
856 * The ID of the new group. Only valid when the function call is successful.
857 * This group is initially empty, i.e. it does not contain any members.
859 * 0 on success or the following error codes otherwise:
860 * -EINVAL: Invalid argument;
861 * -ENOSPC: All groups are currently in use, no group available.
865 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
866 const char *selector_name,
870 * Pipeline selector table group delete
872 * Schedule a group for deletion as part of the next commit operation. The group
873 * to be deleted can be empty or non-empty.
876 * Pipeline control handle.
877 * @param[in] selector_name
878 * Selector table name.
879 * @param[in] group_id
880 * Group to be deleted from the selector table.
882 * 0 on success or the following error codes otherwise:
883 * -EINVAL: Invalid argument;
884 * -ENOMEM: Not enough memory.
888 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
889 const char *selector_name,
893 * Pipeline selector table member add to group
895 * Schedule the operation to add a new member to an existing group as part of
896 * the next commit operation. If this member is already in this group, the
897 * member weight is updated to the new value. A weight of zero means this member
898 * is to be deleted from the group.
901 * Pipeline control handle.
902 * @param[in] selector_name
903 * Selector table name.
904 * @param[in] group_id
906 * @param[in] member_id
907 * The member to be added to the group.
908 * @param[in] member_weight
911 * 0 on success or the following error codes otherwise:
912 * -EINVAL: Invalid argument;
913 * -ENOMEM: Not enough memory;
914 * -ENOSPC: The group is full.
918 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
919 const char *selector_name,
922 uint32_t member_weight);
925 * Pipeline selector table member delete from group
927 * Schedule the operation to delete a member from an existing group as part of
928 * the next commit operation.
931 * Pipeline control handle.
932 * @param[in] selector_name
933 * Selector table name.
934 * @param[in] group_id
935 * The group ID. Must be valid.
936 * @param[in] member_id
937 * The member to be added to the group. Must be valid.
939 * 0 on success or the following error codes otherwise:
940 * -EINVAL: Invalid argument.
944 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
945 const char *selector_name,
950 * Pipeline learner table default entry add
952 * Schedule learner table default entry update as part of the next commit operation.
955 * Pipeline control handle.
956 * @param[in] learner_name
957 * Learner table name.
959 * The new table default entry. The *key* and *key_mask* entry fields are ignored.
961 * 0 on success or the following error codes otherwise:
962 * -EINVAL: Invalid argument.
966 rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
967 const char *learner_name,
968 struct rte_swx_table_entry *entry);
973 * Perform all the scheduled table work.
976 * Pipeline control handle.
977 * @param[in] abort_on_fail
978 * When non-zero (false), all the scheduled work is discarded after a failed
979 * commit. Otherwise, the scheduled work is still kept pending for the next
982 * 0 on success or the following error codes otherwise:
983 * -EINVAL: Invalid argument.
987 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
993 * Discard all the scheduled table work.
996 * Pipeline control handle.
1000 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
1003 * Pipeline table entry read
1005 * Read table entry from string.
1008 * Pipeline control handle.
1009 * @param[in] table_name
1012 * String containing the table entry.
1013 * @param[out] is_blank_or_comment
1014 * On error, this argument provides an indication of whether *string* contains
1015 * an invalid table entry (set to zero) or a blank or comment line that should
1016 * typically be ignored (set to a non-zero value).
1018 * 0 on success or the following error codes otherwise:
1019 * -EINVAL: Invalid argument.
1022 struct rte_swx_table_entry *
1023 rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
1024 const char *table_name,
1026 int *is_blank_or_comment);
1029 * Pipeline learner table default entry read
1031 * Read learner table default entry from string.
1034 * Pipeline control handle.
1035 * @param[in] learner_name
1036 * Learner table name.
1038 * String containing the learner table default entry.
1039 * @param[out] is_blank_or_comment
1040 * On error, this argument provides an indication of whether *string* contains
1041 * an invalid table entry (set to zero) or a blank or comment line that should
1042 * typically be ignored (set to a non-zero value).
1044 * 0 on success or the following error codes otherwise:
1045 * -EINVAL: Invalid argument.
1048 struct rte_swx_table_entry *
1049 rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
1050 const char *learner_name,
1052 int *is_blank_or_comment);
1055 * Pipeline table print to file
1057 * Print all the table entries to file.
1062 * Pipeline control handle.
1063 * @param[in] table_name
1066 * 0 on success or the following error codes otherwise:
1067 * -EINVAL: Invalid argument.
1071 rte_swx_ctl_pipeline_table_fprintf(FILE *f,
1072 struct rte_swx_ctl_pipeline *ctl,
1073 const char *table_name);
1076 * Pipeline selector print to file
1078 * Print all the selector entries to file.
1083 * Pipeline control handle.
1084 * @param[in] selector_name
1085 * Selector table name.
1087 * 0 on success or the following error codes otherwise:
1088 * -EINVAL: Invalid argument.
1092 rte_swx_ctl_pipeline_selector_fprintf(FILE *f,
1093 struct rte_swx_ctl_pipeline *ctl,
1094 const char *selector_name);
1097 * Register Array Query API.
1100 /** Register array info. */
1101 struct rte_swx_ctl_regarray_info {
1102 /** Register array name. */
1103 char name[RTE_SWX_CTL_NAME_SIZE];
1105 /** Register array size. */
1110 * Register array info get
1114 * @param[in] regarray_id
1115 * Register array ID (0 .. *n_regarrays* - 1).
1116 * @param[out] regarray
1117 * Register array info.
1119 * 0 on success or the following error codes otherwise:
1120 * -EINVAL: Invalid argument.
1124 rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
1125 uint32_t regarray_id,
1126 struct rte_swx_ctl_regarray_info *regarray);
1133 * @param[in] regarray_name
1134 * Register array name.
1135 * @param[in] regarray_index
1136 * Register index within the array (0 .. *size* - 1).
1138 * Current register value.
1140 * 0 on success or the following error codes otherwise:
1141 * -EINVAL: Invalid argument.
1145 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1146 const char *regarray_name,
1147 uint32_t regarray_index,
1155 * @param[in] regarray_name
1156 * Register array name.
1157 * @param[in] regarray_index
1158 * Register index within the array (0 .. *size* - 1).
1160 * Value to be written to the register.
1162 * 0 on success or the following error codes otherwise:
1163 * -EINVAL: Invalid argument.
1167 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1168 const char *regarray_name,
1169 uint32_t regarray_index,
1173 * Meter Array Query and Configuration API.
1176 /** Meter array info. */
1177 struct rte_swx_ctl_metarray_info {
1178 /** Meter array name. */
1179 char name[RTE_SWX_CTL_NAME_SIZE];
1181 /** Meter array size. */
1186 * Meter array info get
1190 * @param[in] metarray_id
1191 * Meter array ID (0 .. *n_metarrays* - 1).
1192 * @param[out] metarray
1195 * 0 on success or the following error codes otherwise:
1196 * -EINVAL: Invalid argument.
1200 rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
1201 uint32_t metarray_id,
1202 struct rte_swx_ctl_metarray_info *metarray);
1210 * Meter profile name.
1212 * Meter profile parameters.
1214 * 0 on success or the following error codes otherwise:
1215 * -EINVAL: Invalid argument;
1216 * -ENOMEM: Not enough space/cannot allocate memory;
1217 * -EEXIST: Meter profile with this name already exists.
1221 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1223 struct rte_meter_trtcm_params *params);
1226 * Meter profile delete
1231 * Meter profile name.
1233 * 0 on success or the following error codes otherwise:
1234 * -EINVAL: Invalid argument;
1235 * -EBUSY: Meter profile is currently in use.
1239 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1245 * Reset a meter within a given meter array to use the default profile that
1246 * causes all the input packets to be colored as green. It is the responsibility
1247 * of the control plane to make sure this meter is not used by the data plane
1248 * pipeline before calling this function.
1252 * @param[in] metarray_name
1254 * @param[in] metarray_index
1255 * Meter index within the meter array.
1257 * 0 on success or the following error codes otherwise:
1258 * -EINVAL: Invalid argument.
1262 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1263 const char *metarray_name,
1264 uint32_t metarray_index);
1269 * Set a meter within a given meter array to use a specific profile. It is the
1270 * responsibility of the control plane to make sure this meter is not used by
1271 * the data plane pipeline before calling this function.
1275 * @param[in] metarray_name
1277 * @param[in] metarray_index
1278 * Meter index within the meter array.
1279 * @param[in] profile_name
1280 * Existing meter profile name.
1282 * 0 on success or the following error codes otherwise:
1283 * -EINVAL: Invalid argument.
1287 rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
1288 const char *metarray_name,
1289 uint32_t metarray_index,
1290 const char *profile_name);
1292 /** Meter statistics counters. */
1293 struct rte_swx_ctl_meter_stats {
1294 /** Number of packets tagged by the meter for each color. */
1295 uint64_t n_pkts[RTE_COLORS];
1297 /** Number of bytes tagged by the meter for each color. */
1298 uint64_t n_bytes[RTE_COLORS];
1302 * Meter statistics counters read
1306 * @param[in] metarray_name
1308 * @param[in] metarray_index
1309 * Meter index within the meter array.
1311 * Meter statistics counters.
1313 * 0 on success or the following error codes otherwise:
1314 * -EINVAL: Invalid argument.
1318 rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
1319 const char *metarray_name,
1320 uint32_t metarray_index,
1321 struct rte_swx_ctl_meter_stats *stats);
1324 * Pipeline control free
1327 * Pipeline control handle.
1331 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);