xref: /dpdk/lib/pipeline/rte_swx_ctl.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_CTL_H__
599a2dd95SBruce Richardson #define __INCLUDE_RTE_SWX_CTL_H__
699a2dd95SBruce Richardson 
799a2dd95SBruce Richardson /**
899a2dd95SBruce Richardson  * @file
999a2dd95SBruce Richardson  * RTE SWX Pipeline Control
1099a2dd95SBruce Richardson  */
1199a2dd95SBruce Richardson 
1299a2dd95SBruce Richardson #include <stdint.h>
1399a2dd95SBruce Richardson #include <stdio.h>
1499a2dd95SBruce Richardson 
1599a2dd95SBruce Richardson #include <rte_compat.h>
1699a2dd95SBruce Richardson #include <rte_meter.h>
1799a2dd95SBruce Richardson 
1899a2dd95SBruce Richardson #include "rte_swx_port.h"
1999a2dd95SBruce Richardson #include "rte_swx_table.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 struct rte_swx_pipeline;
2699a2dd95SBruce Richardson 
2799a2dd95SBruce Richardson /** Name size. */
2899a2dd95SBruce Richardson #ifndef RTE_SWX_CTL_NAME_SIZE
2999a2dd95SBruce Richardson #define RTE_SWX_CTL_NAME_SIZE 64
3099a2dd95SBruce Richardson #endif
3199a2dd95SBruce Richardson 
3299a2dd95SBruce Richardson /*
3399a2dd95SBruce Richardson  * Pipeline Query API.
3499a2dd95SBruce Richardson  */
3599a2dd95SBruce Richardson 
3699a2dd95SBruce Richardson /** Pipeline info. */
3799a2dd95SBruce Richardson struct rte_swx_ctl_pipeline_info {
38d69c90c8SCristian Dumitrescu 	/** Pipeline name. */
39d69c90c8SCristian Dumitrescu 	char name[RTE_SWX_CTL_NAME_SIZE];
40d69c90c8SCristian Dumitrescu 
4199a2dd95SBruce Richardson 	/** Number of input ports. */
4299a2dd95SBruce Richardson 	uint32_t n_ports_in;
4399a2dd95SBruce Richardson 
4499a2dd95SBruce Richardson 	/** Number of input ports. */
4599a2dd95SBruce Richardson 	uint32_t n_ports_out;
4699a2dd95SBruce Richardson 
47dac0ecd9SCristian Dumitrescu 	/** Number of packet mirroring slots. */
48dac0ecd9SCristian Dumitrescu 	uint32_t n_mirroring_slots;
49dac0ecd9SCristian Dumitrescu 
50dac0ecd9SCristian Dumitrescu 	/** Number of packet mirroring sessions. */
51dac0ecd9SCristian Dumitrescu 	uint32_t n_mirroring_sessions;
52dac0ecd9SCristian Dumitrescu 
5399a2dd95SBruce Richardson 	/** Number of actions. */
5499a2dd95SBruce Richardson 	uint32_t n_actions;
5599a2dd95SBruce Richardson 
5699a2dd95SBruce Richardson 	/** Number of tables. */
5799a2dd95SBruce Richardson 	uint32_t n_tables;
5899a2dd95SBruce Richardson 
59cdaa937dSCristian Dumitrescu 	/** Number of selector tables. */
60cdaa937dSCristian Dumitrescu 	uint32_t n_selectors;
61cdaa937dSCristian Dumitrescu 
624f59d372SCristian Dumitrescu 	/** Number of learner tables. */
634f59d372SCristian Dumitrescu 	uint32_t n_learners;
644f59d372SCristian Dumitrescu 
6599a2dd95SBruce Richardson 	/** Number of register arrays. */
6699a2dd95SBruce Richardson 	uint32_t n_regarrays;
6799a2dd95SBruce Richardson 
6899a2dd95SBruce Richardson 	/** Number of meter arrays. */
6999a2dd95SBruce Richardson 	uint32_t n_metarrays;
708ba342ceSCristian Dumitrescu 
718ba342ceSCristian Dumitrescu 	/** Number of RSS objects. */
728ba342ceSCristian Dumitrescu 	uint32_t n_rss;
7399a2dd95SBruce Richardson };
7499a2dd95SBruce Richardson 
7599a2dd95SBruce Richardson /**
7699a2dd95SBruce Richardson  * Pipeline info get
7799a2dd95SBruce Richardson  *
7899a2dd95SBruce Richardson  * @param[in] p
7999a2dd95SBruce Richardson  *   Pipeline handle.
8099a2dd95SBruce Richardson  * @param[out] pipeline
8199a2dd95SBruce Richardson  *   Pipeline info.
8299a2dd95SBruce Richardson  * @return
8399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
8499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
8599a2dd95SBruce Richardson  */
8699a2dd95SBruce Richardson __rte_experimental
8799a2dd95SBruce Richardson int
8899a2dd95SBruce Richardson rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
8999a2dd95SBruce Richardson 			      struct rte_swx_ctl_pipeline_info *pipeline);
9099a2dd95SBruce Richardson 
9199a2dd95SBruce Richardson /**
9299a2dd95SBruce Richardson  * Pipeline NUMA node get
9399a2dd95SBruce Richardson  *
9499a2dd95SBruce Richardson  * @param[in] p
9599a2dd95SBruce Richardson  *   Pipeline handle.
9699a2dd95SBruce Richardson  * @param[out] numa_node
9799a2dd95SBruce Richardson  *   Pipeline NUMA node.
9899a2dd95SBruce Richardson  * @return
9999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
10099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
10199a2dd95SBruce Richardson  */
10299a2dd95SBruce Richardson __rte_experimental
10399a2dd95SBruce Richardson int
10499a2dd95SBruce Richardson rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
10599a2dd95SBruce Richardson 				   int *numa_node);
10699a2dd95SBruce Richardson 
10799a2dd95SBruce Richardson /*
10899a2dd95SBruce Richardson  * Ports Query API.
10999a2dd95SBruce Richardson  */
11099a2dd95SBruce Richardson 
11199a2dd95SBruce Richardson /**
11299a2dd95SBruce Richardson  * Input port statistics counters read
11399a2dd95SBruce Richardson  *
11499a2dd95SBruce Richardson  * @param[in] p
11599a2dd95SBruce Richardson  *   Pipeline handle.
11699a2dd95SBruce Richardson  * @param[in] port_id
11799a2dd95SBruce Richardson  *   Port ID (0 .. *n_ports_in* - 1).
11899a2dd95SBruce Richardson  * @param[out] stats
11999a2dd95SBruce Richardson  *   Input port stats.
12099a2dd95SBruce Richardson  * @return
12199a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
12299a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
12399a2dd95SBruce Richardson  */
12499a2dd95SBruce Richardson __rte_experimental
12599a2dd95SBruce Richardson int
12699a2dd95SBruce Richardson rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
12799a2dd95SBruce Richardson 					uint32_t port_id,
12899a2dd95SBruce Richardson 					struct rte_swx_port_in_stats *stats);
12999a2dd95SBruce Richardson 
13099a2dd95SBruce Richardson /**
13199a2dd95SBruce Richardson  * Output port statistics counters read
13299a2dd95SBruce Richardson  *
13399a2dd95SBruce Richardson  * @param[in] p
13499a2dd95SBruce Richardson  *   Pipeline handle.
13599a2dd95SBruce Richardson  * @param[in] port_id
13699a2dd95SBruce Richardson  *   Port ID (0 .. *n_ports_out* - 1).
13799a2dd95SBruce Richardson  * @param[out] stats
13899a2dd95SBruce Richardson  *   Output port stats.
13999a2dd95SBruce Richardson  * @return
14099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
14199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
14299a2dd95SBruce Richardson  */
14399a2dd95SBruce Richardson __rte_experimental
14499a2dd95SBruce Richardson int
14599a2dd95SBruce Richardson rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
14699a2dd95SBruce Richardson 					 uint32_t port_id,
14799a2dd95SBruce Richardson 					 struct rte_swx_port_out_stats *stats);
14899a2dd95SBruce Richardson 
14999a2dd95SBruce Richardson /*
15099a2dd95SBruce Richardson  * Action Query API.
15199a2dd95SBruce Richardson  */
15299a2dd95SBruce Richardson 
15399a2dd95SBruce Richardson /** Action info. */
15499a2dd95SBruce Richardson struct rte_swx_ctl_action_info {
15599a2dd95SBruce Richardson 	/** Action name. */
15699a2dd95SBruce Richardson 	char name[RTE_SWX_CTL_NAME_SIZE];
15799a2dd95SBruce Richardson 
15899a2dd95SBruce Richardson 	/** Number of action arguments. */
15999a2dd95SBruce Richardson 	uint32_t n_args;
16099a2dd95SBruce Richardson };
16199a2dd95SBruce Richardson 
16299a2dd95SBruce Richardson /**
16399a2dd95SBruce Richardson  * Action info get
16499a2dd95SBruce Richardson  *
16599a2dd95SBruce Richardson  * @param[in] p
16699a2dd95SBruce Richardson  *   Pipeline handle.
16799a2dd95SBruce Richardson  * @param[in] action_id
16899a2dd95SBruce Richardson  *   Action ID (0 .. *n_actions* - 1).
16999a2dd95SBruce Richardson  * @param[out] action
17099a2dd95SBruce Richardson  *   Action info.
17199a2dd95SBruce Richardson  * @return
17299a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
17399a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
17499a2dd95SBruce Richardson  */
17599a2dd95SBruce Richardson __rte_experimental
17699a2dd95SBruce Richardson int
17799a2dd95SBruce Richardson rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
17899a2dd95SBruce Richardson 			    uint32_t action_id,
17999a2dd95SBruce Richardson 			    struct rte_swx_ctl_action_info *action);
18099a2dd95SBruce Richardson 
18199a2dd95SBruce Richardson /** Action argument info. */
18299a2dd95SBruce Richardson struct rte_swx_ctl_action_arg_info {
18399a2dd95SBruce Richardson 	/** Action argument name. */
18499a2dd95SBruce Richardson 	char name[RTE_SWX_CTL_NAME_SIZE];
18599a2dd95SBruce Richardson 
18699a2dd95SBruce Richardson 	/** Action argument size (in bits). */
18799a2dd95SBruce Richardson 	uint32_t n_bits;
18899a2dd95SBruce Richardson 
18999a2dd95SBruce Richardson 	/** Non-zero (true) when this action argument must be stored in the
19099a2dd95SBruce Richardson 	 * table in network byte order (NBO), zero when it must be stored in
19199a2dd95SBruce Richardson 	 * host byte order (HBO).
19299a2dd95SBruce Richardson 	 */
19399a2dd95SBruce Richardson 	int is_network_byte_order;
19499a2dd95SBruce Richardson };
19599a2dd95SBruce Richardson 
19699a2dd95SBruce Richardson /**
19799a2dd95SBruce Richardson  * Action argument info get
19899a2dd95SBruce Richardson  *
19999a2dd95SBruce Richardson  * @param[in] p
20099a2dd95SBruce Richardson  *   Pipeline handle.
20199a2dd95SBruce Richardson  * @param[in] action_id
20299a2dd95SBruce Richardson  *   Action ID (0 .. *n_actions* - 1).
20399a2dd95SBruce Richardson  * @param[in] action_arg_id
20499a2dd95SBruce Richardson  *   Action ID (0 .. *n_args* - 1).
20599a2dd95SBruce Richardson  * @param[out] action_arg
20699a2dd95SBruce Richardson  *   Action argument info.
20799a2dd95SBruce Richardson  * @return
20899a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
20999a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
21099a2dd95SBruce Richardson  */
21199a2dd95SBruce Richardson __rte_experimental
21299a2dd95SBruce Richardson int
21399a2dd95SBruce Richardson rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
21499a2dd95SBruce Richardson 				uint32_t action_id,
21599a2dd95SBruce Richardson 				uint32_t action_arg_id,
21699a2dd95SBruce Richardson 				struct rte_swx_ctl_action_arg_info *action_arg);
21799a2dd95SBruce Richardson 
21899a2dd95SBruce Richardson /*
21999a2dd95SBruce Richardson  * Table Query API.
22099a2dd95SBruce Richardson  */
22199a2dd95SBruce Richardson 
22299a2dd95SBruce Richardson /** Table info. */
22399a2dd95SBruce Richardson struct rte_swx_ctl_table_info {
22499a2dd95SBruce Richardson 	/** Table name. */
22599a2dd95SBruce Richardson 	char name[RTE_SWX_CTL_NAME_SIZE];
22699a2dd95SBruce Richardson 
22799a2dd95SBruce Richardson 	/** Table creation arguments. */
22899a2dd95SBruce Richardson 	char args[RTE_SWX_CTL_NAME_SIZE];
22999a2dd95SBruce Richardson 
23099a2dd95SBruce Richardson 	/** Number of match fields. */
23199a2dd95SBruce Richardson 	uint32_t n_match_fields;
23299a2dd95SBruce Richardson 
23399a2dd95SBruce Richardson 	/** Number of actions. */
23499a2dd95SBruce Richardson 	uint32_t n_actions;
23599a2dd95SBruce Richardson 
23699a2dd95SBruce Richardson 	/** Non-zero (true) when the default action is constant, therefore it
23799a2dd95SBruce Richardson 	 * cannot be changed; zero (false) when the default action not constant,
23899a2dd95SBruce Richardson 	 * therefore it can be changed.
23999a2dd95SBruce Richardson 	 */
24099a2dd95SBruce Richardson 	int default_action_is_const;
24199a2dd95SBruce Richardson 
2429560a329SCristian Dumitrescu 	/**  Hash function. */
2439560a329SCristian Dumitrescu 	rte_swx_hash_func_t hash_func;
2449560a329SCristian Dumitrescu 
24599a2dd95SBruce Richardson 	/** Table size parameter. */
24699a2dd95SBruce Richardson 	uint32_t size;
24799a2dd95SBruce Richardson };
24899a2dd95SBruce Richardson 
24999a2dd95SBruce Richardson /**
25099a2dd95SBruce Richardson  * Table info get
25199a2dd95SBruce Richardson  *
25299a2dd95SBruce Richardson  * @param[in] p
25399a2dd95SBruce Richardson  *   Pipeline handle.
25499a2dd95SBruce Richardson  * @param[in] table_id
25599a2dd95SBruce Richardson  *   Table ID (0 .. *n_tables* - 1).
25699a2dd95SBruce Richardson  * @param[out] table
25799a2dd95SBruce Richardson  *   Table info.
25899a2dd95SBruce Richardson  * @return
25999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
26099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
26199a2dd95SBruce Richardson  */
26299a2dd95SBruce Richardson __rte_experimental
26399a2dd95SBruce Richardson int
26499a2dd95SBruce Richardson rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
26599a2dd95SBruce Richardson 			   uint32_t table_id,
26699a2dd95SBruce Richardson 			   struct rte_swx_ctl_table_info *table);
26799a2dd95SBruce Richardson 
26899a2dd95SBruce Richardson /** Table match field info.
26999a2dd95SBruce Richardson  *
27099a2dd95SBruce Richardson  * If (n_bits, offset) are known for all the match fields of the table, then the
27199a2dd95SBruce Richardson  * table (key_offset, key_size, key_mask0) can be computed.
27299a2dd95SBruce Richardson  */
27399a2dd95SBruce Richardson struct rte_swx_ctl_table_match_field_info {
27499a2dd95SBruce Richardson 	/** Match type of the current match field. */
27599a2dd95SBruce Richardson 	enum rte_swx_table_match_type match_type;
27699a2dd95SBruce Richardson 
27799a2dd95SBruce Richardson 	/** Non-zero (true) when the current match field is part of a registered
27899a2dd95SBruce Richardson 	 * header, zero (false) when it is part of the registered meta-data.
27999a2dd95SBruce Richardson 	 */
28099a2dd95SBruce Richardson 	int is_header;
28199a2dd95SBruce Richardson 
28299a2dd95SBruce Richardson 	/** Match field size (in bits). */
28399a2dd95SBruce Richardson 	uint32_t n_bits;
28499a2dd95SBruce Richardson 
28599a2dd95SBruce Richardson 	/** Match field offset within its parent struct (one of the headers or
28699a2dd95SBruce Richardson 	 * the meta-data).
28799a2dd95SBruce Richardson 	 */
28899a2dd95SBruce Richardson 	uint32_t offset;
28999a2dd95SBruce Richardson };
29099a2dd95SBruce Richardson 
29199a2dd95SBruce Richardson /**
29299a2dd95SBruce Richardson  * Table match field info get
29399a2dd95SBruce Richardson  *
29499a2dd95SBruce Richardson  * @param[in] p
29599a2dd95SBruce Richardson  *   Pipeline handle.
29699a2dd95SBruce Richardson  * @param[in] table_id
29799a2dd95SBruce Richardson  *   Table ID (0 .. *n_tables*).
29899a2dd95SBruce Richardson  * @param[in] match_field_id
29999a2dd95SBruce Richardson  *   Match field ID (0 .. *n_match_fields* - 1).
30099a2dd95SBruce Richardson  * @param[out] match_field
30199a2dd95SBruce Richardson  *   Table match field info.
30299a2dd95SBruce Richardson  * @return
30399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
30499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
30599a2dd95SBruce Richardson  */
30699a2dd95SBruce Richardson __rte_experimental
30799a2dd95SBruce Richardson int
30899a2dd95SBruce Richardson rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
30999a2dd95SBruce Richardson 	uint32_t table_id,
31099a2dd95SBruce Richardson 	uint32_t match_field_id,
31199a2dd95SBruce Richardson 	struct rte_swx_ctl_table_match_field_info *match_field);
31299a2dd95SBruce Richardson 
31399a2dd95SBruce Richardson /** Table action info. */
31499a2dd95SBruce Richardson struct rte_swx_ctl_table_action_info {
31599a2dd95SBruce Richardson 	/** Action ID. */
31699a2dd95SBruce Richardson 	uint32_t action_id;
317cd79e020SYogesh Jangra 
318cd79e020SYogesh Jangra 	/**  When non-zero (true), the action can be assigned to regular table entries. */
319cd79e020SYogesh Jangra 	int action_is_for_table_entries;
320cd79e020SYogesh Jangra 
321cd79e020SYogesh Jangra 	/**  When non-zero (true), the action can be assigned to the table default entry. */
322cd79e020SYogesh Jangra 	int action_is_for_default_entry;
32399a2dd95SBruce Richardson };
32499a2dd95SBruce Richardson 
32599a2dd95SBruce Richardson /**
32699a2dd95SBruce Richardson  * Table action info get
32799a2dd95SBruce Richardson  *
32899a2dd95SBruce Richardson  * @param[in] p
32999a2dd95SBruce Richardson  *   Pipeline handle.
33099a2dd95SBruce Richardson  * @param[in] table_id
33199a2dd95SBruce Richardson  *   Table ID (0 .. *n_tables*).
33299a2dd95SBruce Richardson  * @param[in] table_action_id
33399a2dd95SBruce Richardson  *   Action index within the set of table actions (0 .. table n_actions - 1).
33499a2dd95SBruce Richardson  *   Not to be confused with the action ID, which works at the pipeline level
33599a2dd95SBruce Richardson  *   (0 .. pipeline n_actions - 1), which is precisely what this function
33699a2dd95SBruce Richardson  *   returns as part of *table_action*.
33799a2dd95SBruce Richardson  * @param[out] table_action
33899a2dd95SBruce Richardson  *   Table action info.
33999a2dd95SBruce Richardson  * @return
34099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
34199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
34299a2dd95SBruce Richardson  */
34399a2dd95SBruce Richardson __rte_experimental
34499a2dd95SBruce Richardson int
34599a2dd95SBruce Richardson rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
34699a2dd95SBruce Richardson 	uint32_t table_id,
34799a2dd95SBruce Richardson 	uint32_t table_action_id,
34899a2dd95SBruce Richardson 	struct rte_swx_ctl_table_action_info *table_action);
34999a2dd95SBruce Richardson 
35099a2dd95SBruce Richardson /**
35199a2dd95SBruce Richardson  * Table operations get
35299a2dd95SBruce Richardson  *
35399a2dd95SBruce Richardson  * @param[in] p
35499a2dd95SBruce Richardson  *   Pipeline handle.
35599a2dd95SBruce Richardson  * @param[in] table_id
35699a2dd95SBruce Richardson  *   Table ID (0 .. *n_tables*).
35799a2dd95SBruce Richardson  * @param[out] table_ops
35899a2dd95SBruce Richardson  *   Table operations. Only valid when function returns success and *is_stub* is
35999a2dd95SBruce Richardson  *   zero (false).
36099a2dd95SBruce Richardson  * @param[out] is_stub
36199a2dd95SBruce Richardson  *   A stub table is a table with no match fields. No "regular" table entries
36299a2dd95SBruce Richardson  *   (i.e. entries other than the default entry) can be added to such a table,
36399a2dd95SBruce Richardson  *   therefore the lookup operation always results in lookup miss. Non-zero
36499a2dd95SBruce Richardson  *   (true) when the current table is a stub table, zero (false) otherwise.
36599a2dd95SBruce Richardson  * @return
36699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
36799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
36899a2dd95SBruce Richardson  */
36999a2dd95SBruce Richardson __rte_experimental
37099a2dd95SBruce Richardson int
37199a2dd95SBruce Richardson rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
37299a2dd95SBruce Richardson 			  uint32_t table_id,
37399a2dd95SBruce Richardson 			  struct rte_swx_table_ops *table_ops,
37499a2dd95SBruce Richardson 			  int *is_stub);
37599a2dd95SBruce Richardson 
37699a2dd95SBruce Richardson /** Table statistics. */
37799a2dd95SBruce Richardson struct rte_swx_table_stats {
37899a2dd95SBruce Richardson 	/** Number of packets with lookup hit. */
37999a2dd95SBruce Richardson 	uint64_t n_pkts_hit;
38099a2dd95SBruce Richardson 
38199a2dd95SBruce Richardson 	/** Number of packets with lookup miss. */
38299a2dd95SBruce Richardson 	uint64_t n_pkts_miss;
38399a2dd95SBruce Richardson 
38499a2dd95SBruce Richardson 	/** Number of packets (with either lookup hit or miss) per pipeline
3857be78d02SJosh Soref 	 * action. Array of pipeline *n_actions* elements indexed by the
38699a2dd95SBruce Richardson 	 * pipeline-level *action_id*, therefore this array has the same size
38799a2dd95SBruce Richardson 	 * for all the tables within the same pipeline.
38899a2dd95SBruce Richardson 	 */
38999a2dd95SBruce Richardson 	uint64_t *n_pkts_action;
39099a2dd95SBruce Richardson };
39199a2dd95SBruce Richardson 
39299a2dd95SBruce Richardson /**
39399a2dd95SBruce Richardson  * Table statistics counters read
39499a2dd95SBruce Richardson  *
39599a2dd95SBruce Richardson  * @param[in] p
39699a2dd95SBruce Richardson  *   Pipeline handle.
39799a2dd95SBruce Richardson  * @param[in] table_name
39899a2dd95SBruce Richardson  *   Table name.
39999a2dd95SBruce Richardson  * @param[out] stats
40099a2dd95SBruce Richardson  *   Table stats. Must point to a pre-allocated structure. The *n_pkts_action*
40199a2dd95SBruce Richardson  *   field also needs to be pre-allocated as array of pipeline *n_actions*
40299a2dd95SBruce Richardson  *   elements. The pipeline actions that are not valid for the current table
40399a2dd95SBruce Richardson  *   have their associated *n_pkts_action* element always set to zero.
40499a2dd95SBruce Richardson  * @return
40599a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
40699a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
40799a2dd95SBruce Richardson  */
40899a2dd95SBruce Richardson __rte_experimental
40999a2dd95SBruce Richardson int
41099a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
41199a2dd95SBruce Richardson 				      const char *table_name,
41299a2dd95SBruce Richardson 				      struct rte_swx_table_stats *stats);
41399a2dd95SBruce Richardson 
41499a2dd95SBruce Richardson /*
415cdaa937dSCristian Dumitrescu  * Selector Table Query API.
416cdaa937dSCristian Dumitrescu  */
417cdaa937dSCristian Dumitrescu 
418cdaa937dSCristian Dumitrescu /** Selector info. */
419cdaa937dSCristian Dumitrescu struct rte_swx_ctl_selector_info {
420cdaa937dSCristian Dumitrescu 	/** Selector table name. */
421cdaa937dSCristian Dumitrescu 	char name[RTE_SWX_CTL_NAME_SIZE];
422cdaa937dSCristian Dumitrescu 
423cdaa937dSCristian Dumitrescu 	/** Number of selector fields. */
424cdaa937dSCristian Dumitrescu 	uint32_t n_selector_fields;
425cdaa937dSCristian Dumitrescu 
426cdaa937dSCristian Dumitrescu 	/** Maximum number of groups. */
427cdaa937dSCristian Dumitrescu 	uint32_t n_groups_max;
428cdaa937dSCristian Dumitrescu 
429cdaa937dSCristian Dumitrescu 	/** Maximum number of members per group. */
430cdaa937dSCristian Dumitrescu 	uint32_t n_members_per_group_max;
431cdaa937dSCristian Dumitrescu };
432cdaa937dSCristian Dumitrescu 
433cdaa937dSCristian Dumitrescu /**
434cdaa937dSCristian Dumitrescu  * Selector table info get
435cdaa937dSCristian Dumitrescu  *
436cdaa937dSCristian Dumitrescu  * @param[in] p
437cdaa937dSCristian Dumitrescu  *   Pipeline handle.
438cdaa937dSCristian Dumitrescu  * @param[in] selector_id
439cdaa937dSCristian Dumitrescu  *   Selector table ID (0 .. *n_selectors* - 1).
440cdaa937dSCristian Dumitrescu  * @param[out] selector
441cdaa937dSCristian Dumitrescu  *   Selector table info.
442cdaa937dSCristian Dumitrescu  * @return
443cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
444cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
445cdaa937dSCristian Dumitrescu  */
446cdaa937dSCristian Dumitrescu __rte_experimental
447cdaa937dSCristian Dumitrescu int
448cdaa937dSCristian Dumitrescu rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p,
449cdaa937dSCristian Dumitrescu 			      uint32_t selector_id,
450cdaa937dSCristian Dumitrescu 			      struct rte_swx_ctl_selector_info *selector);
451cdaa937dSCristian Dumitrescu 
452cdaa937dSCristian Dumitrescu /**
453cdaa937dSCristian Dumitrescu  * Selector table "group ID" field info get
454cdaa937dSCristian Dumitrescu  *
455cdaa937dSCristian Dumitrescu  * @param[in] p
456cdaa937dSCristian Dumitrescu  *   Pipeline handle.
457cdaa937dSCristian Dumitrescu  * @param[in] selector_id
458cdaa937dSCristian Dumitrescu  *   Selector table ID (0 .. *n_selectors*).
459cdaa937dSCristian Dumitrescu  * @param[out] field
460cdaa937dSCristian Dumitrescu  *   Selector table "group ID" field info.
461cdaa937dSCristian Dumitrescu  * @return
462cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
463cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
464cdaa937dSCristian Dumitrescu  */
465cdaa937dSCristian Dumitrescu __rte_experimental
466cdaa937dSCristian Dumitrescu int
467cdaa937dSCristian Dumitrescu rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p,
468cdaa937dSCristian Dumitrescu 					     uint32_t selector_id,
469cdaa937dSCristian Dumitrescu 					     struct rte_swx_ctl_table_match_field_info *field);
470cdaa937dSCristian Dumitrescu 
471cdaa937dSCristian Dumitrescu /**
472cdaa937dSCristian Dumitrescu  * Sselector table selector field info get
473cdaa937dSCristian Dumitrescu  *
474cdaa937dSCristian Dumitrescu  * @param[in] p
475cdaa937dSCristian Dumitrescu  *   Pipeline handle.
476cdaa937dSCristian Dumitrescu  * @param[in] selector_id
477cdaa937dSCristian Dumitrescu  *   Selector table ID (0 .. *n_selectors*).
478cdaa937dSCristian Dumitrescu  * @param[in] selector_field_id
479cdaa937dSCristian Dumitrescu  *   Selector table selector field ID (0 .. *n_selector_fields* - 1).
480cdaa937dSCristian Dumitrescu  * @param[out] field
481cdaa937dSCristian Dumitrescu  *   Selector table selector field info.
482cdaa937dSCristian Dumitrescu  * @return
483cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
484cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
485cdaa937dSCristian Dumitrescu  */
486cdaa937dSCristian Dumitrescu __rte_experimental
487cdaa937dSCristian Dumitrescu int
488cdaa937dSCristian Dumitrescu rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p,
489cdaa937dSCristian Dumitrescu 				    uint32_t selector_id,
490cdaa937dSCristian Dumitrescu 				    uint32_t selector_field_id,
491cdaa937dSCristian Dumitrescu 				    struct rte_swx_ctl_table_match_field_info *field);
492cdaa937dSCristian Dumitrescu 
493cdaa937dSCristian Dumitrescu /**
494cdaa937dSCristian Dumitrescu  * Selector table "member ID" field info get
495cdaa937dSCristian Dumitrescu  *
496cdaa937dSCristian Dumitrescu  * @param[in] p
497cdaa937dSCristian Dumitrescu  *   Pipeline handle.
498cdaa937dSCristian Dumitrescu  * @param[in] selector_id
499cdaa937dSCristian Dumitrescu  *   Selector table ID (0 .. *n_selectors*).
500cdaa937dSCristian Dumitrescu  * @param[out] field
501cdaa937dSCristian Dumitrescu  *   Selector table "member ID" field info.
502cdaa937dSCristian Dumitrescu  * @return
503cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
504cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
505cdaa937dSCristian Dumitrescu  */
506cdaa937dSCristian Dumitrescu __rte_experimental
507cdaa937dSCristian Dumitrescu int
508cdaa937dSCristian Dumitrescu rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p,
509cdaa937dSCristian Dumitrescu 					      uint32_t selector_id,
510cdaa937dSCristian Dumitrescu 					      struct rte_swx_ctl_table_match_field_info *field);
511cdaa937dSCristian Dumitrescu 
512cdaa937dSCristian Dumitrescu /** Selector table statistics. */
513cdaa937dSCristian Dumitrescu struct rte_swx_pipeline_selector_stats {
514cdaa937dSCristian Dumitrescu 	/** Number of packets. */
515cdaa937dSCristian Dumitrescu 	uint64_t n_pkts;
516cdaa937dSCristian Dumitrescu };
517cdaa937dSCristian Dumitrescu 
518cdaa937dSCristian Dumitrescu /**
519cdaa937dSCristian Dumitrescu  * Selector table statistics counters read
520cdaa937dSCristian Dumitrescu  *
521cdaa937dSCristian Dumitrescu  * @param[in] p
522cdaa937dSCristian Dumitrescu  *   Pipeline handle.
523cdaa937dSCristian Dumitrescu  * @param[in] selector_name
524cdaa937dSCristian Dumitrescu  *   Selector table name.
525cdaa937dSCristian Dumitrescu  * @param[out] stats
526cdaa937dSCristian Dumitrescu  *   Selector table stats. Must point to a pre-allocated structure.
527cdaa937dSCristian Dumitrescu  * @return
528cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
529cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
530cdaa937dSCristian Dumitrescu  */
531cdaa937dSCristian Dumitrescu __rte_experimental
532cdaa937dSCristian Dumitrescu int
533cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p,
534cdaa937dSCristian Dumitrescu 					 const char *selector_name,
535cdaa937dSCristian Dumitrescu 					 struct rte_swx_pipeline_selector_stats *stats);
536cdaa937dSCristian Dumitrescu 
537cdaa937dSCristian Dumitrescu /*
5384f59d372SCristian Dumitrescu  * Learner Table Query API.
5394f59d372SCristian Dumitrescu  */
5404f59d372SCristian Dumitrescu 
5414f59d372SCristian Dumitrescu /** Learner table info. */
5424f59d372SCristian Dumitrescu struct rte_swx_ctl_learner_info {
5434f59d372SCristian Dumitrescu 	/** Learner table name. */
5444f59d372SCristian Dumitrescu 	char name[RTE_SWX_CTL_NAME_SIZE];
5454f59d372SCristian Dumitrescu 
5464f59d372SCristian Dumitrescu 	/** Number of match fields. */
5474f59d372SCristian Dumitrescu 	uint32_t n_match_fields;
5484f59d372SCristian Dumitrescu 
5494f59d372SCristian Dumitrescu 	/** Number of actions. */
5504f59d372SCristian Dumitrescu 	uint32_t n_actions;
5514f59d372SCristian Dumitrescu 
5524f59d372SCristian Dumitrescu 	/** Non-zero (true) when the default action is constant, therefore it
5534f59d372SCristian Dumitrescu 	 * cannot be changed; zero (false) when the default action not constant,
5544f59d372SCristian Dumitrescu 	 * therefore it can be changed.
5554f59d372SCristian Dumitrescu 	 */
5564f59d372SCristian Dumitrescu 	int default_action_is_const;
5574f59d372SCristian Dumitrescu 
5584f59d372SCristian Dumitrescu 	/** Learner table size parameter. */
5594f59d372SCristian Dumitrescu 	uint32_t size;
560e2ecc535SCristian Dumitrescu 
561e2ecc535SCristian Dumitrescu 	/** Number of possible key timeout values. */
562e2ecc535SCristian Dumitrescu 	uint32_t n_key_timeouts;
5634f59d372SCristian Dumitrescu };
5644f59d372SCristian Dumitrescu 
5654f59d372SCristian Dumitrescu /**
5664f59d372SCristian Dumitrescu  * Learner table info get
5674f59d372SCristian Dumitrescu  *
5684f59d372SCristian Dumitrescu  * @param[in] p
5694f59d372SCristian Dumitrescu  *   Pipeline handle.
5704f59d372SCristian Dumitrescu  * @param[in] learner_id
5714f59d372SCristian Dumitrescu  *   Learner table ID (0 .. *n_learners* - 1).
5724f59d372SCristian Dumitrescu  * @param[out] learner
5734f59d372SCristian Dumitrescu  *   Learner table info.
5744f59d372SCristian Dumitrescu  * @return
5754f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
5764f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
5774f59d372SCristian Dumitrescu  */
5784f59d372SCristian Dumitrescu __rte_experimental
5794f59d372SCristian Dumitrescu int
5804f59d372SCristian Dumitrescu rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
5814f59d372SCristian Dumitrescu 			     uint32_t learner_id,
5824f59d372SCristian Dumitrescu 			     struct rte_swx_ctl_learner_info *learner);
5834f59d372SCristian Dumitrescu 
5844f59d372SCristian Dumitrescu /**
5854f59d372SCristian Dumitrescu  * Learner table match field info get
5864f59d372SCristian Dumitrescu  *
5874f59d372SCristian Dumitrescu  * @param[in] p
5884f59d372SCristian Dumitrescu  *   Pipeline handle.
5894f59d372SCristian Dumitrescu  * @param[in] learner_id
5904f59d372SCristian Dumitrescu  *   Learner table ID (0 .. *n_learners* - 1).
5914f59d372SCristian Dumitrescu  * @param[in] match_field_id
5924f59d372SCristian Dumitrescu  *   Match field ID (0 .. *n_match_fields* - 1).
5934f59d372SCristian Dumitrescu  * @param[out] match_field
5944f59d372SCristian Dumitrescu  *   Learner table match field info.
5954f59d372SCristian Dumitrescu  * @return
5964f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
5974f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
5984f59d372SCristian Dumitrescu  */
5994f59d372SCristian Dumitrescu __rte_experimental
6004f59d372SCristian Dumitrescu int
6014f59d372SCristian Dumitrescu rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
6024f59d372SCristian Dumitrescu 					 uint32_t learner_id,
6034f59d372SCristian Dumitrescu 					 uint32_t match_field_id,
6044f59d372SCristian Dumitrescu 					 struct rte_swx_ctl_table_match_field_info *match_field);
6054f59d372SCristian Dumitrescu 
6064f59d372SCristian Dumitrescu /**
6074f59d372SCristian Dumitrescu  * Learner table action info get
6084f59d372SCristian Dumitrescu  *
6094f59d372SCristian Dumitrescu  * @param[in] p
6104f59d372SCristian Dumitrescu  *   Pipeline handle.
6114f59d372SCristian Dumitrescu  * @param[in] learner_id
6124f59d372SCristian Dumitrescu  *   Learner table ID (0 .. *n_learners* - 1).
6134f59d372SCristian Dumitrescu  * @param[in] learner_action_id
6144f59d372SCristian Dumitrescu  *   Action index within the set of learner table actions (0 .. learner table n_actions - 1). Not
6154f59d372SCristian Dumitrescu  *   to be confused with the pipeline-leve action ID (0 .. pipeline n_actions - 1), which is
6164f59d372SCristian Dumitrescu  *   precisely what this function returns as part of the *learner_action*.
6174f59d372SCristian Dumitrescu  * @param[out] learner_action
6184f59d372SCristian Dumitrescu  *   Learner action info.
6194f59d372SCristian Dumitrescu  * @return
6204f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
6214f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
6224f59d372SCristian Dumitrescu  */
6234f59d372SCristian Dumitrescu __rte_experimental
6244f59d372SCristian Dumitrescu int
6254f59d372SCristian Dumitrescu rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
6264f59d372SCristian Dumitrescu 				    uint32_t learner_id,
6274f59d372SCristian Dumitrescu 				    uint32_t learner_action_id,
6284f59d372SCristian Dumitrescu 				    struct rte_swx_ctl_table_action_info *learner_action);
6294f59d372SCristian Dumitrescu 
630e2ecc535SCristian Dumitrescu /**
631e2ecc535SCristian Dumitrescu  * Learner table timeout get
632e2ecc535SCristian Dumitrescu  *
633e2ecc535SCristian Dumitrescu  * @param[in] p
634e2ecc535SCristian Dumitrescu  *   Pipeline handle.
635e2ecc535SCristian Dumitrescu  * @param[in] learner_id
636e2ecc535SCristian Dumitrescu  *   Learner table ID (0 .. *n_learners* - 1).
637e2ecc535SCristian Dumitrescu  * @param[in] timeout_id
638e2ecc535SCristian Dumitrescu  *   Timeout ID.
639e2ecc535SCristian Dumitrescu  * @param[out] timeout
640e2ecc535SCristian Dumitrescu  *   Timeout value measured in seconds. Must be non-NULL.
641e2ecc535SCristian Dumitrescu  * @return
642e2ecc535SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
643e2ecc535SCristian Dumitrescu  *   -EINVAL: Invalid argument.
644e2ecc535SCristian Dumitrescu  */
645e2ecc535SCristian Dumitrescu __rte_experimental
646e2ecc535SCristian Dumitrescu int
647e2ecc535SCristian Dumitrescu rte_swx_ctl_pipeline_learner_timeout_get(struct rte_swx_pipeline *p,
648e2ecc535SCristian Dumitrescu 					 uint32_t learner_id,
649e2ecc535SCristian Dumitrescu 					 uint32_t timeout_id,
650e2ecc535SCristian Dumitrescu 					 uint32_t *timeout);
651e2ecc535SCristian Dumitrescu 
652e2ecc535SCristian Dumitrescu /**
653e2ecc535SCristian Dumitrescu  * Learner table timeout set
654e2ecc535SCristian Dumitrescu  *
655e2ecc535SCristian Dumitrescu  * @param[in] p
656e2ecc535SCristian Dumitrescu  *   Pipeline handle.
657e2ecc535SCristian Dumitrescu  * @param[in] learner_id
658e2ecc535SCristian Dumitrescu  *   Learner table ID (0 .. *n_learners* - 1).
659e2ecc535SCristian Dumitrescu  * @param[in] timeout_id
660e2ecc535SCristian Dumitrescu  *   Timeout ID.
661e2ecc535SCristian Dumitrescu  * @param[in] timeout
662e2ecc535SCristian Dumitrescu  *   Timeout value measured in seconds.
663e2ecc535SCristian Dumitrescu  * @return
664e2ecc535SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
665e2ecc535SCristian Dumitrescu  *   -EINVAL: Invalid argument.
666e2ecc535SCristian Dumitrescu  */
667e2ecc535SCristian Dumitrescu __rte_experimental
668e2ecc535SCristian Dumitrescu int
669e2ecc535SCristian Dumitrescu rte_swx_ctl_pipeline_learner_timeout_set(struct rte_swx_pipeline *p,
670e2ecc535SCristian Dumitrescu 					 uint32_t learner_id,
671e2ecc535SCristian Dumitrescu 					 uint32_t timeout_id,
672e2ecc535SCristian Dumitrescu 					 uint32_t timeout);
673e2ecc535SCristian Dumitrescu 
6744f59d372SCristian Dumitrescu /** Learner table statistics. */
6754f59d372SCristian Dumitrescu struct rte_swx_learner_stats {
6764f59d372SCristian Dumitrescu 	/** Number of packets with lookup hit. */
6774f59d372SCristian Dumitrescu 	uint64_t n_pkts_hit;
6784f59d372SCristian Dumitrescu 
6794f59d372SCristian Dumitrescu 	/** Number of packets with lookup miss. */
6804f59d372SCristian Dumitrescu 	uint64_t n_pkts_miss;
6814f59d372SCristian Dumitrescu 
6824f59d372SCristian Dumitrescu 	/** Number of packets with successful learning. */
6834f59d372SCristian Dumitrescu 	uint64_t n_pkts_learn_ok;
6844f59d372SCristian Dumitrescu 
6854f59d372SCristian Dumitrescu 	/** Number of packets with learning error. */
6864f59d372SCristian Dumitrescu 	uint64_t n_pkts_learn_err;
6874f59d372SCristian Dumitrescu 
688e2ecc535SCristian Dumitrescu 	/** Number of packets with rearm event. */
689e2ecc535SCristian Dumitrescu 	uint64_t n_pkts_rearm;
690e2ecc535SCristian Dumitrescu 
6914f59d372SCristian Dumitrescu 	/** Number of packets with forget event. */
6924f59d372SCristian Dumitrescu 	uint64_t n_pkts_forget;
6934f59d372SCristian Dumitrescu 
6944f59d372SCristian Dumitrescu 	/** Number of packets (with either lookup hit or miss) per pipeline action. Array of
6957be78d02SJosh Soref 	 * pipeline *n_actions* elements indexed by the pipeline-level *action_id*, therefore this
6964f59d372SCristian Dumitrescu 	 * array has the same size for all the tables within the same pipeline.
6974f59d372SCristian Dumitrescu 	 */
6984f59d372SCristian Dumitrescu 	uint64_t *n_pkts_action;
6994f59d372SCristian Dumitrescu };
7004f59d372SCristian Dumitrescu 
7014f59d372SCristian Dumitrescu /**
7024f59d372SCristian Dumitrescu  * Learner table statistics counters read
7034f59d372SCristian Dumitrescu  *
7044f59d372SCristian Dumitrescu  * @param[in] p
7054f59d372SCristian Dumitrescu  *   Pipeline handle.
7064f59d372SCristian Dumitrescu  * @param[in] learner_name
7074f59d372SCristian Dumitrescu  *   Learner table name.
7084f59d372SCristian Dumitrescu  * @param[out] stats
7094f59d372SCristian Dumitrescu  *   Learner table stats. Must point to a pre-allocated structure. The *n_pkts_action* field also
7104f59d372SCristian Dumitrescu  *   needs to be pre-allocated as array of pipeline *n_actions* elements. The pipeline actions that
7114f59d372SCristian Dumitrescu  *   are not valid for the current learner table have their associated *n_pkts_action* element
7124f59d372SCristian Dumitrescu  *   always set to zero.
7134f59d372SCristian Dumitrescu  * @return
7144f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
7154f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
7164f59d372SCristian Dumitrescu  */
7174f59d372SCristian Dumitrescu __rte_experimental
7184f59d372SCristian Dumitrescu int
7194f59d372SCristian Dumitrescu rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
7204f59d372SCristian Dumitrescu 				      const char *learner_name,
7214f59d372SCristian Dumitrescu 				      struct rte_swx_learner_stats *stats);
7224f59d372SCristian Dumitrescu 
7234f59d372SCristian Dumitrescu /*
724dac0ecd9SCristian Dumitrescu  * Packet mirroring API.
725dac0ecd9SCristian Dumitrescu  */
726dac0ecd9SCristian Dumitrescu 
727dac0ecd9SCristian Dumitrescu /** Packet mirroring session parameters. */
728dac0ecd9SCristian Dumitrescu struct rte_swx_pipeline_mirroring_session_params {
729dac0ecd9SCristian Dumitrescu 	/** Output port ID. */
730dac0ecd9SCristian Dumitrescu 	uint32_t port_id;
731dac0ecd9SCristian Dumitrescu 
732dac0ecd9SCristian Dumitrescu 	/** Fast clone flag. */
733dac0ecd9SCristian Dumitrescu 	int fast_clone;
734dac0ecd9SCristian Dumitrescu 
735dac0ecd9SCristian Dumitrescu 	/** Truncation packet length (in bytes). Zero means no truncation. */
736dac0ecd9SCristian Dumitrescu 	uint32_t truncation_length;
737dac0ecd9SCristian Dumitrescu };
738dac0ecd9SCristian Dumitrescu 
739dac0ecd9SCristian Dumitrescu /**
740dac0ecd9SCristian Dumitrescu  * Packet mirroring session set
741dac0ecd9SCristian Dumitrescu  *
742dac0ecd9SCristian Dumitrescu  * @param[in] p
743dac0ecd9SCristian Dumitrescu  *   Pipeline handle.
744dac0ecd9SCristian Dumitrescu  * @param[in] session_id
745dac0ecd9SCristian Dumitrescu  *   Packet mirroring session ID.
746dac0ecd9SCristian Dumitrescu  * @param[in] params
747dac0ecd9SCristian Dumitrescu  *   Packet mirroring session parameters.
748dac0ecd9SCristian Dumitrescu  * @return
749dac0ecd9SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
750dac0ecd9SCristian Dumitrescu  *   -EINVAL: Invalid argument;
751dac0ecd9SCristian Dumitrescu  *   -EEXIST: Pipeline was already built successfully.
752dac0ecd9SCristian Dumitrescu  */
753dac0ecd9SCristian Dumitrescu __rte_experimental
754dac0ecd9SCristian Dumitrescu int
755dac0ecd9SCristian Dumitrescu rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p,
756dac0ecd9SCristian Dumitrescu 	uint32_t session_id,
757dac0ecd9SCristian Dumitrescu 	struct rte_swx_pipeline_mirroring_session_params *params);
758dac0ecd9SCristian Dumitrescu 
759dac0ecd9SCristian Dumitrescu /*
76099a2dd95SBruce Richardson  * Table Update API.
76199a2dd95SBruce Richardson  */
76299a2dd95SBruce Richardson 
76399a2dd95SBruce Richardson /** Table state. */
76499a2dd95SBruce Richardson struct rte_swx_table_state {
76599a2dd95SBruce Richardson 	/** Table object. */
76699a2dd95SBruce Richardson 	void *obj;
76799a2dd95SBruce Richardson 
76899a2dd95SBruce Richardson 	/** Action ID of the table default action. */
76999a2dd95SBruce Richardson 	uint64_t default_action_id;
77099a2dd95SBruce Richardson 
77199a2dd95SBruce Richardson 	/** Action data of the table default action. Ignored when the action
77299a2dd95SBruce Richardson 	 * data size is zero; otherwise, action data size bytes are meaningful.
77399a2dd95SBruce Richardson 	 */
77499a2dd95SBruce Richardson 	uint8_t *default_action_data;
77599a2dd95SBruce Richardson };
77699a2dd95SBruce Richardson 
77799a2dd95SBruce Richardson /**
77899a2dd95SBruce Richardson  * Pipeline table state get
77999a2dd95SBruce Richardson  *
78099a2dd95SBruce Richardson  * @param[in] p
78199a2dd95SBruce Richardson  *   Pipeline handle.
78299a2dd95SBruce Richardson  * @param[out] table_state
78399a2dd95SBruce Richardson  *   After successful execution, the *table_state* contains the pointer to the
78499a2dd95SBruce Richardson  *   current pipeline table state, which is an array of *n_tables* elements,
78599a2dd95SBruce Richardson  *   with array element i containing the state of the i-th pipeline table. The
78699a2dd95SBruce Richardson  *   pipeline continues to own all the data structures directly or indirectly
78799a2dd95SBruce Richardson  *   referenced by the *table_state* until the subsequent successful invocation
78899a2dd95SBruce Richardson  *   of function *rte_swx_pipeline_table_state_set*.
78999a2dd95SBruce Richardson  * @return
79099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
79199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
79299a2dd95SBruce Richardson  */
79399a2dd95SBruce Richardson __rte_experimental
79499a2dd95SBruce Richardson int
79599a2dd95SBruce Richardson rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
79699a2dd95SBruce Richardson 				 struct rte_swx_table_state **table_state);
79799a2dd95SBruce Richardson 
79899a2dd95SBruce Richardson /**
79999a2dd95SBruce Richardson  * Pipeline table state set
80099a2dd95SBruce Richardson  *
80199a2dd95SBruce Richardson  * @param[in] p
80299a2dd95SBruce Richardson  *   Pipeline handle.
80399a2dd95SBruce Richardson  * @param[out] table_state
80499a2dd95SBruce Richardson  *   After successful execution, the pipeline table state is updated to this
80599a2dd95SBruce Richardson  *   *table_state*. The ownership of all the data structures directly or
80699a2dd95SBruce Richardson  *   indirectly referenced by this *table_state* is passed from the caller to
80799a2dd95SBruce Richardson  *   the pipeline.
80899a2dd95SBruce Richardson  * @return
80999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
81099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
81199a2dd95SBruce Richardson  */
81299a2dd95SBruce Richardson __rte_experimental
81399a2dd95SBruce Richardson int
81499a2dd95SBruce Richardson rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
81599a2dd95SBruce Richardson 				 struct rte_swx_table_state *table_state);
81699a2dd95SBruce Richardson 
81799a2dd95SBruce Richardson /*
81899a2dd95SBruce Richardson  * High Level Reference Table Update API.
81999a2dd95SBruce Richardson  */
82099a2dd95SBruce Richardson 
82199a2dd95SBruce Richardson /** Pipeline control opaque data structure. */
82299a2dd95SBruce Richardson struct rte_swx_ctl_pipeline;
82399a2dd95SBruce Richardson 
82499a2dd95SBruce Richardson /**
825d69c90c8SCristian Dumitrescu  * Pipeline control find
826d69c90c8SCristian Dumitrescu  *
827d69c90c8SCristian Dumitrescu  * @param[in] name
828d69c90c8SCristian Dumitrescu  *   Pipeline name.
829d69c90c8SCristian Dumitrescu  * @return
830d69c90c8SCristian Dumitrescu  *   Valid pipeline control handle if found or NULL otherwise.
831d69c90c8SCristian Dumitrescu  */
832d69c90c8SCristian Dumitrescu __rte_experimental
833d69c90c8SCristian Dumitrescu struct rte_swx_ctl_pipeline *
834d69c90c8SCristian Dumitrescu rte_swx_ctl_pipeline_find(const char *name);
835d69c90c8SCristian Dumitrescu 
836d69c90c8SCristian Dumitrescu /**
83799a2dd95SBruce Richardson  * Pipeline control create
83899a2dd95SBruce Richardson  *
83999a2dd95SBruce Richardson  * @param[in] p
84099a2dd95SBruce Richardson  *   Pipeline handle.
84199a2dd95SBruce Richardson  * @return
84299a2dd95SBruce Richardson  *   Pipeline control handle, on success, or NULL, on error.
84399a2dd95SBruce Richardson  */
84499a2dd95SBruce Richardson __rte_experimental
84599a2dd95SBruce Richardson struct rte_swx_ctl_pipeline *
84699a2dd95SBruce Richardson rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
84799a2dd95SBruce Richardson 
84899a2dd95SBruce Richardson /**
84999a2dd95SBruce Richardson  * Pipeline table entry add
85099a2dd95SBruce Richardson  *
85199a2dd95SBruce Richardson  * Schedule entry for addition to table or update as part of the next commit
85299a2dd95SBruce Richardson  * operation.
85399a2dd95SBruce Richardson  *
85499a2dd95SBruce Richardson  * @param[in] ctl
85599a2dd95SBruce Richardson  *   Pipeline control handle.
85699a2dd95SBruce Richardson  * @param[in] table_name
85799a2dd95SBruce Richardson  *   Table name.
85899a2dd95SBruce Richardson  * @param[in] entry
85999a2dd95SBruce Richardson  *   Entry to be added to the table.
86099a2dd95SBruce Richardson  * @return
86199a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
86299a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
86399a2dd95SBruce Richardson  */
86499a2dd95SBruce Richardson __rte_experimental
86599a2dd95SBruce Richardson int
86699a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
86799a2dd95SBruce Richardson 				     const char *table_name,
86899a2dd95SBruce Richardson 				     struct rte_swx_table_entry *entry);
86999a2dd95SBruce Richardson 
87099a2dd95SBruce Richardson /**
87199a2dd95SBruce Richardson  * Pipeline table default entry add
87299a2dd95SBruce Richardson  *
87399a2dd95SBruce Richardson  * Schedule table default entry update as part of the next commit operation.
87499a2dd95SBruce Richardson  *
87599a2dd95SBruce Richardson  * @param[in] ctl
87699a2dd95SBruce Richardson  *   Pipeline control handle.
87799a2dd95SBruce Richardson  * @param[in] table_name
87899a2dd95SBruce Richardson  *   Table name.
87999a2dd95SBruce Richardson  * @param[in] entry
88099a2dd95SBruce Richardson  *   The new table default entry. The *key* and *key_mask* entry fields are
88199a2dd95SBruce Richardson  *   ignored.
88299a2dd95SBruce Richardson  * @return
88399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
88499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
88599a2dd95SBruce Richardson  */
88699a2dd95SBruce Richardson __rte_experimental
88799a2dd95SBruce Richardson int
88899a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
88999a2dd95SBruce Richardson 					     const char *table_name,
89099a2dd95SBruce Richardson 					     struct rte_swx_table_entry *entry);
89199a2dd95SBruce Richardson 
89299a2dd95SBruce Richardson /**
89399a2dd95SBruce Richardson  * Pipeline table entry delete
89499a2dd95SBruce Richardson  *
89599a2dd95SBruce Richardson  * Schedule entry for deletion from table as part of the next commit operation.
89699a2dd95SBruce Richardson  * Request is silently discarded if no such entry exists.
89799a2dd95SBruce Richardson  *
89899a2dd95SBruce Richardson  * @param[in] ctl
89999a2dd95SBruce Richardson  *   Pipeline control handle.
90099a2dd95SBruce Richardson  * @param[in] table_name
90199a2dd95SBruce Richardson  *   Table name.
90299a2dd95SBruce Richardson  * @param[in] entry
90399a2dd95SBruce Richardson  *   Entry to be deleted from the table. The *action_id* and *action_data* entry
90499a2dd95SBruce Richardson  *   fields are ignored.
90599a2dd95SBruce Richardson  * @return
90699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
90799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
90899a2dd95SBruce Richardson  */
90999a2dd95SBruce Richardson __rte_experimental
91099a2dd95SBruce Richardson int
91199a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
91299a2dd95SBruce Richardson 					const char *table_name,
91399a2dd95SBruce Richardson 					struct rte_swx_table_entry *entry);
91499a2dd95SBruce Richardson 
91599a2dd95SBruce Richardson /**
916cdaa937dSCristian Dumitrescu  * Pipeline selector table group add
917cdaa937dSCristian Dumitrescu  *
918cdaa937dSCristian Dumitrescu  * Add a new group to a selector table. This operation is executed before this
919cdaa937dSCristian Dumitrescu  * function returns and its result is independent of the result of the next
920cdaa937dSCristian Dumitrescu  * commit operation.
921cdaa937dSCristian Dumitrescu  *
922cdaa937dSCristian Dumitrescu  * @param[in] ctl
923cdaa937dSCristian Dumitrescu  *   Pipeline control handle.
924cdaa937dSCristian Dumitrescu  * @param[in] selector_name
925cdaa937dSCristian Dumitrescu  *   Selector table name.
926cdaa937dSCristian Dumitrescu  * @param[out] group_id
927cdaa937dSCristian Dumitrescu  *   The ID of the new group. Only valid when the function call is successful.
928cdaa937dSCristian Dumitrescu  *   This group is initially empty, i.e. it does not contain any members.
929cdaa937dSCristian Dumitrescu  * @return
930cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
931cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument;
932cdaa937dSCristian Dumitrescu  *   -ENOSPC: All groups are currently in use, no group available.
933cdaa937dSCristian Dumitrescu  */
934cdaa937dSCristian Dumitrescu __rte_experimental
935cdaa937dSCristian Dumitrescu int
936cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
937cdaa937dSCristian Dumitrescu 					const char *selector_name,
938cdaa937dSCristian Dumitrescu 					uint32_t *group_id);
939cdaa937dSCristian Dumitrescu 
940cdaa937dSCristian Dumitrescu /**
941cdaa937dSCristian Dumitrescu  * Pipeline selector table group delete
942cdaa937dSCristian Dumitrescu  *
943cdaa937dSCristian Dumitrescu  * Schedule a group for deletion as part of the next commit operation. The group
944cdaa937dSCristian Dumitrescu  * to be deleted can be empty or non-empty.
945cdaa937dSCristian Dumitrescu  *
946cdaa937dSCristian Dumitrescu  * @param[in] ctl
947cdaa937dSCristian Dumitrescu  *   Pipeline control handle.
948cdaa937dSCristian Dumitrescu  * @param[in] selector_name
949cdaa937dSCristian Dumitrescu  *   Selector table name.
950cdaa937dSCristian Dumitrescu  * @param[in] group_id
951cdaa937dSCristian Dumitrescu  *   Group to be deleted from the selector table.
952cdaa937dSCristian Dumitrescu  * @return
953cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
954cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument;
955cdaa937dSCristian Dumitrescu  *   -ENOMEM: Not enough memory.
956cdaa937dSCristian Dumitrescu  */
957cdaa937dSCristian Dumitrescu __rte_experimental
958cdaa937dSCristian Dumitrescu int
959cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
960cdaa937dSCristian Dumitrescu 					   const char *selector_name,
961cdaa937dSCristian Dumitrescu 					   uint32_t group_id);
962cdaa937dSCristian Dumitrescu 
963cdaa937dSCristian Dumitrescu /**
964cdaa937dSCristian Dumitrescu  * Pipeline selector table member add to group
965cdaa937dSCristian Dumitrescu  *
966cdaa937dSCristian Dumitrescu  * Schedule the operation to add a new member to an existing group as part of
967cdaa937dSCristian Dumitrescu  * the next commit operation. If this member is already in this group, the
968cdaa937dSCristian Dumitrescu  * member weight is updated to the new value. A weight of zero means this member
969cdaa937dSCristian Dumitrescu  * is to be deleted from the group.
970cdaa937dSCristian Dumitrescu  *
971cdaa937dSCristian Dumitrescu  * @param[in] ctl
972cdaa937dSCristian Dumitrescu  *   Pipeline control handle.
973cdaa937dSCristian Dumitrescu  * @param[in] selector_name
974cdaa937dSCristian Dumitrescu  *   Selector table name.
975cdaa937dSCristian Dumitrescu  * @param[in] group_id
976cdaa937dSCristian Dumitrescu  *   The group ID.
977cdaa937dSCristian Dumitrescu  * @param[in] member_id
978cdaa937dSCristian Dumitrescu  *   The member to be added to the group.
979cdaa937dSCristian Dumitrescu  * @param[in] member_weight
980cdaa937dSCristian Dumitrescu  *   Member weight.
981cdaa937dSCristian Dumitrescu  * @return
982cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
983cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument;
984cdaa937dSCristian Dumitrescu  *   -ENOMEM: Not enough memory;
985cdaa937dSCristian Dumitrescu  *   -ENOSPC: The group is full.
986cdaa937dSCristian Dumitrescu  */
987cdaa937dSCristian Dumitrescu __rte_experimental
988cdaa937dSCristian Dumitrescu int
989cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
990cdaa937dSCristian Dumitrescu 					       const char *selector_name,
991cdaa937dSCristian Dumitrescu 					       uint32_t group_id,
992cdaa937dSCristian Dumitrescu 					       uint32_t member_id,
993cdaa937dSCristian Dumitrescu 					       uint32_t member_weight);
994cdaa937dSCristian Dumitrescu 
995cdaa937dSCristian Dumitrescu /**
996cdaa937dSCristian Dumitrescu  * Pipeline selector table member delete from group
997cdaa937dSCristian Dumitrescu  *
998cdaa937dSCristian Dumitrescu  * Schedule the operation to delete a member from an existing group as part of
999cdaa937dSCristian Dumitrescu  * the next commit operation.
1000cdaa937dSCristian Dumitrescu  *
1001cdaa937dSCristian Dumitrescu  * @param[in] ctl
1002cdaa937dSCristian Dumitrescu  *   Pipeline control handle.
1003cdaa937dSCristian Dumitrescu  * @param[in] selector_name
1004cdaa937dSCristian Dumitrescu  *   Selector table name.
1005cdaa937dSCristian Dumitrescu  * @param[in] group_id
1006cdaa937dSCristian Dumitrescu  *   The group ID. Must be valid.
1007cdaa937dSCristian Dumitrescu  * @param[in] member_id
1008cdaa937dSCristian Dumitrescu  *   The member to be added to the group. Must be valid.
1009cdaa937dSCristian Dumitrescu  * @return
1010cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1011cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
1012cdaa937dSCristian Dumitrescu  */
1013cdaa937dSCristian Dumitrescu __rte_experimental
1014cdaa937dSCristian Dumitrescu int
1015cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
1016cdaa937dSCristian Dumitrescu 						  const char *selector_name,
1017cdaa937dSCristian Dumitrescu 						  uint32_t group_id,
1018cdaa937dSCristian Dumitrescu 						  uint32_t member_id);
1019cdaa937dSCristian Dumitrescu 
1020cdaa937dSCristian Dumitrescu /**
10214f59d372SCristian Dumitrescu  * Pipeline learner table default entry add
10224f59d372SCristian Dumitrescu  *
10234f59d372SCristian Dumitrescu  * Schedule learner table default entry update as part of the next commit operation.
10244f59d372SCristian Dumitrescu  *
10254f59d372SCristian Dumitrescu  * @param[in] ctl
10264f59d372SCristian Dumitrescu  *   Pipeline control handle.
10274f59d372SCristian Dumitrescu  * @param[in] learner_name
10284f59d372SCristian Dumitrescu  *   Learner table name.
10294f59d372SCristian Dumitrescu  * @param[in] entry
10304f59d372SCristian Dumitrescu  *   The new table default entry. The *key* and *key_mask* entry fields are ignored.
10314f59d372SCristian Dumitrescu  * @return
10324f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
10334f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
10344f59d372SCristian Dumitrescu  */
10354f59d372SCristian Dumitrescu __rte_experimental
10364f59d372SCristian Dumitrescu int
10374f59d372SCristian Dumitrescu rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
10384f59d372SCristian Dumitrescu 					       const char *learner_name,
10394f59d372SCristian Dumitrescu 					       struct rte_swx_table_entry *entry);
10404f59d372SCristian Dumitrescu 
10414f59d372SCristian Dumitrescu /**
104299a2dd95SBruce Richardson  * Pipeline commit
104399a2dd95SBruce Richardson  *
104499a2dd95SBruce Richardson  * Perform all the scheduled table work.
104599a2dd95SBruce Richardson  *
104699a2dd95SBruce Richardson  * @param[in] ctl
104799a2dd95SBruce Richardson  *   Pipeline control handle.
104899a2dd95SBruce Richardson  * @param[in] abort_on_fail
104999a2dd95SBruce Richardson  *   When non-zero (false), all the scheduled work is discarded after a failed
105099a2dd95SBruce Richardson  *   commit. Otherwise, the scheduled work is still kept pending for the next
105199a2dd95SBruce Richardson  *   commit.
105299a2dd95SBruce Richardson  * @return
105399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
105499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
105599a2dd95SBruce Richardson  */
105699a2dd95SBruce Richardson __rte_experimental
105799a2dd95SBruce Richardson int
105899a2dd95SBruce Richardson rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
105999a2dd95SBruce Richardson 			    int abort_on_fail);
106099a2dd95SBruce Richardson 
106199a2dd95SBruce Richardson /**
106299a2dd95SBruce Richardson  * Pipeline abort
106399a2dd95SBruce Richardson  *
106499a2dd95SBruce Richardson  * Discard all the scheduled table work.
106599a2dd95SBruce Richardson  *
106699a2dd95SBruce Richardson  * @param[in] ctl
106799a2dd95SBruce Richardson  *   Pipeline control handle.
106899a2dd95SBruce Richardson  */
106999a2dd95SBruce Richardson __rte_experimental
107099a2dd95SBruce Richardson void
107199a2dd95SBruce Richardson rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
107299a2dd95SBruce Richardson 
107399a2dd95SBruce Richardson /**
107499a2dd95SBruce Richardson  * Pipeline table entry read
107599a2dd95SBruce Richardson  *
107699a2dd95SBruce Richardson  * Read table entry from string.
107799a2dd95SBruce Richardson  *
107899a2dd95SBruce Richardson  * @param[in] ctl
107999a2dd95SBruce Richardson  *   Pipeline control handle.
108099a2dd95SBruce Richardson  * @param[in] table_name
108199a2dd95SBruce Richardson  *   Table name.
108299a2dd95SBruce Richardson  * @param[in] string
108399a2dd95SBruce Richardson  *   String containing the table entry.
108499a2dd95SBruce Richardson  * @param[out] is_blank_or_comment
108599a2dd95SBruce Richardson  *   On error, this argument provides an indication of whether *string* contains
108699a2dd95SBruce Richardson  *   an invalid table entry (set to zero) or a blank or comment line that should
108799a2dd95SBruce Richardson  *   typically be ignored (set to a non-zero value).
108899a2dd95SBruce Richardson  * @return
108999a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
109099a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
109199a2dd95SBruce Richardson  */
109299a2dd95SBruce Richardson __rte_experimental
109399a2dd95SBruce Richardson struct rte_swx_table_entry *
109499a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
109599a2dd95SBruce Richardson 				      const char *table_name,
109699a2dd95SBruce Richardson 				      const char *string,
109799a2dd95SBruce Richardson 				      int *is_blank_or_comment);
109899a2dd95SBruce Richardson 
109999a2dd95SBruce Richardson /**
11004f59d372SCristian Dumitrescu  * Pipeline learner table default entry read
11014f59d372SCristian Dumitrescu  *
11024f59d372SCristian Dumitrescu  * Read learner table default entry from string.
11034f59d372SCristian Dumitrescu  *
11044f59d372SCristian Dumitrescu  * @param[in] ctl
11054f59d372SCristian Dumitrescu  *   Pipeline control handle.
11064f59d372SCristian Dumitrescu  * @param[in] learner_name
11074f59d372SCristian Dumitrescu  *   Learner table name.
11084f59d372SCristian Dumitrescu  * @param[in] string
11094f59d372SCristian Dumitrescu  *   String containing the learner table default entry.
11104f59d372SCristian Dumitrescu  * @param[out] is_blank_or_comment
11114f59d372SCristian Dumitrescu  *   On error, this argument provides an indication of whether *string* contains
11124f59d372SCristian Dumitrescu  *   an invalid table entry (set to zero) or a blank or comment line that should
11134f59d372SCristian Dumitrescu  *   typically be ignored (set to a non-zero value).
11144f59d372SCristian Dumitrescu  * @return
11154f59d372SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
11164f59d372SCristian Dumitrescu  *   -EINVAL: Invalid argument.
11174f59d372SCristian Dumitrescu  */
11184f59d372SCristian Dumitrescu __rte_experimental
11194f59d372SCristian Dumitrescu struct rte_swx_table_entry *
11204f59d372SCristian Dumitrescu rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
11214f59d372SCristian Dumitrescu 						const char *learner_name,
11224f59d372SCristian Dumitrescu 						const char *string,
11234f59d372SCristian Dumitrescu 						int *is_blank_or_comment);
11244f59d372SCristian Dumitrescu 
11254f59d372SCristian Dumitrescu /**
112699a2dd95SBruce Richardson  * Pipeline table print to file
112799a2dd95SBruce Richardson  *
112899a2dd95SBruce Richardson  * Print all the table entries to file.
112999a2dd95SBruce Richardson  *
113099a2dd95SBruce Richardson  * @param[in] f
113199a2dd95SBruce Richardson  *   Output file.
113299a2dd95SBruce Richardson  * @param[in] ctl
113399a2dd95SBruce Richardson  *   Pipeline control handle.
113499a2dd95SBruce Richardson  * @param[in] table_name
113599a2dd95SBruce Richardson  *   Table name.
113699a2dd95SBruce Richardson  * @return
113799a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
113899a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
113999a2dd95SBruce Richardson  */
114099a2dd95SBruce Richardson __rte_experimental
114199a2dd95SBruce Richardson int
114299a2dd95SBruce Richardson rte_swx_ctl_pipeline_table_fprintf(FILE *f,
114399a2dd95SBruce Richardson 				   struct rte_swx_ctl_pipeline *ctl,
114499a2dd95SBruce Richardson 				   const char *table_name);
114599a2dd95SBruce Richardson 
1146cdaa937dSCristian Dumitrescu /**
1147cdaa937dSCristian Dumitrescu  * Pipeline selector print to file
1148cdaa937dSCristian Dumitrescu  *
1149cdaa937dSCristian Dumitrescu  * Print all the selector entries to file.
1150cdaa937dSCristian Dumitrescu  *
1151cdaa937dSCristian Dumitrescu  * @param[in] f
1152cdaa937dSCristian Dumitrescu  *   Output file.
1153cdaa937dSCristian Dumitrescu  * @param[in] ctl
1154cdaa937dSCristian Dumitrescu  *   Pipeline control handle.
1155cdaa937dSCristian Dumitrescu  * @param[in] selector_name
1156cdaa937dSCristian Dumitrescu  *   Selector table name.
1157cdaa937dSCristian Dumitrescu  * @return
1158cdaa937dSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1159cdaa937dSCristian Dumitrescu  *   -EINVAL: Invalid argument.
1160cdaa937dSCristian Dumitrescu  */
1161cdaa937dSCristian Dumitrescu __rte_experimental
1162cdaa937dSCristian Dumitrescu int
1163cdaa937dSCristian Dumitrescu rte_swx_ctl_pipeline_selector_fprintf(FILE *f,
1164cdaa937dSCristian Dumitrescu 				      struct rte_swx_ctl_pipeline *ctl,
1165cdaa937dSCristian Dumitrescu 				      const char *selector_name);
1166cdaa937dSCristian Dumitrescu 
116799a2dd95SBruce Richardson /*
116899a2dd95SBruce Richardson  * Register Array Query API.
116999a2dd95SBruce Richardson  */
117099a2dd95SBruce Richardson 
117199a2dd95SBruce Richardson /** Register array info. */
117299a2dd95SBruce Richardson struct rte_swx_ctl_regarray_info {
117399a2dd95SBruce Richardson 	/** Register array name. */
117499a2dd95SBruce Richardson 	char name[RTE_SWX_CTL_NAME_SIZE];
117599a2dd95SBruce Richardson 
117699a2dd95SBruce Richardson 	/** Register array size. */
117799a2dd95SBruce Richardson 	uint32_t size;
117899a2dd95SBruce Richardson };
117999a2dd95SBruce Richardson 
118099a2dd95SBruce Richardson /**
118199a2dd95SBruce Richardson  * Register array info get
118299a2dd95SBruce Richardson  *
118399a2dd95SBruce Richardson  * @param[in] p
118499a2dd95SBruce Richardson  *   Pipeline handle.
118599a2dd95SBruce Richardson  * @param[in] regarray_id
118699a2dd95SBruce Richardson  *   Register array ID (0 .. *n_regarrays* - 1).
118799a2dd95SBruce Richardson  * @param[out] regarray
118899a2dd95SBruce Richardson  *   Register array info.
118999a2dd95SBruce Richardson  * @return
119099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
119199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
119299a2dd95SBruce Richardson  */
119399a2dd95SBruce Richardson __rte_experimental
119499a2dd95SBruce Richardson int
119599a2dd95SBruce Richardson rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
119699a2dd95SBruce Richardson 			      uint32_t regarray_id,
119799a2dd95SBruce Richardson 			      struct rte_swx_ctl_regarray_info *regarray);
119899a2dd95SBruce Richardson 
119999a2dd95SBruce Richardson /**
120099a2dd95SBruce Richardson  * Register read
120199a2dd95SBruce Richardson  *
120299a2dd95SBruce Richardson  * @param[in] p
120399a2dd95SBruce Richardson  *   Pipeline handle.
120499a2dd95SBruce Richardson  * @param[in] regarray_name
120599a2dd95SBruce Richardson  *   Register array name.
120699a2dd95SBruce Richardson  * @param[in] regarray_index
120799a2dd95SBruce Richardson  *   Register index within the array (0 .. *size* - 1).
120899a2dd95SBruce Richardson  * @param[out] value
120999a2dd95SBruce Richardson  *   Current register value.
121099a2dd95SBruce Richardson  * @return
121199a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
121299a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
121399a2dd95SBruce Richardson  */
121499a2dd95SBruce Richardson __rte_experimental
121599a2dd95SBruce Richardson int
121699a2dd95SBruce Richardson rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
121799a2dd95SBruce Richardson 				   const char *regarray_name,
121899a2dd95SBruce Richardson 				   uint32_t regarray_index,
121999a2dd95SBruce Richardson 				   uint64_t *value);
122099a2dd95SBruce Richardson 
122199a2dd95SBruce Richardson /**
122299a2dd95SBruce Richardson  * Register write
122399a2dd95SBruce Richardson  *
122499a2dd95SBruce Richardson  * @param[in] p
122599a2dd95SBruce Richardson  *   Pipeline handle.
122699a2dd95SBruce Richardson  * @param[in] regarray_name
122799a2dd95SBruce Richardson  *   Register array name.
122899a2dd95SBruce Richardson  * @param[in] regarray_index
122999a2dd95SBruce Richardson  *   Register index within the array (0 .. *size* - 1).
123099a2dd95SBruce Richardson  * @param[in] value
123199a2dd95SBruce Richardson  *   Value to be written to the register.
123299a2dd95SBruce Richardson  * @return
123399a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
123499a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
123599a2dd95SBruce Richardson  */
123699a2dd95SBruce Richardson __rte_experimental
123799a2dd95SBruce Richardson int
123899a2dd95SBruce Richardson rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
123999a2dd95SBruce Richardson 				   const char *regarray_name,
124099a2dd95SBruce Richardson 				   uint32_t regarray_index,
124199a2dd95SBruce Richardson 				   uint64_t value);
124299a2dd95SBruce Richardson 
1243aa185523SCristian Dumitrescu /**
1244aa185523SCristian Dumitrescu  * Register read with table key lookup
1245aa185523SCristian Dumitrescu  *
1246aa185523SCristian Dumitrescu  * @param[in] p
1247aa185523SCristian Dumitrescu  *   Pipeline handle.
1248aa185523SCristian Dumitrescu  * @param[in] regarray_name
1249aa185523SCristian Dumitrescu  *   Register array name.
1250aa185523SCristian Dumitrescu  * @param[in] table_name
1251aa185523SCristian Dumitrescu  *   Regular or learner table name.
1252aa185523SCristian Dumitrescu  * @param[in] table_key
1253aa185523SCristian Dumitrescu  *   Table key.
1254aa185523SCristian Dumitrescu  * @param[out] value
1255aa185523SCristian Dumitrescu  *   Current register value.
1256aa185523SCristian Dumitrescu  * @return
1257aa185523SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1258aa185523SCristian Dumitrescu  *   -EINVAL: Invalid argument;
1259aa185523SCristian Dumitrescu  *   -ENOMEM: Not enough memory.
1260aa185523SCristian Dumitrescu  */
1261aa185523SCristian Dumitrescu __rte_experimental
1262aa185523SCristian Dumitrescu int
1263aa185523SCristian Dumitrescu rte_swx_ctl_pipeline_regarray_read_with_key(struct rte_swx_pipeline *p,
1264aa185523SCristian Dumitrescu 					    const char *regarray_name,
1265aa185523SCristian Dumitrescu 					    const char *table_name,
1266aa185523SCristian Dumitrescu 					    uint8_t *table_key,
1267aa185523SCristian Dumitrescu 					    uint64_t *value);
1268aa185523SCristian Dumitrescu 
1269aa185523SCristian Dumitrescu /**
1270aa185523SCristian Dumitrescu  * Register write with table key lookup
1271aa185523SCristian Dumitrescu  *
1272aa185523SCristian Dumitrescu  * @param[in] p
1273aa185523SCristian Dumitrescu  *   Pipeline handle.
1274aa185523SCristian Dumitrescu  * @param[in] regarray_name
1275aa185523SCristian Dumitrescu  *   Register array name.
1276aa185523SCristian Dumitrescu  * @param[in] table_name
1277aa185523SCristian Dumitrescu  *   Regular or learner table name.
1278aa185523SCristian Dumitrescu  * @param[in] table_key
1279aa185523SCristian Dumitrescu  *   Table key.
1280aa185523SCristian Dumitrescu  * @param[in] value
1281aa185523SCristian Dumitrescu  *   Value to be written to the register.
1282aa185523SCristian Dumitrescu  * @return
1283aa185523SCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1284aa185523SCristian Dumitrescu  *   -EINVAL: Invalid argument;
1285aa185523SCristian Dumitrescu  *   -ENOMEM: Not enough memory.
1286aa185523SCristian Dumitrescu  */
1287aa185523SCristian Dumitrescu __rte_experimental
1288aa185523SCristian Dumitrescu int
1289aa185523SCristian Dumitrescu rte_swx_ctl_pipeline_regarray_write_with_key(struct rte_swx_pipeline *p,
1290aa185523SCristian Dumitrescu 					     const char *regarray_name,
1291aa185523SCristian Dumitrescu 					     const char *table_name,
1292aa185523SCristian Dumitrescu 					     uint8_t *table_key,
1293aa185523SCristian Dumitrescu 					     uint64_t value);
1294aa185523SCristian Dumitrescu 
129599a2dd95SBruce Richardson /*
129699a2dd95SBruce Richardson  * Meter Array Query and Configuration API.
129799a2dd95SBruce Richardson  */
129899a2dd95SBruce Richardson 
129999a2dd95SBruce Richardson /** Meter array info. */
130099a2dd95SBruce Richardson struct rte_swx_ctl_metarray_info {
130199a2dd95SBruce Richardson 	/** Meter array name. */
130299a2dd95SBruce Richardson 	char name[RTE_SWX_CTL_NAME_SIZE];
130399a2dd95SBruce Richardson 
130499a2dd95SBruce Richardson 	/** Meter array size. */
130599a2dd95SBruce Richardson 	uint32_t size;
130699a2dd95SBruce Richardson };
130799a2dd95SBruce Richardson 
130899a2dd95SBruce Richardson /**
130999a2dd95SBruce Richardson  * Meter array info get
131099a2dd95SBruce Richardson  *
131199a2dd95SBruce Richardson  * @param[in] p
131299a2dd95SBruce Richardson  *   Pipeline handle.
131399a2dd95SBruce Richardson  * @param[in] metarray_id
131499a2dd95SBruce Richardson  *   Meter array ID (0 .. *n_metarrays* - 1).
131599a2dd95SBruce Richardson  * @param[out] metarray
131699a2dd95SBruce Richardson  *   Meter array info.
131799a2dd95SBruce Richardson  * @return
131899a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
131999a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
132099a2dd95SBruce Richardson  */
132199a2dd95SBruce Richardson __rte_experimental
132299a2dd95SBruce Richardson int
132399a2dd95SBruce Richardson rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
132499a2dd95SBruce Richardson 			      uint32_t metarray_id,
132599a2dd95SBruce Richardson 			      struct rte_swx_ctl_metarray_info *metarray);
132699a2dd95SBruce Richardson 
132799a2dd95SBruce Richardson /**
132899a2dd95SBruce Richardson  * Meter profile add
132999a2dd95SBruce Richardson  *
133099a2dd95SBruce Richardson  * @param[in] p
133199a2dd95SBruce Richardson  *   Pipeline handle.
133299a2dd95SBruce Richardson  * @param[in] name
133399a2dd95SBruce Richardson  *   Meter profile name.
133499a2dd95SBruce Richardson  * @param[in] params
133599a2dd95SBruce Richardson  *   Meter profile parameters.
133699a2dd95SBruce Richardson  * @return
133799a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
133899a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
133999a2dd95SBruce Richardson  *   -ENOMEM: Not enough space/cannot allocate memory;
134099a2dd95SBruce Richardson  *   -EEXIST: Meter profile with this name already exists.
134199a2dd95SBruce Richardson  */
134299a2dd95SBruce Richardson __rte_experimental
134399a2dd95SBruce Richardson int
134499a2dd95SBruce Richardson rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
134599a2dd95SBruce Richardson 			      const char *name,
134699a2dd95SBruce Richardson 			      struct rte_meter_trtcm_params *params);
134799a2dd95SBruce Richardson 
134899a2dd95SBruce Richardson /**
134999a2dd95SBruce Richardson  * Meter profile delete
135099a2dd95SBruce Richardson  *
135199a2dd95SBruce Richardson  * @param[in] p
135299a2dd95SBruce Richardson  *   Pipeline handle.
135399a2dd95SBruce Richardson  * @param[in] name
135499a2dd95SBruce Richardson  *   Meter profile name.
135599a2dd95SBruce Richardson  * @return
135699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
135799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument;
135899a2dd95SBruce Richardson  *   -EBUSY: Meter profile is currently in use.
135999a2dd95SBruce Richardson  */
136099a2dd95SBruce Richardson __rte_experimental
136199a2dd95SBruce Richardson int
136299a2dd95SBruce Richardson rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
136399a2dd95SBruce Richardson 				 const char *name);
136499a2dd95SBruce Richardson 
136599a2dd95SBruce Richardson /**
136699a2dd95SBruce Richardson  * Meter reset
136799a2dd95SBruce Richardson  *
136899a2dd95SBruce Richardson  * Reset a meter within a given meter array to use the default profile that
136999a2dd95SBruce Richardson  * causes all the input packets to be colored as green. It is the responsibility
137099a2dd95SBruce Richardson  * of the control plane to make sure this meter is not used by the data plane
137199a2dd95SBruce Richardson  * pipeline before calling this function.
137299a2dd95SBruce Richardson  *
137399a2dd95SBruce Richardson  * @param[in] p
137499a2dd95SBruce Richardson  *   Pipeline handle.
137599a2dd95SBruce Richardson  * @param[in] metarray_name
137699a2dd95SBruce Richardson  *   Meter array name.
137799a2dd95SBruce Richardson  * @param[in] metarray_index
137899a2dd95SBruce Richardson  *   Meter index within the meter array.
137999a2dd95SBruce Richardson  * @return
138099a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
138199a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
138299a2dd95SBruce Richardson  */
138399a2dd95SBruce Richardson __rte_experimental
138499a2dd95SBruce Richardson int
138599a2dd95SBruce Richardson rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
138699a2dd95SBruce Richardson 			const char *metarray_name,
138799a2dd95SBruce Richardson 			uint32_t metarray_index);
138899a2dd95SBruce Richardson 
138999a2dd95SBruce Richardson /**
139099a2dd95SBruce Richardson  * Meter set
139199a2dd95SBruce Richardson  *
139299a2dd95SBruce Richardson  * Set a meter within a given meter array to use a specific profile. It is the
139399a2dd95SBruce Richardson  * responsibility of the control plane to make sure this meter is not used by
139499a2dd95SBruce Richardson  * the data plane pipeline before calling this function.
139599a2dd95SBruce Richardson  *
139699a2dd95SBruce Richardson  * @param[in] p
139799a2dd95SBruce Richardson  *   Pipeline handle.
139899a2dd95SBruce Richardson  * @param[in] metarray_name
139999a2dd95SBruce Richardson  *   Meter array name.
140099a2dd95SBruce Richardson  * @param[in] metarray_index
140199a2dd95SBruce Richardson  *   Meter index within the meter array.
140299a2dd95SBruce Richardson  * @param[in] profile_name
140399a2dd95SBruce Richardson  *   Existing meter profile name.
140499a2dd95SBruce Richardson  * @return
140599a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
140699a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
140799a2dd95SBruce Richardson  */
140899a2dd95SBruce Richardson __rte_experimental
140999a2dd95SBruce Richardson int
141099a2dd95SBruce Richardson rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
141199a2dd95SBruce Richardson 		      const char *metarray_name,
141299a2dd95SBruce Richardson 		      uint32_t metarray_index,
141399a2dd95SBruce Richardson 		      const char *profile_name);
141499a2dd95SBruce Richardson 
141599a2dd95SBruce Richardson /** Meter statistics counters. */
141699a2dd95SBruce Richardson struct rte_swx_ctl_meter_stats {
141799a2dd95SBruce Richardson 	/** Number of packets tagged by the meter for each color. */
141899a2dd95SBruce Richardson 	uint64_t n_pkts[RTE_COLORS];
141999a2dd95SBruce Richardson 
142099a2dd95SBruce Richardson 	/** Number of bytes tagged by the meter for each color. */
142199a2dd95SBruce Richardson 	uint64_t n_bytes[RTE_COLORS];
142299a2dd95SBruce Richardson };
142399a2dd95SBruce Richardson 
142499a2dd95SBruce Richardson /**
142599a2dd95SBruce Richardson  * Meter statistics counters read
142699a2dd95SBruce Richardson  *
142799a2dd95SBruce Richardson  * @param[in] p
142899a2dd95SBruce Richardson  *   Pipeline handle.
142999a2dd95SBruce Richardson  * @param[in] metarray_name
143099a2dd95SBruce Richardson  *   Meter array name.
143199a2dd95SBruce Richardson  * @param[in] metarray_index
143299a2dd95SBruce Richardson  *   Meter index within the meter array.
143399a2dd95SBruce Richardson  * @param[out] stats
143499a2dd95SBruce Richardson  *   Meter statistics counters.
143599a2dd95SBruce Richardson  * @return
143699a2dd95SBruce Richardson  *   0 on success or the following error codes otherwise:
143799a2dd95SBruce Richardson  *   -EINVAL: Invalid argument.
143899a2dd95SBruce Richardson  */
143999a2dd95SBruce Richardson __rte_experimental
144099a2dd95SBruce Richardson int
144199a2dd95SBruce Richardson rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
144299a2dd95SBruce Richardson 			     const char *metarray_name,
144399a2dd95SBruce Richardson 			     uint32_t metarray_index,
144499a2dd95SBruce Richardson 			     struct rte_swx_ctl_meter_stats *stats);
144599a2dd95SBruce Richardson 
144699a2dd95SBruce Richardson /**
1447ac0d65dfSCristian Dumitrescu  * Meter reset with table key lookup
1448ac0d65dfSCristian Dumitrescu  *
1449ac0d65dfSCristian Dumitrescu  * Reset a meter within a given meter array to use the default profile that
1450ac0d65dfSCristian Dumitrescu  * causes all the input packets to be colored as green. It is the responsibility
1451ac0d65dfSCristian Dumitrescu  * of the control plane to make sure this meter is not used by the data plane
1452ac0d65dfSCristian Dumitrescu  * pipeline before calling this function.
1453ac0d65dfSCristian Dumitrescu  *
1454ac0d65dfSCristian Dumitrescu  * @param[in] p
1455ac0d65dfSCristian Dumitrescu  *   Pipeline handle.
1456ac0d65dfSCristian Dumitrescu  * @param[in] metarray_name
1457ac0d65dfSCristian Dumitrescu  *   Meter array name.
1458ac0d65dfSCristian Dumitrescu  * @param[in] table_name
1459ac0d65dfSCristian Dumitrescu  *   Regular or learner table name.
1460ac0d65dfSCristian Dumitrescu  * @param[in] table_key
1461ac0d65dfSCristian Dumitrescu  *   Table key.
1462ac0d65dfSCristian Dumitrescu  * @return
1463ac0d65dfSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1464ac0d65dfSCristian Dumitrescu  *   -EINVAL: Invalid argument.
1465ac0d65dfSCristian Dumitrescu  */
1466ac0d65dfSCristian Dumitrescu __rte_experimental
1467ac0d65dfSCristian Dumitrescu int
1468ac0d65dfSCristian Dumitrescu rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p,
1469ac0d65dfSCristian Dumitrescu 				 const char *metarray_name,
1470ac0d65dfSCristian Dumitrescu 				 const char *table_name,
1471ac0d65dfSCristian Dumitrescu 				 uint8_t *table_key);
1472ac0d65dfSCristian Dumitrescu 
1473ac0d65dfSCristian Dumitrescu /**
1474ac0d65dfSCristian Dumitrescu  * Meter set with table key lookup
1475ac0d65dfSCristian Dumitrescu  *
1476ac0d65dfSCristian Dumitrescu  * Set a meter within a given meter array to use a specific profile. It is the
1477ac0d65dfSCristian Dumitrescu  * responsibility of the control plane to make sure this meter is not used by
1478ac0d65dfSCristian Dumitrescu  * the data plane pipeline before calling this function.
1479ac0d65dfSCristian Dumitrescu  *
1480ac0d65dfSCristian Dumitrescu  * @param[in] p
1481ac0d65dfSCristian Dumitrescu  *   Pipeline handle.
1482ac0d65dfSCristian Dumitrescu  * @param[in] metarray_name
1483ac0d65dfSCristian Dumitrescu  *   Meter array name.
1484ac0d65dfSCristian Dumitrescu  * @param[in] table_name
1485ac0d65dfSCristian Dumitrescu  *   Regular or learner table name.
1486ac0d65dfSCristian Dumitrescu  * @param[in] table_key
1487ac0d65dfSCristian Dumitrescu  *   Table key.
1488ac0d65dfSCristian Dumitrescu  * @param[in] profile_name
1489ac0d65dfSCristian Dumitrescu  *   Existing meter profile name.
1490ac0d65dfSCristian Dumitrescu  * @return
1491ac0d65dfSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1492ac0d65dfSCristian Dumitrescu  *   -EINVAL: Invalid argument.
1493ac0d65dfSCristian Dumitrescu  */
1494ac0d65dfSCristian Dumitrescu __rte_experimental
1495ac0d65dfSCristian Dumitrescu int
1496ac0d65dfSCristian Dumitrescu rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p,
1497ac0d65dfSCristian Dumitrescu 			       const char *metarray_name,
1498ac0d65dfSCristian Dumitrescu 			       const char *table_name,
1499ac0d65dfSCristian Dumitrescu 			       uint8_t *table_key,
1500ac0d65dfSCristian Dumitrescu 			       const char *profile_name);
1501ac0d65dfSCristian Dumitrescu 
1502ac0d65dfSCristian Dumitrescu /**
1503ac0d65dfSCristian Dumitrescu  * Meter statistics counters read with table key lookup
1504ac0d65dfSCristian Dumitrescu  *
1505ac0d65dfSCristian Dumitrescu  * @param[in] p
1506ac0d65dfSCristian Dumitrescu  *   Pipeline handle.
1507ac0d65dfSCristian Dumitrescu  * @param[in] metarray_name
1508ac0d65dfSCristian Dumitrescu  *   Meter array name.
1509ac0d65dfSCristian Dumitrescu  * @param[in] table_name
1510ac0d65dfSCristian Dumitrescu  *   Regular or learner table name.
1511ac0d65dfSCristian Dumitrescu  * @param[in] table_key
1512ac0d65dfSCristian Dumitrescu  *   Table key.
1513ac0d65dfSCristian Dumitrescu  * @param[out] stats
1514ac0d65dfSCristian Dumitrescu  *   Meter statistics counters.
1515ac0d65dfSCristian Dumitrescu  * @return
1516ac0d65dfSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
1517ac0d65dfSCristian Dumitrescu  *   -EINVAL: Invalid argument.
1518ac0d65dfSCristian Dumitrescu  */
1519ac0d65dfSCristian Dumitrescu __rte_experimental
1520ac0d65dfSCristian Dumitrescu int
1521ac0d65dfSCristian Dumitrescu rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p,
1522ac0d65dfSCristian Dumitrescu 				      const char *metarray_name,
1523ac0d65dfSCristian Dumitrescu 				      const char *table_name,
1524ac0d65dfSCristian Dumitrescu 				      uint8_t *table_key,
1525ac0d65dfSCristian Dumitrescu 				      struct rte_swx_ctl_meter_stats *stats);
1526ac0d65dfSCristian Dumitrescu 
15278ba342ceSCristian Dumitrescu /*
15288ba342ceSCristian Dumitrescu  * RSS Query and Configuration API.
15298ba342ceSCristian Dumitrescu  */
15308ba342ceSCristian Dumitrescu 
15318ba342ceSCristian Dumitrescu /** RSS object info. */
15328ba342ceSCristian Dumitrescu struct rte_swx_ctl_rss_info {
15338ba342ceSCristian Dumitrescu 	/** RSS object name. */
15348ba342ceSCristian Dumitrescu 	char name[RTE_SWX_CTL_NAME_SIZE];
15358ba342ceSCristian Dumitrescu };
15368ba342ceSCristian Dumitrescu 
15378ba342ceSCristian Dumitrescu /**
15388ba342ceSCristian Dumitrescu  * RSS object info get
15398ba342ceSCristian Dumitrescu  *
15408ba342ceSCristian Dumitrescu  * @param[in] p
15418ba342ceSCristian Dumitrescu  *   Pipeline handle.
15428ba342ceSCristian Dumitrescu  * @param[in] rss_obj_id
15438ba342ceSCristian Dumitrescu  *   RSS object ID (0 .. *n_rss* - 1).
15448ba342ceSCristian Dumitrescu  * @param[out] rss
15458ba342ceSCristian Dumitrescu  *   RSS object info.
15468ba342ceSCristian Dumitrescu  * @return
15478ba342ceSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
15488ba342ceSCristian Dumitrescu  *   -EINVAL: Invalid argument.
15498ba342ceSCristian Dumitrescu  */
15508ba342ceSCristian Dumitrescu __rte_experimental
15518ba342ceSCristian Dumitrescu int
15528ba342ceSCristian Dumitrescu rte_swx_ctl_rss_info_get(struct rte_swx_pipeline *p,
15538ba342ceSCristian Dumitrescu 			 uint32_t rss_obj_id,
15548ba342ceSCristian Dumitrescu 			 struct rte_swx_ctl_rss_info *rss);
15558ba342ceSCristian Dumitrescu 
15568ba342ceSCristian Dumitrescu /**
15578ba342ceSCristian Dumitrescu  * RSS object key size read
15588ba342ceSCristian Dumitrescu  *
15598ba342ceSCristian Dumitrescu  * @param[in] p
15608ba342ceSCristian Dumitrescu  *   Pipeline handle.
15618ba342ceSCristian Dumitrescu  * @param[in] rss_obj_name
15628ba342ceSCristian Dumitrescu  *   RSS object name.
15638ba342ceSCristian Dumitrescu  * @param[out] key_size
15648ba342ceSCristian Dumitrescu  *   RSS key size in bytes.
15658ba342ceSCristian Dumitrescu  * @return
15668ba342ceSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
15678ba342ceSCristian Dumitrescu  *   -EINVAL: Invalid argument.
15688ba342ceSCristian Dumitrescu  */
15698ba342ceSCristian Dumitrescu __rte_experimental
15708ba342ceSCristian Dumitrescu int
15718ba342ceSCristian Dumitrescu rte_swx_ctl_pipeline_rss_key_size_read(struct rte_swx_pipeline *p,
15728ba342ceSCristian Dumitrescu 				       const char *rss_obj_name,
15738ba342ceSCristian Dumitrescu 				       uint32_t *key_size);
15748ba342ceSCristian Dumitrescu 
15758ba342ceSCristian Dumitrescu /**
15768ba342ceSCristian Dumitrescu  * RSS object key read
15778ba342ceSCristian Dumitrescu  *
15788ba342ceSCristian Dumitrescu  * @param[in] p
15798ba342ceSCristian Dumitrescu  *   Pipeline handle.
15808ba342ceSCristian Dumitrescu  * @param[in] rss_obj_name
15818ba342ceSCristian Dumitrescu  *   RSS object name.
15828ba342ceSCristian Dumitrescu  * @param[out] key
15838ba342ceSCristian Dumitrescu  *   RSS key. Must be pre-allocated by the caller to store *key_size* bytes.
15848ba342ceSCristian Dumitrescu  * @return
15858ba342ceSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
15868ba342ceSCristian Dumitrescu  *   -EINVAL: Invalid argument.
15878ba342ceSCristian Dumitrescu  */
15888ba342ceSCristian Dumitrescu __rte_experimental
15898ba342ceSCristian Dumitrescu int
15908ba342ceSCristian Dumitrescu rte_swx_ctl_pipeline_rss_key_read(struct rte_swx_pipeline *p,
15918ba342ceSCristian Dumitrescu 				  const char *rss_obj_name,
15928ba342ceSCristian Dumitrescu 				  uint8_t *key);
15938ba342ceSCristian Dumitrescu 
15948ba342ceSCristian Dumitrescu /**
15958ba342ceSCristian Dumitrescu  * RSS object key write
15968ba342ceSCristian Dumitrescu  *
15978ba342ceSCristian Dumitrescu  * @param[in] p
15988ba342ceSCristian Dumitrescu  *   Pipeline handle.
15998ba342ceSCristian Dumitrescu  * @param[in] rss_obj_name
16008ba342ceSCristian Dumitrescu  *   RSS object name.
16018ba342ceSCristian Dumitrescu  * @param[in] key_size
16028ba342ceSCristian Dumitrescu  *   RSS key size in bytes. Must be at least 4 and a power of 2.
16038ba342ceSCristian Dumitrescu  * @param[in] key
16048ba342ceSCristian Dumitrescu  *   RSS key.
16058ba342ceSCristian Dumitrescu  * @return
16068ba342ceSCristian Dumitrescu  *   0 on success or the following error codes otherwise:
16078ba342ceSCristian Dumitrescu  *   -EINVAL: Invalid argument.
16088ba342ceSCristian Dumitrescu  */
16098ba342ceSCristian Dumitrescu __rte_experimental
16108ba342ceSCristian Dumitrescu int
16118ba342ceSCristian Dumitrescu rte_swx_ctl_pipeline_rss_key_write(struct rte_swx_pipeline *p,
16128ba342ceSCristian Dumitrescu 				   const char *rss_obj_name,
16138ba342ceSCristian Dumitrescu 				   uint32_t key_size,
16148ba342ceSCristian Dumitrescu 				   uint8_t *key);
16158ba342ceSCristian Dumitrescu 
1616ac0d65dfSCristian Dumitrescu /**
161799a2dd95SBruce Richardson  * Pipeline control free
161899a2dd95SBruce Richardson  *
161999a2dd95SBruce Richardson  * @param[in] ctl
162099a2dd95SBruce Richardson  *   Pipeline control handle.
1621448e01f1SStephen Hemminger  *   If ctl is NULL, no operation is performed.
162299a2dd95SBruce Richardson  */
162399a2dd95SBruce Richardson __rte_experimental
162499a2dd95SBruce Richardson void
162599a2dd95SBruce Richardson rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
162699a2dd95SBruce Richardson 
162799a2dd95SBruce Richardson #ifdef __cplusplus
162899a2dd95SBruce Richardson }
162999a2dd95SBruce Richardson #endif
163099a2dd95SBruce Richardson 
163199a2dd95SBruce Richardson #endif
1632