DPDK  22.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 
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  * Packet mirroring
164  */
165 
167 #ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
168 #define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
169 #endif
170 
172 #ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
173 #define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
174 #endif
175 
179  uint32_t n_slots;
180 
182  uint32_t n_sessions;
183 };
184 
198 __rte_experimental
199 int
200 rte_swx_pipeline_mirroring_config(struct rte_swx_pipeline *p,
201  struct rte_swx_pipeline_mirroring_params *params);
202 
203 /*
204  * Extern objects and functions
205  */
206 
229 __rte_experimental
230 int
231 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
232  const char *name,
233  const char *mailbox_struct_type_name,
236 
255 __rte_experimental
256 int
257 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
258  const char *extern_type_name,
259  const char *name,
261 
282 __rte_experimental
283 int
284 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
285  const char *extern_type_name,
286  const char *name,
287  const char *args);
288 
308 __rte_experimental
309 int
310 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
311  const char *name,
312  const char *mailbox_struct_type_name,
313  rte_swx_extern_func_t func);
314 /*
315  * Hash function.
316  */
317 
330 typedef uint32_t
331 (*rte_swx_hash_func_t)(const void *key,
332  uint32_t length,
333  uint32_t seed);
334 
350 __rte_experimental
351 int
352 rte_swx_pipeline_hash_func_register(struct rte_swx_pipeline *p,
353  const char *name,
354  rte_swx_hash_func_t func);
355 
356 /*
357  * Packet headers and meta-data
358  */
359 
363  const char *name;
364 
369  uint32_t n_bits;
370 };
371 
407 __rte_experimental
408 int
409 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
410  const char *name,
411  struct rte_swx_field_params *fields,
412  uint32_t n_fields,
413  int last_field_has_variable_size);
414 
431 __rte_experimental
432 int
433 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
434  const char *name,
435  const char *struct_type_name);
436 
448 __rte_experimental
449 int
450 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
451  const char *struct_type_name);
452 
453 /*
454  * Instructions
455  */
456 
558 /*
559  * Pipeline action
560  */
561 
583 __rte_experimental
584 int
585 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
586  const char *name,
587  const char *args_struct_type_name,
588  const char **instructions,
589  uint32_t n_instructions);
590 
591 /*
592  * Pipeline table
593  */
594 
612 __rte_experimental
613 int
614 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
615  const char *name,
616  enum rte_swx_table_match_type match_type,
617  struct rte_swx_table_ops *ops);
618 
625  const char *name;
626 
628  enum rte_swx_table_match_type match_type;
629 };
630 
639 
645  uint32_t n_fields;
646 
648  const char **action_names;
649 
656 
663 
666  uint32_t n_actions;
667 
671  const char *default_action_name;
672 
678  const char *default_action_args;
679 
686 };
687 
714 __rte_experimental
715 int
716 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
717  const char *name,
718  struct rte_swx_pipeline_table_params *params,
719  const char *recommended_table_type_name,
720  const char *args,
721  uint32_t size);
722 
728  const char *group_id_field_name;
729 
735  const char **selector_field_names;
736 
739 
743  const char *member_id_field_name;
744 
746  uint32_t n_groups_max;
747 
750 };
751 
768 __rte_experimental
769 int
770 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
771  const char *name,
772  struct rte_swx_pipeline_selector_params *params);
773 
781  const char **field_names;
782 
785  uint32_t n_fields;
786 
788  const char **action_names;
789 
796 
803 
806  uint32_t n_actions;
807 
811  const char *default_action_name;
812 
818  const char *default_action_args;
819 
826 };
827 
850 __rte_experimental
851 int
852 rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
853  const char *name,
854  struct rte_swx_pipeline_learner_params *params,
855  uint32_t size,
856  uint32_t *timeout,
857  uint32_t n_timeouts);
858 
876 __rte_experimental
877 int
878 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
879  const char *name,
880  uint32_t size,
881  uint64_t init_val);
882 
899 __rte_experimental
900 int
901 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
902  const char *name,
903  uint32_t size);
904 
919 __rte_experimental
920 int
921 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
922  const char **instructions,
923  uint32_t n_instructions);
924 
940 __rte_experimental
941 int
942 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
943 
963 __rte_experimental
964 int
965 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
966  FILE *spec,
967  uint32_t *err_line,
968  const char **err_msg);
969 
978 __rte_experimental
979 void
980 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
981  uint32_t n_instructions);
982 
992 __rte_experimental
993 void
994 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
995 
1002 __rte_experimental
1003 void
1004 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
1005 
1006 #ifdef __cplusplus
1007 }
1008 #endif
1009 
1010 #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_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_config(struct rte_swx_pipeline **p, int numa_node)
__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_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)
uint32_t(* rte_swx_hash_func_t)(const void *key, uint32_t length, uint32_t seed)
__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)