DPDK  21.05.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 
632 __rte_experimental
633 int
634 rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
635  const char *name,
636  uint32_t size,
637  uint64_t init_val);
638 
655 __rte_experimental
656 int
657 rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
658  const char *name,
659  uint32_t size);
660 
675 __rte_experimental
676 int
677 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
678  const char **instructions,
679  uint32_t n_instructions);
680 
696 __rte_experimental
697 int
698 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
699 
719 __rte_experimental
720 int
721 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
722  FILE *spec,
723  uint32_t *err_line,
724  const char **err_msg);
725 
734 __rte_experimental
735 void
736 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
737  uint32_t n_instructions);
738 
747 __rte_experimental
748 void
749 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
750 
757 __rte_experimental
758 void
759 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
760 
761 #ifdef __cplusplus
762 }
763 #endif
764 
765 #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_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)