xref: /dpdk/lib/pipeline/rte_swx_pipeline.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2020 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson #ifndef __INCLUDE_RTE_SWX_PIPELINE_H__
599a2dd95SBruce Richardson #define __INCLUDE_RTE_SWX_PIPELINE_H__
699a2dd95SBruce Richardson 
799a2dd95SBruce Richardson /**
899a2dd95SBruce Richardson  * @file
999a2dd95SBruce Richardson  * RTE SWX Pipeline
1099a2dd95SBruce Richardson  */
1199a2dd95SBruce Richardson 
1299a2dd95SBruce Richardson #include <stdint.h>
1399a2dd95SBruce Richardson #include <stdio.h>
1499a2dd95SBruce Richardson 
1599a2dd95SBruce Richardson #include <rte_compat.h>
1699a2dd95SBruce Richardson 
1799a2dd95SBruce Richardson #include "rte_swx_port.h"
1899a2dd95SBruce Richardson #include "rte_swx_table.h"
1999a2dd95SBruce Richardson #include "rte_swx_extern.h"
2099a2dd95SBruce Richardson 
21*719834a6SMattias Rönnblom #ifdef __cplusplus
22*719834a6SMattias Rönnblom extern "C" {
23*719834a6SMattias Rönnblom #endif
24*719834a6SMattias Rönnblom 
2599a2dd95SBruce Richardson /** Name size. */
2699a2dd95SBruce Richardson #ifndef RTE_SWX_NAME_SIZE
2799a2dd95SBruce Richardson #define RTE_SWX_NAME_SIZE 64
2899a2dd95SBruce Richardson #endif
2999a2dd95SBruce Richardson 
3099a2dd95SBruce Richardson /** Instruction size. */
3199a2dd95SBruce Richardson #ifndef RTE_SWX_INSTRUCTION_SIZE
3299a2dd95SBruce Richardson #define RTE_SWX_INSTRUCTION_SIZE 256
3399a2dd95SBruce Richardson #endif
3499a2dd95SBruce Richardson 
3599a2dd95SBruce Richardson /** Instruction tokens. */
3699a2dd95SBruce Richardson #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX
3799a2dd95SBruce Richardson #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16
3899a2dd95SBruce Richardson #endif
3999a2dd95SBruce Richardson 
4099a2dd95SBruce Richardson /*
4199a2dd95SBruce Richardson  * Pipeline setup and operation
4299a2dd95SBruce Richardson  */
4399a2dd95SBruce Richardson 
4499a2dd95SBruce Richardson /** Pipeline opaque data structure. */
4599a2dd95SBruce Richardson struct rte_swx_pipeline;
4699a2dd95SBruce Richardson 
4799a2dd95SBruce Richardson /**
48d69c90c8SCristian Dumitrescu  * Pipeline find
49d69c90c8SCristian Dumitrescu  *
50d69c90c8SCristian Dumitrescu  * @param[in] name
51d69c90c8SCristian Dumitrescu  *   Pipeline name.
52d69c90c8SCristian Dumitrescu  * @return
53d69c90c8SCristian Dumitrescu  *   Valid pipeline handle if found or NULL otherwise.
54d69c90c8SCristian Dumitrescu  */
55d69c90c8SCristian Dumitrescu __rte_experimental
56d69c90c8SCristian Dumitrescu struct rte_swx_pipeline *
57d69c90c8SCristian Dumitrescu rte_swx_pipeline_find(const char *name);
58d69c90c8SCristian Dumitrescu 
59d69c90c8SCristian Dumitrescu /**
6099a2dd95SBruce Richardson  * Pipeline configure
6199a2dd95SBruce Richardson  *
6299a2dd95SBruce Richardson  * @param[out] p
6399a2dd95SBruce Richardson  *   Pipeline handle. Must point to valid memory. Contains valid pipeline handle
6499a2dd95SBruce Richardson  *   when the function returns successfully.
65d69c90c8SCristian Dumitrescu  * @param[in] name
66d69c90c8SCristian Dumitrescu  *   Pipeline unique name.
6799a2dd95SBruce Richardson  * @param[in] numa_node
6899a2dd95SBruce Richardson  *   Non-Uniform Memory Access (NUMA) node.
6999a2dd95SBruce Richardson  * @return
7099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
7199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
72d69c90c8SCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
73d69c90c8SCristian Dumitrescu  *   -EEXIST: Pipeline with this name already exists.
7499a2dd95SBruce Richardson  */
7599a2dd95SBruce Richardson __rte_experimental
7699a2dd95SBruce Richardson int
7799a2dd95SBruce Richardson rte_swx_pipeline_config(struct rte_swx_pipeline **p,
78d69c90c8SCristian Dumitrescu 			const char *name,
7999a2dd95SBruce Richardson 			int numa_node);
8099a2dd95SBruce Richardson 
8199a2dd95SBruce Richardson /*
8299a2dd95SBruce Richardson  * Pipeline input ports
8399a2dd95SBruce Richardson  */
8499a2dd95SBruce Richardson 
8599a2dd95SBruce Richardson /**
8699a2dd95SBruce Richardson  * Pipeline input port type register
8799a2dd95SBruce Richardson  *
8899a2dd95SBruce Richardson  * @param[in] p
8999a2dd95SBruce Richardson  *   Pipeline handle.
9099a2dd95SBruce Richardson  * @param[in] name
9199a2dd95SBruce Richardson  *   Input port type name.
9299a2dd95SBruce Richardson  * @param[in] ops
9399a2dd95SBruce Richardson  *   Input port type operations.
9499a2dd95SBruce Richardson  * @return
9599a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
9699a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
9799a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
9899a2dd95SBruce Richardson  *   -EEXIST: Input port type with this name already exists.
9999a2dd95SBruce Richardson  */
10099a2dd95SBruce Richardson __rte_experimental
10199a2dd95SBruce Richardson int
10299a2dd95SBruce Richardson rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,
10399a2dd95SBruce Richardson 				       const char *name,
10499a2dd95SBruce Richardson 				       struct rte_swx_port_in_ops *ops);
10599a2dd95SBruce Richardson 
10699a2dd95SBruce Richardson /**
10799a2dd95SBruce Richardson  * Pipeline input port configure
10899a2dd95SBruce Richardson  *
10999a2dd95SBruce Richardson  * @param[in] p
11099a2dd95SBruce Richardson  *   Pipeline handle.
11199a2dd95SBruce Richardson  * @param[in] port_id
11299a2dd95SBruce Richardson  *   Input port ID.
11399a2dd95SBruce Richardson  * @param[in] port_type_name
11499a2dd95SBruce Richardson  *   Existing input port type name.
11599a2dd95SBruce Richardson  * @param[in] args
11699a2dd95SBruce Richardson  *   Input port creation arguments.
11799a2dd95SBruce Richardson  * @return
11899a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
11999a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
12099a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
12199a2dd95SBruce Richardson  *   -ENODEV: Input port object creation error.
12299a2dd95SBruce Richardson  */
12399a2dd95SBruce Richardson __rte_experimental
12499a2dd95SBruce Richardson int
12599a2dd95SBruce Richardson rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,
12699a2dd95SBruce Richardson 				uint32_t port_id,
12799a2dd95SBruce Richardson 				const char *port_type_name,
12899a2dd95SBruce Richardson 				void *args);
12999a2dd95SBruce Richardson 
13099a2dd95SBruce Richardson /*
13199a2dd95SBruce Richardson  * Pipeline output ports
13299a2dd95SBruce Richardson  */
13399a2dd95SBruce Richardson 
13499a2dd95SBruce Richardson /**
13599a2dd95SBruce Richardson  * Pipeline output port type register
13699a2dd95SBruce Richardson  *
13799a2dd95SBruce Richardson  * @param[in] p
13899a2dd95SBruce Richardson  *   Pipeline handle.
13999a2dd95SBruce Richardson  * @param[in] name
14099a2dd95SBruce Richardson  *   Output port type name.
14199a2dd95SBruce Richardson  * @param[in] ops
14299a2dd95SBruce Richardson  *   Output port type operations.
14399a2dd95SBruce Richardson  * @return
14499a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
14599a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
14699a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
14799a2dd95SBruce Richardson  *   -EEXIST: Output port type with this name already exists.
14899a2dd95SBruce Richardson  */
14999a2dd95SBruce Richardson __rte_experimental
15099a2dd95SBruce Richardson int
15199a2dd95SBruce Richardson rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p,
15299a2dd95SBruce Richardson 					const char *name,
15399a2dd95SBruce Richardson 					struct rte_swx_port_out_ops *ops);
15499a2dd95SBruce Richardson 
15599a2dd95SBruce Richardson /**
15699a2dd95SBruce Richardson  * Pipeline output port configure
15799a2dd95SBruce Richardson  *
15899a2dd95SBruce Richardson  * @param[in] p
15999a2dd95SBruce Richardson  *   Pipeline handle.
16099a2dd95SBruce Richardson  * @param[in] port_id
16199a2dd95SBruce Richardson  *   Output port ID.
16299a2dd95SBruce Richardson  * @param[in] port_type_name
16399a2dd95SBruce Richardson  *   Existing output port type name.
16499a2dd95SBruce Richardson  * @param[in] args
16599a2dd95SBruce Richardson  *   Output port creation arguments.
16699a2dd95SBruce Richardson  * @return
16799a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
16899a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
16999a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
17099a2dd95SBruce Richardson  *   -ENODEV: Output port object creation error.
17199a2dd95SBruce Richardson  */
17299a2dd95SBruce Richardson __rte_experimental
17399a2dd95SBruce Richardson int
17499a2dd95SBruce Richardson rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
17599a2dd95SBruce Richardson 				 uint32_t port_id,
17699a2dd95SBruce Richardson 				 const char *port_type_name,
17799a2dd95SBruce Richardson 				 void *args);
178dac0ecd9SCristian Dumitrescu /*
179dac0ecd9SCristian Dumitrescu  * Packet mirroring
180dac0ecd9SCristian Dumitrescu  */
181dac0ecd9SCristian Dumitrescu 
1820a00384aSCristian Dumitrescu /** Default number of packet mirroring slots. */
1830a00384aSCristian Dumitrescu #ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
1840a00384aSCristian Dumitrescu #define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
1850a00384aSCristian Dumitrescu #endif
1860a00384aSCristian Dumitrescu 
1870a00384aSCristian Dumitrescu /** Default maximum number of packet mirroring sessions. */
1880a00384aSCristian Dumitrescu #ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
1890a00384aSCristian Dumitrescu #define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
1900a00384aSCristian Dumitrescu #endif
1910a00384aSCristian Dumitrescu 
192dac0ecd9SCristian Dumitrescu /** Packet mirroring parameters. */
193dac0ecd9SCristian Dumitrescu struct rte_swx_pipeline_mirroring_params {
194dac0ecd9SCristian Dumitrescu 	/** Number of packet mirroring slots. */
195dac0ecd9SCristian Dumitrescu 	uint32_t n_slots;
196dac0ecd9SCristian Dumitrescu 
197dac0ecd9SCristian Dumitrescu 	/** Maximum number of packet mirroring sessions. */
198dac0ecd9SCristian Dumitrescu 	uint32_t n_sessions;
199dac0ecd9SCristian Dumitrescu };
200dac0ecd9SCristian Dumitrescu 
201dac0ecd9SCristian Dumitrescu /**
202dac0ecd9SCristian Dumitrescu  * Packet mirroring configure
203dac0ecd9SCristian Dumitrescu  *
204dac0ecd9SCristian Dumitrescu  * @param[in] p
205dac0ecd9SCristian Dumitrescu  *   Pipeline handle.
206dac0ecd9SCristian Dumitrescu  * @param[in] params
207dac0ecd9SCristian Dumitrescu  *   Packet mirroring parameters.
208dac0ecd9SCristian Dumitrescu  * @return
209dac0ecd9SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
210dac0ecd9SCristian Dumitrescu  *   -EINVAL: Invalid argument;
211dac0ecd9SCristian Dumitrescu  *   -ENOMEM: Not enough memory;
212dac0ecd9SCristian Dumitrescu  *   -EEXIST: Pipeline was already built successfully.
213dac0ecd9SCristian Dumitrescu  */
214dac0ecd9SCristian Dumitrescu __rte_experimental
215dac0ecd9SCristian Dumitrescu int
216dac0ecd9SCristian Dumitrescu rte_swx_pipeline_mirroring_config(struct rte_swx_pipeline *p,
217dac0ecd9SCristian Dumitrescu 				  struct rte_swx_pipeline_mirroring_params *params);
21899a2dd95SBruce Richardson 
21999a2dd95SBruce Richardson /*
22099a2dd95SBruce Richardson  * Extern objects and functions
22199a2dd95SBruce Richardson  */
22299a2dd95SBruce Richardson 
22399a2dd95SBruce Richardson /**
22499a2dd95SBruce Richardson  * Pipeline extern type register
22599a2dd95SBruce Richardson  *
22699a2dd95SBruce Richardson  * @param[in] p
22799a2dd95SBruce Richardson  *   Pipeline handle.
22899a2dd95SBruce Richardson  * @param[in] name
22999a2dd95SBruce Richardson  *   Extern type name.
23099a2dd95SBruce Richardson  * @param[in] mailbox_struct_type_name
23199a2dd95SBruce Richardson  *   Name of existing struct type used to define the mailbox size and layout for
23299a2dd95SBruce Richardson  *   the extern objects that are instances of this type. Each extern object gets
23399a2dd95SBruce Richardson  *   its own mailbox, which is used to pass the input arguments to the member
23499a2dd95SBruce Richardson  *   functions and retrieve the output results.
23599a2dd95SBruce Richardson  * @param[in] constructor
23699a2dd95SBruce Richardson  *   Function used to create the extern objects that are instances of this type.
23799a2dd95SBruce Richardson  * @param[in] destructor
23899a2dd95SBruce Richardson  *   Function used to free the extern objects that are instances of  this type.
23999a2dd95SBruce Richardson  * @return
24099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
24199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
24299a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
24399a2dd95SBruce Richardson  *   -EEXIST: Extern type with this name already exists.
24499a2dd95SBruce Richardson  */
24599a2dd95SBruce Richardson __rte_experimental
24699a2dd95SBruce Richardson int
24799a2dd95SBruce Richardson rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,
24899a2dd95SBruce Richardson 	const char *name,
24999a2dd95SBruce Richardson 	const char *mailbox_struct_type_name,
25099a2dd95SBruce Richardson 	rte_swx_extern_type_constructor_t constructor,
25199a2dd95SBruce Richardson 	rte_swx_extern_type_destructor_t destructor);
25299a2dd95SBruce Richardson 
25399a2dd95SBruce Richardson /**
25499a2dd95SBruce Richardson  * Pipeline extern type member function register
25599a2dd95SBruce Richardson  *
25699a2dd95SBruce Richardson  * @param[in] p
25799a2dd95SBruce Richardson  *   Pipeline handle.
25899a2dd95SBruce Richardson  * @param[in] extern_type_name
25999a2dd95SBruce Richardson  *   Existing extern type name.
26099a2dd95SBruce Richardson  * @param[in] name
26199a2dd95SBruce Richardson  *   Name for the new member function to be added to the extern type.
26299a2dd95SBruce Richardson  * @param[in] member_func
26399a2dd95SBruce Richardson  *   The new member function.
26499a2dd95SBruce Richardson  * @return
26599a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
26699a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
26799a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
26899a2dd95SBruce Richardson  *   -EEXIST: Member function with this name already exists for this type;
26999a2dd95SBruce Richardson  *   -ENOSPC: Maximum number of member functions reached for this type.
27099a2dd95SBruce Richardson  */
27199a2dd95SBruce Richardson __rte_experimental
27299a2dd95SBruce Richardson int
27399a2dd95SBruce Richardson rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p,
27499a2dd95SBruce Richardson 	const char *extern_type_name,
27599a2dd95SBruce Richardson 	const char *name,
27699a2dd95SBruce Richardson 	rte_swx_extern_type_member_func_t member_func);
27799a2dd95SBruce Richardson 
27899a2dd95SBruce Richardson /**
27999a2dd95SBruce Richardson  * Pipeline extern object configure
28099a2dd95SBruce Richardson  *
28199a2dd95SBruce Richardson  * Instantiate a given extern type to create new extern object.
28299a2dd95SBruce Richardson  *
28399a2dd95SBruce Richardson  * @param[in] p
28499a2dd95SBruce Richardson  *   Pipeline handle.
28599a2dd95SBruce Richardson  * @param[in] extern_type_name
28699a2dd95SBruce Richardson  *   Existing extern type name.
28799a2dd95SBruce Richardson  * @param[in] name
28899a2dd95SBruce Richardson  *   Name for the new object instantiating the extern type.
28999a2dd95SBruce Richardson  * @param[in] args
29099a2dd95SBruce Richardson  *   Extern object constructor arguments.
29199a2dd95SBruce Richardson  * @return
29299a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
29399a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
29499a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
29599a2dd95SBruce Richardson  *   -EEXIST: Extern object with this name already exists;
29699a2dd95SBruce Richardson  *   -ENODEV: Extern object constructor error.
29799a2dd95SBruce Richardson  */
29899a2dd95SBruce Richardson __rte_experimental
29999a2dd95SBruce Richardson int
30099a2dd95SBruce Richardson rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p,
30199a2dd95SBruce Richardson 				      const char *extern_type_name,
30299a2dd95SBruce Richardson 				      const char *name,
30399a2dd95SBruce Richardson 				      const char *args);
30499a2dd95SBruce Richardson 
30599a2dd95SBruce Richardson /**
30699a2dd95SBruce Richardson  * Pipeline extern function register
30799a2dd95SBruce Richardson  *
30899a2dd95SBruce Richardson  * @param[in] p
30999a2dd95SBruce Richardson  *   Pipeline handle.
31099a2dd95SBruce Richardson  * @param[in] name
31199a2dd95SBruce Richardson  *   Extern function name.
31299a2dd95SBruce Richardson  * @param[in] mailbox_struct_type_name
31399a2dd95SBruce Richardson  *   Name of existing struct type used to define the mailbox size and layout for
31499a2dd95SBruce Richardson  *   this extern function. The mailbox is used to pass the input arguments to
31599a2dd95SBruce Richardson  *   the extern function and retrieve the output results.
31699a2dd95SBruce Richardson  * @param[in] func
31799a2dd95SBruce Richardson  *   The extern function.
31899a2dd95SBruce Richardson  * @return
31999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
32099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
32199a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
32299a2dd95SBruce Richardson  *   -EEXIST: Extern function with this name already exists.
32399a2dd95SBruce Richardson  */
32499a2dd95SBruce Richardson __rte_experimental
32599a2dd95SBruce Richardson int
32699a2dd95SBruce Richardson rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,
32799a2dd95SBruce Richardson 				      const char *name,
32899a2dd95SBruce Richardson 				      const char *mailbox_struct_type_name,
32999a2dd95SBruce Richardson 				      rte_swx_extern_func_t func);
33092f2944dSCristian Dumitrescu /*
33192f2944dSCristian Dumitrescu  * Hash function.
33292f2944dSCristian Dumitrescu  */
33392f2944dSCristian Dumitrescu 
33492f2944dSCristian Dumitrescu /**
33592f2944dSCristian Dumitrescu  * Pipeline hash function register
33692f2944dSCristian Dumitrescu  *
33792f2944dSCristian Dumitrescu  * @param[in] p
33892f2944dSCristian Dumitrescu  *   Pipeline handle.
33992f2944dSCristian Dumitrescu  * @param[in] name
34092f2944dSCristian Dumitrescu  *   Hash function name.
34192f2944dSCristian Dumitrescu  * @param[in] func
34292f2944dSCristian Dumitrescu  *   Hash function.
34392f2944dSCristian Dumitrescu  * @return
34492f2944dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
34592f2944dSCristian Dumitrescu  *   -EINVAL: Invalid argument;
34692f2944dSCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
34792f2944dSCristian Dumitrescu  *   -EEXIST: Hash function with this name already exists.
34892f2944dSCristian Dumitrescu  */
34992f2944dSCristian Dumitrescu __rte_experimental
35092f2944dSCristian Dumitrescu int
35192f2944dSCristian Dumitrescu rte_swx_pipeline_hash_func_register(struct rte_swx_pipeline *p,
35292f2944dSCristian Dumitrescu 				    const char *name,
35392f2944dSCristian Dumitrescu 				    rte_swx_hash_func_t func);
35499a2dd95SBruce Richardson 
35599a2dd95SBruce Richardson /*
3568ba342ceSCristian Dumitrescu  * RSS.
3578ba342ceSCristian Dumitrescu  */
3588ba342ceSCristian Dumitrescu 
3598ba342ceSCristian Dumitrescu /**
3608ba342ceSCristian Dumitrescu  * Pipeline Receive Side Scaling (RSS) object configure
3618ba342ceSCristian Dumitrescu  *
3628ba342ceSCristian Dumitrescu  * @param[in] p
3638ba342ceSCristian Dumitrescu  *   Pipeline handle.
3648ba342ceSCristian Dumitrescu  * @param[in] name
3658ba342ceSCristian Dumitrescu  *   Name for the new RSS object.
3668ba342ceSCristian Dumitrescu  * @return
3678ba342ceSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
3688ba342ceSCristian Dumitrescu  *   -EINVAL: Invalid argument;
3698ba342ceSCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
3708ba342ceSCristian Dumitrescu  *   -EEXIST: RSS object with this name already exists.
3718ba342ceSCristian Dumitrescu  */
3728ba342ceSCristian Dumitrescu __rte_experimental
3738ba342ceSCristian Dumitrescu int
3748ba342ceSCristian Dumitrescu rte_swx_pipeline_rss_config(struct rte_swx_pipeline *p,
3758ba342ceSCristian Dumitrescu 			    const char *name);
3768ba342ceSCristian Dumitrescu 
3778ba342ceSCristian Dumitrescu /*
37899a2dd95SBruce Richardson  * Packet headers and meta-data
37999a2dd95SBruce Richardson  */
38099a2dd95SBruce Richardson 
38199a2dd95SBruce Richardson /** Structure (struct) field. */
38299a2dd95SBruce Richardson struct rte_swx_field_params {
38399a2dd95SBruce Richardson 	/** Struct field name. */
38499a2dd95SBruce Richardson 	const char *name;
38599a2dd95SBruce Richardson 
38699a2dd95SBruce Richardson 	/** Struct field size (in bits).
38799a2dd95SBruce Richardson 	 * Restriction: All struct fields must be a multiple of 8 bits.
38899a2dd95SBruce Richardson 	 * Restriction: All struct fields must be no greater than 64 bits.
38999a2dd95SBruce Richardson 	 */
39099a2dd95SBruce Richardson 	uint32_t n_bits;
39199a2dd95SBruce Richardson };
39299a2dd95SBruce Richardson 
39399a2dd95SBruce Richardson /**
39499a2dd95SBruce Richardson  * Pipeline struct type register
39599a2dd95SBruce Richardson  *
39699a2dd95SBruce Richardson  * Structs are used extensively in many part of the pipeline to define the size
39799a2dd95SBruce Richardson  * and layout of a specific memory piece such as: headers, meta-data, action
39899a2dd95SBruce Richardson  * data stored in a table entry, mailboxes for extern objects and functions.
39999a2dd95SBruce Richardson  * Similar to C language structs, they are a well defined sequence of fields,
40099a2dd95SBruce Richardson  * with each field having a unique name and a constant size.
40199a2dd95SBruce Richardson  *
402cef38969SCristian Dumitrescu  * In order to use structs to express variable size packet headers such as IPv4
403cef38969SCristian Dumitrescu  * with options, it is allowed for the last field of the struct type to have a
404cef38969SCristian Dumitrescu  * variable size between 0 and *n_bits* bits, with the actual size of this field
405cef38969SCristian Dumitrescu  * determined at run-time for each packet. This struct feature is restricted to
406cef38969SCristian Dumitrescu  * just a few selected instructions that deal with packet headers, so a typical
407cef38969SCristian Dumitrescu  * struct generally has a constant size that is fully known when its struct type
408cef38969SCristian Dumitrescu  * is registered.
409cef38969SCristian Dumitrescu  *
41099a2dd95SBruce Richardson  * @param[in] p
41199a2dd95SBruce Richardson  *   Pipeline handle.
41299a2dd95SBruce Richardson  * @param[in] name
41399a2dd95SBruce Richardson  *   Struct type name.
41499a2dd95SBruce Richardson  * @param[in] fields
41599a2dd95SBruce Richardson  *   The sequence of struct fields.
41699a2dd95SBruce Richardson  * @param[in] n_fields
41799a2dd95SBruce Richardson  *   The number of struct fields.
418cef38969SCristian Dumitrescu  * @param[in] last_field_has_variable_size
419cef38969SCristian Dumitrescu  *   If non-zero (true), then the last field has a variable size between 0 and
420cef38969SCristian Dumitrescu  *   *n_bits* bits, with its actual size determined at run-time for each packet.
421cef38969SCristian Dumitrescu  *   If zero (false), then the last field has a constant size of *n_bits* bits.
42299a2dd95SBruce Richardson  * @return
42399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
42499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
42599a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
42699a2dd95SBruce Richardson  *   -EEXIST: Struct type with this name already exists.
42799a2dd95SBruce Richardson  */
42899a2dd95SBruce Richardson __rte_experimental
42999a2dd95SBruce Richardson int
43099a2dd95SBruce Richardson rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
43199a2dd95SBruce Richardson 				      const char *name,
43299a2dd95SBruce Richardson 				      struct rte_swx_field_params *fields,
433cef38969SCristian Dumitrescu 				      uint32_t n_fields,
434cef38969SCristian Dumitrescu 				      int last_field_has_variable_size);
43599a2dd95SBruce Richardson 
43699a2dd95SBruce Richardson /**
43799a2dd95SBruce Richardson  * Pipeline packet header register
43899a2dd95SBruce Richardson  *
43999a2dd95SBruce Richardson  * @param[in] p
44099a2dd95SBruce Richardson  *   Pipeline handle.
44199a2dd95SBruce Richardson  * @param[in] name
44299a2dd95SBruce Richardson  *   Header name.
44399a2dd95SBruce Richardson  * @param[in] struct_type_name
44499a2dd95SBruce Richardson  *   The struct type instantiated by this packet header.
44599a2dd95SBruce Richardson  * @return
44699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
44799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
44899a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
44999a2dd95SBruce Richardson  *   -EEXIST: Header with this name already exists;
45099a2dd95SBruce Richardson  *   -ENOSPC: Maximum number of headers reached for the pipeline.
45199a2dd95SBruce Richardson  */
45299a2dd95SBruce Richardson __rte_experimental
45399a2dd95SBruce Richardson int
45499a2dd95SBruce Richardson rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p,
45599a2dd95SBruce Richardson 					const char *name,
45699a2dd95SBruce Richardson 					const char *struct_type_name);
45799a2dd95SBruce Richardson 
45899a2dd95SBruce Richardson /**
45999a2dd95SBruce Richardson  * Pipeline packet meta-data register
46099a2dd95SBruce Richardson  *
46199a2dd95SBruce Richardson  * @param[in] p
46299a2dd95SBruce Richardson  *   Pipeline handle.
46399a2dd95SBruce Richardson  * @param[in] struct_type_name
46499a2dd95SBruce Richardson  *   The struct type instantiated by the packet meta-data.
46599a2dd95SBruce Richardson  * @return
46699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
46799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
46899a2dd95SBruce Richardson  */
46999a2dd95SBruce Richardson __rte_experimental
47099a2dd95SBruce Richardson int
47199a2dd95SBruce Richardson rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,
47299a2dd95SBruce Richardson 					  const char *struct_type_name);
47399a2dd95SBruce Richardson 
47499a2dd95SBruce Richardson /*
47599a2dd95SBruce Richardson  * Instructions
47699a2dd95SBruce Richardson  */
47799a2dd95SBruce Richardson 
47899a2dd95SBruce Richardson /**
47999a2dd95SBruce Richardson  * Instruction operands:
48099a2dd95SBruce Richardson  *
48199a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
48299a2dd95SBruce Richardson  *<pre>|     | Description               | Format           | DST | SRC |</pre>
48399a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
48499a2dd95SBruce Richardson  *<pre>| hdr | Header                    | h.header         |     |     |</pre>
48599a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
48699a2dd95SBruce Richardson  *<pre>| act | Action                    | ACTION           |     |     |</pre>
48799a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
48899a2dd95SBruce Richardson  *<pre>| tbl | Table                     | TABLE            |     |     |</pre>
48999a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
49099a2dd95SBruce Richardson  *<pre>| H   | Header field              | h.header.field   | YES | YES |</pre>
49199a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
49299a2dd95SBruce Richardson  *<pre>| M   | Meta-data field           | m.field          | YES | YES |</pre>
49399a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
49499a2dd95SBruce Richardson  *<pre>| E   | Extern obj mailbox field  | e.ext_obj.field  | YES | YES |</pre>
49599a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
49699a2dd95SBruce Richardson  *<pre>| F   | Extern func mailbox field | f.ext_func.field | YES | YES |</pre>
49799a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
49899a2dd95SBruce Richardson  *<pre>| T   | Table action data field   | t.header.field   | NO  | YES |</pre>
49999a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
50099a2dd95SBruce Richardson  *<pre>| I   | Immediate value (64-bit)  | h.header.field   | NO  | YES |</pre>
50199a2dd95SBruce Richardson  *<pre>+-----+---------------------------+------------------+-----+-----+</pre>
50299a2dd95SBruce Richardson  *
50399a2dd95SBruce Richardson  * Instruction set:
50499a2dd95SBruce Richardson  *
50599a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
50699a2dd95SBruce Richardson  *<pre>| Instr.     | Instruction          | Instruction       | 1st  | 2nd    |</pre>
50799a2dd95SBruce Richardson  *<pre>| Name       | Description          | Format            | opnd.| opnd.  |</pre>
50899a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
50999a2dd95SBruce Richardson  *<pre>| rx         | Receive one pkt      | rx m.port_in      | M    |        |</pre>
51099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
51199a2dd95SBruce Richardson  *<pre>| tx         | Transmit one pkt     | tx m.port_out     | M    |        |</pre>
51299a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
51399a2dd95SBruce Richardson  *<pre>| extract    | Extract one hdr      | extract h.hdr     | hdr  |        |</pre>
51499a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
51599a2dd95SBruce Richardson  *<pre>| emit       | Emit one hdr         | emit h.hdr        | hdr  |        |</pre>
51699a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
51799a2dd95SBruce Richardson  *<pre>| validate   | Validate one hdr     | validate h.hdr    | hdr  |        |</pre>
51899a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
51999a2dd95SBruce Richardson  *<pre>| invalidate | Invalidate one hdr   | invalidate h.hdr  | hdr  |        |</pre>
52099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
52199a2dd95SBruce Richardson  *<pre>| mov        | dst = src            | mov dst src       | HMEF | HMEFTI |</pre>
52299a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
52399a2dd95SBruce Richardson  *<pre>| add        | dst += src           | add dst src       | HMEF | HMEFTI |</pre>
52499a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
52599a2dd95SBruce Richardson  *<pre>| sub        | dst -= src           | add dst src       | HMEF | HMEFTI |</pre>
52699a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
52799a2dd95SBruce Richardson  *<pre>| ckadd      | Checksum add: dst =  | add dst src       | HMEF | HMEFTI |</pre>
52899a2dd95SBruce Richardson  *<pre>|            | dst '+ src[0:1] '+   |                   |      | or hdr |</pre>
52999a2dd95SBruce Richardson  *<pre>|            | src[2:3] '+ ...      |                   |      |        |</pre>
53099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
53199a2dd95SBruce Richardson  *<pre>| cksub      | Checksum subtract:   | add dst src       | HMEF | HMEFTI |</pre>
53299a2dd95SBruce Richardson  *<pre>|            | dst = dst '- src     |                   |      |        |</pre>
53399a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
53499a2dd95SBruce Richardson  *<pre>| and        | dst &= src           | and dst src       | HMEF | HMEFTI |</pre>
53599a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
53699a2dd95SBruce Richardson  *<pre>| or         | dst |= src           | or  dst src       | HMEF | HMEFTI |</pre>
53799a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
53899a2dd95SBruce Richardson  *<pre>| xor        | dst ^= src           | xor dst src       | HMEF | HMEFTI |</pre>
53999a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
54099a2dd95SBruce Richardson  *<pre>| shl        | dst <<= src          | shl dst src       | HMEF | HMEFTI |</pre>
54199a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
54299a2dd95SBruce Richardson  *<pre>| shr        | dst >>= src          | shr dst src       | HMEF | HMEFTI |</pre>
54399a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
54499a2dd95SBruce Richardson  *<pre>| table      | Table lookup         | table TABLE       | tbl  |        |</pre>
54599a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
54699a2dd95SBruce Richardson  *<pre>| extern     | Ext obj member func  | extern e.obj.mfunc| ext  |        |</pre>
54799a2dd95SBruce Richardson  *<pre>|            | call or ext func call| extern f.func     |      |        |</pre>
54899a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
54999a2dd95SBruce Richardson  *<pre>| jmp        | Unconditional jump   | jmp LABEL         |      |        |</pre>
55099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
55199a2dd95SBruce Richardson  *<pre>| jmpv       | Jump if hdr is valid | jmpv LABEL h.hdr  | hdr  |        |</pre>
55299a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
55399a2dd95SBruce Richardson  *<pre>| jmpnv      | Jump if hdr is inval | jmpnv LABEL h.hdr | hdr  |        |</pre>
55499a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
55599a2dd95SBruce Richardson  *<pre>| jmph       | Jump if tbl lkp hit  | jmph LABEL        |      |        |</pre>
55699a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
55799a2dd95SBruce Richardson  *<pre>| jmpnh      | Jump if tbl lkp miss | jmpnh LABEL       |      |        |</pre>
55899a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
55999a2dd95SBruce Richardson  *<pre>| jmpa       | Jump if action run   | jmpa LABEL ACTION | act  |        |</pre>
56099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
56199a2dd95SBruce Richardson  *<pre>| jmpna      | Jump if act not run  | jmpna LABEL ACTION| act  |        |</pre>
56299a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
56399a2dd95SBruce Richardson  *<pre>| jmpeq      | Jump if (a == b)     | jmpeq LABEL a b   | HMEFT| HMEFTI |</pre>
56499a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
56599a2dd95SBruce Richardson  *<pre>| jmpneq     | Jump if (a != b)     | jmpneq LABEL a b  | HMEFT| HMEFTI |</pre>
56699a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
56799a2dd95SBruce Richardson  *<pre>| jmplt      | Jump if (a < b)      | jmplt LABEL a b   | HMEFT| HMEFTI |</pre>
56899a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
56999a2dd95SBruce Richardson  *<pre>| jmpgt      | Jump if (a > b)      | jmpgt LABEL a b   | HMEFT| HMEFTI |</pre>
57099a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
57199a2dd95SBruce Richardson  *<pre>| return     | Return from action   | return            |      |        |</pre>
57299a2dd95SBruce Richardson  *<pre>+------------+----------------------+-------------------+------+--------+</pre>
57399a2dd95SBruce Richardson  *
57499a2dd95SBruce Richardson  * At initialization time, the pipeline and action instructions (including the
57599a2dd95SBruce Richardson  * symbolic name operands) are translated to internal data structures that are
57699a2dd95SBruce Richardson  * used at run-time.
57799a2dd95SBruce Richardson  */
57899a2dd95SBruce Richardson 
57999a2dd95SBruce Richardson /*
58099a2dd95SBruce Richardson  * Pipeline action
58199a2dd95SBruce Richardson  */
58299a2dd95SBruce Richardson 
58399a2dd95SBruce Richardson /**
58499a2dd95SBruce Richardson  * Pipeline action configure
58599a2dd95SBruce Richardson  *
58699a2dd95SBruce Richardson  * @param[in] p
58799a2dd95SBruce Richardson  *   Pipeline handle.
58899a2dd95SBruce Richardson  * @param[in] name
58999a2dd95SBruce Richardson  *   Action name.
59099a2dd95SBruce Richardson  * @param[in] args_struct_type_name
59199a2dd95SBruce Richardson  *   The struct type instantiated by the action data. The action data represent
59299a2dd95SBruce Richardson  *   the action arguments that are stored in the table entry together with the
59399a2dd95SBruce Richardson  *   action ID. Set to NULL when the action does not have any arguments.
59499a2dd95SBruce Richardson  * @param[in] instructions
59599a2dd95SBruce Richardson  *   Action instructions.
59699a2dd95SBruce Richardson  * @param[in] n_instructions
59799a2dd95SBruce Richardson  *   Number of action instructions.
59899a2dd95SBruce Richardson  * @return
59999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
60099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
60199a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
60299a2dd95SBruce Richardson  *   -EEXIST: Action with this name already exists.
60399a2dd95SBruce Richardson  */
60499a2dd95SBruce Richardson __rte_experimental
60599a2dd95SBruce Richardson int
60699a2dd95SBruce Richardson rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,
60799a2dd95SBruce Richardson 			       const char *name,
60899a2dd95SBruce Richardson 			       const char *args_struct_type_name,
60999a2dd95SBruce Richardson 			       const char **instructions,
61099a2dd95SBruce Richardson 			       uint32_t n_instructions);
61199a2dd95SBruce Richardson 
61299a2dd95SBruce Richardson /*
61399a2dd95SBruce Richardson  * Pipeline table
61499a2dd95SBruce Richardson  */
61599a2dd95SBruce Richardson 
61699a2dd95SBruce Richardson /**
61799a2dd95SBruce Richardson  * Pipeline table type register
61899a2dd95SBruce Richardson  *
61999a2dd95SBruce Richardson  * @param[in] p
62099a2dd95SBruce Richardson  *   Pipeline handle.
62199a2dd95SBruce Richardson  * @param[in] name
62299a2dd95SBruce Richardson  *   Table type name.
62399a2dd95SBruce Richardson  * @param[in] match_type
62499a2dd95SBruce Richardson  *   Match type implemented by the new table type.
62599a2dd95SBruce Richardson  * @param[in] ops
62699a2dd95SBruce Richardson  *   Table type operations.
62799a2dd95SBruce Richardson  * @return
62899a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
62999a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
63099a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
63199a2dd95SBruce Richardson  *   -EEXIST: Table type with this name already exists.
63299a2dd95SBruce Richardson  */
63399a2dd95SBruce Richardson __rte_experimental
63499a2dd95SBruce Richardson int
63599a2dd95SBruce Richardson rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,
63699a2dd95SBruce Richardson 				     const char *name,
63799a2dd95SBruce Richardson 				     enum rte_swx_table_match_type match_type,
63899a2dd95SBruce Richardson 				     struct rte_swx_table_ops *ops);
63999a2dd95SBruce Richardson 
64099a2dd95SBruce Richardson /** Match field parameters. */
64199a2dd95SBruce Richardson struct rte_swx_match_field_params {
64299a2dd95SBruce Richardson 	/** Match field name. Must be either a field of one of the registered
64399a2dd95SBruce Richardson 	 * packet headers ("h.header.field") or a field of the registered
64499a2dd95SBruce Richardson 	 * meta-data ("m.field").
64599a2dd95SBruce Richardson 	 */
64699a2dd95SBruce Richardson 	const char *name;
64799a2dd95SBruce Richardson 
64899a2dd95SBruce Richardson 	/** Match type of the field. */
64999a2dd95SBruce Richardson 	enum rte_swx_table_match_type match_type;
65099a2dd95SBruce Richardson };
65199a2dd95SBruce Richardson 
65299a2dd95SBruce Richardson /** Pipeline table parameters. */
65399a2dd95SBruce Richardson struct rte_swx_pipeline_table_params {
65499a2dd95SBruce Richardson 	/** The set of match fields for the current table.
65599a2dd95SBruce Richardson 	 * Restriction: All the match fields of the current table need to be
65699a2dd95SBruce Richardson 	 * part of the same struct, i.e. either all the match fields are part of
65799a2dd95SBruce Richardson 	 * the same header or all the match fields are part of the meta-data.
65899a2dd95SBruce Richardson 	 */
65999a2dd95SBruce Richardson 	struct rte_swx_match_field_params *fields;
66099a2dd95SBruce Richardson 
66199a2dd95SBruce Richardson 	/** The number of match fields for the current table. If set to zero, no
66299a2dd95SBruce Richardson 	 * "regular" entries (i.e. entries other than the default entry) can be
66399a2dd95SBruce Richardson 	 * added to the current table and the match process always results in
66499a2dd95SBruce Richardson 	 * lookup miss.
66599a2dd95SBruce Richardson 	 */
66699a2dd95SBruce Richardson 	uint32_t n_fields;
66799a2dd95SBruce Richardson 
66899a2dd95SBruce Richardson 	/** The set of actions for the current table. */
66999a2dd95SBruce Richardson 	const char **action_names;
67099a2dd95SBruce Richardson 
671cd79e020SYogesh Jangra 	/**  Array of *n_actions* flags. For each action, the associated flag
672cd79e020SYogesh Jangra 	 * indicates whether the action can be assigned to regular table entries
673cd79e020SYogesh Jangra 	 * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
674cd79e020SYogesh Jangra 	 * to NULL, it defaults to true for all actions.
675cd79e020SYogesh Jangra 	 */
676cd79e020SYogesh Jangra 	int *action_is_for_table_entries;
677cd79e020SYogesh Jangra 
678cd79e020SYogesh Jangra 	/**  Array of *n_actions* flags. For each action, the associated flag
679cd79e020SYogesh Jangra 	 * indicates whether the action can be assigned to the default table
680cd79e020SYogesh Jangra 	 * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
681cd79e020SYogesh Jangra 	 * When set to NULL, it defaults to true for all actions.
682cd79e020SYogesh Jangra 	 */
683cd79e020SYogesh Jangra 	int *action_is_for_default_entry;
684cd79e020SYogesh Jangra 
68599a2dd95SBruce Richardson 	/** The number of actions for the current table. Must be at least one.
68699a2dd95SBruce Richardson 	 */
68799a2dd95SBruce Richardson 	uint32_t n_actions;
68899a2dd95SBruce Richardson 
68999a2dd95SBruce Richardson 	/** The default table action that gets executed on lookup miss. Must be
69099a2dd95SBruce Richardson 	 * one of the table actions included in the *action_names*.
69199a2dd95SBruce Richardson 	 */
69299a2dd95SBruce Richardson 	const char *default_action_name;
69399a2dd95SBruce Richardson 
69473d94b00SCristian Dumitrescu 	/** Default action arguments. Specified as a string with the format
69573d94b00SCristian Dumitrescu 	 * "ARG0_NAME ARG0_VALUE ...". The number of arguments in this string
69673d94b00SCristian Dumitrescu 	 * must match exactly the number of arguments of the default action.
69773d94b00SCristian Dumitrescu 	 * Must be NULL if the default action does not have any arguments.
69899a2dd95SBruce Richardson 	 */
69973d94b00SCristian Dumitrescu 	const char *default_action_args;
70099a2dd95SBruce Richardson 
70199a2dd95SBruce Richardson 	/** If non-zero (true), then the default action of the current table
70299a2dd95SBruce Richardson 	 * cannot be changed. If zero (false), then the default action can be
70399a2dd95SBruce Richardson 	 * changed in the future with another action from the *action_names*
70499a2dd95SBruce Richardson 	 * list.
70599a2dd95SBruce Richardson 	 */
70699a2dd95SBruce Richardson 	int default_action_is_const;
7079560a329SCristian Dumitrescu 
7089560a329SCristian Dumitrescu 	/** Hash function name. When not set to NULL, it must point to one of
7099560a329SCristian Dumitrescu 	 * the hash functions that were registered for the current pipeline.
7109560a329SCristian Dumitrescu 	 * Ignored by the table implementation when not needed. When needed but
7119560a329SCristian Dumitrescu 	 * NULL, the table implementation will select the hash function to use.
7129560a329SCristian Dumitrescu 	 */
7139560a329SCristian Dumitrescu 	const char *hash_func_name;
71499a2dd95SBruce Richardson };
71599a2dd95SBruce Richardson 
71699a2dd95SBruce Richardson /**
71799a2dd95SBruce Richardson  * Pipeline table configure
71899a2dd95SBruce Richardson  *
71999a2dd95SBruce Richardson  * @param[out] p
72099a2dd95SBruce Richardson  *   Pipeline handle.
72199a2dd95SBruce Richardson  * @param[in] name
72299a2dd95SBruce Richardson  *   Table name.
72399a2dd95SBruce Richardson  * @param[in] params
72499a2dd95SBruce Richardson  *   Table parameters.
72599a2dd95SBruce Richardson  * @param[in] recommended_table_type_name
72699a2dd95SBruce Richardson  *   Recommended table type. Typically set to NULL. Useful as guidance when
72799a2dd95SBruce Richardson  *   there are multiple table types registered for the match type of the table,
72899a2dd95SBruce Richardson  *   as determined from the table match fields specification. Silently ignored
72999a2dd95SBruce Richardson  *   if the recommended table type does not exist or it serves a different match
73099a2dd95SBruce Richardson  *   type.
73199a2dd95SBruce Richardson  * @param[in] args
73299a2dd95SBruce Richardson  *   Table creation arguments.
73399a2dd95SBruce Richardson  * @param[in] size
73499a2dd95SBruce Richardson  *   Guideline on maximum number of table entries.
73599a2dd95SBruce Richardson  * @return
73699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
73799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
73899a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
73999a2dd95SBruce Richardson  *   -EEXIST: Table with this name already exists;
74099a2dd95SBruce Richardson  *   -ENODEV: Table creation error.
74199a2dd95SBruce Richardson  */
74299a2dd95SBruce Richardson __rte_experimental
74399a2dd95SBruce Richardson int
74499a2dd95SBruce Richardson rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,
74599a2dd95SBruce Richardson 			      const char *name,
74699a2dd95SBruce Richardson 			      struct rte_swx_pipeline_table_params *params,
74799a2dd95SBruce Richardson 			      const char *recommended_table_type_name,
74899a2dd95SBruce Richardson 			      const char *args,
74999a2dd95SBruce Richardson 			      uint32_t size);
75099a2dd95SBruce Richardson 
751cdaa937dSCristian Dumitrescu /** Pipeline selector table parameters. */
752cdaa937dSCristian Dumitrescu struct rte_swx_pipeline_selector_params {
753cdaa937dSCristian Dumitrescu 	/** The group ID field. Input into the selection operation.
754cdaa937dSCristian Dumitrescu 	 * Restriction: This field must be a meta-data field.
755cdaa937dSCristian Dumitrescu 	 */
756cdaa937dSCristian Dumitrescu 	const char *group_id_field_name;
757cdaa937dSCristian Dumitrescu 
758cdaa937dSCristian Dumitrescu 	/** The set of fields used to select (through a hashing scheme) the
7594a6672c2SStephen Hemminger 	 * member within the current group. Inputs into the selection operation.
760cdaa937dSCristian Dumitrescu 	 * Restriction: All the selector fields must be part of the same struct,
761cdaa937dSCristian Dumitrescu 	 * i.e. part of the same header or part of the meta-data structure.
762cdaa937dSCristian Dumitrescu 	 */
763cdaa937dSCristian Dumitrescu 	const char **selector_field_names;
764cdaa937dSCristian Dumitrescu 
765cdaa937dSCristian Dumitrescu 	/** The number of selector fields. Must be non-zero. */
766cdaa937dSCristian Dumitrescu 	uint32_t n_selector_fields;
767cdaa937dSCristian Dumitrescu 
768cdaa937dSCristian Dumitrescu 	/** The member ID field. Output from the selection operation.
769cdaa937dSCristian Dumitrescu 	 * Restriction: This field must be a meta-data field.
770cdaa937dSCristian Dumitrescu 	 */
771cdaa937dSCristian Dumitrescu 	const char *member_id_field_name;
772cdaa937dSCristian Dumitrescu 
773cdaa937dSCristian Dumitrescu 	/** Maximum number of groups. Must be non-zero. */
774cdaa937dSCristian Dumitrescu 	uint32_t n_groups_max;
775cdaa937dSCristian Dumitrescu 
776cdaa937dSCristian Dumitrescu 	/** Maximum number of members per group. Must be non-zero. */
777cdaa937dSCristian Dumitrescu 	uint32_t n_members_per_group_max;
778cdaa937dSCristian Dumitrescu };
779cdaa937dSCristian Dumitrescu 
780cdaa937dSCristian Dumitrescu /**
781cdaa937dSCristian Dumitrescu  * Pipeline selector table configure
782cdaa937dSCristian Dumitrescu  *
783cdaa937dSCristian Dumitrescu  * @param[out] p
784cdaa937dSCristian Dumitrescu  *   Pipeline handle.
785cdaa937dSCristian Dumitrescu  * @param[in] name
786cdaa937dSCristian Dumitrescu  *   Selector table name.
787cdaa937dSCristian Dumitrescu  * @param[in] params
788cdaa937dSCristian Dumitrescu  *   Selector table parameters.
789cdaa937dSCristian Dumitrescu  * @return
790cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
791cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument;
792cdaa937dSCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
793cdaa937dSCristian Dumitrescu  *   -EEXIST: Selector table with this name already exists;
794cdaa937dSCristian Dumitrescu  *   -ENODEV: Selector table creation error.
795cdaa937dSCristian Dumitrescu  */
796cdaa937dSCristian Dumitrescu __rte_experimental
797cdaa937dSCristian Dumitrescu int
798cdaa937dSCristian Dumitrescu rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
799cdaa937dSCristian Dumitrescu 				 const char *name,
800cdaa937dSCristian Dumitrescu 				 struct rte_swx_pipeline_selector_params *params);
801cdaa937dSCristian Dumitrescu 
8024f59d372SCristian Dumitrescu /** Pipeline learner table parameters. */
8034f59d372SCristian Dumitrescu struct rte_swx_pipeline_learner_params {
8044f59d372SCristian Dumitrescu 	/** The set of match fields for the current table.
8054f59d372SCristian Dumitrescu 	 * Restriction: All the match fields of the current table need to be
8064f59d372SCristian Dumitrescu 	 * part of the same struct, i.e. either all the match fields are part of
8074f59d372SCristian Dumitrescu 	 * the same header or all the match fields are part of the meta-data.
8084f59d372SCristian Dumitrescu 	 */
8094f59d372SCristian Dumitrescu 	const char **field_names;
8104f59d372SCristian Dumitrescu 
8114f59d372SCristian Dumitrescu 	/** The number of match fields for the current table. Must be non-zero.
8124f59d372SCristian Dumitrescu 	 */
8134f59d372SCristian Dumitrescu 	uint32_t n_fields;
8144f59d372SCristian Dumitrescu 
8154f59d372SCristian Dumitrescu 	/** The set of actions for the current table. */
8164f59d372SCristian Dumitrescu 	const char **action_names;
8174f59d372SCristian Dumitrescu 
818cd79e020SYogesh Jangra 	/**  Array of *n_actions* flags. For each action, the associated flag
819cd79e020SYogesh Jangra 	 * indicates whether the action can be assigned to regular table entries
820cd79e020SYogesh Jangra 	 * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
821cd79e020SYogesh Jangra 	 * to NULL, it defaults to true for all actions.
822cd79e020SYogesh Jangra 	 */
823cd79e020SYogesh Jangra 	int *action_is_for_table_entries;
824cd79e020SYogesh Jangra 
825cd79e020SYogesh Jangra 	/**  Array of *n_actions* flags. For each action, the associated flag
826cd79e020SYogesh Jangra 	 * indicates whether the action can be assigned to the default table
827cd79e020SYogesh Jangra 	 * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
828cd79e020SYogesh Jangra 	 * When set to NULL, it defaults to true for all actions.
829cd79e020SYogesh Jangra 	 */
830cd79e020SYogesh Jangra 	int *action_is_for_default_entry;
831cd79e020SYogesh Jangra 
8324f59d372SCristian Dumitrescu 	/** The number of actions for the current table. Must be at least one.
8334f59d372SCristian Dumitrescu 	 */
8344f59d372SCristian Dumitrescu 	uint32_t n_actions;
8354f59d372SCristian Dumitrescu 
8364f59d372SCristian Dumitrescu 	/** The default table action that gets executed on lookup miss. Must be
8374f59d372SCristian Dumitrescu 	 * one of the table actions included in the *action_names*.
8384f59d372SCristian Dumitrescu 	 */
8394f59d372SCristian Dumitrescu 	const char *default_action_name;
8404f59d372SCristian Dumitrescu 
84173d94b00SCristian Dumitrescu 	/** Default action arguments. Specified as a string with the format
84273d94b00SCristian Dumitrescu 	 * "ARG0_NAME ARG0_VALUE ...". The number of arguments in this string
84373d94b00SCristian Dumitrescu 	 * must match exactly the number of arguments of the default action.
84473d94b00SCristian Dumitrescu 	 * Must be NULL if the default action does not have any arguments.
8454f59d372SCristian Dumitrescu 	 */
84673d94b00SCristian Dumitrescu 	const char *default_action_args;
8474f59d372SCristian Dumitrescu 
8484f59d372SCristian Dumitrescu 	/** If non-zero (true), then the default action of the current table
8494f59d372SCristian Dumitrescu 	 * cannot be changed. If zero (false), then the default action can be
8504f59d372SCristian Dumitrescu 	 * changed in the future with another action from the *action_names*
8514f59d372SCristian Dumitrescu 	 * list.
8524f59d372SCristian Dumitrescu 	 */
8534f59d372SCristian Dumitrescu 	int default_action_is_const;
854fa7723b5SCristian Dumitrescu 
855fa7723b5SCristian Dumitrescu 	/** Hash function name. When not set to NULL, it must point to one of
856fa7723b5SCristian Dumitrescu 	 * the hash functions that were registered for the current pipeline.
857fa7723b5SCristian Dumitrescu 	 * When NULL, the default hash function will be used.
858fa7723b5SCristian Dumitrescu 	 */
859fa7723b5SCristian Dumitrescu 	const char *hash_func_name;
8604f59d372SCristian Dumitrescu };
8614f59d372SCristian Dumitrescu 
8624f59d372SCristian Dumitrescu /**
8634f59d372SCristian Dumitrescu  * Pipeline learner table configure
8644f59d372SCristian Dumitrescu  *
8654f59d372SCristian Dumitrescu  * @param[out] p
8664f59d372SCristian Dumitrescu  *   Pipeline handle.
8674f59d372SCristian Dumitrescu  * @param[in] name
8684f59d372SCristian Dumitrescu  *   Learner table name.
8694f59d372SCristian Dumitrescu  * @param[in] params
8704f59d372SCristian Dumitrescu  *   Learner table parameters.
8714f59d372SCristian Dumitrescu  * @param[in] size
8724f59d372SCristian Dumitrescu  *   The maximum number of table entries. Must be non-zero.
8734f59d372SCristian Dumitrescu  * @param[in] timeout
874e2ecc535SCristian Dumitrescu  *   Array of possible table entry timeouts in seconds. Must be non-NULL.
875e2ecc535SCristian Dumitrescu  * @param[in] n_timeouts
876e2ecc535SCristian Dumitrescu  *   Number of elements in the *timeout* array.
8774f59d372SCristian Dumitrescu  * @return
8784f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
8794f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument;
8804f59d372SCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
8814f59d372SCristian Dumitrescu  *   -EEXIST: Learner table with this name already exists;
8824f59d372SCristian Dumitrescu  *   -ENODEV: Learner table creation error.
8834f59d372SCristian Dumitrescu  */
8844f59d372SCristian Dumitrescu __rte_experimental
8854f59d372SCristian Dumitrescu int
8864f59d372SCristian Dumitrescu rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
8874f59d372SCristian Dumitrescu 				const char *name,
8884f59d372SCristian Dumitrescu 				struct rte_swx_pipeline_learner_params *params,
8894f59d372SCristian Dumitrescu 				uint32_t size,
890e2ecc535SCristian Dumitrescu 				uint32_t *timeout,
891e2ecc535SCristian Dumitrescu 				uint32_t n_timeouts);
8924f59d372SCristian Dumitrescu 
89399a2dd95SBruce Richardson /**
89499a2dd95SBruce Richardson  * Pipeline register array configure
89599a2dd95SBruce Richardson  *
89699a2dd95SBruce Richardson  * @param[in] p
89799a2dd95SBruce Richardson  *   Pipeline handle.
89899a2dd95SBruce Richardson  * @param[in] name
89999a2dd95SBruce Richardson  *   Register array name.
90099a2dd95SBruce Richardson  * @param[in] size
90199a2dd95SBruce Richardson  *   Number of registers in the array. Each register is 64-bit in size.
90299a2dd95SBruce Richardson  * @param[in] init_val
90399a2dd95SBruce Richardson  *   Initial value for every register in the array. The recommended value is 0.
90499a2dd95SBruce Richardson  * @return
90599a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
90699a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
90799a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
90899a2dd95SBruce Richardson  *   -EEXIST: Register array with this name already exists.
90999a2dd95SBruce Richardson  */
91099a2dd95SBruce Richardson __rte_experimental
91199a2dd95SBruce Richardson int
91299a2dd95SBruce Richardson rte_swx_pipeline_regarray_config(struct rte_swx_pipeline *p,
91399a2dd95SBruce Richardson 				 const char *name,
91499a2dd95SBruce Richardson 				 uint32_t size,
91599a2dd95SBruce Richardson 				 uint64_t init_val);
91699a2dd95SBruce Richardson 
91799a2dd95SBruce Richardson /**
91899a2dd95SBruce Richardson  * Pipeline meter array configure
91999a2dd95SBruce Richardson  *
92099a2dd95SBruce Richardson  * @param[in] p
92199a2dd95SBruce Richardson  *   Pipeline handle.
92299a2dd95SBruce Richardson  * @param[in] name
92399a2dd95SBruce Richardson  *   Meter array name.
92499a2dd95SBruce Richardson  * @param[in] size
92599a2dd95SBruce Richardson  *   Number of meters in the array. Each meter in the array implements the Two
92699a2dd95SBruce Richardson  *   Rate Three Color Marker (trTCM) algorithm, as specified by RFC 2698.
92799a2dd95SBruce Richardson  * @return
92899a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
92999a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
93099a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
93199a2dd95SBruce Richardson  *   -EEXIST: Meter array with this name already exists.
93299a2dd95SBruce Richardson  */
93399a2dd95SBruce Richardson __rte_experimental
93499a2dd95SBruce Richardson int
93599a2dd95SBruce Richardson rte_swx_pipeline_metarray_config(struct rte_swx_pipeline *p,
93699a2dd95SBruce Richardson 				 const char *name,
93799a2dd95SBruce Richardson 				 uint32_t size);
93899a2dd95SBruce Richardson 
93999a2dd95SBruce Richardson /**
94099a2dd95SBruce Richardson  * Pipeline instructions configure
94199a2dd95SBruce Richardson  *
94299a2dd95SBruce Richardson  * @param[in] p
94399a2dd95SBruce Richardson  *   Pipeline handle.
94499a2dd95SBruce Richardson  * @param[in] instructions
94599a2dd95SBruce Richardson  *   Pipeline instructions.
94699a2dd95SBruce Richardson  * @param[in] n_instructions
94799a2dd95SBruce Richardson  *   Number of pipeline instructions.
94899a2dd95SBruce Richardson  * @return
94999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
95099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
95199a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory.
95299a2dd95SBruce Richardson  */
95399a2dd95SBruce Richardson __rte_experimental
95499a2dd95SBruce Richardson int
95599a2dd95SBruce Richardson rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p,
95699a2dd95SBruce Richardson 				     const char **instructions,
95799a2dd95SBruce Richardson 				     uint32_t n_instructions);
95899a2dd95SBruce Richardson 
95999a2dd95SBruce Richardson /**
96099a2dd95SBruce Richardson  * Pipeline build
96199a2dd95SBruce Richardson  *
96299a2dd95SBruce Richardson  * Once called, the pipeline build operation marks the end of pipeline
96399a2dd95SBruce Richardson  * configuration. At this point, all the internal data structures needed to run
96499a2dd95SBruce Richardson  * the pipeline are built.
96599a2dd95SBruce Richardson  *
96699a2dd95SBruce Richardson  * @param[in] p
96799a2dd95SBruce Richardson  *   Pipeline handle.
96899a2dd95SBruce Richardson  * @return
96999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
97099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
97199a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
97299a2dd95SBruce Richardson  *   -EEXIST: Pipeline was already built successfully.
97399a2dd95SBruce Richardson  */
97499a2dd95SBruce Richardson __rte_experimental
97599a2dd95SBruce Richardson int
97699a2dd95SBruce Richardson rte_swx_pipeline_build(struct rte_swx_pipeline *p);
97799a2dd95SBruce Richardson 
97899a2dd95SBruce Richardson /**
9798f55f896SCristian Dumitrescu  * Pipeline C code generate based on input specification file
9808f55f896SCristian Dumitrescu  *
9818f55f896SCristian Dumitrescu  * @param[in] spec_file
9828f55f896SCristian Dumitrescu  *   Pipeline specification file (.spec) provided as input.
9838f55f896SCristian Dumitrescu  * @param[in] code_file
9848f55f896SCristian Dumitrescu  *   Pipeline C language file (.c) to be generated.
9858f55f896SCristian Dumitrescu  * @param[out] err_line
9868f55f896SCristian Dumitrescu  *   In case of error and non-NULL, the line number within the *spec* file where
9878f55f896SCristian Dumitrescu  *   the error occurred. The first line number in the file is 1.
9888f55f896SCristian Dumitrescu  * @param[out] err_msg
9898f55f896SCristian Dumitrescu  *   In case of error and non-NULL, the error message.
9908f55f896SCristian Dumitrescu  * @return
9918f55f896SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
9928f55f896SCristian Dumitrescu  *   -EINVAL: Invalid argument;
9938f55f896SCristian Dumitrescu  *   -ENOMEM: Not enough space/cannot allocate memory;
9948f55f896SCristian Dumitrescu  *   -EEXIST: Resource with the same name already exists.
9958f55f896SCristian Dumitrescu  */
9968f55f896SCristian Dumitrescu __rte_experimental
9978f55f896SCristian Dumitrescu int
9988f55f896SCristian Dumitrescu rte_swx_pipeline_codegen(FILE *spec_file,
9998f55f896SCristian Dumitrescu 			 FILE *code_file,
10008f55f896SCristian Dumitrescu 			 uint32_t *err_line,
10018f55f896SCristian Dumitrescu 			 const char **err_msg);
10028f55f896SCristian Dumitrescu 
10038f55f896SCristian Dumitrescu /**
100468b95704SCristian Dumitrescu  * Pipeline build from shared object library
100599a2dd95SBruce Richardson  *
100668b95704SCristian Dumitrescu  * The shared object library must be built from the C language source code file
100768b95704SCristian Dumitrescu  * previously generated by the rte_swx_pipeline_codegen() API function.
100868b95704SCristian Dumitrescu  *
100968b95704SCristian Dumitrescu  * The pipeline I/O specification file defines the I/O ports of the pipeline.
101068b95704SCristian Dumitrescu  *
101168b95704SCristian Dumitrescu  * @param[out] p
101268b95704SCristian Dumitrescu  *   Pipeline handle. Must point to valid memory. Contains valid pipeline handle
101368b95704SCristian Dumitrescu  *   when the function returns successfully.
101468b95704SCristian Dumitrescu  * @param[in] name
101568b95704SCristian Dumitrescu  *   Pipeline unique name.
101668b95704SCristian Dumitrescu  * @param[in] lib_file_name
101768b95704SCristian Dumitrescu  *   Shared object library file name.
101868b95704SCristian Dumitrescu  * @param[in] iospec_file
101968b95704SCristian Dumitrescu  *   Pipeline I/O specification file.
102068b95704SCristian Dumitrescu  * @param[in] numa_node
102168b95704SCristian Dumitrescu  *   Non-Uniform Memory Access (NUMA) node.
102299a2dd95SBruce Richardson  * @return
102399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
102499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
102599a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
102668b95704SCristian Dumitrescu  *   -EEXIST: Pipeline with this name already exists;
102799a2dd95SBruce Richardson  *   -ENODEV: Extern object or table creation error.
102899a2dd95SBruce Richardson  */
102999a2dd95SBruce Richardson __rte_experimental
103099a2dd95SBruce Richardson int
103168b95704SCristian Dumitrescu rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **p,
103268b95704SCristian Dumitrescu 				const char *name,
103368b95704SCristian Dumitrescu 				const char *lib_file_name,
103468b95704SCristian Dumitrescu 				FILE *iospec_file,
103568b95704SCristian Dumitrescu 				int numa_node);
103699a2dd95SBruce Richardson 
103799a2dd95SBruce Richardson /**
103899a2dd95SBruce Richardson  * Pipeline run
103999a2dd95SBruce Richardson  *
104099a2dd95SBruce Richardson  * @param[in] p
104199a2dd95SBruce Richardson  *   Pipeline handle.
104299a2dd95SBruce Richardson  * @param[in] n_instructions
104399a2dd95SBruce Richardson  *   Number of instructions to execute.
104499a2dd95SBruce Richardson  */
104599a2dd95SBruce Richardson __rte_experimental
104699a2dd95SBruce Richardson void
104799a2dd95SBruce Richardson rte_swx_pipeline_run(struct rte_swx_pipeline *p,
104899a2dd95SBruce Richardson 		     uint32_t n_instructions);
104999a2dd95SBruce Richardson 
105099a2dd95SBruce Richardson /**
105199a2dd95SBruce Richardson  * Pipeline flush
105299a2dd95SBruce Richardson  *
105399a2dd95SBruce Richardson  * Flush all output ports of the pipeline.
105499a2dd95SBruce Richardson  *
105599a2dd95SBruce Richardson  * @param[in] p
105699a2dd95SBruce Richardson  *   Pipeline handle.
1057448e01f1SStephen Hemminger  *   If p is NULL, no operation is performed.
105899a2dd95SBruce Richardson  */
105999a2dd95SBruce Richardson __rte_experimental
106099a2dd95SBruce Richardson void
106199a2dd95SBruce Richardson rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
106299a2dd95SBruce Richardson 
106399a2dd95SBruce Richardson /**
106499a2dd95SBruce Richardson  * Pipeline free
106599a2dd95SBruce Richardson  *
106699a2dd95SBruce Richardson  * @param[in] p
106799a2dd95SBruce Richardson  *   Pipeline handle.
106899a2dd95SBruce Richardson  */
106999a2dd95SBruce Richardson __rte_experimental
107099a2dd95SBruce Richardson void
107199a2dd95SBruce Richardson rte_swx_pipeline_free(struct rte_swx_pipeline *p);
107299a2dd95SBruce Richardson 
107399a2dd95SBruce Richardson #ifdef __cplusplus
107499a2dd95SBruce Richardson }
107599a2dd95SBruce Richardson #endif
107699a2dd95SBruce Richardson 
107799a2dd95SBruce Richardson #endif
1078