xref: /dpdk/lib/pipeline/rte_table_action.h (revision 5ac1abdd37aa43692603cd8670111c354014766f)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2018 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef __INCLUDE_RTE_TABLE_ACTION_H__
699a2dd95SBruce Richardson #define __INCLUDE_RTE_TABLE_ACTION_H__
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  * RTE Pipeline Table Actions
1199a2dd95SBruce Richardson  *
1299a2dd95SBruce Richardson  * This API provides a common set of actions for pipeline tables to speed up
1399a2dd95SBruce Richardson  * application development.
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * Each match-action rule added to a pipeline table has associated data that
1699a2dd95SBruce Richardson  * stores the action context. This data is input to the table action handler
1799a2dd95SBruce Richardson  * called for every input packet that hits the rule as part of the table lookup
1899a2dd95SBruce Richardson  * during the pipeline execution. The pipeline library allows the user to define
1999a2dd95SBruce Richardson  * his own table actions by providing customized table action handlers (table
2099a2dd95SBruce Richardson  * lookup) and complete freedom of setting the rules and their data (table rule
2199a2dd95SBruce Richardson  * add/delete). While the user can still follow this process, this API is
2299a2dd95SBruce Richardson  * intended to provide a quicker development alternative for a set of predefined
2399a2dd95SBruce Richardson  * actions.
2499a2dd95SBruce Richardson  *
2599a2dd95SBruce Richardson  * The typical steps to use this API are:
2699a2dd95SBruce Richardson  *  - Define a table action profile. This is a configuration template that can
2799a2dd95SBruce Richardson  *    potentially be shared by multiple tables from the same or different
2899a2dd95SBruce Richardson  *    pipelines, with different tables from the same pipeline likely to use
2999a2dd95SBruce Richardson  *    different action profiles. For every table using a given action profile,
3099a2dd95SBruce Richardson  *    the profile defines the set of actions and the action configuration to be
3199a2dd95SBruce Richardson  *    implemented for all the table rules. API functions:
3299a2dd95SBruce Richardson  *    rte_table_action_profile_create(),
3399a2dd95SBruce Richardson  *    rte_table_action_profile_action_register(),
3499a2dd95SBruce Richardson  *    rte_table_action_profile_freeze().
3599a2dd95SBruce Richardson  *
3699a2dd95SBruce Richardson  *  - Instantiate the table action profile to create table action objects. Each
3799a2dd95SBruce Richardson  *    pipeline table has its own table action object. API functions:
3899a2dd95SBruce Richardson  *    rte_table_action_create().
3999a2dd95SBruce Richardson  *
4099a2dd95SBruce Richardson  *  - Use the table action object to generate the pipeline table action handlers
4199a2dd95SBruce Richardson  *    (invoked by the pipeline table lookup operation). API functions:
4299a2dd95SBruce Richardson  *    rte_table_action_table_params_get().
4399a2dd95SBruce Richardson  *
4499a2dd95SBruce Richardson  *  - Use the table action object to generate the rule data (for the pipeline
4599a2dd95SBruce Richardson  *    table rule add operation) based on given action parameters. API functions:
4699a2dd95SBruce Richardson  *    rte_table_action_apply().
4799a2dd95SBruce Richardson  *
4899a2dd95SBruce Richardson  *  - Use the table action object to read action data (e.g. stats counters) for
4999a2dd95SBruce Richardson  *    any given rule. API functions: rte_table_action_XYZ_read().
5099a2dd95SBruce Richardson  *
5199a2dd95SBruce Richardson  * @warning
5299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
5399a2dd95SBruce Richardson  */
5499a2dd95SBruce Richardson 
5599a2dd95SBruce Richardson #include <stdint.h>
5699a2dd95SBruce Richardson 
5799a2dd95SBruce Richardson #include <rte_compat.h>
5899a2dd95SBruce Richardson #include <rte_ether.h>
59*5ac1abddSRobin Jarry #include <rte_ip6.h>
6099a2dd95SBruce Richardson #include <rte_meter.h>
6199a2dd95SBruce Richardson #include <rte_table_hash.h>
6299a2dd95SBruce Richardson 
6399a2dd95SBruce Richardson #include "rte_pipeline.h"
6499a2dd95SBruce Richardson 
65719834a6SMattias Rönnblom #ifdef __cplusplus
66719834a6SMattias Rönnblom extern "C" {
67719834a6SMattias Rönnblom #endif
68719834a6SMattias Rönnblom 
6999a2dd95SBruce Richardson /** Table actions. */
7099a2dd95SBruce Richardson enum rte_table_action_type {
7199a2dd95SBruce Richardson 	/** Forward to next pipeline table, output port or drop. */
7299a2dd95SBruce Richardson 	RTE_TABLE_ACTION_FWD = 0,
7399a2dd95SBruce Richardson 
7499a2dd95SBruce Richardson 	/**  Load balance. */
7599a2dd95SBruce Richardson 	RTE_TABLE_ACTION_LB,
7699a2dd95SBruce Richardson 
7799a2dd95SBruce Richardson 	/**  Traffic Metering and Policing. */
7899a2dd95SBruce Richardson 	RTE_TABLE_ACTION_MTR,
7999a2dd95SBruce Richardson 
8099a2dd95SBruce Richardson 	/**  Traffic Management. */
8199a2dd95SBruce Richardson 	RTE_TABLE_ACTION_TM,
8299a2dd95SBruce Richardson 
8399a2dd95SBruce Richardson 	/** Packet encapsulations. */
8499a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP,
8599a2dd95SBruce Richardson 
8699a2dd95SBruce Richardson 	/** Network Address Translation (NAT). */
8799a2dd95SBruce Richardson 	RTE_TABLE_ACTION_NAT,
8899a2dd95SBruce Richardson 
8999a2dd95SBruce Richardson 	/** Time to Live (TTL) update. */
9099a2dd95SBruce Richardson 	RTE_TABLE_ACTION_TTL,
9199a2dd95SBruce Richardson 
9299a2dd95SBruce Richardson 	/** Statistics. */
9399a2dd95SBruce Richardson 	RTE_TABLE_ACTION_STATS,
9499a2dd95SBruce Richardson 
9599a2dd95SBruce Richardson 	/** Timestamp. */
9699a2dd95SBruce Richardson 	RTE_TABLE_ACTION_TIME,
9799a2dd95SBruce Richardson 
9899a2dd95SBruce Richardson 	/** Crypto. */
9999a2dd95SBruce Richardson 	RTE_TABLE_ACTION_SYM_CRYPTO,
10099a2dd95SBruce Richardson 
10199a2dd95SBruce Richardson 	/** Tag. */
10299a2dd95SBruce Richardson 	RTE_TABLE_ACTION_TAG,
10399a2dd95SBruce Richardson 
10499a2dd95SBruce Richardson 	/** Packet decapsulations. */
10599a2dd95SBruce Richardson 	RTE_TABLE_ACTION_DECAP,
10699a2dd95SBruce Richardson };
10799a2dd95SBruce Richardson 
10899a2dd95SBruce Richardson /** Common action configuration (per table action profile). */
10999a2dd95SBruce Richardson struct rte_table_action_common_config {
11099a2dd95SBruce Richardson 	/** Input packet Internet Protocol (IP) version. Non-zero for IPv4, zero
11199a2dd95SBruce Richardson 	 * for IPv6.
11299a2dd95SBruce Richardson 	 */
11399a2dd95SBruce Richardson 	int ip_version;
11499a2dd95SBruce Richardson 
11599a2dd95SBruce Richardson 	/** IP header offset within the input packet buffer. Offset 0 points to
11699a2dd95SBruce Richardson 	 * the first byte of the MBUF structure.
11799a2dd95SBruce Richardson 	 */
11899a2dd95SBruce Richardson 	uint32_t ip_offset;
11999a2dd95SBruce Richardson };
12099a2dd95SBruce Richardson 
12199a2dd95SBruce Richardson /**
12299a2dd95SBruce Richardson  * RTE_TABLE_ACTION_FWD
12399a2dd95SBruce Richardson  */
12499a2dd95SBruce Richardson /** Forward action parameters (per table rule). */
12599a2dd95SBruce Richardson struct rte_table_action_fwd_params {
12699a2dd95SBruce Richardson 	/** Forward action. */
12799a2dd95SBruce Richardson 	enum rte_pipeline_action action;
12899a2dd95SBruce Richardson 
12999a2dd95SBruce Richardson 	/** Pipeline table ID or output port ID. */
13099a2dd95SBruce Richardson 	uint32_t id;
13199a2dd95SBruce Richardson };
13299a2dd95SBruce Richardson 
13399a2dd95SBruce Richardson /**
13499a2dd95SBruce Richardson  * RTE_TABLE_ACTION_LB
13599a2dd95SBruce Richardson  */
13699a2dd95SBruce Richardson /** Load balance key size min (number of bytes). */
13799a2dd95SBruce Richardson #define RTE_TABLE_ACTION_LB_KEY_SIZE_MIN                    8
13899a2dd95SBruce Richardson 
13999a2dd95SBruce Richardson /** Load balance key size max (number of bytes). */
14099a2dd95SBruce Richardson #define RTE_TABLE_ACTION_LB_KEY_SIZE_MAX                    64
14199a2dd95SBruce Richardson 
14299a2dd95SBruce Richardson /** Load balance table size. */
14399a2dd95SBruce Richardson #define RTE_TABLE_ACTION_LB_TABLE_SIZE                      8
14499a2dd95SBruce Richardson 
14599a2dd95SBruce Richardson /** Load balance action configuration (per table action profile). */
14699a2dd95SBruce Richardson struct rte_table_action_lb_config {
14799a2dd95SBruce Richardson 	/** Key size (number of bytes). */
14899a2dd95SBruce Richardson 	uint32_t key_size;
14999a2dd95SBruce Richardson 
15099a2dd95SBruce Richardson 	/** Key offset within the input packet buffer. Offset 0 points to the
15199a2dd95SBruce Richardson 	 * first byte of the MBUF structure.
15299a2dd95SBruce Richardson 	 */
15399a2dd95SBruce Richardson 	uint32_t key_offset;
15499a2dd95SBruce Richardson 
15599a2dd95SBruce Richardson 	/** Key mask (*key_size* bytes are valid). */
15699a2dd95SBruce Richardson 	uint8_t key_mask[RTE_TABLE_ACTION_LB_KEY_SIZE_MAX];
15799a2dd95SBruce Richardson 
15899a2dd95SBruce Richardson 	/** Hash function. */
15999a2dd95SBruce Richardson 	rte_table_hash_op_hash f_hash;
16099a2dd95SBruce Richardson 
16199a2dd95SBruce Richardson 	/** Seed value for *f_hash*. */
16299a2dd95SBruce Richardson 	uint64_t seed;
16399a2dd95SBruce Richardson 
16499a2dd95SBruce Richardson 	/** Output value offset within the input packet buffer. Offset 0 points
16599a2dd95SBruce Richardson 	 * to the first byte of the MBUF structure.
16699a2dd95SBruce Richardson 	 */
16799a2dd95SBruce Richardson 	uint32_t out_offset;
16899a2dd95SBruce Richardson };
16999a2dd95SBruce Richardson 
17099a2dd95SBruce Richardson /** Load balance action parameters (per table rule). */
17199a2dd95SBruce Richardson struct rte_table_action_lb_params {
17299a2dd95SBruce Richardson 	/** Table defining the output values and their weights. The weights are
17399a2dd95SBruce Richardson 	 * set in 1/RTE_TABLE_ACTION_LB_TABLE_SIZE increments. To assign a
17499a2dd95SBruce Richardson 	 * weight of N/RTE_TABLE_ACTION_LB_TABLE_SIZE to a given output value
17599a2dd95SBruce Richardson 	 * (0 <= N <= RTE_TABLE_ACTION_LB_TABLE_SIZE), the same output value
17699a2dd95SBruce Richardson 	 * needs to show up exactly N times in this table.
17799a2dd95SBruce Richardson 	 */
17899a2dd95SBruce Richardson 	uint32_t out[RTE_TABLE_ACTION_LB_TABLE_SIZE];
17999a2dd95SBruce Richardson };
18099a2dd95SBruce Richardson 
18199a2dd95SBruce Richardson /**
18299a2dd95SBruce Richardson  * RTE_TABLE_ACTION_MTR
18399a2dd95SBruce Richardson  */
18499a2dd95SBruce Richardson /** Max number of traffic classes (TCs). */
18599a2dd95SBruce Richardson #define RTE_TABLE_ACTION_TC_MAX                                  16
18699a2dd95SBruce Richardson 
18799a2dd95SBruce Richardson /** Max number of queues per traffic class. */
18899a2dd95SBruce Richardson #define RTE_TABLE_ACTION_TC_QUEUE_MAX                            16
18999a2dd95SBruce Richardson 
19099a2dd95SBruce Richardson /** Differentiated Services Code Point (DSCP) translation table entry. */
19199a2dd95SBruce Richardson struct rte_table_action_dscp_table_entry {
19299a2dd95SBruce Richardson 	/** Traffic class. Used by the meter or the traffic management actions.
19399a2dd95SBruce Richardson 	 * Has to be strictly smaller than *RTE_TABLE_ACTION_TC_MAX*. Traffic
19499a2dd95SBruce Richardson 	 * class 0 is the highest priority.
19599a2dd95SBruce Richardson 	 */
19699a2dd95SBruce Richardson 	uint32_t tc_id;
19799a2dd95SBruce Richardson 
19899a2dd95SBruce Richardson 	/** Traffic class queue. Used by the traffic management action. Has to
19999a2dd95SBruce Richardson 	 * be strictly smaller than *RTE_TABLE_ACTION_TC_QUEUE_MAX*.
20099a2dd95SBruce Richardson 	 */
20199a2dd95SBruce Richardson 	uint32_t tc_queue_id;
20299a2dd95SBruce Richardson 
20399a2dd95SBruce Richardson 	/** Packet color. Used by the meter action as the packet input color
20499a2dd95SBruce Richardson 	 * for the color aware mode of the traffic metering algorithm.
20599a2dd95SBruce Richardson 	 */
20699a2dd95SBruce Richardson 	enum rte_color color;
20799a2dd95SBruce Richardson };
20899a2dd95SBruce Richardson 
20999a2dd95SBruce Richardson /** DSCP translation table. */
21099a2dd95SBruce Richardson struct rte_table_action_dscp_table {
21199a2dd95SBruce Richardson 	/** Array of DSCP table entries */
21299a2dd95SBruce Richardson 	struct rte_table_action_dscp_table_entry entry[64];
21399a2dd95SBruce Richardson };
21499a2dd95SBruce Richardson 
21599a2dd95SBruce Richardson /** Supported traffic metering algorithms. */
21699a2dd95SBruce Richardson enum rte_table_action_meter_algorithm {
21799a2dd95SBruce Richardson 	/** Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */
21899a2dd95SBruce Richardson 	RTE_TABLE_ACTION_METER_SRTCM,
21999a2dd95SBruce Richardson 
22099a2dd95SBruce Richardson 	/** Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */
22199a2dd95SBruce Richardson 	RTE_TABLE_ACTION_METER_TRTCM,
22299a2dd95SBruce Richardson };
22399a2dd95SBruce Richardson 
22499a2dd95SBruce Richardson /** Traffic metering profile (configuration template). */
22599a2dd95SBruce Richardson struct rte_table_action_meter_profile {
22699a2dd95SBruce Richardson 	/** Traffic metering algorithm. */
22799a2dd95SBruce Richardson 	enum rte_table_action_meter_algorithm alg;
22899a2dd95SBruce Richardson 
22999a2dd95SBruce Richardson 	union {
23099a2dd95SBruce Richardson 		/** Only valid when *alg* is set to srTCM - IETF RFC 2697. */
23199a2dd95SBruce Richardson 		struct rte_meter_srtcm_params srtcm;
23299a2dd95SBruce Richardson 
23399a2dd95SBruce Richardson 		/** Only valid when *alg* is set to trTCM - IETF RFC 2698. */
23499a2dd95SBruce Richardson 		struct rte_meter_trtcm_params trtcm;
23599a2dd95SBruce Richardson 	};
23699a2dd95SBruce Richardson };
23799a2dd95SBruce Richardson 
23899a2dd95SBruce Richardson /** Policer actions. */
23999a2dd95SBruce Richardson enum rte_table_action_policer {
24099a2dd95SBruce Richardson 	/** Recolor the packet as green. */
24199a2dd95SBruce Richardson 	RTE_TABLE_ACTION_POLICER_COLOR_GREEN = 0,
24299a2dd95SBruce Richardson 
24399a2dd95SBruce Richardson 	/** Recolor the packet as yellow. */
24499a2dd95SBruce Richardson 	RTE_TABLE_ACTION_POLICER_COLOR_YELLOW,
24599a2dd95SBruce Richardson 
24699a2dd95SBruce Richardson 	/** Recolor the packet as red. */
24799a2dd95SBruce Richardson 	RTE_TABLE_ACTION_POLICER_COLOR_RED,
24899a2dd95SBruce Richardson 
24999a2dd95SBruce Richardson 	/** Drop the packet. */
25099a2dd95SBruce Richardson 	RTE_TABLE_ACTION_POLICER_DROP,
25199a2dd95SBruce Richardson 
25299a2dd95SBruce Richardson 	/** Number of policer actions. */
25399a2dd95SBruce Richardson 	RTE_TABLE_ACTION_POLICER_MAX
25499a2dd95SBruce Richardson };
25599a2dd95SBruce Richardson 
25699a2dd95SBruce Richardson /** Meter action configuration per traffic class. */
25799a2dd95SBruce Richardson struct rte_table_action_mtr_tc_params {
25899a2dd95SBruce Richardson 	/** Meter profile ID. */
25999a2dd95SBruce Richardson 	uint32_t meter_profile_id;
26099a2dd95SBruce Richardson 
26199a2dd95SBruce Richardson 	/** Policer actions. */
26299a2dd95SBruce Richardson 	enum rte_table_action_policer policer[RTE_COLORS];
26399a2dd95SBruce Richardson };
26499a2dd95SBruce Richardson 
26599a2dd95SBruce Richardson /** Meter action statistics counters per traffic class. */
26699a2dd95SBruce Richardson struct rte_table_action_mtr_counters_tc {
26799a2dd95SBruce Richardson 	/** Number of packets per color at the output of the traffic metering
26899a2dd95SBruce Richardson 	 * and before the policer actions are executed. Only valid when
26999a2dd95SBruce Richardson 	 * *n_packets_valid* is non-zero.
27099a2dd95SBruce Richardson 	 */
27199a2dd95SBruce Richardson 	uint64_t n_packets[RTE_COLORS];
27299a2dd95SBruce Richardson 
27399a2dd95SBruce Richardson 	/** Number of packet bytes per color at the output of the traffic
27499a2dd95SBruce Richardson 	 * metering and before the policer actions are executed. Only valid when
27599a2dd95SBruce Richardson 	 * *n_bytes_valid* is non-zero.
27699a2dd95SBruce Richardson 	 */
27799a2dd95SBruce Richardson 	uint64_t n_bytes[RTE_COLORS];
27899a2dd95SBruce Richardson 
27999a2dd95SBruce Richardson 	/** When non-zero, the *n_packets* field is valid. */
28099a2dd95SBruce Richardson 	int n_packets_valid;
28199a2dd95SBruce Richardson 
28299a2dd95SBruce Richardson 	/** When non-zero, the *n_bytes* field is valid. */
28399a2dd95SBruce Richardson 	int n_bytes_valid;
28499a2dd95SBruce Richardson };
28599a2dd95SBruce Richardson 
28699a2dd95SBruce Richardson /** Meter action configuration (per table action profile). */
28799a2dd95SBruce Richardson struct rte_table_action_mtr_config {
28899a2dd95SBruce Richardson 	/** Meter algorithm. */
28999a2dd95SBruce Richardson 	enum rte_table_action_meter_algorithm alg;
29099a2dd95SBruce Richardson 
29199a2dd95SBruce Richardson 	/** Number of traffic classes. Each traffic class has its own traffic
29299a2dd95SBruce Richardson 	 * meter and policer instances. Needs to be equal to either 1 or to
29399a2dd95SBruce Richardson 	 * *RTE_TABLE_ACTION_TC_MAX*.
29499a2dd95SBruce Richardson 	 */
29599a2dd95SBruce Richardson 	uint32_t n_tc;
29699a2dd95SBruce Richardson 
29799a2dd95SBruce Richardson 	/** When non-zero, the *n_packets* meter stats counter is enabled,
29899a2dd95SBruce Richardson 	 * otherwise it is disabled.
29999a2dd95SBruce Richardson 	 *
30099a2dd95SBruce Richardson 	 * @see struct rte_table_action_mtr_counters_tc
30199a2dd95SBruce Richardson 	 */
30299a2dd95SBruce Richardson 	int n_packets_enabled;
30399a2dd95SBruce Richardson 
30499a2dd95SBruce Richardson 	/** When non-zero, the *n_bytes* meter stats counter is enabled,
30599a2dd95SBruce Richardson 	 * otherwise it is disabled.
30699a2dd95SBruce Richardson 	 *
30799a2dd95SBruce Richardson 	 * @see struct rte_table_action_mtr_counters_tc
30899a2dd95SBruce Richardson 	 */
30999a2dd95SBruce Richardson 	int n_bytes_enabled;
31099a2dd95SBruce Richardson };
31199a2dd95SBruce Richardson 
31299a2dd95SBruce Richardson /** Meter action parameters (per table rule). */
31399a2dd95SBruce Richardson struct rte_table_action_mtr_params {
31499a2dd95SBruce Richardson 	/** Traffic meter and policer parameters for each of the *tc_mask*
31599a2dd95SBruce Richardson 	 * traffic classes.
31699a2dd95SBruce Richardson 	 */
31799a2dd95SBruce Richardson 	struct rte_table_action_mtr_tc_params mtr[RTE_TABLE_ACTION_TC_MAX];
31899a2dd95SBruce Richardson 
31999a2dd95SBruce Richardson 	/** Bit mask defining which traffic class parameters are valid in *mtr*.
32099a2dd95SBruce Richardson 	 * If bit N is set in *tc_mask*, then parameters for traffic class N are
32199a2dd95SBruce Richardson 	 * valid in *mtr*.
32299a2dd95SBruce Richardson 	 */
32399a2dd95SBruce Richardson 	uint32_t tc_mask;
32499a2dd95SBruce Richardson };
32599a2dd95SBruce Richardson 
32699a2dd95SBruce Richardson /** Meter action statistics counters (per table rule). */
32799a2dd95SBruce Richardson struct rte_table_action_mtr_counters {
32899a2dd95SBruce Richardson 	/** Stats counters for each of the *tc_mask* traffic classes. */
32999a2dd95SBruce Richardson 	struct rte_table_action_mtr_counters_tc stats[RTE_TABLE_ACTION_TC_MAX];
33099a2dd95SBruce Richardson 
33199a2dd95SBruce Richardson 	/** Bit mask defining which traffic class parameters are valid in *mtr*.
33299a2dd95SBruce Richardson 	 * If bit N is set in *tc_mask*, then parameters for traffic class N are
33399a2dd95SBruce Richardson 	 * valid in *mtr*.
33499a2dd95SBruce Richardson 	 */
33599a2dd95SBruce Richardson 	uint32_t tc_mask;
33699a2dd95SBruce Richardson };
33799a2dd95SBruce Richardson 
33899a2dd95SBruce Richardson /**
33999a2dd95SBruce Richardson  * RTE_TABLE_ACTION_TM
34099a2dd95SBruce Richardson  */
34199a2dd95SBruce Richardson /** Traffic management action configuration (per table action profile). */
34299a2dd95SBruce Richardson struct rte_table_action_tm_config {
34399a2dd95SBruce Richardson 	/** Number of subports per port. */
34499a2dd95SBruce Richardson 	uint32_t n_subports_per_port;
34599a2dd95SBruce Richardson 
34699a2dd95SBruce Richardson 	/** Number of pipes per subport. */
34799a2dd95SBruce Richardson 	uint32_t n_pipes_per_subport;
34899a2dd95SBruce Richardson };
34999a2dd95SBruce Richardson 
35099a2dd95SBruce Richardson /** Traffic management action parameters (per table rule). */
35199a2dd95SBruce Richardson struct rte_table_action_tm_params {
35299a2dd95SBruce Richardson 	/** Subport ID. */
35399a2dd95SBruce Richardson 	uint32_t subport_id;
35499a2dd95SBruce Richardson 
35599a2dd95SBruce Richardson 	/** Pipe ID. */
35699a2dd95SBruce Richardson 	uint32_t pipe_id;
35799a2dd95SBruce Richardson };
35899a2dd95SBruce Richardson 
35999a2dd95SBruce Richardson /**
36099a2dd95SBruce Richardson  * RTE_TABLE_ACTION_ENCAP
36199a2dd95SBruce Richardson  */
36299a2dd95SBruce Richardson /** Supported packet encapsulation types. */
36399a2dd95SBruce Richardson enum rte_table_action_encap_type {
36499a2dd95SBruce Richardson 	/** IP -> { Ether | IP } */
36599a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_ETHER = 0,
36699a2dd95SBruce Richardson 
36799a2dd95SBruce Richardson 	/** IP -> { Ether | VLAN | IP } */
36899a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_VLAN,
36999a2dd95SBruce Richardson 
37099a2dd95SBruce Richardson 	/** IP -> { Ether | S-VLAN | C-VLAN | IP } */
37199a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_QINQ,
37299a2dd95SBruce Richardson 
37399a2dd95SBruce Richardson 	/** IP -> { Ether | MPLS | IP } */
37499a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_MPLS,
37599a2dd95SBruce Richardson 
37699a2dd95SBruce Richardson 	/** IP -> { Ether | PPPoE | PPP | IP } */
37799a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_PPPOE,
37899a2dd95SBruce Richardson 
37999a2dd95SBruce Richardson 	/** Ether -> { Ether | IP | UDP | VXLAN | Ether }
38099a2dd95SBruce Richardson 	 * Ether -> { Ether | VLAN | IP | UDP | VXLAN | Ether }
38199a2dd95SBruce Richardson 	 */
38299a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_VXLAN,
38399a2dd95SBruce Richardson 
38499a2dd95SBruce Richardson 	/** IP -> { Ether | S-VLAN | C-VLAN | PPPoE | PPP | IP } */
38599a2dd95SBruce Richardson 	RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE,
38699a2dd95SBruce Richardson };
38799a2dd95SBruce Richardson 
38899a2dd95SBruce Richardson /** Pre-computed Ethernet header fields for encapsulation action. */
38999a2dd95SBruce Richardson struct rte_table_action_ether_hdr {
39099a2dd95SBruce Richardson 	struct rte_ether_addr da; /**< Destination address. */
39199a2dd95SBruce Richardson 	struct rte_ether_addr sa; /**< Source address. */
39299a2dd95SBruce Richardson };
39399a2dd95SBruce Richardson 
39499a2dd95SBruce Richardson /** Pre-computed VLAN header fields for encapsulation action. */
39599a2dd95SBruce Richardson struct rte_table_action_vlan_hdr {
39699a2dd95SBruce Richardson 	uint8_t pcp; /**< Priority Code Point (PCP). */
39799a2dd95SBruce Richardson 	uint8_t dei; /**< Drop Eligibility Indicator (DEI). */
39899a2dd95SBruce Richardson 	uint16_t vid; /**< VLAN Identifier (VID). */
39999a2dd95SBruce Richardson };
40099a2dd95SBruce Richardson 
40199a2dd95SBruce Richardson /** Pre-computed MPLS header fields for encapsulation action. */
40299a2dd95SBruce Richardson struct rte_table_action_mpls_hdr {
40399a2dd95SBruce Richardson 	uint32_t label; /**< Label. */
40499a2dd95SBruce Richardson 	uint8_t tc; /**< Traffic Class (TC). */
40599a2dd95SBruce Richardson 	uint8_t ttl; /**< Time to Live (TTL). */
40699a2dd95SBruce Richardson };
40799a2dd95SBruce Richardson 
40899a2dd95SBruce Richardson /** Pre-computed PPPoE header fields for encapsulation action. */
40999a2dd95SBruce Richardson struct rte_table_action_pppoe_hdr {
41099a2dd95SBruce Richardson 	uint16_t session_id; /**< Session ID. */
41199a2dd95SBruce Richardson };
41299a2dd95SBruce Richardson 
41399a2dd95SBruce Richardson /** Pre-computed IPv4 header fields for encapsulation action. */
41499a2dd95SBruce Richardson struct rte_table_action_ipv4_header {
41599a2dd95SBruce Richardson 	uint32_t sa; /**< Source address. */
41699a2dd95SBruce Richardson 	uint32_t da; /**< Destination address. */
41799a2dd95SBruce Richardson 	uint8_t dscp; /**< DiffServ Code Point (DSCP). */
41899a2dd95SBruce Richardson 	uint8_t ttl; /**< Time To Live (TTL). */
41999a2dd95SBruce Richardson };
42099a2dd95SBruce Richardson 
42199a2dd95SBruce Richardson /** Pre-computed IPv6 header fields for encapsulation action. */
42299a2dd95SBruce Richardson struct rte_table_action_ipv6_header {
423*5ac1abddSRobin Jarry 	struct rte_ipv6_addr sa; /**< Source address. */
424*5ac1abddSRobin Jarry 	struct rte_ipv6_addr da; /**< Destination address. */
42599a2dd95SBruce Richardson 	uint32_t flow_label; /**< Flow label. */
42699a2dd95SBruce Richardson 	uint8_t dscp; /**< DiffServ Code Point (DSCP). */
42799a2dd95SBruce Richardson 	uint8_t hop_limit; /**< Hop Limit (HL). */
42899a2dd95SBruce Richardson };
42999a2dd95SBruce Richardson 
43099a2dd95SBruce Richardson /** Pre-computed UDP header fields for encapsulation action. */
43199a2dd95SBruce Richardson struct rte_table_action_udp_header {
43299a2dd95SBruce Richardson 	uint16_t sp; /**< Source port. */
43399a2dd95SBruce Richardson 	uint16_t dp; /**< Destination port. */
43499a2dd95SBruce Richardson };
43599a2dd95SBruce Richardson 
43699a2dd95SBruce Richardson /** Pre-computed VXLAN header fields for encapsulation action. */
43799a2dd95SBruce Richardson struct rte_table_action_vxlan_hdr {
43899a2dd95SBruce Richardson 	uint32_t vni; /**< VXLAN Network Identifier (VNI). */
43999a2dd95SBruce Richardson };
44099a2dd95SBruce Richardson 
44199a2dd95SBruce Richardson /** Ether encap parameters. */
44299a2dd95SBruce Richardson struct rte_table_action_encap_ether_params {
44399a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
44499a2dd95SBruce Richardson };
44599a2dd95SBruce Richardson 
44699a2dd95SBruce Richardson /** VLAN encap parameters. */
44799a2dd95SBruce Richardson struct rte_table_action_encap_vlan_params {
44899a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
44999a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr vlan; /**< VLAN header. */
45099a2dd95SBruce Richardson };
45199a2dd95SBruce Richardson 
45299a2dd95SBruce Richardson /** QinQ encap parameters. */
45399a2dd95SBruce Richardson struct rte_table_action_encap_qinq_params {
45499a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
45599a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr svlan; /**< Service VLAN header. */
45699a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr cvlan; /**< Customer VLAN header. */
45799a2dd95SBruce Richardson };
45899a2dd95SBruce Richardson 
45999a2dd95SBruce Richardson /** Max number of MPLS labels per output packet for MPLS encapsulation. */
46099a2dd95SBruce Richardson #ifndef RTE_TABLE_ACTION_MPLS_LABELS_MAX
46199a2dd95SBruce Richardson #define RTE_TABLE_ACTION_MPLS_LABELS_MAX                   4
46299a2dd95SBruce Richardson #endif
46399a2dd95SBruce Richardson 
46499a2dd95SBruce Richardson /** MPLS encap parameters. */
46599a2dd95SBruce Richardson struct rte_table_action_encap_mpls_params {
46699a2dd95SBruce Richardson 	/** Ethernet header. */
46799a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether;
46899a2dd95SBruce Richardson 
46999a2dd95SBruce Richardson 	/** MPLS header. */
47099a2dd95SBruce Richardson 	struct rte_table_action_mpls_hdr mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
47199a2dd95SBruce Richardson 
47299a2dd95SBruce Richardson 	/** Number of MPLS labels in MPLS header. */
47399a2dd95SBruce Richardson 	uint32_t mpls_count;
47499a2dd95SBruce Richardson 
47599a2dd95SBruce Richardson 	/** Non-zero for MPLS unicast, zero for MPLS multicast. */
47699a2dd95SBruce Richardson 	int unicast;
47799a2dd95SBruce Richardson };
47899a2dd95SBruce Richardson 
47999a2dd95SBruce Richardson /** PPPoE encap parameters. */
48099a2dd95SBruce Richardson struct rte_table_action_encap_pppoe_params {
48199a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
48299a2dd95SBruce Richardson 	struct rte_table_action_pppoe_hdr pppoe; /**< PPPoE/PPP headers. */
48399a2dd95SBruce Richardson };
48499a2dd95SBruce Richardson 
48599a2dd95SBruce Richardson /** VXLAN encap parameters. */
48699a2dd95SBruce Richardson struct rte_table_action_encap_vxlan_params {
48799a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
48899a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr vlan; /**< VLAN header. */
48999a2dd95SBruce Richardson 
49099a2dd95SBruce Richardson 	union {
49199a2dd95SBruce Richardson 		struct rte_table_action_ipv4_header ipv4; /**< IPv4 header. */
49299a2dd95SBruce Richardson 		struct rte_table_action_ipv6_header ipv6; /**< IPv6 header. */
49399a2dd95SBruce Richardson 	};
49499a2dd95SBruce Richardson 
49599a2dd95SBruce Richardson 	struct rte_table_action_udp_header udp; /**< UDP header. */
49699a2dd95SBruce Richardson 	struct rte_table_action_vxlan_hdr vxlan; /**< VXLAN header. */
49799a2dd95SBruce Richardson };
49899a2dd95SBruce Richardson 
49999a2dd95SBruce Richardson /** Encap action configuration (per table action profile). */
50099a2dd95SBruce Richardson struct rte_table_action_encap_config {
50199a2dd95SBruce Richardson 	/** Bit mask defining the set of packet encapsulations enabled for the
50299a2dd95SBruce Richardson 	 * current table action profile. If bit (1 << N) is set in *encap_mask*,
50399a2dd95SBruce Richardson 	 * then packet encapsulation N is enabled, otherwise it is disabled.
50499a2dd95SBruce Richardson 	 *
50599a2dd95SBruce Richardson 	 * @see enum rte_table_action_encap_type
50699a2dd95SBruce Richardson 	 */
50799a2dd95SBruce Richardson 	uint64_t encap_mask;
50899a2dd95SBruce Richardson 
50999a2dd95SBruce Richardson 	/** Encapsulation type specific configuration. */
51099a2dd95SBruce Richardson 	union {
51199a2dd95SBruce Richardson 		struct {
51299a2dd95SBruce Richardson 			/** Input packet to be encapsulated: offset within the
51399a2dd95SBruce Richardson 			 * input packet buffer to the start of the Ethernet
51499a2dd95SBruce Richardson 			 * frame to be encapsulated. Offset 0 points to the
51599a2dd95SBruce Richardson 			 * first byte of the MBUF structure.
51699a2dd95SBruce Richardson 			 */
51799a2dd95SBruce Richardson 			uint32_t data_offset;
51899a2dd95SBruce Richardson 
51999a2dd95SBruce Richardson 			/** Encapsulation header: non-zero when encapsulation
52099a2dd95SBruce Richardson 			 * header includes a VLAN tag, zero otherwise.
52199a2dd95SBruce Richardson 			 */
52299a2dd95SBruce Richardson 			int vlan;
52399a2dd95SBruce Richardson 
52499a2dd95SBruce Richardson 			/** Encapsulation header: IP version of the IP header
52599a2dd95SBruce Richardson 			 * within the encapsulation header. Non-zero for IPv4,
52699a2dd95SBruce Richardson 			 * zero for IPv6.
52799a2dd95SBruce Richardson 			 */
52899a2dd95SBruce Richardson 			int ip_version;
52999a2dd95SBruce Richardson 		} vxlan; /**< VXLAN specific configuration. */
53099a2dd95SBruce Richardson 	};
53199a2dd95SBruce Richardson };
53299a2dd95SBruce Richardson 
53399a2dd95SBruce Richardson /** QinQ_PPPoE encap parameters. */
53499a2dd95SBruce Richardson struct rte_table_encap_ether_qinq_pppoe {
53599a2dd95SBruce Richardson 
53699a2dd95SBruce Richardson 	/** Only valid when *type* is set to QinQ. */
53799a2dd95SBruce Richardson 	struct rte_table_action_ether_hdr ether;
53899a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr svlan; /**< Service VLAN header. */
53999a2dd95SBruce Richardson 	struct rte_table_action_vlan_hdr cvlan; /**< Customer VLAN header. */
54099a2dd95SBruce Richardson 	struct rte_table_action_pppoe_hdr pppoe; /**< PPPoE/PPP headers. */
54199a2dd95SBruce Richardson };
54299a2dd95SBruce Richardson 
54399a2dd95SBruce Richardson /** Encap action parameters (per table rule). */
54499a2dd95SBruce Richardson struct rte_table_action_encap_params {
54599a2dd95SBruce Richardson 	/** Encapsulation type. */
54699a2dd95SBruce Richardson 	enum rte_table_action_encap_type type;
54799a2dd95SBruce Richardson 
54899a2dd95SBruce Richardson 	union {
54999a2dd95SBruce Richardson 		/** Only valid when *type* is set to Ether. */
55099a2dd95SBruce Richardson 		struct rte_table_action_encap_ether_params ether;
55199a2dd95SBruce Richardson 
55299a2dd95SBruce Richardson 		/** Only valid when *type* is set to VLAN. */
55399a2dd95SBruce Richardson 		struct rte_table_action_encap_vlan_params vlan;
55499a2dd95SBruce Richardson 
55599a2dd95SBruce Richardson 		/** Only valid when *type* is set to QinQ. */
55699a2dd95SBruce Richardson 		struct rte_table_action_encap_qinq_params qinq;
55799a2dd95SBruce Richardson 
55899a2dd95SBruce Richardson 		/** Only valid when *type* is set to MPLS. */
55999a2dd95SBruce Richardson 		struct rte_table_action_encap_mpls_params mpls;
56099a2dd95SBruce Richardson 
56199a2dd95SBruce Richardson 		/** Only valid when *type* is set to PPPoE. */
56299a2dd95SBruce Richardson 		struct rte_table_action_encap_pppoe_params pppoe;
56399a2dd95SBruce Richardson 
56499a2dd95SBruce Richardson 		/** Only valid when *type* is set to VXLAN. */
56599a2dd95SBruce Richardson 		struct rte_table_action_encap_vxlan_params vxlan;
56699a2dd95SBruce Richardson 
56799a2dd95SBruce Richardson 		/** Only valid when *type* is set to QinQ_PPPoE. */
56899a2dd95SBruce Richardson 		struct rte_table_encap_ether_qinq_pppoe qinq_pppoe;
56999a2dd95SBruce Richardson 	};
57099a2dd95SBruce Richardson };
57199a2dd95SBruce Richardson 
57299a2dd95SBruce Richardson /**
57399a2dd95SBruce Richardson  * RTE_TABLE_ACTION_NAT
57499a2dd95SBruce Richardson  */
57599a2dd95SBruce Richardson /** NAT action configuration (per table action profile). */
57699a2dd95SBruce Richardson struct rte_table_action_nat_config {
57799a2dd95SBruce Richardson 	/** When non-zero, the IP source address and L4 protocol source port are
57899a2dd95SBruce Richardson 	 * translated. When zero, the IP destination address and L4 protocol
57999a2dd95SBruce Richardson 	 * destination port are translated.
58099a2dd95SBruce Richardson 	 */
58199a2dd95SBruce Richardson 	int source_nat;
58299a2dd95SBruce Richardson 
58399a2dd95SBruce Richardson 	/** Layer 4 protocol, for example TCP (0x06) or UDP (0x11). The checksum
58499a2dd95SBruce Richardson 	 * field is computed differently and placed at different header offset
58599a2dd95SBruce Richardson 	 * by each layer 4 protocol.
58699a2dd95SBruce Richardson 	 */
58799a2dd95SBruce Richardson 	uint8_t proto;
58899a2dd95SBruce Richardson };
58999a2dd95SBruce Richardson 
59099a2dd95SBruce Richardson /** NAT action parameters (per table rule). */
59199a2dd95SBruce Richardson struct rte_table_action_nat_params {
59299a2dd95SBruce Richardson 	/** IP version for *addr*: non-zero for IPv4, zero for IPv6. */
59399a2dd95SBruce Richardson 	int ip_version;
59499a2dd95SBruce Richardson 
59599a2dd95SBruce Richardson 	/** IP address. */
59699a2dd95SBruce Richardson 	union {
59799a2dd95SBruce Richardson 		/** IPv4 address; only valid when *ip_version* is non-zero. */
59899a2dd95SBruce Richardson 		uint32_t ipv4;
59999a2dd95SBruce Richardson 
60099a2dd95SBruce Richardson 		/** IPv6 address; only valid when *ip_version* is set to 0. */
601*5ac1abddSRobin Jarry 		struct rte_ipv6_addr ipv6;
60299a2dd95SBruce Richardson 	} addr;
60399a2dd95SBruce Richardson 
60499a2dd95SBruce Richardson 	/** Port. */
60599a2dd95SBruce Richardson 	uint16_t port;
60699a2dd95SBruce Richardson };
60799a2dd95SBruce Richardson 
60899a2dd95SBruce Richardson /**
60999a2dd95SBruce Richardson  * RTE_TABLE_ACTION_TTL
61099a2dd95SBruce Richardson  */
61199a2dd95SBruce Richardson /** TTL action configuration (per table action profile). */
61299a2dd95SBruce Richardson struct rte_table_action_ttl_config {
61399a2dd95SBruce Richardson 	/** When non-zero, the input packets whose updated IPv4 Time to Live
61499a2dd95SBruce Richardson 	 * (TTL) field or IPv6 Hop Limit (HL) field is zero are dropped.
61599a2dd95SBruce Richardson 	 * When zero, the input packets whose updated IPv4 TTL field or IPv6 HL
61699a2dd95SBruce Richardson 	 * field is zero are forwarded as usual (typically for debugging
61799a2dd95SBruce Richardson 	 * purpose).
61899a2dd95SBruce Richardson 	 */
61999a2dd95SBruce Richardson 	int drop;
62099a2dd95SBruce Richardson 
62199a2dd95SBruce Richardson 	/** When non-zero, the *n_packets* stats counter for TTL action is
62299a2dd95SBruce Richardson 	 * enabled, otherwise disabled.
62399a2dd95SBruce Richardson 	 *
62499a2dd95SBruce Richardson 	 * @see struct rte_table_action_ttl_counters
62599a2dd95SBruce Richardson 	 */
62699a2dd95SBruce Richardson 	int n_packets_enabled;
62799a2dd95SBruce Richardson };
62899a2dd95SBruce Richardson 
62999a2dd95SBruce Richardson /** TTL action parameters (per table rule). */
63099a2dd95SBruce Richardson struct rte_table_action_ttl_params {
63199a2dd95SBruce Richardson 	/** When non-zero, decrement the IPv4 TTL field and update the checksum
63299a2dd95SBruce Richardson 	 * field, or decrement the IPv6 HL field. When zero, the IPv4 TTL field
63399a2dd95SBruce Richardson 	 * or the IPv6 HL field is not changed.
63499a2dd95SBruce Richardson 	 */
63599a2dd95SBruce Richardson 	int decrement;
63699a2dd95SBruce Richardson };
63799a2dd95SBruce Richardson 
63899a2dd95SBruce Richardson /** TTL action statistics packets (per table rule). */
63999a2dd95SBruce Richardson struct rte_table_action_ttl_counters {
64099a2dd95SBruce Richardson 	/** Number of IPv4 packets whose updated TTL field is zero or IPv6
64199a2dd95SBruce Richardson 	 * packets whose updated HL field is zero.
64299a2dd95SBruce Richardson 	 */
64399a2dd95SBruce Richardson 	uint64_t n_packets;
64499a2dd95SBruce Richardson };
64599a2dd95SBruce Richardson 
64699a2dd95SBruce Richardson /**
64799a2dd95SBruce Richardson  * RTE_TABLE_ACTION_STATS
64899a2dd95SBruce Richardson  */
64999a2dd95SBruce Richardson /** Stats action configuration (per table action profile). */
65099a2dd95SBruce Richardson struct rte_table_action_stats_config {
65199a2dd95SBruce Richardson 	/** When non-zero, the *n_packets* stats counter is enabled, otherwise
65299a2dd95SBruce Richardson 	 * disabled.
65399a2dd95SBruce Richardson 	 *
65499a2dd95SBruce Richardson 	 * @see struct rte_table_action_stats_counters
65599a2dd95SBruce Richardson 	 */
65699a2dd95SBruce Richardson 	int n_packets_enabled;
65799a2dd95SBruce Richardson 
65899a2dd95SBruce Richardson 	/** When non-zero, the *n_bytes* stats counter is enabled, otherwise
65999a2dd95SBruce Richardson 	 * disabled.
66099a2dd95SBruce Richardson 	 *
66199a2dd95SBruce Richardson 	 * @see struct rte_table_action_stats_counters
66299a2dd95SBruce Richardson 	 */
66399a2dd95SBruce Richardson 	int n_bytes_enabled;
66499a2dd95SBruce Richardson };
66599a2dd95SBruce Richardson 
66699a2dd95SBruce Richardson /** Stats action parameters (per table rule). */
66799a2dd95SBruce Richardson struct rte_table_action_stats_params {
66899a2dd95SBruce Richardson 	/** Initial value for the *n_packets* stats counter. Typically set to 0.
66999a2dd95SBruce Richardson 	 *
67099a2dd95SBruce Richardson 	 * @see struct rte_table_action_stats_counters
67199a2dd95SBruce Richardson 	 */
67299a2dd95SBruce Richardson 	uint64_t n_packets;
67399a2dd95SBruce Richardson 
67499a2dd95SBruce Richardson 	/** Initial value for the *n_bytes* stats counter. Typically set to 0.
67599a2dd95SBruce Richardson 	 *
67699a2dd95SBruce Richardson 	 * @see struct rte_table_action_stats_counters
67799a2dd95SBruce Richardson 	 */
67899a2dd95SBruce Richardson 	uint64_t n_bytes;
67999a2dd95SBruce Richardson };
68099a2dd95SBruce Richardson 
68199a2dd95SBruce Richardson /** Stats action counters (per table rule). */
68299a2dd95SBruce Richardson struct rte_table_action_stats_counters {
68399a2dd95SBruce Richardson 	/** Number of packets. Valid only when *n_packets_valid* is non-zero. */
68499a2dd95SBruce Richardson 	uint64_t n_packets;
68599a2dd95SBruce Richardson 
68699a2dd95SBruce Richardson 	/** Number of bytes. Valid only when *n_bytes_valid* is non-zero. */
68799a2dd95SBruce Richardson 	uint64_t n_bytes;
68899a2dd95SBruce Richardson 
68999a2dd95SBruce Richardson 	/** When non-zero, the *n_packets* field is valid, otherwise invalid. */
69099a2dd95SBruce Richardson 	int n_packets_valid;
69199a2dd95SBruce Richardson 
69299a2dd95SBruce Richardson 	/** When non-zero, the *n_bytes* field is valid, otherwise invalid. */
69399a2dd95SBruce Richardson 	int n_bytes_valid;
69499a2dd95SBruce Richardson };
69599a2dd95SBruce Richardson 
69699a2dd95SBruce Richardson /**
69799a2dd95SBruce Richardson  * RTE_TABLE_ACTION_TIME
69899a2dd95SBruce Richardson  */
69999a2dd95SBruce Richardson /** Timestamp action parameters (per table rule). */
70099a2dd95SBruce Richardson struct rte_table_action_time_params {
70199a2dd95SBruce Richardson 	/** Initial timestamp value. Typically set to current time. */
70299a2dd95SBruce Richardson 	uint64_t time;
70399a2dd95SBruce Richardson };
70499a2dd95SBruce Richardson 
70599a2dd95SBruce Richardson /**
70699a2dd95SBruce Richardson  * RTE_TABLE_ACTION_CRYPTO
70799a2dd95SBruce Richardson  */
70899a2dd95SBruce Richardson #ifndef RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX
70999a2dd95SBruce Richardson #define RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX		(16)
71099a2dd95SBruce Richardson #endif
71199a2dd95SBruce Richardson 
71299a2dd95SBruce Richardson #ifndef RTE_TABLE_ACTION_SYM_CRYPTO_AAD_SIZE_MAX
71399a2dd95SBruce Richardson #define RTE_TABLE_ACTION_SYM_CRYPTO_AAD_SIZE_MAX	(16)
71499a2dd95SBruce Richardson #endif
71599a2dd95SBruce Richardson 
71699a2dd95SBruce Richardson #ifndef RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET
71799a2dd95SBruce Richardson #define RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET				\
71899a2dd95SBruce Richardson 	(sizeof(struct rte_crypto_op) + sizeof(struct rte_crypto_sym_op))
71999a2dd95SBruce Richardson #endif
72099a2dd95SBruce Richardson 
72199a2dd95SBruce Richardson /** Common action structure to store the data's value, length, and offset */
72299a2dd95SBruce Richardson struct rte_table_action_vlo {
72399a2dd95SBruce Richardson 	uint8_t *val;
72499a2dd95SBruce Richardson 	uint32_t length;
72599a2dd95SBruce Richardson 	uint32_t offset;
72699a2dd95SBruce Richardson };
72799a2dd95SBruce Richardson 
72899a2dd95SBruce Richardson /** Symmetric crypto action configuration (per table action profile). */
72999a2dd95SBruce Richardson struct rte_table_action_sym_crypto_config {
73099a2dd95SBruce Richardson 	/** Target Cryptodev ID. */
73199a2dd95SBruce Richardson 	uint8_t cryptodev_id;
73299a2dd95SBruce Richardson 
73399a2dd95SBruce Richardson 	/**
73499a2dd95SBruce Richardson 	 * Offset to rte_crypto_op structure within the input packet buffer.
73599a2dd95SBruce Richardson 	 * Offset 0 points to the first byte of the MBUF structure.
73699a2dd95SBruce Richardson 	 */
73799a2dd95SBruce Richardson 	uint32_t op_offset;
73899a2dd95SBruce Richardson 
73999a2dd95SBruce Richardson 	/** The mempool for creating cryptodev sessions. */
74099a2dd95SBruce Richardson 	struct rte_mempool *mp_create;
74199a2dd95SBruce Richardson 
74299a2dd95SBruce Richardson 	/** The mempool for initializing cryptodev sessions. */
74399a2dd95SBruce Richardson 	struct rte_mempool *mp_init;
74499a2dd95SBruce Richardson };
74599a2dd95SBruce Richardson 
74699a2dd95SBruce Richardson /** Symmetric Crypto action parameters (per table rule). */
74799a2dd95SBruce Richardson struct rte_table_action_sym_crypto_params {
74899a2dd95SBruce Richardson 
74999a2dd95SBruce Richardson 	/** Xform pointer contains all relevant information */
75099a2dd95SBruce Richardson 	struct rte_crypto_sym_xform *xform;
75199a2dd95SBruce Richardson 
75299a2dd95SBruce Richardson 	/**
75399a2dd95SBruce Richardson 	 * Offset within the input packet buffer to the first byte of data
75499a2dd95SBruce Richardson 	 * to be processed by the crypto unit. Offset 0 points to the first
75599a2dd95SBruce Richardson 	 * byte of the MBUF structure.
75699a2dd95SBruce Richardson 	 */
75799a2dd95SBruce Richardson 	uint32_t data_offset;
75899a2dd95SBruce Richardson 
75999a2dd95SBruce Richardson 	union {
76099a2dd95SBruce Richardson 		struct {
76199a2dd95SBruce Richardson 			/** Cipher iv data. */
76299a2dd95SBruce Richardson 			struct rte_table_action_vlo cipher_iv;
76399a2dd95SBruce Richardson 
76499a2dd95SBruce Richardson 			/** Cipher iv data. */
76599a2dd95SBruce Richardson 			struct rte_table_action_vlo cipher_iv_update;
76699a2dd95SBruce Richardson 
76799a2dd95SBruce Richardson 			/** Auth iv data. */
76899a2dd95SBruce Richardson 			struct rte_table_action_vlo auth_iv;
76999a2dd95SBruce Richardson 
77099a2dd95SBruce Richardson 			/** Auth iv data. */
77199a2dd95SBruce Richardson 			struct rte_table_action_vlo auth_iv_update;
77299a2dd95SBruce Richardson 
77399a2dd95SBruce Richardson 		} cipher_auth;
77499a2dd95SBruce Richardson 
77599a2dd95SBruce Richardson 		struct {
77699a2dd95SBruce Richardson 			/** AEAD AAD data. */
77799a2dd95SBruce Richardson 			struct rte_table_action_vlo aad;
77899a2dd95SBruce Richardson 
77999a2dd95SBruce Richardson 			/** AEAD iv data. */
78099a2dd95SBruce Richardson 			struct rte_table_action_vlo iv;
78199a2dd95SBruce Richardson 
78299a2dd95SBruce Richardson 			/** AEAD AAD data. */
78399a2dd95SBruce Richardson 			struct rte_table_action_vlo aad_update;
78499a2dd95SBruce Richardson 
78599a2dd95SBruce Richardson 			/** AEAD iv data. */
78699a2dd95SBruce Richardson 			struct rte_table_action_vlo iv_update;
78799a2dd95SBruce Richardson 
78899a2dd95SBruce Richardson 		} aead;
78999a2dd95SBruce Richardson 	};
79099a2dd95SBruce Richardson };
79199a2dd95SBruce Richardson 
79299a2dd95SBruce Richardson /**
79399a2dd95SBruce Richardson  * RTE_TABLE_ACTION_TAG
79499a2dd95SBruce Richardson  */
79599a2dd95SBruce Richardson /** Tag action parameters (per table rule). */
79699a2dd95SBruce Richardson struct rte_table_action_tag_params {
79799a2dd95SBruce Richardson 	/** Tag to be attached to the input packet. */
79899a2dd95SBruce Richardson 	uint32_t tag;
79999a2dd95SBruce Richardson };
80099a2dd95SBruce Richardson 
80199a2dd95SBruce Richardson /**
80299a2dd95SBruce Richardson  * RTE_TABLE_ACTION_DECAP
80399a2dd95SBruce Richardson  */
80499a2dd95SBruce Richardson /** Decap action parameters (per table rule). */
80599a2dd95SBruce Richardson struct rte_table_action_decap_params {
80699a2dd95SBruce Richardson 	/** Number of bytes to be removed from the start of the packet. */
80799a2dd95SBruce Richardson 	uint16_t n;
80899a2dd95SBruce Richardson };
80999a2dd95SBruce Richardson 
81099a2dd95SBruce Richardson /**
81199a2dd95SBruce Richardson  * Table action profile.
81299a2dd95SBruce Richardson  */
81399a2dd95SBruce Richardson struct rte_table_action_profile;
81499a2dd95SBruce Richardson 
81599a2dd95SBruce Richardson /**
81699a2dd95SBruce Richardson  * Table action profile create.
81799a2dd95SBruce Richardson  *
81899a2dd95SBruce Richardson  * @param[in] common
81999a2dd95SBruce Richardson  *   Common action configuration.
82099a2dd95SBruce Richardson  * @return
82199a2dd95SBruce Richardson  *   Table action profile handle on success, NULL otherwise.
82299a2dd95SBruce Richardson  */
82399a2dd95SBruce Richardson __rte_experimental
82499a2dd95SBruce Richardson struct rte_table_action_profile *
82599a2dd95SBruce Richardson rte_table_action_profile_create(struct rte_table_action_common_config *common);
82699a2dd95SBruce Richardson 
82799a2dd95SBruce Richardson /**
82899a2dd95SBruce Richardson  * Table action profile free.
82999a2dd95SBruce Richardson  *
83099a2dd95SBruce Richardson  * @param[in] profile
83199a2dd95SBruce Richardson  *   Table profile action handle (needs to be valid).
83299a2dd95SBruce Richardson  * @return
83399a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
83499a2dd95SBruce Richardson  */
83599a2dd95SBruce Richardson __rte_experimental
83699a2dd95SBruce Richardson int
83799a2dd95SBruce Richardson rte_table_action_profile_free(struct rte_table_action_profile *profile);
83899a2dd95SBruce Richardson 
83999a2dd95SBruce Richardson /**
84099a2dd95SBruce Richardson  * Table action profile action register.
84199a2dd95SBruce Richardson  *
84299a2dd95SBruce Richardson  * @param[in] profile
84399a2dd95SBruce Richardson  *   Table profile action handle (needs to be valid and not in frozen state).
84499a2dd95SBruce Richardson  * @param[in] type
84599a2dd95SBruce Richardson  *   Specific table action to be registered for *profile*.
84699a2dd95SBruce Richardson  * @param[in] action_config
84799a2dd95SBruce Richardson  *   Configuration for the *type* action.
84899a2dd95SBruce Richardson  *   If struct rte_table_action_*type*_config is defined by the Table Action
84999a2dd95SBruce Richardson  *   API, it needs to point to a valid instance of this structure, otherwise it
85099a2dd95SBruce Richardson  *   needs to be set to NULL.
85199a2dd95SBruce Richardson  * @return
85299a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
85399a2dd95SBruce Richardson  */
85499a2dd95SBruce Richardson __rte_experimental
85599a2dd95SBruce Richardson int
85699a2dd95SBruce Richardson rte_table_action_profile_action_register(struct rte_table_action_profile *profile,
85799a2dd95SBruce Richardson 	enum rte_table_action_type type,
85899a2dd95SBruce Richardson 	void *action_config);
85999a2dd95SBruce Richardson 
86099a2dd95SBruce Richardson /**
86199a2dd95SBruce Richardson  * Table action profile freeze.
86299a2dd95SBruce Richardson  *
86399a2dd95SBruce Richardson  * Once this function is called successfully, the given profile enters the
86499a2dd95SBruce Richardson  * frozen state with the following immediate effects: no more actions can be
86599a2dd95SBruce Richardson  * registered for this profile, so the profile can be instantiated to create
86699a2dd95SBruce Richardson  * table action objects.
86799a2dd95SBruce Richardson  *
86899a2dd95SBruce Richardson  * @param[in] profile
86999a2dd95SBruce Richardson  *   Table profile action handle (needs to be valid and not in frozen state).
87099a2dd95SBruce Richardson  * @return
87199a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
87299a2dd95SBruce Richardson  *
87399a2dd95SBruce Richardson  * @see rte_table_action_create()
87499a2dd95SBruce Richardson  */
87599a2dd95SBruce Richardson __rte_experimental
87699a2dd95SBruce Richardson int
87799a2dd95SBruce Richardson rte_table_action_profile_freeze(struct rte_table_action_profile *profile);
87899a2dd95SBruce Richardson 
87999a2dd95SBruce Richardson /**
88099a2dd95SBruce Richardson  * Table action.
88199a2dd95SBruce Richardson  */
88299a2dd95SBruce Richardson struct rte_table_action;
88399a2dd95SBruce Richardson 
88499a2dd95SBruce Richardson /**
88599a2dd95SBruce Richardson  * Table action create.
88699a2dd95SBruce Richardson  *
88799a2dd95SBruce Richardson  * Instantiates the given table action profile to create a table action object.
88899a2dd95SBruce Richardson  *
88999a2dd95SBruce Richardson  * @param[in] profile
89099a2dd95SBruce Richardson  *   Table profile action handle (needs to be valid and in frozen state).
89199a2dd95SBruce Richardson  * @param[in] socket_id
89299a2dd95SBruce Richardson  *   CPU socket ID where the internal data structures required by the new table
89399a2dd95SBruce Richardson  *   action object should be allocated.
89499a2dd95SBruce Richardson  * @return
89599a2dd95SBruce Richardson  *   Handle to table action object on success, NULL on error.
89699a2dd95SBruce Richardson  *
89799a2dd95SBruce Richardson  * @see rte_table_action_create()
89899a2dd95SBruce Richardson  */
89999a2dd95SBruce Richardson __rte_experimental
90099a2dd95SBruce Richardson struct rte_table_action *
90199a2dd95SBruce Richardson rte_table_action_create(struct rte_table_action_profile *profile,
90299a2dd95SBruce Richardson 	uint32_t socket_id);
90399a2dd95SBruce Richardson 
90499a2dd95SBruce Richardson /**
90599a2dd95SBruce Richardson  * Table action free.
90699a2dd95SBruce Richardson  *
90799a2dd95SBruce Richardson  * @param[in] action
90899a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
90999a2dd95SBruce Richardson  * @return
91099a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
91199a2dd95SBruce Richardson  */
91299a2dd95SBruce Richardson __rte_experimental
91399a2dd95SBruce Richardson int
91499a2dd95SBruce Richardson rte_table_action_free(struct rte_table_action *action);
91599a2dd95SBruce Richardson 
91699a2dd95SBruce Richardson /**
91799a2dd95SBruce Richardson  * Table action table params get.
91899a2dd95SBruce Richardson  *
91999a2dd95SBruce Richardson  * @param[in] action
92099a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
92199a2dd95SBruce Richardson  * @param[inout] params
92299a2dd95SBruce Richardson  *   Pipeline table parameters (needs to be pre-allocated).
92399a2dd95SBruce Richardson  * @return
92499a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
92599a2dd95SBruce Richardson  */
92699a2dd95SBruce Richardson __rte_experimental
92799a2dd95SBruce Richardson int
92899a2dd95SBruce Richardson rte_table_action_table_params_get(struct rte_table_action *action,
92999a2dd95SBruce Richardson 	struct rte_pipeline_table_params *params);
93099a2dd95SBruce Richardson 
93199a2dd95SBruce Richardson /**
93299a2dd95SBruce Richardson  * Table action apply.
93399a2dd95SBruce Richardson  *
93499a2dd95SBruce Richardson  * @param[in] action
93599a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
93699a2dd95SBruce Richardson  * @param[in] data
93799a2dd95SBruce Richardson  *   Data byte array (typically table rule data) to apply action *type* on.
93899a2dd95SBruce Richardson  * @param[in] type
93999a2dd95SBruce Richardson  *   Specific table action previously registered for the table action profile of
94099a2dd95SBruce Richardson  *   the *action* object.
94199a2dd95SBruce Richardson  * @param[in] action_params
94299a2dd95SBruce Richardson  *   Parameters for the *type* action.
94399a2dd95SBruce Richardson  *   If struct rte_table_action_*type*_params is defined by the Table Action
94499a2dd95SBruce Richardson  *   API, it needs to point to a valid instance of this structure, otherwise it
94599a2dd95SBruce Richardson  *   needs to be set to NULL.
94699a2dd95SBruce Richardson  * @return
94799a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
94899a2dd95SBruce Richardson  */
94999a2dd95SBruce Richardson __rte_experimental
95099a2dd95SBruce Richardson int
95199a2dd95SBruce Richardson rte_table_action_apply(struct rte_table_action *action,
95299a2dd95SBruce Richardson 	void *data,
95399a2dd95SBruce Richardson 	enum rte_table_action_type type,
95499a2dd95SBruce Richardson 	void *action_params);
95599a2dd95SBruce Richardson 
95699a2dd95SBruce Richardson /**
95799a2dd95SBruce Richardson  * Table action DSCP table update.
95899a2dd95SBruce Richardson  *
95999a2dd95SBruce Richardson  * @param[in] action
96099a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
96199a2dd95SBruce Richardson  * @param[in] dscp_mask
96299a2dd95SBruce Richardson  *   64-bit mask defining the DSCP table entries to be updated. If bit N is set
96399a2dd95SBruce Richardson  *   in this bit mask, then DSCP table entry N is to be updated, otherwise not.
96499a2dd95SBruce Richardson  * @param[in] table
96599a2dd95SBruce Richardson  *   DSCP table.
96699a2dd95SBruce Richardson  * @return
96799a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
96899a2dd95SBruce Richardson  */
96999a2dd95SBruce Richardson __rte_experimental
97099a2dd95SBruce Richardson int
97199a2dd95SBruce Richardson rte_table_action_dscp_table_update(struct rte_table_action *action,
97299a2dd95SBruce Richardson 	uint64_t dscp_mask,
97399a2dd95SBruce Richardson 	struct rte_table_action_dscp_table *table);
97499a2dd95SBruce Richardson 
97599a2dd95SBruce Richardson /**
97699a2dd95SBruce Richardson  * Table action meter profile add.
97799a2dd95SBruce Richardson  *
97899a2dd95SBruce Richardson  * @param[in] action
97999a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
98099a2dd95SBruce Richardson  * @param[in] meter_profile_id
98199a2dd95SBruce Richardson  *   Meter profile ID to be used for the *profile* once it is successfully added
98299a2dd95SBruce Richardson  *   to the *action* object (needs to be unused by the set of meter profiles
98399a2dd95SBruce Richardson  *   currently registered for the *action* object).
98499a2dd95SBruce Richardson  * @param[in] profile
98599a2dd95SBruce Richardson  *   Meter profile to be added.
98699a2dd95SBruce Richardson  * @return
98799a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
98899a2dd95SBruce Richardson  */
98999a2dd95SBruce Richardson __rte_experimental
99099a2dd95SBruce Richardson int
99199a2dd95SBruce Richardson rte_table_action_meter_profile_add(struct rte_table_action *action,
99299a2dd95SBruce Richardson 	uint32_t meter_profile_id,
99399a2dd95SBruce Richardson 	struct rte_table_action_meter_profile *profile);
99499a2dd95SBruce Richardson 
99599a2dd95SBruce Richardson /**
99699a2dd95SBruce Richardson  * Table action meter profile delete.
99799a2dd95SBruce Richardson  *
99899a2dd95SBruce Richardson  * @param[in] action
99999a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
100099a2dd95SBruce Richardson  * @param[in] meter_profile_id
100199a2dd95SBruce Richardson  *   Meter profile ID of the meter profile to be deleted from the *action*
100299a2dd95SBruce Richardson  *   object (needs to be valid for the *action* object).
100399a2dd95SBruce Richardson  * @return
100499a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
100599a2dd95SBruce Richardson  */
100699a2dd95SBruce Richardson __rte_experimental
100799a2dd95SBruce Richardson int
100899a2dd95SBruce Richardson rte_table_action_meter_profile_delete(struct rte_table_action *action,
100999a2dd95SBruce Richardson 	uint32_t meter_profile_id);
101099a2dd95SBruce Richardson 
101199a2dd95SBruce Richardson /**
101299a2dd95SBruce Richardson  * Table action meter read.
101399a2dd95SBruce Richardson  *
101499a2dd95SBruce Richardson  * @param[in] action
101599a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
101699a2dd95SBruce Richardson  * @param[in] data
101799a2dd95SBruce Richardson  *   Data byte array (typically table rule data) with meter action previously
101899a2dd95SBruce Richardson  *   applied on it.
101999a2dd95SBruce Richardson  * @param[in] tc_mask
102099a2dd95SBruce Richardson  *   Bit mask defining which traffic classes should have the meter stats
102199a2dd95SBruce Richardson  *   counters read from *data* and stored into *stats*. If bit N is set in this
102299a2dd95SBruce Richardson  *   bit mask, then traffic class N is part of this operation, otherwise it is
102399a2dd95SBruce Richardson  *   not. If bit N is set in this bit mask, then traffic class N must be one of
102499a2dd95SBruce Richardson  *   the traffic classes that are enabled for the meter action in the table
102599a2dd95SBruce Richardson  *   action profile used by the *action* object.
102699a2dd95SBruce Richardson  * @param[inout] stats
102799a2dd95SBruce Richardson  *   When non-NULL, it points to the area where the meter stats counters read
102899a2dd95SBruce Richardson  *   from *data* are saved. Only the meter stats counters for the *tc_mask*
102999a2dd95SBruce Richardson  *   traffic classes are read and stored to *stats*.
103099a2dd95SBruce Richardson  * @param[in] clear
103199a2dd95SBruce Richardson  *   When non-zero, the meter stats counters are cleared (i.e. set to zero),
103299a2dd95SBruce Richardson  *   otherwise the counters are not modified. When the read operation is enabled
103399a2dd95SBruce Richardson  *   (*stats* is non-NULL), the clear operation is performed after the read
103499a2dd95SBruce Richardson  *   operation is completed.
103599a2dd95SBruce Richardson  * @return
103699a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
103799a2dd95SBruce Richardson  */
103899a2dd95SBruce Richardson __rte_experimental
103999a2dd95SBruce Richardson int
104099a2dd95SBruce Richardson rte_table_action_meter_read(struct rte_table_action *action,
104199a2dd95SBruce Richardson 	void *data,
104299a2dd95SBruce Richardson 	uint32_t tc_mask,
104399a2dd95SBruce Richardson 	struct rte_table_action_mtr_counters *stats,
104499a2dd95SBruce Richardson 	int clear);
104599a2dd95SBruce Richardson 
104699a2dd95SBruce Richardson /**
104799a2dd95SBruce Richardson  * Table action TTL read.
104899a2dd95SBruce Richardson  *
104999a2dd95SBruce Richardson  * @param[in] action
105099a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
105199a2dd95SBruce Richardson  * @param[in] data
105299a2dd95SBruce Richardson  *   Data byte array (typically table rule data) with TTL action previously
105399a2dd95SBruce Richardson  *   applied on it.
105499a2dd95SBruce Richardson  * @param[inout] stats
105599a2dd95SBruce Richardson  *   When non-NULL, it points to the area where the TTL stats counters read from
105699a2dd95SBruce Richardson  *   *data* are saved.
105799a2dd95SBruce Richardson  * @param[in] clear
105899a2dd95SBruce Richardson  *   When non-zero, the TTL stats counters are cleared (i.e. set to zero),
105999a2dd95SBruce Richardson  *   otherwise the counters are not modified. When the read operation is enabled
106099a2dd95SBruce Richardson  *   (*stats* is non-NULL), the clear operation is performed after the read
106199a2dd95SBruce Richardson  *   operation is completed.
106299a2dd95SBruce Richardson  * @return
106399a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
106499a2dd95SBruce Richardson  */
106599a2dd95SBruce Richardson __rte_experimental
106699a2dd95SBruce Richardson int
106799a2dd95SBruce Richardson rte_table_action_ttl_read(struct rte_table_action *action,
106899a2dd95SBruce Richardson 	void *data,
106999a2dd95SBruce Richardson 	struct rte_table_action_ttl_counters *stats,
107099a2dd95SBruce Richardson 	int clear);
107199a2dd95SBruce Richardson 
107299a2dd95SBruce Richardson /**
107399a2dd95SBruce Richardson  * Table action stats read.
107499a2dd95SBruce Richardson  *
107599a2dd95SBruce Richardson  * @param[in] action
107699a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
107799a2dd95SBruce Richardson  * @param[in] data
107899a2dd95SBruce Richardson  *   Data byte array (typically table rule data) with stats action previously
107999a2dd95SBruce Richardson  *   applied on it.
108099a2dd95SBruce Richardson  * @param[inout] stats
108199a2dd95SBruce Richardson  *   When non-NULL, it points to the area where the stats counters read from
108299a2dd95SBruce Richardson  *   *data* are saved.
108399a2dd95SBruce Richardson  * @param[in] clear
108499a2dd95SBruce Richardson  *   When non-zero, the stats counters are cleared (i.e. set to zero), otherwise
108599a2dd95SBruce Richardson  *   the counters are not modified. When the read operation is enabled (*stats*
108699a2dd95SBruce Richardson  *   is non-NULL), the clear operation is performed after the read operation is
108799a2dd95SBruce Richardson  *   completed.
108899a2dd95SBruce Richardson  * @return
108999a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
109099a2dd95SBruce Richardson  */
109199a2dd95SBruce Richardson __rte_experimental
109299a2dd95SBruce Richardson int
109399a2dd95SBruce Richardson rte_table_action_stats_read(struct rte_table_action *action,
109499a2dd95SBruce Richardson 	void *data,
109599a2dd95SBruce Richardson 	struct rte_table_action_stats_counters *stats,
109699a2dd95SBruce Richardson 	int clear);
109799a2dd95SBruce Richardson 
109899a2dd95SBruce Richardson /**
109999a2dd95SBruce Richardson  * Table action timestamp read.
110099a2dd95SBruce Richardson  *
110199a2dd95SBruce Richardson  * @param[in] action
110299a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
110399a2dd95SBruce Richardson  * @param[in] data
110499a2dd95SBruce Richardson  *   Data byte array (typically table rule data) with timestamp action
110599a2dd95SBruce Richardson  *   previously applied on it.
110699a2dd95SBruce Richardson  * @param[inout] timestamp
110799a2dd95SBruce Richardson  *   Pre-allocated memory where the timestamp read from *data* is saved (has to
110899a2dd95SBruce Richardson  *   be non-NULL).
110999a2dd95SBruce Richardson  * @return
111099a2dd95SBruce Richardson  *   Zero on success, non-zero error code otherwise.
111199a2dd95SBruce Richardson  */
111299a2dd95SBruce Richardson __rte_experimental
111399a2dd95SBruce Richardson int
111499a2dd95SBruce Richardson rte_table_action_time_read(struct rte_table_action *action,
111599a2dd95SBruce Richardson 	void *data,
111699a2dd95SBruce Richardson 	uint64_t *timestamp);
111799a2dd95SBruce Richardson 
111899a2dd95SBruce Richardson /**
111999a2dd95SBruce Richardson  * Table action cryptodev symmetric session get.
112099a2dd95SBruce Richardson  *
112199a2dd95SBruce Richardson  * @param[in] action
112299a2dd95SBruce Richardson  *   Handle to table action object (needs to be valid).
112399a2dd95SBruce Richardson  * @param[in] data
112499a2dd95SBruce Richardson  *   Data byte array (typically table rule data) with sym crypto action.
112599a2dd95SBruce Richardson  * @return
112699a2dd95SBruce Richardson  *   The pointer to the session on success, NULL otherwise.
112799a2dd95SBruce Richardson  */
112899a2dd95SBruce Richardson __rte_experimental
112999a2dd95SBruce Richardson struct rte_cryptodev_sym_session *
113099a2dd95SBruce Richardson rte_table_action_crypto_sym_session_get(struct rte_table_action *action,
113199a2dd95SBruce Richardson 	void *data);
113299a2dd95SBruce Richardson 
113399a2dd95SBruce Richardson #ifdef __cplusplus
113499a2dd95SBruce Richardson }
113599a2dd95SBruce Richardson #endif
113699a2dd95SBruce Richardson 
113799a2dd95SBruce Richardson #endif /* __INCLUDE_RTE_TABLE_ACTION_H__ */
1138