DPDK  20.11.10
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 
469 /*
470  * Pipeline action
471  */
472 
494 __rte_experimental
495 int
496 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
497  const char *name,
498  const char *args_struct_type_name,
499  const char **instructions,
500  uint32_t n_instructions);
501 
502 /*
503  * Pipeline table
504  */
505 
523 __rte_experimental
524 int
525 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
526  const char *name,
527  enum rte_swx_table_match_type match_type,
528  struct rte_swx_table_ops *ops);
529 
536  const char *name;
537 
539  enum rte_swx_table_match_type match_type;
540 };
541 
550 
556  uint32_t n_fields;
557 
559  const char **action_names;
560 
563  uint32_t n_actions;
564 
568  const char *default_action_name;
569 
575 
582 };
583 
610 __rte_experimental
611 int
612 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
613  const char *name,
614  struct rte_swx_pipeline_table_params *params,
615  const char *recommended_table_type_name,
616  const char *args,
617  uint32_t size);
618 
633 __rte_experimental
634 int
635 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
636  const char **instructions,
637  uint32_t n_instructions);
638 
654 __rte_experimental
655 int
656 rte_swx_pipeline_build(struct rte_swx_pipeline *p);
657 
677 __rte_experimental
678 int
679 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
680  FILE *spec,
681  uint32_t *err_line,
682  const char **err_msg);
683 
692 __rte_experimental
693 void
694 rte_swx_pipeline_run(struct rte_swx_pipeline *p,
695  uint32_t n_instructions);
696 
705 __rte_experimental
706 void
707 rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
708 
715 __rte_experimental
716 void
717 rte_swx_pipeline_free(struct rte_swx_pipeline *p);
718 
719 #ifdef __cplusplus
720 }
721 #endif
722 
723 #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)
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)