DPDK  21.11.8
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 <stddef.h>
17 #include <stdint.h>
18 #include <stdio.h>
19 
20 #include <rte_compat.h>
21 
22 #include "rte_swx_port.h"
23 #include "rte_swx_table.h"
24 #include "rte_swx_extern.h"
25 
27 #ifndef RTE_SWX_NAME_SIZE
28 #define RTE_SWX_NAME_SIZE 64
29 #endif
30 
32 #ifndef RTE_SWX_INSTRUCTION_SIZE
33 #define RTE_SWX_INSTRUCTION_SIZE 256
34 #endif
35 
37 #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX
38 #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16
39 #endif
40 
41 /*
42  * Pipeline setup and operation
43  */
44 
46 struct rte_swx_pipeline;
47 
61 __rte_experimental
62 int
63 rte_swx_pipeline_config(struct rte_swx_pipeline **p,
64  int numa_node);
65 
66 /*
67  * Pipeline input ports
68  */
69 
85 __rte_experimental
86 int
87 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
88  const char *name,
89  struct rte_swx_port_in_ops *ops);
90 
108 __rte_experimental
109 int
110 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
111  uint32_t port_id,
112  const char *port_type_name,
113  void *args);
114 
115 /*
116  * Pipeline output ports
117  */
118 
134 __rte_experimental
135 int
136 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
137  const char *name,
138  struct rte_swx_port_out_ops *ops);
139 
157 __rte_experimental
158 int
159 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
160  uint32_t port_id,
161  const char *port_type_name,
162  void *args);
163 
164 /*
165  * Extern objects and functions
166  */
167 
190 __rte_experimental
191 int
192 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
193  const char *name,
194  const char *mailbox_struct_type_name,
197 
216 __rte_experimental
217 int
218 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
219  const char *extern_type_name,
220  const char *name,
222 
243 __rte_experimental
244 int
245 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
246  const char *extern_type_name,
247  const char *name,
248  const char *args);
249 
269 __rte_experimental
270 int
271 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
272  const char *name,
273  const char *mailbox_struct_type_name,
274  rte_swx_extern_func_t func);
275 
276 /*
277  * Packet headers and meta-data
278  */
279 
283  const char *name;
284 
289  uint32_t n_bits;
290 };
291 
327 __rte_experimental
328 int
329 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
330  const char *name,
331  struct rte_swx_field_params *fields,
332  uint32_t n_fields,
333  int last_field_has_variable_size);
334 
351 __rte_experimental
352 int
353 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
354  const char *name,
355  const char *struct_type_name);
356 
368 __rte_experimental
369 int
370 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
371  const char *struct_type_name);
372 
373 /*
374  * Instructions
375  */
376 
478 /*
479  * Pipeline action
480  */
481 
503 __rte_experimental
504 int
505 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
506  const char *name,
507  const char *args_struct_type_name,
508  const char **instructions,
509  uint32_t n_instructions);
510 
511 /*
512  * Pipeline table
513  */
514 
532 __rte_experimental
533 int
534 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
535  const char *name,
536  enum rte_swx_table_match_type match_type,
537  struct rte_swx_table_ops *ops);
538 
545  const char *name;
546 
548  enum rte_swx_table_match_type match_type;
549 };
550 
559 
565  uint32_t n_fields;
566 
568  const char **action_names;
569 
576 
583 
586  uint32_t n_actions;
587 
591  const char *default_action_name;
592 
598 
605 };
606 
633 __rte_experimental
634 int
635 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
636  const char *name,
637  struct rte_swx_pipeline_table_params *params,
638  const char *recommended_table_type_name,
639  const char *args,
640  uint32_t size);
641 
647  const char *group_id_field_name;
648 
654  const char **selector_field_names;
655 
658 
662  const char *member_id_field_name;
663 
665  uint32_t n_groups_max;
666 
669 };
670 
687 __rte_experimental
688 int
689 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
690  const char *name,
691  struct rte_swx_pipeline_selector_params *params);
692 
700  const char **field_names;
701 
704  uint32_t n_fields;
705 
707  const char **action_names;
708 
715 
722 
725  uint32_t n_actions;
726 
730  const char *default_action_name;
731 
737 
744 };
745 
766 __rte_experimental
767 int
768 rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
769  const char *name,
770  struct rte_swx_pipeline_learner_params *params,
771  uint32_t size,
772  uint32_t timeout);
773 
791 __rte_experimental
792 int
793 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
794  const char *name,
795  uint32_t size,
796  uint64_t init_val);
797 
814 __rte_experimental
815 int
816 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
817  const char *name,
818  uint32_t size);
819 
834 __rte_experimental
835 int
836 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
837  const char **instructions,
838  uint32_t n_instructions);
839 
855 __rte_experimental
856 int
857 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
858 
878 __rte_experimental
879 int
880 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
881  FILE *spec,
882  uint32_t *err_line,
883  const char **err_msg);
884 
893 __rte_experimental
894 void
895 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
896  uint32_t n_instructions);
897 
906 __rte_experimental
907 void
908 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
909 
916 __rte_experimental
917 void
918 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
919 
920 #ifdef __cplusplus
921 }
922 #endif
923 
924 #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)