DPDK  22.03.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 
60 __rte_experimental
61 int
62 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
63  int numa_node);
64 
65 /*
66  * Pipeline input ports
67  */
68 
84 __rte_experimental
85 int
86 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
87  const char *name,
88  struct rte_swx_port_in_ops *ops);
89 
107 __rte_experimental
108 int
109 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
110  uint32_t port_id,
111  const char *port_type_name,
112  void *args);
113 
114 /*
115  * Pipeline output ports
116  */
117 
133 __rte_experimental
134 int
135 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
136  const char *name,
137  struct rte_swx_port_out_ops *ops);
138 
156 __rte_experimental
157 int
158 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
159  uint32_t port_id,
160  const char *port_type_name,
161  void *args);
162 
163 /*
164  * Extern objects and functions
165  */
166 
189 __rte_experimental
190 int
191 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
192  const char *name,
193  const char *mailbox_struct_type_name,
196 
215 __rte_experimental
216 int
217 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
218  const char *extern_type_name,
219  const char *name,
221 
242 __rte_experimental
243 int
244 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
245  const char *extern_type_name,
246  const char *name,
247  const char *args);
248 
268 __rte_experimental
269 int
270 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
271  const char *name,
272  const char *mailbox_struct_type_name,
273  rte_swx_extern_func_t func);
274 
275 /*
276  * Packet headers and meta-data
277  */
278 
282  const char *name;
283 
288  uint32_t n_bits;
289 };
290 
326 __rte_experimental
327 int
328 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
329  const char *name,
330  struct rte_swx_field_params *fields,
331  uint32_t n_fields,
332  int last_field_has_variable_size);
333 
350 __rte_experimental
351 int
352 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
353  const char *name,
354  const char *struct_type_name);
355 
367 __rte_experimental
368 int
369 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
370  const char *struct_type_name);
371 
372 /*
373  * Instructions
374  */
375 
477 /*
478  * Pipeline action
479  */
480 
502 __rte_experimental
503 int
504 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
505  const char *name,
506  const char *args_struct_type_name,
507  const char **instructions,
508  uint32_t n_instructions);
509 
510 /*
511  * Pipeline table
512  */
513 
531 __rte_experimental
532 int
533 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
534  const char *name,
535  enum rte_swx_table_match_type match_type,
536  struct rte_swx_table_ops *ops);
537 
544  const char *name;
545 
547  enum rte_swx_table_match_type match_type;
548 };
549 
558 
564  uint32_t n_fields;
565 
567  const char **action_names;
568 
575 
582 
585  uint32_t n_actions;
586 
590  const char *default_action_name;
591 
597 
604 };
605 
632 __rte_experimental
633 int
634 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
635  const char *name,
636  struct rte_swx_pipeline_table_params *params,
637  const char *recommended_table_type_name,
638  const char *args,
639  uint32_t size);
640 
646  const char *group_id_field_name;
647 
653  const char **selector_field_names;
654 
657 
661  const char *member_id_field_name;
662 
664  uint32_t n_groups_max;
665 
668 };
669 
686 __rte_experimental
687 int
688 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
689  const char *name,
690  struct rte_swx_pipeline_selector_params *params);
691 
699  const char **field_names;
700 
703  uint32_t n_fields;
704 
706  const char **action_names;
707 
714 
721 
724  uint32_t n_actions;
725 
729  const char *default_action_name;
730 
736 
743 };
744 
765 __rte_experimental
766 int
767 rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
768  const char *name,
769  struct rte_swx_pipeline_learner_params *params,
770  uint32_t size,
771  uint32_t timeout);
772 
790 __rte_experimental
791 int
792 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
793  const char *name,
794  uint32_t size,
795  uint64_t init_val);
796 
813 __rte_experimental
814 int
815 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
816  const char *name,
817  uint32_t size);
818 
833 __rte_experimental
834 int
835 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
836  const char **instructions,
837  uint32_t n_instructions);
838 
854 __rte_experimental
855 int
856 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
857 
877 __rte_experimental
878 int
879 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
880  FILE *spec,
881  uint32_t *err_line,
882  const char **err_msg);
883 
892 __rte_experimental
893 void
894 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
895  uint32_t n_instructions);
896 
905 __rte_experimental
906 void
907 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
908 
915 __rte_experimental
916 void
917 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
918 
919 #ifdef __cplusplus
920 }
921 #endif
922 
923 #endif
__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_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_config(struct rte_swx_pipeline **p, int numa_node)
__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)
__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_build_from_spec(struct rte_swx_pipeline *p, FILE *spec, uint32_t *err_line, const char **err_msg)
__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:23
__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_metarray_config(struct rte_swx_pipeline *p, const char *name, uint32_t size)
__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 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_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)