DPDK  22.07.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 
46 
49 
51  uint32_t n_actions;
52 
54  uint32_t n_tables;
55 
57  uint32_t n_selectors;
58 
60  uint32_t n_learners;
61 
63  uint32_t n_regarrays;
64 
66  uint32_t n_metarrays;
67 };
68 
80 __rte_experimental
81 int
82 rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
83  struct rte_swx_ctl_pipeline_info *pipeline);
84 
96 __rte_experimental
97 int
98 rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
99  int *numa_node);
100 
101 /*
102  * Ports Query API.
103  */
104 
118 __rte_experimental
119 int
120 rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
121  uint32_t port_id,
122  struct rte_swx_port_in_stats *stats);
123 
137 __rte_experimental
138 int
139 rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
140  uint32_t port_id,
141  struct rte_swx_port_out_stats *stats);
142 
143 /*
144  * Action Query API.
145  */
146 
151 
153  uint32_t n_args;
154 };
155 
169 __rte_experimental
170 int
171 rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
172  uint32_t action_id,
173  struct rte_swx_ctl_action_info *action);
174 
179 
181  uint32_t n_bits;
182 
188 };
189 
205 __rte_experimental
206 int
207 rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
208  uint32_t action_id,
209  uint32_t action_arg_id,
210  struct rte_swx_ctl_action_arg_info *action_arg);
211 
212 /*
213  * Table Query API.
214  */
215 
220 
223 
225  uint32_t n_match_fields;
226 
228  uint32_t n_actions;
229 
235 
237  uint32_t size;
238 };
239 
253 __rte_experimental
254 int
255 rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
256  uint32_t table_id,
257  struct rte_swx_ctl_table_info *table);
258 
266  enum rte_swx_table_match_type match_type;
267 
272 
274  uint32_t n_bits;
275 
279  uint32_t offset;
280 };
281 
297 __rte_experimental
298 int
299 rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
300  uint32_t table_id,
301  uint32_t match_field_id,
302  struct rte_swx_ctl_table_match_field_info *match_field);
303 
307  uint32_t action_id;
308 
311 
314 };
315 
334 __rte_experimental
335 int
336 rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
337  uint32_t table_id,
338  uint32_t table_action_id,
339  struct rte_swx_ctl_table_action_info *table_action);
340 
360 __rte_experimental
361 int
362 rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
363  uint32_t table_id,
364  struct rte_swx_table_ops *table_ops,
365  int *is_stub);
366 
370  uint64_t n_pkts_hit;
371 
373  uint64_t n_pkts_miss;
374 
380  uint64_t *n_pkts_action;
381 };
382 
399 __rte_experimental
400 int
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);
404 
405 /*
406  * Selector Table Query API.
407  */
408 
413 
416 
418  uint32_t n_groups_max;
419 
422 };
423 
437 __rte_experimental
438 int
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);
442 
456 __rte_experimental
457 int
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);
461 
477 __rte_experimental
478 int
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);
483 
497 __rte_experimental
498 int
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);
502 
506  uint64_t n_pkts;
507 };
508 
522 __rte_experimental
523 int
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);
527 
528 /*
529  * Learner Table Query API.
530  */
531 
536 
538  uint32_t n_match_fields;
539 
541  uint32_t n_actions;
542 
548 
550  uint32_t size;
551 
553  uint32_t n_key_timeouts;
554 };
555 
569 __rte_experimental
570 int
571 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
572  uint32_t learner_id,
573  struct rte_swx_ctl_learner_info *learner);
574 
590 __rte_experimental
591 int
592 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
593  uint32_t learner_id,
594  uint32_t match_field_id,
595  struct rte_swx_ctl_table_match_field_info *match_field);
596 
614 __rte_experimental
615 int
616 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
617  uint32_t learner_id,
618  uint32_t learner_action_id,
619  struct rte_swx_ctl_table_action_info *learner_action);
620 
636 __rte_experimental
637 int
638 rte_swx_ctl_pipeline_learner_timeout_get(struct rte_swx_pipeline *p,
639  uint32_t learner_id,
640  uint32_t timeout_id,
641  uint32_t *timeout);
642 
658 __rte_experimental
659 int
660 rte_swx_ctl_pipeline_learner_timeout_set(struct rte_swx_pipeline *p,
661  uint32_t learner_id,
662  uint32_t timeout_id,
663  uint32_t timeout);
664 
668  uint64_t n_pkts_hit;
669 
671  uint64_t n_pkts_miss;
672 
674  uint64_t n_pkts_learn_ok;
675 
678 
680  uint64_t n_pkts_rearm;
681 
683  uint64_t n_pkts_forget;
684 
689  uint64_t *n_pkts_action;
690 };
691 
708 __rte_experimental
709 int
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);
713 
714 /*
715  * Packet mirroring API.
716  */
717 
721  uint32_t port_id;
722 
725 
728 };
729 
744 __rte_experimental
745 int
746 rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p,
747  uint32_t session_id,
749 
750 /*
751  * Table Update API.
752  */
753 
757  void *obj;
758 
761 
766 };
767 
784 __rte_experimental
785 int
786 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
787  struct rte_swx_table_state **table_state);
788 
803 __rte_experimental
804 int
805 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
806  struct rte_swx_table_state *table_state);
807 
808 /*
809  * High Level Reference Table Update API.
810  */
811 
813 struct rte_swx_ctl_pipeline;
814 
823 __rte_experimental
824 struct rte_swx_ctl_pipeline *
825 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
826 
843 __rte_experimental
844 int
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);
848 
865 __rte_experimental
866 int
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);
870 
888 __rte_experimental
889 int
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);
893 
913 __rte_experimental
914 int
915 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
916  const char *selector_name,
917  uint32_t *group_id);
918 
936 __rte_experimental
937 int
938 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
939  const char *selector_name,
940  uint32_t group_id);
941 
966 __rte_experimental
967 int
968 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
969  const char *selector_name,
970  uint32_t group_id,
971  uint32_t member_id,
972  uint32_t member_weight);
973 
992 __rte_experimental
993 int
994 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
995  const char *selector_name,
996  uint32_t group_id,
997  uint32_t member_id);
998 
1014 __rte_experimental
1015 int
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);
1019 
1035 __rte_experimental
1036 int
1037 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
1038  int abort_on_fail);
1039 
1048 __rte_experimental
1049 void
1050 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
1051 
1071 __rte_experimental
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,
1075  const char *string,
1076  int *is_blank_or_comment);
1077 
1097 __rte_experimental
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,
1101  const char *string,
1102  int *is_blank_or_comment);
1103 
1119 __rte_experimental
1120 int
1122  struct rte_swx_ctl_pipeline *ctl,
1123  const char *table_name);
1124 
1140 __rte_experimental
1141 int
1143  struct rte_swx_ctl_pipeline *ctl,
1144  const char *selector_name);
1145 
1146 /*
1147  * Register Array Query API.
1148  */
1149 
1154 
1156  uint32_t size;
1157 };
1158 
1172 __rte_experimental
1173 int
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);
1177 
1193 __rte_experimental
1194 int
1195 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1196  const char *regarray_name,
1197  uint32_t regarray_index,
1198  uint64_t *value);
1199 
1215 __rte_experimental
1216 int
1217 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1218  const char *regarray_name,
1219  uint32_t regarray_index,
1220  uint64_t value);
1221 
1222 /*
1223  * Meter Array Query and Configuration API.
1224  */
1225 
1230 
1232  uint32_t size;
1233 };
1234 
1248 __rte_experimental
1249 int
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);
1253 
1269 __rte_experimental
1270 int
1271 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1272  const char *name,
1273  struct rte_meter_trtcm_params *params);
1274 
1287 __rte_experimental
1288 int
1289 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1290  const char *name);
1291 
1310 __rte_experimental
1311 int
1312 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1313  const char *metarray_name,
1314  uint32_t metarray_index);
1315 
1335 __rte_experimental
1336 int
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);
1341 
1345  uint64_t n_pkts[RTE_COLORS];
1346 
1348  uint64_t n_bytes[RTE_COLORS];
1349 };
1350 
1366 __rte_experimental
1367 int
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);
1372 
1380 __rte_experimental
1381 void
1382 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
1383 
1384 #ifdef __cplusplus
1385 }
1386 #endif
1387 
1388 #endif
__rte_experimental int rte_swx_ctl_pipeline_learner_timeout_set(struct rte_swx_pipeline *p, uint32_t learner_id, uint32_t timeout_id, uint32_t timeout)
__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:380
__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:765
__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:760
__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:689
__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_ctl_pipeline_learner_timeout_get(struct rte_swx_pipeline *p, uint32_t learner_id, uint32_t timeout_id, uint32_t *timeout)
__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)
__rte_experimental int rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p, uint32_t session_id, struct rte_swx_pipeline_mirroring_session_params *params)