DPDK  21.08.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 <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 
315 __rte_experimental
316 int
317 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
318  const char *name,
319  struct rte_swx_field_params *fields,
320  uint32_t n_fields);
321 
338 __rte_experimental
339 int
340 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
341  const char *name,
342  const char *struct_type_name);
343 
355 __rte_experimental
356 int
357 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
358  const char *struct_type_name);
359 
360 /*
361  * Instructions
362  */
363 
465 /*
466  * Pipeline action
467  */
468 
490 __rte_experimental
491 int
492 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
493  const char *name,
494  const char *args_struct_type_name,
495  const char **instructions,
496  uint32_t n_instructions);
497 
498 /*
499  * Pipeline table
500  */
501 
519 __rte_experimental
520 int
521 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
522  const char *name,
523  enum rte_swx_table_match_type match_type,
524  struct rte_swx_table_ops *ops);
525 
532  const char *name;
533 
535  enum rte_swx_table_match_type match_type;
536 };
537 
546 
552  uint32_t n_fields;
553 
555  const char **action_names;
556 
559  uint32_t n_actions;
560 
564  const char *default_action_name;
565 
571 
578 };
579 
606 __rte_experimental
607 int
608 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
609  const char *name,
610  struct rte_swx_pipeline_table_params *params,
611  const char *recommended_table_type_name,
612  const char *args,
613  uint32_t size);
614 
620  const char *group_id_field_name;
621 
627  const char **selector_field_names;
628 
631 
635  const char *member_id_field_name;
636 
638  uint32_t n_groups_max;
639 
642 };
643 
660 __rte_experimental
661 int
662 rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
663  const char *name,
664  struct rte_swx_pipeline_selector_params *params);
665 
683 __rte_experimental
684 int
685 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
686  const char *name,
687  uint32_t size,
688  uint64_t init_val);
689 
706 __rte_experimental
707 int
708 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
709  const char *name,
710  uint32_t size);
711 
726 __rte_experimental
727 int
728 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
729  const char **instructions,
730  uint32_t n_instructions);
731 
747 __rte_experimental
748 int
749 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
750 
770 __rte_experimental
771 int
772 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
773  FILE *spec,
774  uint32_t *err_line,
775  const char **err_msg);
776 
785 __rte_experimental
786 void
787 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
788  uint32_t n_instructions);
789 
798 __rte_experimental
799 void
800 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
801 
808 __rte_experimental
809 void
810 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
811 
812 #ifdef __cplusplus
813 }
814 #endif
815 
816 #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_struct_type_register(struct rte_swx_pipeline *p, const char *name, struct rte_swx_field_params *fields, uint32_t n_fields)
__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:22
__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_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)