199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2010-2016 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef __INCLUDE_RTE_PIPELINE_H__ 699a2dd95SBruce Richardson #define __INCLUDE_RTE_PIPELINE_H__ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * @file 1099a2dd95SBruce Richardson * RTE Pipeline 1199a2dd95SBruce Richardson * 1299a2dd95SBruce Richardson * This tool is part of the DPDK Packet Framework tool suite and provides 1399a2dd95SBruce Richardson * a standard methodology (logically similar to OpenFlow) for rapid development 1499a2dd95SBruce Richardson * of complex packet processing pipelines out of ports, tables and actions. 1599a2dd95SBruce Richardson * 1699a2dd95SBruce Richardson * <B>Basic operation.</B> A pipeline is constructed by connecting its input 1799a2dd95SBruce Richardson * ports to its output ports through a chain of lookup tables. As result of 1899a2dd95SBruce Richardson * lookup operation into the current table, one of the table entries (or the 1999a2dd95SBruce Richardson * default table entry, in case of lookup miss) is identified to provide the 2099a2dd95SBruce Richardson * actions to be executed on the current packet and the associated action 2199a2dd95SBruce Richardson * meta-data. The behavior of user actions is defined through the configurable 2299a2dd95SBruce Richardson * table action handler, while the reserved actions define the next hop for the 2399a2dd95SBruce Richardson * current packet (either another table, an output port or packet drop) and are 2499a2dd95SBruce Richardson * handled transparently by the framework. 2599a2dd95SBruce Richardson * 2699a2dd95SBruce Richardson * <B>Initialization and run-time flows.</B> Once all the pipeline elements 2799a2dd95SBruce Richardson * (input ports, tables, output ports) have been created, input ports connected 2899a2dd95SBruce Richardson * to tables, table action handlers configured, tables populated with the 2999a2dd95SBruce Richardson * initial set of entries (actions and action meta-data) and input ports 3099a2dd95SBruce Richardson * enabled, the pipeline runs automatically, pushing packets from input ports 3199a2dd95SBruce Richardson * to tables and output ports. At each table, the identified user actions are 3299a2dd95SBruce Richardson * being executed, resulting in action meta-data (stored in the table entry) 3399a2dd95SBruce Richardson * and packet meta-data (stored with the packet descriptor) being updated. The 3499a2dd95SBruce Richardson * pipeline tables can have further updates and input ports can be disabled or 3599a2dd95SBruce Richardson * enabled later on as required. 3699a2dd95SBruce Richardson * 3799a2dd95SBruce Richardson * <B>Multi-core scaling.</B> Typically, each CPU core will run its own 3899a2dd95SBruce Richardson * pipeline instance. Complex application-level pipelines can be implemented by 3999a2dd95SBruce Richardson * interconnecting multiple CPU core-level pipelines in tree-like topologies, 4099a2dd95SBruce Richardson * as the same port devices (e.g. SW rings) can serve as output ports for the 4199a2dd95SBruce Richardson * pipeline running on CPU core A, as well as input ports for the pipeline 4299a2dd95SBruce Richardson * running on CPU core B. This approach enables the application development 4399a2dd95SBruce Richardson * using the pipeline (CPU cores connected serially), cluster/run-to-completion 4499a2dd95SBruce Richardson * (CPU cores connected in parallel) or mixed (pipeline of CPU core clusters) 4599a2dd95SBruce Richardson * programming models. 4699a2dd95SBruce Richardson * 4799a2dd95SBruce Richardson * <B>Thread safety.</B> It is possible to have multiple pipelines running on 4899a2dd95SBruce Richardson * the same CPU core, but it is not allowed (for thread safety reasons) to have 4999a2dd95SBruce Richardson * multiple CPU cores running the same pipeline instance. 503e4c5be9SThomas Monjalon */ 5199a2dd95SBruce Richardson 5299a2dd95SBruce Richardson #include <stdint.h> 5399a2dd95SBruce Richardson 5499a2dd95SBruce Richardson #include <rte_port.h> 5599a2dd95SBruce Richardson #include <rte_table.h> 5699a2dd95SBruce Richardson #include <rte_common.h> 5799a2dd95SBruce Richardson 58*719834a6SMattias Rönnblom #ifdef __cplusplus 59*719834a6SMattias Rönnblom extern "C" { 60*719834a6SMattias Rönnblom #endif 61*719834a6SMattias Rönnblom 6299a2dd95SBruce Richardson struct rte_mbuf; 6399a2dd95SBruce Richardson 6499a2dd95SBruce Richardson /* 6599a2dd95SBruce Richardson * Pipeline 6699a2dd95SBruce Richardson */ 6799a2dd95SBruce Richardson /** Opaque data type for pipeline */ 6899a2dd95SBruce Richardson struct rte_pipeline; 6999a2dd95SBruce Richardson 7099a2dd95SBruce Richardson /** Parameters for pipeline creation */ 7199a2dd95SBruce Richardson struct rte_pipeline_params { 7299a2dd95SBruce Richardson /** Pipeline name */ 7399a2dd95SBruce Richardson const char *name; 7499a2dd95SBruce Richardson 7599a2dd95SBruce Richardson /** CPU socket ID where memory for the pipeline and its elements (ports 7699a2dd95SBruce Richardson and tables) should be allocated */ 7799a2dd95SBruce Richardson int socket_id; 7899a2dd95SBruce Richardson 7999a2dd95SBruce Richardson /** Offset within packet meta-data to port_id to be used by action 8099a2dd95SBruce Richardson "Send packet to output port read from packet meta-data". Has to be 8199a2dd95SBruce Richardson 4-byte aligned. */ 8299a2dd95SBruce Richardson uint32_t offset_port_id; 8399a2dd95SBruce Richardson }; 8499a2dd95SBruce Richardson 8599a2dd95SBruce Richardson /** Pipeline port in stats. */ 8699a2dd95SBruce Richardson struct rte_pipeline_port_in_stats { 8799a2dd95SBruce Richardson /** Port in stats. */ 8899a2dd95SBruce Richardson struct rte_port_in_stats stats; 8999a2dd95SBruce Richardson 9099a2dd95SBruce Richardson /** Number of packets dropped by action handler. */ 9199a2dd95SBruce Richardson uint64_t n_pkts_dropped_by_ah; 9299a2dd95SBruce Richardson 9399a2dd95SBruce Richardson }; 9499a2dd95SBruce Richardson 9599a2dd95SBruce Richardson /** Pipeline port out stats. */ 9699a2dd95SBruce Richardson struct rte_pipeline_port_out_stats { 9799a2dd95SBruce Richardson /** Port out stats. */ 9899a2dd95SBruce Richardson struct rte_port_out_stats stats; 9999a2dd95SBruce Richardson 10099a2dd95SBruce Richardson /** Number of packets dropped by action handler. */ 10199a2dd95SBruce Richardson uint64_t n_pkts_dropped_by_ah; 10299a2dd95SBruce Richardson }; 10399a2dd95SBruce Richardson 10499a2dd95SBruce Richardson /** Pipeline table stats. */ 10599a2dd95SBruce Richardson struct rte_pipeline_table_stats { 10699a2dd95SBruce Richardson /** Table stats. */ 10799a2dd95SBruce Richardson struct rte_table_stats stats; 10899a2dd95SBruce Richardson 10999a2dd95SBruce Richardson /** Number of packets dropped by lookup hit action handler. */ 11099a2dd95SBruce Richardson uint64_t n_pkts_dropped_by_lkp_hit_ah; 11199a2dd95SBruce Richardson 11299a2dd95SBruce Richardson /** Number of packets dropped by lookup miss action handler. */ 11399a2dd95SBruce Richardson uint64_t n_pkts_dropped_by_lkp_miss_ah; 11499a2dd95SBruce Richardson 11599a2dd95SBruce Richardson /** Number of packets dropped by pipeline in behalf of this 11699a2dd95SBruce Richardson * table based on action specified in table entry. */ 11799a2dd95SBruce Richardson uint64_t n_pkts_dropped_lkp_hit; 11899a2dd95SBruce Richardson 11999a2dd95SBruce Richardson /** Number of packets dropped by pipeline in behalf of this 12099a2dd95SBruce Richardson * table based on action specified in table entry. */ 12199a2dd95SBruce Richardson uint64_t n_pkts_dropped_lkp_miss; 12299a2dd95SBruce Richardson }; 12399a2dd95SBruce Richardson 12499a2dd95SBruce Richardson /** 12599a2dd95SBruce Richardson * Pipeline create 12699a2dd95SBruce Richardson * 12799a2dd95SBruce Richardson * @param params 12899a2dd95SBruce Richardson * Parameters for pipeline creation 12999a2dd95SBruce Richardson * @return 13099a2dd95SBruce Richardson * Handle to pipeline instance on success or NULL otherwise 13199a2dd95SBruce Richardson */ 13299a2dd95SBruce Richardson struct rte_pipeline *rte_pipeline_create(struct rte_pipeline_params *params); 13399a2dd95SBruce Richardson 13499a2dd95SBruce Richardson /** 13599a2dd95SBruce Richardson * Pipeline free 13699a2dd95SBruce Richardson * 13799a2dd95SBruce Richardson * @param p 13899a2dd95SBruce Richardson * Handle to pipeline instance 13999a2dd95SBruce Richardson * @return 14099a2dd95SBruce Richardson * 0 on success, error code otherwise 14199a2dd95SBruce Richardson */ 14299a2dd95SBruce Richardson int rte_pipeline_free(struct rte_pipeline *p); 14399a2dd95SBruce Richardson 14499a2dd95SBruce Richardson /** 14599a2dd95SBruce Richardson * Pipeline consistency check 14699a2dd95SBruce Richardson * 14799a2dd95SBruce Richardson * @param p 14899a2dd95SBruce Richardson * Handle to pipeline instance 14999a2dd95SBruce Richardson * @return 15099a2dd95SBruce Richardson * 0 on success, error code otherwise 15199a2dd95SBruce Richardson */ 15299a2dd95SBruce Richardson int rte_pipeline_check(struct rte_pipeline *p); 15399a2dd95SBruce Richardson 15499a2dd95SBruce Richardson /** 15599a2dd95SBruce Richardson * Pipeline run 15699a2dd95SBruce Richardson * 15799a2dd95SBruce Richardson * @param p 15899a2dd95SBruce Richardson * Handle to pipeline instance 15999a2dd95SBruce Richardson * @return 16099a2dd95SBruce Richardson * Number of packets read and processed 16199a2dd95SBruce Richardson */ 16299a2dd95SBruce Richardson int rte_pipeline_run(struct rte_pipeline *p); 16399a2dd95SBruce Richardson 16499a2dd95SBruce Richardson /** 16599a2dd95SBruce Richardson * Pipeline flush 16699a2dd95SBruce Richardson * 16799a2dd95SBruce Richardson * @param p 16899a2dd95SBruce Richardson * Handle to pipeline instance 16999a2dd95SBruce Richardson * @return 17099a2dd95SBruce Richardson * 0 on success, error code otherwise 17199a2dd95SBruce Richardson */ 17299a2dd95SBruce Richardson int rte_pipeline_flush(struct rte_pipeline *p); 17399a2dd95SBruce Richardson 17499a2dd95SBruce Richardson /* 17599a2dd95SBruce Richardson * Actions 17699a2dd95SBruce Richardson */ 17799a2dd95SBruce Richardson /** Reserved actions */ 17899a2dd95SBruce Richardson enum rte_pipeline_action { 17999a2dd95SBruce Richardson /** Drop the packet */ 18099a2dd95SBruce Richardson RTE_PIPELINE_ACTION_DROP = 0, 18199a2dd95SBruce Richardson 18299a2dd95SBruce Richardson /** Send packet to output port */ 18399a2dd95SBruce Richardson RTE_PIPELINE_ACTION_PORT, 18499a2dd95SBruce Richardson 18599a2dd95SBruce Richardson /** Send packet to output port read from packet meta-data */ 18699a2dd95SBruce Richardson RTE_PIPELINE_ACTION_PORT_META, 18799a2dd95SBruce Richardson 18899a2dd95SBruce Richardson /** Send packet to table */ 18999a2dd95SBruce Richardson RTE_PIPELINE_ACTION_TABLE, 19099a2dd95SBruce Richardson 19199a2dd95SBruce Richardson /** Number of reserved actions */ 19299a2dd95SBruce Richardson RTE_PIPELINE_ACTIONS 19399a2dd95SBruce Richardson }; 19499a2dd95SBruce Richardson 19599a2dd95SBruce Richardson /* 19699a2dd95SBruce Richardson * Table 19799a2dd95SBruce Richardson */ 19899a2dd95SBruce Richardson /** Maximum number of tables allowed for any given pipeline instance. The 19999a2dd95SBruce Richardson value of this parameter cannot be changed. */ 20099a2dd95SBruce Richardson #define RTE_PIPELINE_TABLE_MAX 64 20199a2dd95SBruce Richardson 20299a2dd95SBruce Richardson /** 20399a2dd95SBruce Richardson * Head format for the table entry of any pipeline table. For any given 20499a2dd95SBruce Richardson * pipeline table, all table entries should have the same size and format. For 20599a2dd95SBruce Richardson * any given pipeline table, the table entry has to start with a head of this 20699a2dd95SBruce Richardson * structure, which contains the reserved actions and their associated 20799a2dd95SBruce Richardson * meta-data, and then optionally continues with user actions and their 20899a2dd95SBruce Richardson * associated meta-data. As all the currently defined reserved actions are 20999a2dd95SBruce Richardson * mutually exclusive, only one reserved action can be set per table entry. 21099a2dd95SBruce Richardson */ 21199a2dd95SBruce Richardson struct rte_pipeline_table_entry { 21299a2dd95SBruce Richardson /** Reserved action */ 21399a2dd95SBruce Richardson enum rte_pipeline_action action; 21499a2dd95SBruce Richardson 21599a2dd95SBruce Richardson union { 21699a2dd95SBruce Richardson /** Output port ID (meta-data for "Send packet to output port" 21799a2dd95SBruce Richardson action) */ 21899a2dd95SBruce Richardson uint32_t port_id; 21999a2dd95SBruce Richardson /** Table ID (meta-data for "Send packet to table" action) */ 22099a2dd95SBruce Richardson uint32_t table_id; 22199a2dd95SBruce Richardson }; 22299a2dd95SBruce Richardson /** Start of table entry area for user defined actions and meta-data */ 2238d765993STyler Retzlaff uint8_t action_data[]; 22499a2dd95SBruce Richardson }; 22599a2dd95SBruce Richardson 22699a2dd95SBruce Richardson /** 22799a2dd95SBruce Richardson * Pipeline table action handler on lookup hit 22899a2dd95SBruce Richardson * 22999a2dd95SBruce Richardson * The action handler can decide to drop packets by resetting the associated 23099a2dd95SBruce Richardson * packet bit in the pkts_mask parameter. In this case, the action handler is 23199a2dd95SBruce Richardson * required not to free the packet buffer, which will be freed eventually by 23299a2dd95SBruce Richardson * the pipeline. 23399a2dd95SBruce Richardson * 23499a2dd95SBruce Richardson * @param p 23599a2dd95SBruce Richardson * Handle to pipeline instance 23699a2dd95SBruce Richardson * @param pkts 23799a2dd95SBruce Richardson * Burst of input packets specified as array of up to 64 pointers to struct 23899a2dd95SBruce Richardson * rte_mbuf 23999a2dd95SBruce Richardson * @param pkts_mask 24099a2dd95SBruce Richardson * 64-bit bitmask specifying which packets in the input burst are valid. When 24199a2dd95SBruce Richardson * pkts_mask bit n is set, then element n of pkts array is pointing to a 24299a2dd95SBruce Richardson * valid packet and element n of entries array is pointing to a valid table 24399a2dd95SBruce Richardson * entry associated with the packet, with the association typically done by 24499a2dd95SBruce Richardson * the table lookup operation. Otherwise, element n of pkts array and element 24599a2dd95SBruce Richardson * n of entries array will not be accessed. 24699a2dd95SBruce Richardson * @param entries 24799a2dd95SBruce Richardson * Set of table entries specified as array of up to 64 pointers to struct 24899a2dd95SBruce Richardson * rte_pipeline_table_entry 24999a2dd95SBruce Richardson * @param arg 25099a2dd95SBruce Richardson * Opaque parameter registered by the user at the pipeline table creation 25199a2dd95SBruce Richardson * time 25299a2dd95SBruce Richardson * @return 25399a2dd95SBruce Richardson * 0 on success, error code otherwise 25499a2dd95SBruce Richardson */ 25599a2dd95SBruce Richardson typedef int (*rte_pipeline_table_action_handler_hit)( 25699a2dd95SBruce Richardson struct rte_pipeline *p, 25799a2dd95SBruce Richardson struct rte_mbuf **pkts, 25899a2dd95SBruce Richardson uint64_t pkts_mask, 25999a2dd95SBruce Richardson struct rte_pipeline_table_entry **entries, 26099a2dd95SBruce Richardson void *arg); 26199a2dd95SBruce Richardson 26299a2dd95SBruce Richardson /** 26399a2dd95SBruce Richardson * Pipeline table action handler on lookup miss 26499a2dd95SBruce Richardson * 26599a2dd95SBruce Richardson * The action handler can decide to drop packets by resetting the associated 26699a2dd95SBruce Richardson * packet bit in the pkts_mask parameter. In this case, the action handler is 26799a2dd95SBruce Richardson * required not to free the packet buffer, which will be freed eventually by 26899a2dd95SBruce Richardson * the pipeline. 26999a2dd95SBruce Richardson * 27099a2dd95SBruce Richardson * @param p 27199a2dd95SBruce Richardson * Handle to pipeline instance 27299a2dd95SBruce Richardson * @param pkts 27399a2dd95SBruce Richardson * Burst of input packets specified as array of up to 64 pointers to struct 27499a2dd95SBruce Richardson * rte_mbuf 27599a2dd95SBruce Richardson * @param pkts_mask 27699a2dd95SBruce Richardson * 64-bit bitmask specifying which packets in the input burst are valid. When 27799a2dd95SBruce Richardson * pkts_mask bit n is set, then element n of pkts array is pointing to a 27899a2dd95SBruce Richardson * valid packet. Otherwise, element n of pkts array will not be accessed. 27999a2dd95SBruce Richardson * @param entry 28099a2dd95SBruce Richardson * Single table entry associated with all the valid packets from the input 28199a2dd95SBruce Richardson * burst, specified as pointer to struct rte_pipeline_table_entry. 28299a2dd95SBruce Richardson * This entry is the pipeline table default entry that is associated by the 28399a2dd95SBruce Richardson * table lookup operation with the input packets that have resulted in lookup 28499a2dd95SBruce Richardson * miss. 28599a2dd95SBruce Richardson * @param arg 28699a2dd95SBruce Richardson * Opaque parameter registered by the user at the pipeline table creation 28799a2dd95SBruce Richardson * time 28899a2dd95SBruce Richardson * @return 28999a2dd95SBruce Richardson * 0 on success, error code otherwise 29099a2dd95SBruce Richardson */ 29199a2dd95SBruce Richardson typedef int (*rte_pipeline_table_action_handler_miss)( 29299a2dd95SBruce Richardson struct rte_pipeline *p, 29399a2dd95SBruce Richardson struct rte_mbuf **pkts, 29499a2dd95SBruce Richardson uint64_t pkts_mask, 29599a2dd95SBruce Richardson struct rte_pipeline_table_entry *entry, 29699a2dd95SBruce Richardson void *arg); 29799a2dd95SBruce Richardson 29899a2dd95SBruce Richardson /** Parameters for pipeline table creation. Action handlers have to be either 29999a2dd95SBruce Richardson both enabled or both disabled (they can be disabled by setting them to 30099a2dd95SBruce Richardson NULL). */ 30199a2dd95SBruce Richardson struct rte_pipeline_table_params { 30299a2dd95SBruce Richardson /** Table operations (specific to each table type) */ 30399a2dd95SBruce Richardson struct rte_table_ops *ops; 30499a2dd95SBruce Richardson /** Opaque param to be passed to the table create operation when 30599a2dd95SBruce Richardson invoked */ 30699a2dd95SBruce Richardson void *arg_create; 30799a2dd95SBruce Richardson /** Callback function to execute the user actions on input packets in 30899a2dd95SBruce Richardson case of lookup hit */ 30999a2dd95SBruce Richardson rte_pipeline_table_action_handler_hit f_action_hit; 31099a2dd95SBruce Richardson /** Callback function to execute the user actions on input packets in 31199a2dd95SBruce Richardson case of lookup miss */ 31299a2dd95SBruce Richardson rte_pipeline_table_action_handler_miss f_action_miss; 31399a2dd95SBruce Richardson 31499a2dd95SBruce Richardson /** Opaque parameter to be passed to lookup hit and/or lookup miss 31599a2dd95SBruce Richardson action handlers when invoked */ 31699a2dd95SBruce Richardson void *arg_ah; 31799a2dd95SBruce Richardson /** Memory size to be reserved per table entry for storing the user 31899a2dd95SBruce Richardson actions and their meta-data */ 31999a2dd95SBruce Richardson uint32_t action_data_size; 32099a2dd95SBruce Richardson }; 32199a2dd95SBruce Richardson 32299a2dd95SBruce Richardson /** 32399a2dd95SBruce Richardson * Pipeline table create 32499a2dd95SBruce Richardson * 32599a2dd95SBruce Richardson * @param p 32699a2dd95SBruce Richardson * Handle to pipeline instance 32799a2dd95SBruce Richardson * @param params 32899a2dd95SBruce Richardson * Parameters for pipeline table creation 32999a2dd95SBruce Richardson * @param table_id 33099a2dd95SBruce Richardson * Table ID. Valid only within the scope of table IDs of the current 33199a2dd95SBruce Richardson * pipeline. Only returned after a successful invocation. 33299a2dd95SBruce Richardson * @return 33399a2dd95SBruce Richardson * 0 on success, error code otherwise 33499a2dd95SBruce Richardson */ 33599a2dd95SBruce Richardson int rte_pipeline_table_create(struct rte_pipeline *p, 33699a2dd95SBruce Richardson struct rte_pipeline_table_params *params, 33799a2dd95SBruce Richardson uint32_t *table_id); 33899a2dd95SBruce Richardson 33999a2dd95SBruce Richardson /** 34099a2dd95SBruce Richardson * Pipeline table default entry add 34199a2dd95SBruce Richardson * 34299a2dd95SBruce Richardson * The contents of the table default entry is updated with the provided actions 34399a2dd95SBruce Richardson * and meta-data. When the default entry is not configured (by using this 34499a2dd95SBruce Richardson * function), the built-in default entry has the action "Drop" and meta-data 34599a2dd95SBruce Richardson * set to all-zeros. 34699a2dd95SBruce Richardson * 34799a2dd95SBruce Richardson * @param p 34899a2dd95SBruce Richardson * Handle to pipeline instance 34999a2dd95SBruce Richardson * @param table_id 35099a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 35199a2dd95SBruce Richardson * @param default_entry 35299a2dd95SBruce Richardson * New contents for the table default entry 35399a2dd95SBruce Richardson * @param default_entry_ptr 35499a2dd95SBruce Richardson * On successful invocation, pointer to the default table entry which can be 35599a2dd95SBruce Richardson * used for further read-write accesses to this table entry. This pointer 35699a2dd95SBruce Richardson * is valid until the default entry is deleted or re-added. 35799a2dd95SBruce Richardson * @return 35899a2dd95SBruce Richardson * 0 on success, error code otherwise 35999a2dd95SBruce Richardson */ 36099a2dd95SBruce Richardson int rte_pipeline_table_default_entry_add(struct rte_pipeline *p, 36199a2dd95SBruce Richardson uint32_t table_id, 36299a2dd95SBruce Richardson struct rte_pipeline_table_entry *default_entry, 36399a2dd95SBruce Richardson struct rte_pipeline_table_entry **default_entry_ptr); 36499a2dd95SBruce Richardson 36599a2dd95SBruce Richardson /** 36699a2dd95SBruce Richardson * Pipeline table default entry delete 36799a2dd95SBruce Richardson * 36899a2dd95SBruce Richardson * The new contents of the table default entry is set to reserved action "Drop 36999a2dd95SBruce Richardson * the packet" with meta-data cleared (i.e. set to all-zeros). 37099a2dd95SBruce Richardson * 37199a2dd95SBruce Richardson * @param p 37299a2dd95SBruce Richardson * Handle to pipeline instance 37399a2dd95SBruce Richardson * @param table_id 37499a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 37599a2dd95SBruce Richardson * @param entry 37699a2dd95SBruce Richardson * On successful invocation, when entry points to a valid buffer, the 37799a2dd95SBruce Richardson * previous contents of the table default entry (as it was just before the 37899a2dd95SBruce Richardson * delete operation) is copied to this buffer 37999a2dd95SBruce Richardson * @return 38099a2dd95SBruce Richardson * 0 on success, error code otherwise 38199a2dd95SBruce Richardson */ 38299a2dd95SBruce Richardson int rte_pipeline_table_default_entry_delete(struct rte_pipeline *p, 38399a2dd95SBruce Richardson uint32_t table_id, 38499a2dd95SBruce Richardson struct rte_pipeline_table_entry *entry); 38599a2dd95SBruce Richardson 38699a2dd95SBruce Richardson /** 38799a2dd95SBruce Richardson * Pipeline table entry add 38899a2dd95SBruce Richardson * 38999a2dd95SBruce Richardson * @param p 39099a2dd95SBruce Richardson * Handle to pipeline instance 39199a2dd95SBruce Richardson * @param table_id 39299a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 39399a2dd95SBruce Richardson * @param key 39499a2dd95SBruce Richardson * Table entry key 39599a2dd95SBruce Richardson * @param entry 39699a2dd95SBruce Richardson * New contents for the table entry identified by key 39799a2dd95SBruce Richardson * @param key_found 39899a2dd95SBruce Richardson * On successful invocation, set to TRUE (value different than 0) if key was 39999a2dd95SBruce Richardson * already present in the table before the add operation and to FALSE (value 40099a2dd95SBruce Richardson * 0) if not 40199a2dd95SBruce Richardson * @param entry_ptr 40299a2dd95SBruce Richardson * On successful invocation, pointer to the table entry associated with key. 40399a2dd95SBruce Richardson * This can be used for further read-write accesses to this table entry and 40499a2dd95SBruce Richardson * is valid until the key is deleted from the table or re-added (usually for 40599a2dd95SBruce Richardson * associating different actions and/or action meta-data to the current key) 40699a2dd95SBruce Richardson * @return 40799a2dd95SBruce Richardson * 0 on success, error code otherwise 40899a2dd95SBruce Richardson */ 40999a2dd95SBruce Richardson int rte_pipeline_table_entry_add(struct rte_pipeline *p, 41099a2dd95SBruce Richardson uint32_t table_id, 41199a2dd95SBruce Richardson void *key, 41299a2dd95SBruce Richardson struct rte_pipeline_table_entry *entry, 41399a2dd95SBruce Richardson int *key_found, 41499a2dd95SBruce Richardson struct rte_pipeline_table_entry **entry_ptr); 41599a2dd95SBruce Richardson 41699a2dd95SBruce Richardson /** 41799a2dd95SBruce Richardson * Pipeline table entry delete 41899a2dd95SBruce Richardson * 41999a2dd95SBruce Richardson * @param p 42099a2dd95SBruce Richardson * Handle to pipeline instance 42199a2dd95SBruce Richardson * @param table_id 42299a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 42399a2dd95SBruce Richardson * @param key 42499a2dd95SBruce Richardson * Table entry key 42599a2dd95SBruce Richardson * @param key_found 42699a2dd95SBruce Richardson * On successful invocation, set to TRUE (value different than 0) if key was 42799a2dd95SBruce Richardson * found in the table before the delete operation and to FALSE (value 0) if 42899a2dd95SBruce Richardson * not 42999a2dd95SBruce Richardson * @param entry 43099a2dd95SBruce Richardson * On successful invocation, when key is found in the table and entry points 43199a2dd95SBruce Richardson * to a valid buffer, the table entry contents (as it was before the delete 43299a2dd95SBruce Richardson * was performed) is copied to this buffer 43399a2dd95SBruce Richardson * @return 43499a2dd95SBruce Richardson * 0 on success, error code otherwise 43599a2dd95SBruce Richardson */ 43699a2dd95SBruce Richardson int rte_pipeline_table_entry_delete(struct rte_pipeline *p, 43799a2dd95SBruce Richardson uint32_t table_id, 43899a2dd95SBruce Richardson void *key, 43999a2dd95SBruce Richardson int *key_found, 44099a2dd95SBruce Richardson struct rte_pipeline_table_entry *entry); 44199a2dd95SBruce Richardson 44299a2dd95SBruce Richardson /** 44399a2dd95SBruce Richardson * Pipeline table entry add bulk 44499a2dd95SBruce Richardson * 44599a2dd95SBruce Richardson * @param p 44699a2dd95SBruce Richardson * Handle to pipeline instance 44799a2dd95SBruce Richardson * @param table_id 44899a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 44999a2dd95SBruce Richardson * @param keys 45099a2dd95SBruce Richardson * Array containing table entry keys 45199a2dd95SBruce Richardson * @param entries 45299a2dd95SBruce Richardson * Array containing new contents for every table entry identified by key 45399a2dd95SBruce Richardson * @param n_keys 45499a2dd95SBruce Richardson * Number of keys to add 45599a2dd95SBruce Richardson * @param key_found 45699a2dd95SBruce Richardson * On successful invocation, key_found for every item in the array is set to 45799a2dd95SBruce Richardson * TRUE (value different than 0) if key was already present in the table 45899a2dd95SBruce Richardson * before the add operation and to FALSE (value 0) if not 45999a2dd95SBruce Richardson * @param entries_ptr 46099a2dd95SBruce Richardson * On successful invocation, array *entries_ptr stores pointer to every table 46199a2dd95SBruce Richardson * entry associated with key. This can be used for further read-write accesses 46299a2dd95SBruce Richardson * to this table entry and is valid until the key is deleted from the table or 46399a2dd95SBruce Richardson * re-added (usually for associating different actions and/or action meta-data 46499a2dd95SBruce Richardson * to the current key) 46599a2dd95SBruce Richardson * @return 46699a2dd95SBruce Richardson * 0 on success, error code otherwise 46799a2dd95SBruce Richardson */ 46899a2dd95SBruce Richardson int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p, 46999a2dd95SBruce Richardson uint32_t table_id, 47099a2dd95SBruce Richardson void **keys, 47199a2dd95SBruce Richardson struct rte_pipeline_table_entry **entries, 47299a2dd95SBruce Richardson uint32_t n_keys, 47399a2dd95SBruce Richardson int *key_found, 47499a2dd95SBruce Richardson struct rte_pipeline_table_entry **entries_ptr); 47599a2dd95SBruce Richardson 47699a2dd95SBruce Richardson /** 47799a2dd95SBruce Richardson * Pipeline table entry delete bulk 47899a2dd95SBruce Richardson * 47999a2dd95SBruce Richardson * @param p 48099a2dd95SBruce Richardson * Handle to pipeline instance 48199a2dd95SBruce Richardson * @param table_id 48299a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 48399a2dd95SBruce Richardson * @param keys 48499a2dd95SBruce Richardson * Array containing table entry keys 48599a2dd95SBruce Richardson * @param n_keys 48699a2dd95SBruce Richardson * Number of keys to delete 48799a2dd95SBruce Richardson * @param key_found 48899a2dd95SBruce Richardson * On successful invocation, key_found for every item in the array is set to 48999a2dd95SBruce Richardson * TRUE (value different than 0) if key was found in the table before the 49099a2dd95SBruce Richardson * delete operation and to FALSE (value 0) if not 49199a2dd95SBruce Richardson * @param entries 49299a2dd95SBruce Richardson * If entries pointer is NULL, this pointer is ignored for every entry found. 49399a2dd95SBruce Richardson * Else, after successful invocation, if specific key is found in the table 49499a2dd95SBruce Richardson * and entry points to a valid buffer, the table entry contents (as it was 49599a2dd95SBruce Richardson * before the delete was performed) is copied to this buffer. 49699a2dd95SBruce Richardson * @return 49799a2dd95SBruce Richardson * 0 on success, error code otherwise 49899a2dd95SBruce Richardson */ 49999a2dd95SBruce Richardson int rte_pipeline_table_entry_delete_bulk(struct rte_pipeline *p, 50099a2dd95SBruce Richardson uint32_t table_id, 50199a2dd95SBruce Richardson void **keys, 50299a2dd95SBruce Richardson uint32_t n_keys, 50399a2dd95SBruce Richardson int *key_found, 50499a2dd95SBruce Richardson struct rte_pipeline_table_entry **entries); 50599a2dd95SBruce Richardson 50699a2dd95SBruce Richardson /** 50799a2dd95SBruce Richardson * Read pipeline table stats. 50899a2dd95SBruce Richardson * 50999a2dd95SBruce Richardson * This function reads table statistics identified by *table_id* of given 51099a2dd95SBruce Richardson * pipeline *p*. 51199a2dd95SBruce Richardson * 51299a2dd95SBruce Richardson * @param p 51399a2dd95SBruce Richardson * Handle to pipeline instance. 51499a2dd95SBruce Richardson * @param table_id 51599a2dd95SBruce Richardson * Port ID what stats will be returned. 51699a2dd95SBruce Richardson * @param stats 51799a2dd95SBruce Richardson * Statistics buffer. 51899a2dd95SBruce Richardson * @param clear 51999a2dd95SBruce Richardson * If not 0 clear stats after reading. 52099a2dd95SBruce Richardson * @return 52199a2dd95SBruce Richardson * 0 on success, error code otherwise 52299a2dd95SBruce Richardson */ 52399a2dd95SBruce Richardson int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id, 52499a2dd95SBruce Richardson struct rte_pipeline_table_stats *stats, int clear); 52599a2dd95SBruce Richardson 52699a2dd95SBruce Richardson /* 52799a2dd95SBruce Richardson * Port IN 52899a2dd95SBruce Richardson */ 52999a2dd95SBruce Richardson /** Maximum number of input ports allowed for any given pipeline instance. The 53099a2dd95SBruce Richardson value of this parameter cannot be changed. */ 53199a2dd95SBruce Richardson #define RTE_PIPELINE_PORT_IN_MAX 64 53299a2dd95SBruce Richardson 53399a2dd95SBruce Richardson /** 53499a2dd95SBruce Richardson * Pipeline input port action handler 53599a2dd95SBruce Richardson * 53699a2dd95SBruce Richardson * The action handler can decide to drop packets by resetting the associated 53799a2dd95SBruce Richardson * packet bit in the pkts_mask parameter. In this case, the action handler is 53899a2dd95SBruce Richardson * required not to free the packet buffer, which will be freed eventually by 53999a2dd95SBruce Richardson * the pipeline. 54099a2dd95SBruce Richardson * 54199a2dd95SBruce Richardson * @param p 54299a2dd95SBruce Richardson * Handle to pipeline instance 54399a2dd95SBruce Richardson * @param pkts 54499a2dd95SBruce Richardson * Burst of input packets specified as array of up to 64 pointers to struct 54599a2dd95SBruce Richardson * rte_mbuf 54699a2dd95SBruce Richardson * @param n 54799a2dd95SBruce Richardson * Number of packets in the input burst. This parameter specifies that 54899a2dd95SBruce Richardson * elements 0 to (n-1) of pkts array are valid. 54999a2dd95SBruce Richardson * @param arg 55099a2dd95SBruce Richardson * Opaque parameter registered by the user at the pipeline table creation 55199a2dd95SBruce Richardson * time 55299a2dd95SBruce Richardson * @return 55399a2dd95SBruce Richardson * 0 on success, error code otherwise 55499a2dd95SBruce Richardson */ 55599a2dd95SBruce Richardson typedef int (*rte_pipeline_port_in_action_handler)( 55699a2dd95SBruce Richardson struct rte_pipeline *p, 55799a2dd95SBruce Richardson struct rte_mbuf **pkts, 55899a2dd95SBruce Richardson uint32_t n, 55999a2dd95SBruce Richardson void *arg); 56099a2dd95SBruce Richardson 56199a2dd95SBruce Richardson /** Parameters for pipeline input port creation */ 56299a2dd95SBruce Richardson struct rte_pipeline_port_in_params { 56399a2dd95SBruce Richardson /** Input port operations (specific to each table type) */ 56499a2dd95SBruce Richardson struct rte_port_in_ops *ops; 56599a2dd95SBruce Richardson /** Opaque parameter to be passed to create operation when invoked */ 56699a2dd95SBruce Richardson void *arg_create; 56799a2dd95SBruce Richardson 56899a2dd95SBruce Richardson /** Callback function to execute the user actions on input packets. 56999a2dd95SBruce Richardson Disabled if set to NULL. */ 57099a2dd95SBruce Richardson rte_pipeline_port_in_action_handler f_action; 57199a2dd95SBruce Richardson /** Opaque parameter to be passed to the action handler when invoked */ 57299a2dd95SBruce Richardson void *arg_ah; 57399a2dd95SBruce Richardson 57499a2dd95SBruce Richardson /** Recommended burst size for the RX operation(in number of pkts) */ 57599a2dd95SBruce Richardson uint32_t burst_size; 57699a2dd95SBruce Richardson }; 57799a2dd95SBruce Richardson 57899a2dd95SBruce Richardson /** 57999a2dd95SBruce Richardson * Pipeline input port create 58099a2dd95SBruce Richardson * 58199a2dd95SBruce Richardson * @param p 58299a2dd95SBruce Richardson * Handle to pipeline instance 58399a2dd95SBruce Richardson * @param params 58499a2dd95SBruce Richardson * Parameters for pipeline input port creation 58599a2dd95SBruce Richardson * @param port_id 58699a2dd95SBruce Richardson * Input port ID. Valid only within the scope of input port IDs of the 58799a2dd95SBruce Richardson * current pipeline. Only returned after a successful invocation. 58899a2dd95SBruce Richardson * @return 58999a2dd95SBruce Richardson * 0 on success, error code otherwise 59099a2dd95SBruce Richardson */ 59199a2dd95SBruce Richardson int rte_pipeline_port_in_create(struct rte_pipeline *p, 59299a2dd95SBruce Richardson struct rte_pipeline_port_in_params *params, 59399a2dd95SBruce Richardson uint32_t *port_id); 59499a2dd95SBruce Richardson 59599a2dd95SBruce Richardson /** 59699a2dd95SBruce Richardson * Pipeline input port connect to table 59799a2dd95SBruce Richardson * 59899a2dd95SBruce Richardson * @param p 59999a2dd95SBruce Richardson * Handle to pipeline instance 60099a2dd95SBruce Richardson * @param port_id 60199a2dd95SBruce Richardson * Port ID (returned by previous invocation of pipeline input port create) 60299a2dd95SBruce Richardson * @param table_id 60399a2dd95SBruce Richardson * Table ID (returned by previous invocation of pipeline table create) 60499a2dd95SBruce Richardson * @return 60599a2dd95SBruce Richardson * 0 on success, error code otherwise 60699a2dd95SBruce Richardson */ 60799a2dd95SBruce Richardson int rte_pipeline_port_in_connect_to_table(struct rte_pipeline *p, 60899a2dd95SBruce Richardson uint32_t port_id, 60999a2dd95SBruce Richardson uint32_t table_id); 61099a2dd95SBruce Richardson 61199a2dd95SBruce Richardson /** 61299a2dd95SBruce Richardson * Pipeline input port enable 61399a2dd95SBruce Richardson * 61499a2dd95SBruce Richardson * @param p 61599a2dd95SBruce Richardson * Handle to pipeline instance 61699a2dd95SBruce Richardson * @param port_id 61799a2dd95SBruce Richardson * Port ID (returned by previous invocation of pipeline input port create) 61899a2dd95SBruce Richardson * @return 61999a2dd95SBruce Richardson * 0 on success, error code otherwise 62099a2dd95SBruce Richardson */ 62199a2dd95SBruce Richardson int rte_pipeline_port_in_enable(struct rte_pipeline *p, 62299a2dd95SBruce Richardson uint32_t port_id); 62399a2dd95SBruce Richardson 62499a2dd95SBruce Richardson /** 62599a2dd95SBruce Richardson * Pipeline input port disable 62699a2dd95SBruce Richardson * 62799a2dd95SBruce Richardson * @param p 62899a2dd95SBruce Richardson * Handle to pipeline instance 62999a2dd95SBruce Richardson * @param port_id 63099a2dd95SBruce Richardson * Port ID (returned by previous invocation of pipeline input port create) 63199a2dd95SBruce Richardson * @return 63299a2dd95SBruce Richardson * 0 on success, error code otherwise 63399a2dd95SBruce Richardson */ 63499a2dd95SBruce Richardson int rte_pipeline_port_in_disable(struct rte_pipeline *p, 63599a2dd95SBruce Richardson uint32_t port_id); 63699a2dd95SBruce Richardson 63799a2dd95SBruce Richardson /** 63899a2dd95SBruce Richardson * Read pipeline port in stats. 63999a2dd95SBruce Richardson * 64099a2dd95SBruce Richardson * This function reads port in statistics identified by *port_id* of given 64199a2dd95SBruce Richardson * pipeline *p*. 64299a2dd95SBruce Richardson * 64399a2dd95SBruce Richardson * @param p 64499a2dd95SBruce Richardson * Handle to pipeline instance. 64599a2dd95SBruce Richardson * @param port_id 64699a2dd95SBruce Richardson * Port ID what stats will be returned. 64799a2dd95SBruce Richardson * @param stats 64899a2dd95SBruce Richardson * Statistics buffer. 64999a2dd95SBruce Richardson * @param clear 65099a2dd95SBruce Richardson * If not 0 clear stats after reading. 65199a2dd95SBruce Richardson * @return 65299a2dd95SBruce Richardson * 0 on success, error code otherwise 65399a2dd95SBruce Richardson */ 65499a2dd95SBruce Richardson int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id, 65599a2dd95SBruce Richardson struct rte_pipeline_port_in_stats *stats, int clear); 65699a2dd95SBruce Richardson 65799a2dd95SBruce Richardson /* 65899a2dd95SBruce Richardson * Port OUT 65999a2dd95SBruce Richardson */ 66099a2dd95SBruce Richardson /** Maximum number of output ports allowed for any given pipeline instance. The 66199a2dd95SBruce Richardson value of this parameter cannot be changed. */ 66299a2dd95SBruce Richardson #define RTE_PIPELINE_PORT_OUT_MAX 64 66399a2dd95SBruce Richardson 66499a2dd95SBruce Richardson /** 66599a2dd95SBruce Richardson * Pipeline output port action handler 66699a2dd95SBruce Richardson * 66799a2dd95SBruce Richardson * The action handler can decide to drop packets by resetting the associated 66899a2dd95SBruce Richardson * packet bit in the pkts_mask parameter. In this case, the action handler is 66999a2dd95SBruce Richardson * required not to free the packet buffer, which will be freed eventually by 67099a2dd95SBruce Richardson * the pipeline. 67199a2dd95SBruce Richardson * 67299a2dd95SBruce Richardson * @param p 67399a2dd95SBruce Richardson * Handle to pipeline instance 67499a2dd95SBruce Richardson * @param pkts 67599a2dd95SBruce Richardson * Burst of input packets specified as array of up to 64 pointers to struct 67699a2dd95SBruce Richardson * rte_mbuf 67799a2dd95SBruce Richardson * @param pkts_mask 67899a2dd95SBruce Richardson * 64-bit bitmask specifying which packets in the input burst are valid. When 67999a2dd95SBruce Richardson * pkts_mask bit n is set, then element n of pkts array is pointing to a 68099a2dd95SBruce Richardson * valid packet. Otherwise, element n of pkts array will not be accessed. 68199a2dd95SBruce Richardson * @param arg 68299a2dd95SBruce Richardson * Opaque parameter registered by the user at the pipeline table creation 68399a2dd95SBruce Richardson * time 68499a2dd95SBruce Richardson * @return 68599a2dd95SBruce Richardson * 0 on success, error code otherwise 68699a2dd95SBruce Richardson */ 68799a2dd95SBruce Richardson typedef int (*rte_pipeline_port_out_action_handler)( 68899a2dd95SBruce Richardson struct rte_pipeline *p, 68999a2dd95SBruce Richardson struct rte_mbuf **pkts, 69099a2dd95SBruce Richardson uint64_t pkts_mask, 69199a2dd95SBruce Richardson void *arg); 69299a2dd95SBruce Richardson 69399a2dd95SBruce Richardson /** Parameters for pipeline output port creation. The action handlers have to 69499a2dd95SBruce Richardson be either both enabled or both disabled (by setting them to NULL). When 69599a2dd95SBruce Richardson enabled, the pipeline selects between them at different moments, based on the 69699a2dd95SBruce Richardson number of packets that have to be sent to the same output port. */ 69799a2dd95SBruce Richardson struct rte_pipeline_port_out_params { 69899a2dd95SBruce Richardson /** Output port operations (specific to each table type) */ 69999a2dd95SBruce Richardson struct rte_port_out_ops *ops; 70099a2dd95SBruce Richardson /** Opaque parameter to be passed to create operation when invoked */ 70199a2dd95SBruce Richardson void *arg_create; 70299a2dd95SBruce Richardson 70399a2dd95SBruce Richardson /** Callback function executing the user actions on bust of input 70499a2dd95SBruce Richardson packets */ 70599a2dd95SBruce Richardson rte_pipeline_port_out_action_handler f_action; 70699a2dd95SBruce Richardson /** Opaque parameter to be passed to the action handler when invoked */ 70799a2dd95SBruce Richardson void *arg_ah; 70899a2dd95SBruce Richardson }; 70999a2dd95SBruce Richardson 71099a2dd95SBruce Richardson /** 71199a2dd95SBruce Richardson * Pipeline output port create 71299a2dd95SBruce Richardson * 71399a2dd95SBruce Richardson * @param p 71499a2dd95SBruce Richardson * Handle to pipeline instance 71599a2dd95SBruce Richardson * @param params 71699a2dd95SBruce Richardson * Parameters for pipeline output port creation 71799a2dd95SBruce Richardson * @param port_id 71899a2dd95SBruce Richardson * Output port ID. Valid only within the scope of output port IDs of the 71999a2dd95SBruce Richardson * current pipeline. Only returned after a successful invocation. 72099a2dd95SBruce Richardson * @return 72199a2dd95SBruce Richardson * 0 on success, error code otherwise 72299a2dd95SBruce Richardson */ 72399a2dd95SBruce Richardson int rte_pipeline_port_out_create(struct rte_pipeline *p, 72499a2dd95SBruce Richardson struct rte_pipeline_port_out_params *params, 72599a2dd95SBruce Richardson uint32_t *port_id); 72699a2dd95SBruce Richardson 72799a2dd95SBruce Richardson /** 72899a2dd95SBruce Richardson * Read pipeline port out stats. 72999a2dd95SBruce Richardson * 73099a2dd95SBruce Richardson * This function reads port out statistics identified by *port_id* of given 73199a2dd95SBruce Richardson * pipeline *p*. 73299a2dd95SBruce Richardson * 73399a2dd95SBruce Richardson * @param p 73499a2dd95SBruce Richardson * Handle to pipeline instance. 73599a2dd95SBruce Richardson * @param port_id 73699a2dd95SBruce Richardson * Port ID what stats will be returned. 73799a2dd95SBruce Richardson * @param stats 73899a2dd95SBruce Richardson * Statistics buffer. 73999a2dd95SBruce Richardson * @param clear 74099a2dd95SBruce Richardson * If not 0 clear stats after reading. 74199a2dd95SBruce Richardson * @return 74299a2dd95SBruce Richardson * 0 on success, error code otherwise 74399a2dd95SBruce Richardson */ 74499a2dd95SBruce Richardson int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id, 74599a2dd95SBruce Richardson struct rte_pipeline_port_out_stats *stats, int clear); 74699a2dd95SBruce Richardson 74799a2dd95SBruce Richardson /* 74899a2dd95SBruce Richardson * Functions to be called as part of the port IN/OUT or table action handlers 74999a2dd95SBruce Richardson */ 75099a2dd95SBruce Richardson /** 75199a2dd95SBruce Richardson * Action handler packet insert to output port 75299a2dd95SBruce Richardson * 75399a2dd95SBruce Richardson * This function can be called by any input/output port or table action handler 75499a2dd95SBruce Richardson * to send a packet out through one of the pipeline output ports. This packet is 75599a2dd95SBruce Richardson * generated by the action handler, i.e. this packet is not part of the burst of 75699a2dd95SBruce Richardson * packets read from one of the pipeline input ports and currently processed by 75799a2dd95SBruce Richardson * the pipeline (this packet is not an element of the pkts array input parameter 75899a2dd95SBruce Richardson * of the action handler). 75999a2dd95SBruce Richardson * 76099a2dd95SBruce Richardson * @param p 76199a2dd95SBruce Richardson * Handle to pipeline instance 76299a2dd95SBruce Richardson * @param port_id 76399a2dd95SBruce Richardson * Output port ID (returned by previous invocation of pipeline output port 76499a2dd95SBruce Richardson * create) to send the packet specified by pkt 76599a2dd95SBruce Richardson * @param pkt 76699a2dd95SBruce Richardson * New packet generated by the action handler 76799a2dd95SBruce Richardson * @return 76899a2dd95SBruce Richardson * 0 on success, error code otherwise 76999a2dd95SBruce Richardson */ 77099a2dd95SBruce Richardson int rte_pipeline_port_out_packet_insert(struct rte_pipeline *p, 77199a2dd95SBruce Richardson uint32_t port_id, 77299a2dd95SBruce Richardson struct rte_mbuf *pkt); 77399a2dd95SBruce Richardson 77499a2dd95SBruce Richardson #define rte_pipeline_ah_port_out_packet_insert \ 77599a2dd95SBruce Richardson rte_pipeline_port_out_packet_insert 77699a2dd95SBruce Richardson 77799a2dd95SBruce Richardson /** 77899a2dd95SBruce Richardson * Action handler packet hijack 77999a2dd95SBruce Richardson * 78099a2dd95SBruce Richardson * This function can be called by any input/output port or table action handler 78199a2dd95SBruce Richardson * to hijack selected packets from the burst of packets read from one of the 78299a2dd95SBruce Richardson * pipeline input ports and currently processed by the pipeline. The hijacked 78399a2dd95SBruce Richardson * packets are removed from any further pipeline processing, with the action 78499a2dd95SBruce Richardson * handler now having the full ownership for these packets. 78599a2dd95SBruce Richardson * 78699a2dd95SBruce Richardson * The action handler can further send the hijacked packets out through any 78799a2dd95SBruce Richardson * pipeline output port by calling the rte_pipeline_ah_port_out_packet_insert() 78899a2dd95SBruce Richardson * function. The action handler can also drop these packets by calling the 78999a2dd95SBruce Richardson * rte_pktmbuf_free() function, although a better alternative is provided by 79099a2dd95SBruce Richardson * the action handler using the rte_pipeline_ah_packet_drop() function. 79199a2dd95SBruce Richardson * 79299a2dd95SBruce Richardson * @param p 79399a2dd95SBruce Richardson * Handle to pipeline instance 79499a2dd95SBruce Richardson * @param pkts_mask 79599a2dd95SBruce Richardson * 64-bit bitmask specifying which of the packets handed over for processing 79699a2dd95SBruce Richardson * to the action handler is to be hijacked by the action handler. When 79799a2dd95SBruce Richardson * pkts_mask bit n is set, then element n of the pkts array (input argument to 79899a2dd95SBruce Richardson * the action handler) is hijacked. 79999a2dd95SBruce Richardson * @return 80099a2dd95SBruce Richardson * 0 on success, error code otherwise 80199a2dd95SBruce Richardson */ 80299a2dd95SBruce Richardson int rte_pipeline_ah_packet_hijack(struct rte_pipeline *p, 80399a2dd95SBruce Richardson uint64_t pkts_mask); 80499a2dd95SBruce Richardson 80599a2dd95SBruce Richardson /** 80699a2dd95SBruce Richardson * Action handler packet drop 80799a2dd95SBruce Richardson * 80899a2dd95SBruce Richardson * This function is called by the pipeline action handlers (port in/out, table) 80999a2dd95SBruce Richardson * to drop the packets selected using packet mask. 81099a2dd95SBruce Richardson * 81199a2dd95SBruce Richardson * This function can be called by any input/output port or table action handler 81299a2dd95SBruce Richardson * to drop selected packets from the burst of packets read from one of the 81399a2dd95SBruce Richardson * pipeline input ports and currently processed by the pipeline. The dropped 81499a2dd95SBruce Richardson * packets are removed from any further pipeline processing and the packet 81599a2dd95SBruce Richardson * buffers are eventually freed to their buffer pool. 81699a2dd95SBruce Richardson * 81799a2dd95SBruce Richardson * This function updates the drop statistics counters correctly, therefore the 81899a2dd95SBruce Richardson * recommended approach for dropping packets by the action handlers is to call 81999a2dd95SBruce Richardson * this function as opposed to the action handler hijacking the packets first 82099a2dd95SBruce Richardson * and then dropping them invisibly to the pipeline (by using the 82199a2dd95SBruce Richardson * rte_pktmbuf_free() function). 82299a2dd95SBruce Richardson * 82399a2dd95SBruce Richardson * @param p 82499a2dd95SBruce Richardson * Handle to pipeline instance 82599a2dd95SBruce Richardson * @param pkts_mask 82699a2dd95SBruce Richardson * 64-bit bitmask specifying which of the packets handed over for processing 82799a2dd95SBruce Richardson * to the action handler is to be dropped by the action handler. When 82899a2dd95SBruce Richardson * pkts_mask bit n is set, then element n of the pkts array (input argument to 82999a2dd95SBruce Richardson * the action handler) is dropped. 83099a2dd95SBruce Richardson * @return 83199a2dd95SBruce Richardson * 0 on success, error code otherwise 83299a2dd95SBruce Richardson */ 83399a2dd95SBruce Richardson int rte_pipeline_ah_packet_drop(struct rte_pipeline *p, 83499a2dd95SBruce Richardson uint64_t pkts_mask); 83599a2dd95SBruce Richardson 83699a2dd95SBruce Richardson #ifdef __cplusplus 83799a2dd95SBruce Richardson } 83899a2dd95SBruce Richardson #endif 83999a2dd95SBruce Richardson 84099a2dd95SBruce Richardson #endif 841