DPDK  22.03.0
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 <stdint.h>
17 #include <stdio.h>
18 
19 #include <rte_compat.h>
20 #include <rte_meter.h>
21 
22 #include "rte_swx_port.h"
23 #include "rte_swx_table.h"
24 
25 struct rte_swx_pipeline;
26 
28 #ifndef RTE_SWX_CTL_NAME_SIZE
29 #define RTE_SWX_CTL_NAME_SIZE 64
30 #endif
31 
32 /*
33  * Pipeline Query API.
34  */
35 
39  uint32_t n_ports_in;
40 
42  uint32_t n_ports_out;
43 
45  uint32_t n_actions;
46 
48  uint32_t n_tables;
49 
51  uint32_t n_selectors;
52 
54  uint32_t n_learners;
55 
57  uint32_t n_regarrays;
58 
60  uint32_t n_metarrays;
61 };
62 
74 __rte_experimental
75 int
76 rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
77  struct rte_swx_ctl_pipeline_info *pipeline);
78 
90 __rte_experimental
91 int
92 rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
93  int *numa_node);
94 
95 /*
96  * Ports Query API.
97  */
98 
112 __rte_experimental
113 int
114 rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
115  uint32_t port_id,
116  struct rte_swx_port_in_stats *stats);
117 
131 __rte_experimental
132 int
133 rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
134  uint32_t port_id,
135  struct rte_swx_port_out_stats *stats);
136 
137 /*
138  * Action Query API.
139  */
140 
145 
147  uint32_t n_args;
148 };
149 
163 __rte_experimental
164 int
165 rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
166  uint32_t action_id,
167  struct rte_swx_ctl_action_info *action);
168 
173 
175  uint32_t n_bits;
176 
182 };
183 
199 __rte_experimental
200 int
201 rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
202  uint32_t action_id,
203  uint32_t action_arg_id,
204  struct rte_swx_ctl_action_arg_info *action_arg);
205 
206 /*
207  * Table Query API.
208  */
209 
214 
217 
219  uint32_t n_match_fields;
220 
222  uint32_t n_actions;
223 
229 
231  uint32_t size;
232 };
233 
247 __rte_experimental
248 int
249 rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
250  uint32_t table_id,
251  struct rte_swx_ctl_table_info *table);
252 
260  enum rte_swx_table_match_type match_type;
261 
266 
268  uint32_t n_bits;
269 
273  uint32_t offset;
274 };
275 
291 __rte_experimental
292 int
293 rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
294  uint32_t table_id,
295  uint32_t match_field_id,
296  struct rte_swx_ctl_table_match_field_info *match_field);
297 
301  uint32_t action_id;
302 
305 
308 };
309 
328 __rte_experimental
329 int
330 rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
331  uint32_t table_id,
332  uint32_t table_action_id,
333  struct rte_swx_ctl_table_action_info *table_action);
334 
354 __rte_experimental
355 int
356 rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
357  uint32_t table_id,
358  struct rte_swx_table_ops *table_ops,
359  int *is_stub);
360 
364  uint64_t n_pkts_hit;
365 
367  uint64_t n_pkts_miss;
368 
374  uint64_t *n_pkts_action;
375 };
376 
393 __rte_experimental
394 int
395 rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
396  const char *table_name,
397  struct rte_swx_table_stats *stats);
398 
399 /*
400  * Selector Table Query API.
401  */
402 
407 
410 
412  uint32_t n_groups_max;
413 
416 };
417 
431 __rte_experimental
432 int
433 rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p,
434  uint32_t selector_id,
435  struct rte_swx_ctl_selector_info *selector);
436 
450 __rte_experimental
451 int
452 rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p,
453  uint32_t selector_id,
454  struct rte_swx_ctl_table_match_field_info *field);
455 
471 __rte_experimental
472 int
473 rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p,
474  uint32_t selector_id,
475  uint32_t selector_field_id,
476  struct rte_swx_ctl_table_match_field_info *field);
477 
491 __rte_experimental
492 int
493 rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p,
494  uint32_t selector_id,
495  struct rte_swx_ctl_table_match_field_info *field);
496 
500  uint64_t n_pkts;
501 };
502 
516 __rte_experimental
517 int
518 rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p,
519  const char *selector_name,
520  struct rte_swx_pipeline_selector_stats *stats);
521 
522 /*
523  * Learner Table Query API.
524  */
525 
530 
532  uint32_t n_match_fields;
533 
535  uint32_t n_actions;
536 
542 
544  uint32_t size;
545 };
546 
560 __rte_experimental
561 int
562 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
563  uint32_t learner_id,
564  struct rte_swx_ctl_learner_info *learner);
565 
581 __rte_experimental
582 int
583 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
584  uint32_t learner_id,
585  uint32_t match_field_id,
586  struct rte_swx_ctl_table_match_field_info *match_field);
587 
605 __rte_experimental
606 int
607 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
608  uint32_t learner_id,
609  uint32_t learner_action_id,
610  struct rte_swx_ctl_table_action_info *learner_action);
611 
615  uint64_t n_pkts_hit;
616 
618  uint64_t n_pkts_miss;
619 
621  uint64_t n_pkts_learn_ok;
622 
625 
627  uint64_t n_pkts_forget;
628 
633  uint64_t *n_pkts_action;
634 };
635 
652 __rte_experimental
653 int
654 rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
655  const char *learner_name,
656  struct rte_swx_learner_stats *stats);
657 
658 /*
659  * Table Update API.
660  */
661 
665  void *obj;
666 
669 
674 };
675 
692 __rte_experimental
693 int
694 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
695  struct rte_swx_table_state **table_state);
696 
711 __rte_experimental
712 int
713 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
714  struct rte_swx_table_state *table_state);
715 
716 /*
717  * High Level Reference Table Update API.
718  */
719 
721 struct rte_swx_ctl_pipeline;
722 
731 __rte_experimental
732 struct rte_swx_ctl_pipeline *
733 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
734 
751 __rte_experimental
752 int
753 rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
754  const char *table_name,
755  struct rte_swx_table_entry *entry);
756 
773 __rte_experimental
774 int
775 rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
776  const char *table_name,
777  struct rte_swx_table_entry *entry);
778 
796 __rte_experimental
797 int
798 rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
799  const char *table_name,
800  struct rte_swx_table_entry *entry);
801 
821 __rte_experimental
822 int
823 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
824  const char *selector_name,
825  uint32_t *group_id);
826 
844 __rte_experimental
845 int
846 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
847  const char *selector_name,
848  uint32_t group_id);
849 
874 __rte_experimental
875 int
876 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
877  const char *selector_name,
878  uint32_t group_id,
879  uint32_t member_id,
880  uint32_t member_weight);
881 
900 __rte_experimental
901 int
902 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
903  const char *selector_name,
904  uint32_t group_id,
905  uint32_t member_id);
906 
922 __rte_experimental
923 int
924 rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
925  const char *learner_name,
926  struct rte_swx_table_entry *entry);
927 
943 __rte_experimental
944 int
945 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
946  int abort_on_fail);
947 
956 __rte_experimental
957 void
958 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
959 
979 __rte_experimental
980 struct rte_swx_table_entry *
981 rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
982  const char *table_name,
983  const char *string,
984  int *is_blank_or_comment);
985 
1005 __rte_experimental
1006 struct rte_swx_table_entry *
1007 rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
1008  const char *learner_name,
1009  const char *string,
1010  int *is_blank_or_comment);
1011 
1027 __rte_experimental
1028 int
1030  struct rte_swx_ctl_pipeline *ctl,
1031  const char *table_name);
1032 
1048 __rte_experimental
1049 int
1051  struct rte_swx_ctl_pipeline *ctl,
1052  const char *selector_name);
1053 
1054 /*
1055  * Register Array Query API.
1056  */
1057 
1062 
1064  uint32_t size;
1065 };
1066 
1080 __rte_experimental
1081 int
1082 rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
1083  uint32_t regarray_id,
1084  struct rte_swx_ctl_regarray_info *regarray);
1085 
1101 __rte_experimental
1102 int
1103 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1104  const char *regarray_name,
1105  uint32_t regarray_index,
1106  uint64_t *value);
1107 
1123 __rte_experimental
1124 int
1125 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1126  const char *regarray_name,
1127  uint32_t regarray_index,
1128  uint64_t value);
1129 
1130 /*
1131  * Meter Array Query and Configuration API.
1132  */
1133 
1138 
1140  uint32_t size;
1141 };
1142 
1156 __rte_experimental
1157 int
1158 rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
1159  uint32_t metarray_id,
1160  struct rte_swx_ctl_metarray_info *metarray);
1161 
1177 __rte_experimental
1178 int
1179 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1180  const char *name,
1181  struct rte_meter_trtcm_params *params);
1182 
1195 __rte_experimental
1196 int
1197 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1198  const char *name);
1199 
1218 __rte_experimental
1219 int
1220 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1221  const char *metarray_name,
1222  uint32_t metarray_index);
1223 
1243 __rte_experimental
1244 int
1245 rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
1246  const char *metarray_name,
1247  uint32_t metarray_index,
1248  const char *profile_name);
1249 
1253  uint64_t n_pkts[RTE_COLORS];
1254 
1256  uint64_t n_bytes[RTE_COLORS];
1257 };
1258 
1274 __rte_experimental
1275 int
1276 rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
1277  const char *metarray_name,
1278  uint32_t metarray_index,
1279  struct rte_swx_ctl_meter_stats *stats);
1280 
1287 __rte_experimental
1288 void
1289 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
1290 
1291 #ifdef __cplusplus
1292 }
1293 #endif
1294 
1295 #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:374
__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:673
__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:668
__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:633
__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:29
__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)