DPDK  24.07.0
Data Structures | Macros | Enumerations | Functions
rte_table_action.h File Reference
#include <stdint.h>
#include <rte_compat.h>
#include <rte_ether.h>
#include <rte_meter.h>
#include <rte_table_hash.h>
#include "rte_pipeline.h"

Go to the source code of this file.

Data Structures

struct  rte_table_action_common_config
 
struct  rte_table_action_fwd_params
 
struct  rte_table_action_lb_config
 
struct  rte_table_action_lb_params
 
struct  rte_table_action_dscp_table_entry
 
struct  rte_table_action_dscp_table
 
struct  rte_table_action_meter_profile
 
struct  rte_table_action_mtr_tc_params
 
struct  rte_table_action_mtr_counters_tc
 
struct  rte_table_action_mtr_config
 
struct  rte_table_action_mtr_params
 
struct  rte_table_action_mtr_counters
 
struct  rte_table_action_tm_config
 
struct  rte_table_action_tm_params
 
struct  rte_table_action_ether_hdr
 
struct  rte_table_action_vlan_hdr
 
struct  rte_table_action_mpls_hdr
 
struct  rte_table_action_pppoe_hdr
 
struct  rte_table_action_ipv4_header
 
struct  rte_table_action_ipv6_header
 
struct  rte_table_action_udp_header
 
struct  rte_table_action_vxlan_hdr
 
struct  rte_table_action_encap_ether_params
 
struct  rte_table_action_encap_vlan_params
 
struct  rte_table_action_encap_qinq_params
 
struct  rte_table_action_encap_mpls_params
 
struct  rte_table_action_encap_pppoe_params
 
struct  rte_table_action_encap_vxlan_params
 
struct  rte_table_action_encap_config
 
struct  rte_table_encap_ether_qinq_pppoe
 
struct  rte_table_action_encap_params
 
struct  rte_table_action_nat_config
 
struct  rte_table_action_nat_params
 
struct  rte_table_action_ttl_config
 
struct  rte_table_action_ttl_params
 
struct  rte_table_action_ttl_counters
 
struct  rte_table_action_stats_config
 
struct  rte_table_action_stats_params
 
struct  rte_table_action_stats_counters
 
struct  rte_table_action_time_params
 
struct  rte_table_action_vlo
 
struct  rte_table_action_sym_crypto_config
 
struct  rte_table_action_sym_crypto_params
 
struct  rte_table_action_tag_params
 
struct  rte_table_action_decap_params
 

Macros

#define RTE_TABLE_ACTION_LB_KEY_SIZE_MIN   8
 
#define RTE_TABLE_ACTION_LB_KEY_SIZE_MAX   64
 
#define RTE_TABLE_ACTION_LB_TABLE_SIZE   8
 
#define RTE_TABLE_ACTION_TC_MAX   16
 
#define RTE_TABLE_ACTION_TC_QUEUE_MAX   16
 
#define RTE_TABLE_ACTION_MPLS_LABELS_MAX   4
 
#define RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX   (16)
 

Enumerations

enum  rte_table_action_type {
  RTE_TABLE_ACTION_FWD = 0, RTE_TABLE_ACTION_LB, RTE_TABLE_ACTION_MTR, RTE_TABLE_ACTION_TM,
  RTE_TABLE_ACTION_ENCAP, RTE_TABLE_ACTION_NAT, RTE_TABLE_ACTION_TTL, RTE_TABLE_ACTION_STATS,
  RTE_TABLE_ACTION_TIME, RTE_TABLE_ACTION_SYM_CRYPTO, RTE_TABLE_ACTION_TAG, RTE_TABLE_ACTION_DECAP
}
 
enum  rte_table_action_meter_algorithm { RTE_TABLE_ACTION_METER_SRTCM, RTE_TABLE_ACTION_METER_TRTCM }
 
enum  rte_table_action_policer {
  RTE_TABLE_ACTION_POLICER_COLOR_GREEN = 0, RTE_TABLE_ACTION_POLICER_COLOR_YELLOW, RTE_TABLE_ACTION_POLICER_COLOR_RED, RTE_TABLE_ACTION_POLICER_DROP,
  RTE_TABLE_ACTION_POLICER_MAX
}
 
enum  rte_table_action_encap_type {
  RTE_TABLE_ACTION_ENCAP_ETHER = 0, RTE_TABLE_ACTION_ENCAP_VLAN, RTE_TABLE_ACTION_ENCAP_QINQ, RTE_TABLE_ACTION_ENCAP_MPLS,
  RTE_TABLE_ACTION_ENCAP_PPPOE, RTE_TABLE_ACTION_ENCAP_VXLAN, RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE
}
 

Functions

__rte_experimental struct rte_table_action_profile * rte_table_action_profile_create (struct rte_table_action_common_config *common)
 
__rte_experimental int rte_table_action_profile_free (struct rte_table_action_profile *profile)
 
__rte_experimental int rte_table_action_profile_action_register (struct rte_table_action_profile *profile, enum rte_table_action_type type, void *action_config)
 
__rte_experimental int rte_table_action_profile_freeze (struct rte_table_action_profile *profile)
 
__rte_experimental struct rte_table_action * rte_table_action_create (struct rte_table_action_profile *profile, uint32_t socket_id)
 
__rte_experimental int rte_table_action_free (struct rte_table_action *action)
 
__rte_experimental int rte_table_action_table_params_get (struct rte_table_action *action, struct rte_pipeline_table_params *params)
 
__rte_experimental int rte_table_action_apply (struct rte_table_action *action, void *data, enum rte_table_action_type type, void *action_params)
 
__rte_experimental int rte_table_action_dscp_table_update (struct rte_table_action *action, uint64_t dscp_mask, struct rte_table_action_dscp_table *table)
 
__rte_experimental int rte_table_action_meter_profile_add (struct rte_table_action *action, uint32_t meter_profile_id, struct rte_table_action_meter_profile *profile)
 
__rte_experimental int rte_table_action_meter_profile_delete (struct rte_table_action *action, uint32_t meter_profile_id)
 
__rte_experimental int rte_table_action_meter_read (struct rte_table_action *action, void *data, uint32_t tc_mask, struct rte_table_action_mtr_counters *stats, int clear)
 
__rte_experimental int rte_table_action_ttl_read (struct rte_table_action *action, void *data, struct rte_table_action_ttl_counters *stats, int clear)
 
__rte_experimental int rte_table_action_stats_read (struct rte_table_action *action, void *data, struct rte_table_action_stats_counters *stats, int clear)
 
__rte_experimental int rte_table_action_time_read (struct rte_table_action *action, void *data, uint64_t *timestamp)
 
__rte_experimental struct rte_cryptodev_sym_session * rte_table_action_crypto_sym_session_get (struct rte_table_action *action, void *data)
 

Detailed Description

RTE Pipeline Table Actions

This API provides a common set of actions for pipeline tables to speed up application development.

Each match-action rule added to a pipeline table has associated data that stores the action context. This data is input to the table action handler called for every input packet that hits the rule as part of the table lookup during the pipeline execution. The pipeline library allows the user to define his own table actions by providing customized table action handlers (table lookup) and complete freedom of setting the rules and their data (table rule add/delete). While the user can still follow this process, this API is intended to provide a quicker development alternative for a set of predefined actions.

The typical steps to use this API are:

Warning
EXPERIMENTAL: this API may change without prior notice

Definition in file rte_table_action.h.

Macro Definition Documentation

◆ RTE_TABLE_ACTION_LB_KEY_SIZE_MIN

#define RTE_TABLE_ACTION_LB_KEY_SIZE_MIN   8

RTE_TABLE_ACTION_LBLoad balance key size min (number of bytes).

Definition at line 136 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_LB_KEY_SIZE_MAX

#define RTE_TABLE_ACTION_LB_KEY_SIZE_MAX   64

Load balance key size max (number of bytes).

Definition at line 139 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_LB_TABLE_SIZE

#define RTE_TABLE_ACTION_LB_TABLE_SIZE   8

Load balance table size.

Examples:
examples/ip_pipeline/cli.c.

Definition at line 142 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_TC_MAX

#define RTE_TABLE_ACTION_TC_MAX   16

RTE_TABLE_ACTION_MTRMax number of traffic classes (TCs).

Examples:
examples/ip_pipeline/cli.c.

Definition at line 184 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_TC_QUEUE_MAX

#define RTE_TABLE_ACTION_TC_QUEUE_MAX   16

Max number of queues per traffic class.

Examples:
examples/ip_pipeline/cli.c.

Definition at line 187 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_MPLS_LABELS_MAX

#define RTE_TABLE_ACTION_MPLS_LABELS_MAX   4

Max number of MPLS labels per output packet for MPLS encapsulation.

Definition at line 460 of file rte_table_action.h.

◆ RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX

#define RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX   (16)

RTE_TABLE_ACTION_CRYPTO

Definition at line 708 of file rte_table_action.h.

Enumeration Type Documentation

◆ rte_table_action_type

Table actions.

Enumerator
RTE_TABLE_ACTION_FWD 

Forward to next pipeline table, output port or drop.

RTE_TABLE_ACTION_LB 

Load balance.

RTE_TABLE_ACTION_MTR 

Traffic Metering and Policing.

RTE_TABLE_ACTION_TM 

Traffic Management.

RTE_TABLE_ACTION_ENCAP 

Packet encapsulations.

RTE_TABLE_ACTION_NAT 

Network Address Translation (NAT).

RTE_TABLE_ACTION_TTL 

Time to Live (TTL) update.

RTE_TABLE_ACTION_STATS 

Statistics.

RTE_TABLE_ACTION_TIME 

Timestamp.

RTE_TABLE_ACTION_SYM_CRYPTO 

Crypto.

RTE_TABLE_ACTION_TAG 

Tag.

RTE_TABLE_ACTION_DECAP 

Packet decapsulations.

Definition at line 69 of file rte_table_action.h.

◆ rte_table_action_meter_algorithm

Supported traffic metering algorithms.

Enumerator
RTE_TABLE_ACTION_METER_SRTCM 

Single Rate Three Color Marker (srTCM) - IETF RFC 2697.

RTE_TABLE_ACTION_METER_TRTCM 

Two Rate Three Color Marker (trTCM) - IETF RFC 2698.

Definition at line 215 of file rte_table_action.h.

◆ rte_table_action_policer

Policer actions.

Enumerator
RTE_TABLE_ACTION_POLICER_COLOR_GREEN 

Recolor the packet as green.

RTE_TABLE_ACTION_POLICER_COLOR_YELLOW 

Recolor the packet as yellow.

RTE_TABLE_ACTION_POLICER_COLOR_RED 

Recolor the packet as red.

RTE_TABLE_ACTION_POLICER_DROP 

Drop the packet.

RTE_TABLE_ACTION_POLICER_MAX 

Number of policer actions.

Definition at line 238 of file rte_table_action.h.

◆ rte_table_action_encap_type

RTE_TABLE_ACTION_ENCAPSupported packet encapsulation types.

Enumerator
RTE_TABLE_ACTION_ENCAP_ETHER 

IP -> { Ether | IP }

RTE_TABLE_ACTION_ENCAP_VLAN 

IP -> { Ether | VLAN | IP }

RTE_TABLE_ACTION_ENCAP_QINQ 

IP -> { Ether | S-VLAN | C-VLAN | IP }

RTE_TABLE_ACTION_ENCAP_MPLS 

IP -> { Ether | MPLS | IP }

RTE_TABLE_ACTION_ENCAP_PPPOE 

IP -> { Ether | PPPoE | PPP | IP }

RTE_TABLE_ACTION_ENCAP_VXLAN 

Ether -> { Ether | IP | UDP | VXLAN | Ether } Ether -> { Ether | VLAN | IP | UDP | VXLAN | Ether }

RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE 

IP -> { Ether | S-VLAN | C-VLAN | PPPoE | PPP | IP }

Definition at line 362 of file rte_table_action.h.

Function Documentation

◆ rte_table_action_profile_create()

__rte_experimental struct rte_table_action_profile* rte_table_action_profile_create ( struct rte_table_action_common_config common)

Table action profile create.

Parameters
[in]commonCommon action configuration.
Returns
Table action profile handle on success, NULL otherwise.
Examples:
examples/ip_pipeline/action.c.

◆ rte_table_action_profile_free()

__rte_experimental int rte_table_action_profile_free ( struct rte_table_action_profile *  profile)

Table action profile free.

Parameters
[in]profileTable profile action handle (needs to be valid).
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/action.c.

◆ rte_table_action_profile_action_register()

__rte_experimental int rte_table_action_profile_action_register ( struct rte_table_action_profile *  profile,
enum rte_table_action_type  type,
void *  action_config 
)

Table action profile action register.

Parameters
[in]profileTable profile action handle (needs to be valid and not in frozen state).
[in]typeSpecific table action to be registered for profile.
[in]action_configConfiguration for the type action. If struct rte_table_action_*type*_config is defined by the Table Action API, it needs to point to a valid instance of this structure, otherwise it needs to be set to NULL.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/action.c.

◆ rte_table_action_profile_freeze()

__rte_experimental int rte_table_action_profile_freeze ( struct rte_table_action_profile *  profile)

Table action profile freeze.

Once this function is called successfully, the given profile enters the frozen state with the following immediate effects: no more actions can be registered for this profile, so the profile can be instantiated to create table action objects.

Parameters
[in]profileTable profile action handle (needs to be valid and not in frozen state).
Returns
Zero on success, non-zero error code otherwise.
See also
rte_table_action_create()
Examples:
examples/ip_pipeline/action.c.

◆ rte_table_action_create()

__rte_experimental struct rte_table_action* rte_table_action_create ( struct rte_table_action_profile *  profile,
uint32_t  socket_id 
)

Table action create.

Instantiates the given table action profile to create a table action object.

Parameters
[in]profileTable profile action handle (needs to be valid and in frozen state).
[in]socket_idCPU socket ID where the internal data structures required by the new table action object should be allocated.
Returns
Handle to table action object on success, NULL on error.
See also
rte_table_action_create()
Examples:
examples/ip_pipeline/pipeline.c.

◆ rte_table_action_free()

__rte_experimental int rte_table_action_free ( struct rte_table_action *  action)

Table action free.

Parameters
[in]actionHandle to table action object (needs to be valid).
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/pipeline.c.

◆ rte_table_action_table_params_get()

__rte_experimental int rte_table_action_table_params_get ( struct rte_table_action *  action,
struct rte_pipeline_table_params params 
)

Table action table params get.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in,out]paramsPipeline table parameters (needs to be pre-allocated).
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/pipeline.c.

◆ rte_table_action_apply()

__rte_experimental int rte_table_action_apply ( struct rte_table_action *  action,
void *  data,
enum rte_table_action_type  type,
void *  action_params 
)

Table action apply.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) to apply action type on.
[in]typeSpecific table action previously registered for the table action profile of the action object.
[in]action_paramsParameters for the type action. If struct rte_table_action_*type*_params is defined by the Table Action API, it needs to point to a valid instance of this structure, otherwise it needs to be set to NULL.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_dscp_table_update()

__rte_experimental int rte_table_action_dscp_table_update ( struct rte_table_action *  action,
uint64_t  dscp_mask,
struct rte_table_action_dscp_table table 
)

Table action DSCP table update.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dscp_mask64-bit mask defining the DSCP table entries to be updated. If bit N is set in this bit mask, then DSCP table entry N is to be updated, otherwise not.
[in]tableDSCP table.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_meter_profile_add()

__rte_experimental int rte_table_action_meter_profile_add ( struct rte_table_action *  action,
uint32_t  meter_profile_id,
struct rte_table_action_meter_profile profile 
)

Table action meter profile add.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]meter_profile_idMeter profile ID to be used for the profile once it is successfully added to the action object (needs to be unused by the set of meter profiles currently registered for the action object).
[in]profileMeter profile to be added.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_meter_profile_delete()

__rte_experimental int rte_table_action_meter_profile_delete ( struct rte_table_action *  action,
uint32_t  meter_profile_id 
)

Table action meter profile delete.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]meter_profile_idMeter profile ID of the meter profile to be deleted from the action object (needs to be valid for the action object).
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_meter_read()

__rte_experimental int rte_table_action_meter_read ( struct rte_table_action *  action,
void *  data,
uint32_t  tc_mask,
struct rte_table_action_mtr_counters stats,
int  clear 
)

Table action meter read.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) with meter action previously applied on it.
[in]tc_maskBit mask defining which traffic classes should have the meter stats counters read from data and stored into stats. If bit N is set in this bit mask, then traffic class N is part of this operation, otherwise it is not. If bit N is set in this bit mask, then traffic class N must be one of the traffic classes that are enabled for the meter action in the table action profile used by the action object.
[in,out]statsWhen non-NULL, it points to the area where the meter stats counters read from data are saved. Only the meter stats counters for the tc_mask traffic classes are read and stored to stats.
[in]clearWhen non-zero, the meter stats counters are cleared (i.e. set to zero), otherwise the counters are not modified. When the read operation is enabled (stats is non-NULL), the clear operation is performed after the read operation is completed.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_ttl_read()

__rte_experimental int rte_table_action_ttl_read ( struct rte_table_action *  action,
void *  data,
struct rte_table_action_ttl_counters stats,
int  clear 
)

Table action TTL read.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) with TTL action previously applied on it.
[in,out]statsWhen non-NULL, it points to the area where the TTL stats counters read from data are saved.
[in]clearWhen non-zero, the TTL stats counters are cleared (i.e. set to zero), otherwise the counters are not modified. When the read operation is enabled (stats is non-NULL), the clear operation is performed after the read operation is completed.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_stats_read()

__rte_experimental int rte_table_action_stats_read ( struct rte_table_action *  action,
void *  data,
struct rte_table_action_stats_counters stats,
int  clear 
)

Table action stats read.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) with stats action previously applied on it.
[in,out]statsWhen non-NULL, it points to the area where the stats counters read from data are saved.
[in]clearWhen non-zero, the stats counters are cleared (i.e. set to zero), otherwise the counters are not modified. When the read operation is enabled (stats is non-NULL), the clear operation is performed after the read operation is completed.
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_time_read()

__rte_experimental int rte_table_action_time_read ( struct rte_table_action *  action,
void *  data,
uint64_t *  timestamp 
)

Table action timestamp read.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) with timestamp action previously applied on it.
[in,out]timestampPre-allocated memory where the timestamp read from data is saved (has to be non-NULL).
Returns
Zero on success, non-zero error code otherwise.
Examples:
examples/ip_pipeline/thread.c.

◆ rte_table_action_crypto_sym_session_get()

__rte_experimental struct rte_cryptodev_sym_session* rte_table_action_crypto_sym_session_get ( struct rte_table_action *  action,
void *  data 
)

Table action cryptodev symmetric session get.

Parameters
[in]actionHandle to table action object (needs to be valid).
[in]dataData byte array (typically table rule data) with sym crypto action.
Returns
The pointer to the session on success, NULL otherwise.