DPDK  21.11.8
rte_swx_ctl.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 #ifndef __INCLUDE_RTE_SWX_CTL_H__
5 #define __INCLUDE_RTE_SWX_CTL_H__
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <stdio.h>
19 
20 #include <rte_compat.h>
21 #include <rte_meter.h>
22 
23 #include "rte_swx_port.h"
24 #include "rte_swx_table.h"
25 #include "rte_swx_table_selector.h"
26 
27 struct rte_swx_pipeline;
28 
30 #ifndef RTE_SWX_CTL_NAME_SIZE
31 #define RTE_SWX_CTL_NAME_SIZE 64
32 #endif
33 
34 /*
35  * Pipeline Query API.
36  */
37 
41  uint32_t n_ports_in;
42 
44  uint32_t n_ports_out;
45 
47  uint32_t n_actions;
48 
50  uint32_t n_tables;
51 
53  uint32_t n_selectors;
54 
56  uint32_t n_learners;
57 
59  uint32_t n_regarrays;
60 
62  uint32_t n_metarrays;
63 };
64 
76 __rte_experimental
77 int
78 rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
79  struct rte_swx_ctl_pipeline_info *pipeline);
80 
92 __rte_experimental
93 int
94 rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
95  int *numa_node);
96 
97 /*
98  * Ports Query API.
99  */
100 
114 __rte_experimental
115 int
116 rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
117  uint32_t port_id,
118  struct rte_swx_port_in_stats *stats);
119 
133 __rte_experimental
134 int
135 rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
136  uint32_t port_id,
137  struct rte_swx_port_out_stats *stats);
138 
139 /*
140  * Action Query API.
141  */
142 
147 
149  uint32_t n_args;
150 };
151 
165 __rte_experimental
166 int
167 rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
168  uint32_t action_id,
169  struct rte_swx_ctl_action_info *action);
170 
175 
177  uint32_t n_bits;
178 
184 };
185 
201 __rte_experimental
202 int
203 rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
204  uint32_t action_id,
205  uint32_t action_arg_id,
206  struct rte_swx_ctl_action_arg_info *action_arg);
207 
208 /*
209  * Table Query API.
210  */
211 
216 
219 
221  uint32_t n_match_fields;
222 
224  uint32_t n_actions;
225 
231 
233  uint32_t size;
234 };
235 
249 __rte_experimental
250 int
251 rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
252  uint32_t table_id,
253  struct rte_swx_ctl_table_info *table);
254 
262  enum rte_swx_table_match_type match_type;
263 
268 
270  uint32_t n_bits;
271 
275  uint32_t offset;
276 };
277 
293 __rte_experimental
294 int
295 rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
296  uint32_t table_id,
297  uint32_t match_field_id,
298  struct rte_swx_ctl_table_match_field_info *match_field);
299 
303  uint32_t action_id;
304 
307 
310 };
311 
330 __rte_experimental
331 int
332 rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
333  uint32_t table_id,
334  uint32_t table_action_id,
335  struct rte_swx_ctl_table_action_info *table_action);
336 
356 __rte_experimental
357 int
358 rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
359  uint32_t table_id,
360  struct rte_swx_table_ops *table_ops,
361  int *is_stub);
362 
366  uint64_t n_pkts_hit;
367 
369  uint64_t n_pkts_miss;
370 
376  uint64_t *n_pkts_action;
377 };
378 
395 __rte_experimental
396 int
397 rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
398  const char *table_name,
399  struct rte_swx_table_stats *stats);
400 
401 /*
402  * Selector Table Query API.
403  */
404 
409 
412 
414  uint32_t n_groups_max;
415 
418 };
419 
433 __rte_experimental
434 int
435 rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p,
436  uint32_t selector_id,
437  struct rte_swx_ctl_selector_info *selector);
438 
452 __rte_experimental
453 int
454 rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p,
455  uint32_t selector_id,
456  struct rte_swx_ctl_table_match_field_info *field);
457 
473 __rte_experimental
474 int
475 rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p,
476  uint32_t selector_id,
477  uint32_t selector_field_id,
478  struct rte_swx_ctl_table_match_field_info *field);
479 
493 __rte_experimental
494 int
495 rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p,
496  uint32_t selector_id,
497  struct rte_swx_ctl_table_match_field_info *field);
498 
502  uint64_t n_pkts;
503 };
504 
518 __rte_experimental
519 int
520 rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p,
521  const char *selector_name,
522  struct rte_swx_pipeline_selector_stats *stats);
523 
524 /*
525  * Learner Table Query API.
526  */
527 
532 
534  uint32_t n_match_fields;
535 
537  uint32_t n_actions;
538 
544 
546  uint32_t size;
547 };
548 
562 __rte_experimental
563 int
564 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
565  uint32_t learner_id,
566  struct rte_swx_ctl_learner_info *learner);
567 
583 __rte_experimental
584 int
585 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
586  uint32_t learner_id,
587  uint32_t match_field_id,
588  struct rte_swx_ctl_table_match_field_info *match_field);
589 
607 __rte_experimental
608 int
609 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
610  uint32_t learner_id,
611  uint32_t learner_action_id,
612  struct rte_swx_ctl_table_action_info *learner_action);
613 
617  uint64_t n_pkts_hit;
618 
620  uint64_t n_pkts_miss;
621 
623  uint64_t n_pkts_learn_ok;
624 
627 
629  uint64_t n_pkts_forget;
630 
635  uint64_t *n_pkts_action;
636 };
637 
654 __rte_experimental
655 int
656 rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
657  const char *learner_name,
658  struct rte_swx_learner_stats *stats);
659 
660 /*
661  * Table Update API.
662  */
663 
667  void *obj;
668 
671 
676 };
677 
694 __rte_experimental
695 int
696 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
697  struct rte_swx_table_state **table_state);
698 
713 __rte_experimental
714 int
715 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
716  struct rte_swx_table_state *table_state);
717 
718 /*
719  * High Level Reference Table Update API.
720  */
721 
723 struct rte_swx_ctl_pipeline;
724 
733 __rte_experimental
734 struct rte_swx_ctl_pipeline *
735 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
736 
753 __rte_experimental
754 int
755 rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
756  const char *table_name,
757  struct rte_swx_table_entry *entry);
758 
775 __rte_experimental
776 int
777 rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
778  const char *table_name,
779  struct rte_swx_table_entry *entry);
780 
798 __rte_experimental
799 int
800 rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
801  const char *table_name,
802  struct rte_swx_table_entry *entry);
803 
823 __rte_experimental
824 int
825 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
826  const char *selector_name,
827  uint32_t *group_id);
828 
846 __rte_experimental
847 int
848 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
849  const char *selector_name,
850  uint32_t group_id);
851 
876 __rte_experimental
877 int
878 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
879  const char *selector_name,
880  uint32_t group_id,
881  uint32_t member_id,
882  uint32_t member_weight);
883 
902 __rte_experimental
903 int
904 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
905  const char *selector_name,
906  uint32_t group_id,
907  uint32_t member_id);
908 
924 __rte_experimental
925 int
926 rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
927  const char *learner_name,
928  struct rte_swx_table_entry *entry);
929 
945 __rte_experimental
946 int
947 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
948  int abort_on_fail);
949 
958 __rte_experimental
959 void
960 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
961 
981 __rte_experimental
982 struct rte_swx_table_entry *
983 rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
984  const char *table_name,
985  const char *string,
986  int *is_blank_or_comment);
987 
1007 __rte_experimental
1008 struct rte_swx_table_entry *
1009 rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
1010  const char *learner_name,
1011  const char *string,
1012  int *is_blank_or_comment);
1013 
1029 __rte_experimental
1030 int
1032  struct rte_swx_ctl_pipeline *ctl,
1033  const char *table_name);
1034 
1050 __rte_experimental
1051 int
1053  struct rte_swx_ctl_pipeline *ctl,
1054  const char *selector_name);
1055 
1056 /*
1057  * Register Array Query API.
1058  */
1059 
1064 
1066  uint32_t size;
1067 };
1068 
1082 __rte_experimental
1083 int
1084 rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
1085  uint32_t regarray_id,
1086  struct rte_swx_ctl_regarray_info *regarray);
1087 
1103 __rte_experimental
1104 int
1105 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1106  const char *regarray_name,
1107  uint32_t regarray_index,
1108  uint64_t *value);
1109 
1125 __rte_experimental
1126 int
1127 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1128  const char *regarray_name,
1129  uint32_t regarray_index,
1130  uint64_t value);
1131 
1132 /*
1133  * Meter Array Query and Configuration API.
1134  */
1135 
1140 
1142  uint32_t size;
1143 };
1144 
1158 __rte_experimental
1159 int
1160 rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
1161  uint32_t metarray_id,
1162  struct rte_swx_ctl_metarray_info *metarray);
1163 
1179 __rte_experimental
1180 int
1181 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1182  const char *name,
1183  struct rte_meter_trtcm_params *params);
1184 
1197 __rte_experimental
1198 int
1199 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1200  const char *name);
1201 
1220 __rte_experimental
1221 int
1222 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1223  const char *metarray_name,
1224  uint32_t metarray_index);
1225 
1245 __rte_experimental
1246 int
1247 rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
1248  const char *metarray_name,
1249  uint32_t metarray_index,
1250  const char *profile_name);
1251 
1255  uint64_t n_pkts[RTE_COLORS];
1256 
1258  uint64_t n_bytes[RTE_COLORS];
1259 };
1260 
1276 __rte_experimental
1277 int
1278 rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
1279  const char *metarray_name,
1280  uint32_t metarray_index,
1281  struct rte_swx_ctl_meter_stats *stats);
1282 
1289 __rte_experimental
1290 void
1291 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
1292 
1293 #ifdef __cplusplus
1294 }
1295 #endif
1296 
1297 #endif
__rte_experimental int rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p, uint32_t table_id, uint32_t table_action_id, struct rte_swx_ctl_table_action_info *table_action)
__rte_experimental int rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p, uint32_t selector_id, struct rte_swx_ctl_selector_info *selector)
__rte_experimental int rte_swx_ctl_meter_set(struct rte_swx_pipeline *p, const char *metarray_name, uint32_t metarray_index, const char *profile_name)
__rte_experimental int rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p, const char *name)
__rte_experimental int rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p, const char *selector_name, struct rte_swx_pipeline_selector_stats *stats)
__rte_experimental struct rte_swx_table_entry * rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl, const char *learner_name, const char *string, int *is_blank_or_comment)
__rte_experimental int rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl, const char *selector_name, uint32_t *group_id)
Definition: rte_swx_table.h:68
uint64_t * n_pkts_action
Definition: rte_swx_ctl.h:376
__rte_experimental int rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl, const char *table_name, struct rte_swx_table_entry *entry)
uint8_t * default_action_data
Definition: rte_swx_ctl.h:675
__rte_experimental int rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p, const char *table_name, struct rte_swx_table_stats *stats)
__rte_experimental int rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl, const char *selector_name, uint32_t group_id, uint32_t member_id, uint32_t member_weight)
__rte_experimental int rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p, uint32_t action_id, uint32_t action_arg_id, struct rte_swx_ctl_action_arg_info *action_arg)
rte_swx_table_match_type
Definition: rte_swx_table.h:23
__rte_experimental int rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p, const char *name, struct rte_meter_trtcm_params *params)
uint64_t default_action_id
Definition: rte_swx_ctl.h:670
__rte_experimental int rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p, int *numa_node)
__rte_experimental void rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl)
__rte_experimental int rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p, uint32_t table_id, struct rte_swx_table_ops *table_ops, int *is_stub)
__rte_experimental int rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p, uint32_t learner_id, uint32_t match_field_id, struct rte_swx_ctl_table_match_field_info *match_field)
__rte_experimental int rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl, const char *table_name, struct rte_swx_table_entry *entry)
__rte_experimental int rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p, const char *metarray_name, uint32_t metarray_index)
__rte_experimental int rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl, const char *learner_name, struct rte_swx_table_entry *entry)
__rte_experimental int rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p, uint32_t action_id, struct rte_swx_ctl_action_info *action)
__rte_experimental int rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p, uint32_t selector_id, struct rte_swx_ctl_table_match_field_info *field)
__rte_experimental int rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl, const char *table_name, struct rte_swx_table_entry *entry)
__rte_experimental int rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p, const char *regarray_name, uint32_t regarray_index, uint64_t value)
__rte_experimental int rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p, uint32_t metarray_id, struct rte_swx_ctl_metarray_info *metarray)
__rte_experimental int rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p, uint32_t port_id, struct rte_swx_port_out_stats *stats)
__rte_experimental int rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p, struct rte_swx_ctl_pipeline_info *pipeline)
__rte_experimental struct rte_swx_ctl_pipeline * rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p)
__rte_experimental int rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p, uint32_t port_id, struct rte_swx_port_in_stats *stats)
__rte_experimental int rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p, uint32_t table_id, uint32_t match_field_id, struct rte_swx_ctl_table_match_field_info *match_field)
__rte_experimental int rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p, struct rte_swx_table_state **table_state)
__rte_experimental int rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl, const char *selector_name, uint32_t group_id, uint32_t member_id)
__rte_experimental struct rte_swx_table_entry * rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl, const char *table_name, const char *string, int *is_blank_or_comment)
uint64_t * n_pkts_action
Definition: rte_swx_ctl.h:635
__rte_experimental int rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p, uint32_t table_id, struct rte_swx_ctl_table_info *table)
__rte_experimental int rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p, uint32_t selector_id, struct rte_swx_ctl_table_match_field_info *field)
__rte_experimental int rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p, uint32_t selector_id, uint32_t selector_field_id, struct rte_swx_ctl_table_match_field_info *field)
__rte_experimental int rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl, int abort_on_fail)
__rte_experimental int rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p, const char *regarray_name, uint32_t regarray_index, uint64_t *value)
__rte_experimental int rte_swx_ctl_pipeline_selector_fprintf(FILE *f, struct rte_swx_ctl_pipeline *ctl, const char *selector_name)
__rte_experimental int rte_swx_ctl_pipeline_table_fprintf(FILE *f, struct rte_swx_ctl_pipeline *ctl, const char *table_name)
__rte_experimental int rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl, const char *selector_name, uint32_t group_id)
#define RTE_SWX_CTL_NAME_SIZE
Definition: rte_swx_ctl.h:31
__rte_experimental int rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p, uint32_t regarray_id, struct rte_swx_ctl_regarray_info *regarray)
__rte_experimental int rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p, uint32_t learner_id, struct rte_swx_ctl_learner_info *learner)
__rte_experimental int rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p, const char *learner_name, struct rte_swx_learner_stats *stats)
__rte_experimental int rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p, struct rte_swx_table_state *table_state)
__rte_experimental void rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl)
__rte_experimental int rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p, uint32_t learner_id, uint32_t learner_action_id, struct rte_swx_ctl_table_action_info *learner_action)
__rte_experimental int rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p, const char *metarray_name, uint32_t metarray_index, struct rte_swx_ctl_meter_stats *stats)