DPDK  24.07.0
rte_swx_pipeline.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_PIPELINE_H__
5 #define __INCLUDE_RTE_SWX_PIPELINE_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 
21 #include "rte_swx_port.h"
22 #include "rte_swx_table.h"
23 #include "rte_swx_extern.h"
24 
26 #ifndef RTE_SWX_NAME_SIZE
27 #define RTE_SWX_NAME_SIZE 64
28 #endif
29 
31 #ifndef RTE_SWX_INSTRUCTION_SIZE
32 #define RTE_SWX_INSTRUCTION_SIZE 256
33 #endif
34 
36 #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX
37 #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16
38 #endif
39 
40 /*
41  * Pipeline setup and operation
42  */
43 
45 struct rte_swx_pipeline;
46 
55 __rte_experimental
56 struct rte_swx_pipeline *
57 rte_swx_pipeline_find(const char *name);
58 
75 __rte_experimental
76 int
77 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
78  const char *name,
79  int numa_node);
80 
81 /*
82  * Pipeline input ports
83  */
84 
100 __rte_experimental
101 int
102 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
103  const char *name,
104  struct rte_swx_port_in_ops *ops);
105 
123 __rte_experimental
124 int
125 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
126  uint32_t port_id,
127  const char *port_type_name,
128  void *args);
129 
130 /*
131  * Pipeline output ports
132  */
133 
149 __rte_experimental
150 int
151 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
152  const char *name,
153  struct rte_swx_port_out_ops *ops);
154 
172 __rte_experimental
173 int
174 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
175  uint32_t port_id,
176  const char *port_type_name,
177  void *args);
178 /*
179  * Packet mirroring
180  */
181 
183 #ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
184 #define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
185 #endif
186 
188 #ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
189 #define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
190 #endif
191 
195  uint32_t n_slots;
196 
198  uint32_t n_sessions;
199 };
200 
214 __rte_experimental
215 int
216 rte_swx_pipeline_mirroring_config(struct rte_swx_pipeline *p,
217  struct rte_swx_pipeline_mirroring_params *params);
218 
219 /*
220  * Extern objects and functions
221  */
222 
245 __rte_experimental
246 int
247 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
248  const char *name,
249  const char *mailbox_struct_type_name,
252 
271 __rte_experimental
272 int
273 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
274  const char *extern_type_name,
275  const char *name,
277 
298 __rte_experimental
299 int
300 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
301  const char *extern_type_name,
302  const char *name,
303  const char *args);
304 
324 __rte_experimental
325 int
326 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
327  const char *name,
328  const char *mailbox_struct_type_name,
329  rte_swx_extern_func_t func);
330 /*
331  * Hash function.
332  */
333 
349 __rte_experimental
350 int
351 rte_swx_pipeline_hash_func_register(struct rte_swx_pipeline *p,
352  const char *name,
353  rte_swx_hash_func_t func);
354 
355 /*
356  * RSS.
357  */
358 
372 __rte_experimental
373 int
374 rte_swx_pipeline_rss_config(struct rte_swx_pipeline *p,
375  const char *name);
376 
377 /*
378  * Packet headers and meta-data
379  */
380 
384  const char *name;
385 
390  uint32_t n_bits;
391 };
392 
428 __rte_experimental
429 int
430 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
431  const char *name,
432  struct rte_swx_field_params *fields,
433  uint32_t n_fields,
434  int last_field_has_variable_size);
435 
452 __rte_experimental
453 int
454 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
455  const char *name,
456  const char *struct_type_name);
457 
469 __rte_experimental
470 int
471 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
472  const char *struct_type_name);
473 
474 /*
475  * Instructions
476  */
477 
579 /*
580  * Pipeline action
581  */
582 
604 __rte_experimental
605 int
606 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
607  const char *name,
608  const char *args_struct_type_name,
609  const char **instructions,
610  uint32_t n_instructions);
611 
612 /*
613  * Pipeline table
614  */
615 
633 __rte_experimental
634 int
635 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
636  const char *name,
637  enum rte_swx_table_match_type match_type,
638  struct rte_swx_table_ops *ops);
639 
646  const char *name;
647 
649  enum rte_swx_table_match_type match_type;
650 };
651 
660 
666  uint32_t n_fields;
667 
669  const char **action_names;
670 
677 
684 
687  uint32_t n_actions;
688 
692  const char *default_action_name;
693 
699  const char *default_action_args;
700 
707 
713  const char *hash_func_name;
714 };
715 
742 __rte_experimental
743 int
744 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
745  const char *name,
746  struct rte_swx_pipeline_table_params *params,
747  const char *recommended_table_type_name,
748  const char *args,
749  uint32_t size);
750 
756  const char *group_id_field_name;
757 
763  const char **selector_field_names;
764 
767 
771  const char *member_id_field_name;
772 
774  uint32_t n_groups_max;
775 
778 };
779 
796 __rte_experimental
797 int
798 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
799  const char *name,
800  struct rte_swx_pipeline_selector_params *params);
801 
809  const char **field_names;
810 
813  uint32_t n_fields;
814 
816  const char **action_names;
817 
824 
831 
834  uint32_t n_actions;
835 
839  const char *default_action_name;
840 
846  const char *default_action_args;
847 
854 
859  const char *hash_func_name;
860 };
861 
884 __rte_experimental
885 int
886 rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
887  const char *name,
888  struct rte_swx_pipeline_learner_params *params,
889  uint32_t size,
890  uint32_t *timeout,
891  uint32_t n_timeouts);
892 
910 __rte_experimental
911 int
912 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
913  const char *name,
914  uint32_t size,
915  uint64_t init_val);
916 
933 __rte_experimental
934 int
935 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
936  const char *name,
937  uint32_t size);
938 
953 __rte_experimental
954 int
955 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
956  const char **instructions,
957  uint32_t n_instructions);
958 
974 __rte_experimental
975 int
976 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
977 
996 __rte_experimental
997 int
998 rte_swx_pipeline_codegen(FILE *spec_file,
999  FILE *code_file,
1000  uint32_t *err_line,
1001  const char **err_msg);
1002 
1029 __rte_experimental
1030 int
1031 rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **p,
1032  const char *name,
1033  const char *lib_file_name,
1034  FILE *iospec_file,
1035  int numa_node);
1036 
1045 __rte_experimental
1046 void
1047 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
1048  uint32_t n_instructions);
1049 
1059 __rte_experimental
1060 void
1061 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
1062 
1069 __rte_experimental
1070 void
1071 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
1072 
1073 #ifdef __cplusplus
1074 }
1075 #endif
1076 
1077 #endif
uint32_t(* rte_swx_hash_func_t)(const void *key, uint32_t length, uint32_t seed)
__rte_experimental int rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p, const char *name, struct rte_swx_port_out_ops *ops)
int(* rte_swx_extern_func_t)(void *mailbox)
__rte_experimental int rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p, const char *name, enum rte_swx_table_match_type match_type, struct rte_swx_table_ops *ops)
__rte_experimental int rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p, uint32_t port_id, const char *port_type_name, void *args)
__rte_experimental int rte_swx_pipeline_hash_func_register(struct rte_swx_pipeline *p, const char *name, rte_swx_hash_func_t func)
__rte_experimental int rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p, const char *name, const char *struct_type_name)
__rte_experimental int rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p, const char *name, struct rte_swx_pipeline_selector_params *params)
__rte_experimental int rte_swx_pipeline_mirroring_config(struct rte_swx_pipeline *p, struct rte_swx_pipeline_mirroring_params *params)
__rte_experimental void rte_swx_pipeline_run(struct rte_swx_pipeline *p, uint32_t n_instructions)
struct rte_swx_match_field_params * fields
__rte_experimental int rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p, const char **instructions, uint32_t n_instructions)
__rte_experimental int rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p, const char *extern_type_name, const char *name, rte_swx_extern_type_member_func_t member_func)
rte_swx_table_match_type
Definition: rte_swx_table.h:25
__rte_experimental int rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **p, const char *name, const char *lib_file_name, FILE *iospec_file, int numa_node)
__rte_experimental int rte_swx_pipeline_config(struct rte_swx_pipeline **p, const char *name, int numa_node)
__rte_experimental int rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p, const char *extern_type_name, const char *name, const char *args)
__rte_experimental void rte_swx_pipeline_free(struct rte_swx_pipeline *p)
__rte_experimental int rte_swx_pipeline_rss_config(struct rte_swx_pipeline *p, const char *name)
__rte_experimental int rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p, const char *name, uint32_t size)
__rte_experimental int rte_swx_pipeline_codegen(FILE *spec_file, FILE *code_file, uint32_t *err_line, const char **err_msg)
__rte_experimental int rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p, const char *name, uint32_t size, uint64_t init_val)
void(* rte_swx_extern_type_destructor_t)(void *object)
__rte_experimental int rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p, const char *name, struct rte_swx_port_in_ops *ops)
__rte_experimental void rte_swx_pipeline_flush(struct rte_swx_pipeline *p)
void *(* rte_swx_extern_type_constructor_t)(const char *args)
__rte_experimental struct rte_swx_pipeline * rte_swx_pipeline_find(const char *name)
__rte_experimental int rte_swx_pipeline_build(struct rte_swx_pipeline *p)
__rte_experimental int rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p, const char *struct_type_name)
__rte_experimental int rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p, const char *name, const char *mailbox_struct_type_name, rte_swx_extern_type_constructor_t constructor, rte_swx_extern_type_destructor_t destructor)
__rte_experimental int rte_swx_pipeline_table_config(struct rte_swx_pipeline *p, const char *name, struct rte_swx_pipeline_table_params *params, const char *recommended_table_type_name, const char *args, uint32_t size)
__rte_experimental int rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p, const char *name, struct rte_swx_field_params *fields, uint32_t n_fields, int last_field_has_variable_size)
__rte_experimental int rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p, const char *name, struct rte_swx_pipeline_learner_params *params, uint32_t size, uint32_t *timeout, uint32_t n_timeouts)
__rte_experimental int rte_swx_pipeline_action_config(struct rte_swx_pipeline *p, const char *name, const char *args_struct_type_name, const char **instructions, uint32_t n_instructions)
int(* rte_swx_extern_type_member_func_t)(void *object, void *mailbox)
__rte_experimental int rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p, uint32_t port_id, const char *port_type_name, void *args)
__rte_experimental int rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p, const char *name, const char *mailbox_struct_type_name, rte_swx_extern_func_t func)