[PATCH v3 13/19] net/i40e: add support for common flow parsing

Medvedkin, Vladimir vladimir.medvedkin at intel.com
Sat Sep 19 18:13:00 CEST 2026


Acked-by: Vladimir Medvedkin <vladimir.medvedkin at intel.com>

On 9/16/2026 1:18 PM, Anatoly Burakov wrote:
> Implement support for common flow parsing infrastructure in preparation for
> migration of flow engines.
>
> Currently, i40e explicitly clears KEEP_FLOW capability flag, meaning that
> it advertises that all flows are flushed on dev stop. However, in
> practice i40e actually restores all flows on dev start, so while we will
> not (yet) advertise the KEEP_FLOW capability flag, we will also not flush
> the flows on dev stop with the new engines, and instead replay them.
>
> Signed-off-by: Anatoly Burakov<anatoly.burakov at intel.com>
> ---
>   drivers/net/intel/i40e/i40e_ethdev.c | 21 +++++++++++
>   drivers/net/intel/i40e/i40e_ethdev.h |  5 +++
>   drivers/net/intel/i40e/i40e_flow.c   | 53 +++++++++++++++++++++++++++-
>   drivers/net/intel/i40e/i40e_flow.h   | 12 +++++++
>   4 files changed, 90 insertions(+), 1 deletion(-)
>   create mode 100644 drivers/net/intel/i40e/i40e_flow.h
>
> diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
> index d64d8dd7b56..a7fc82f67d6 100644
> --- a/drivers/net/intel/i40e/i40e_ethdev.c
> +++ b/drivers/net/intel/i40e/i40e_ethdev.c
> @@ -42,6 +42,9 @@
>   #include "i40e_regs.h"
>   #include "rte_pmd_i40e.h"
>   #include "i40e_hash.h"
> +#include "i40e_flow.h"
> +
> +#include "../common/flow_engine.h"
>   
>   #define ETH_I40E_FLOATING_VEB_ARG	"enable_floating_veb"
>   #define ETH_I40E_FLOATING_VEB_LIST_ARG	"floating_veb_list"
> @@ -1838,6 +1841,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
>   	if (ret < 0)
>   		goto err_init_fdir_filter_list;
>   
> +	/* initialize flow engine configuration */
> +	ret = ci_flow_engine_conf_init(&pf->flow_engine_conf,
> +			&i40e_flow_engine_list, dev->data);
> +	if (ret < 0)
> +		goto err_flow_engine_conf_init;
> +
>   	/* initialize queue region configuration */
>   	i40e_init_queue_region_conf(dev);
>   
> @@ -1846,6 +1855,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
>   
>   	return 0;
>   
> +err_flow_engine_conf_init:
> +	rte_free(pf->fdir.fdir_flow_pool.bitmap);
> +	rte_free(pf->fdir.fdir_flow_pool.pool);
> +	rte_free(pf->fdir.fdir_filter_array);
> +	rte_free(pf->fdir.hash_map);
> +	rte_hash_free(pf->fdir.hash_table);
>   err_init_fdir_filter_list:
>   	rte_hash_free(pf->tunnel.hash_table);
>   	rte_free(pf->tunnel.hash_map);
> @@ -2613,6 +2628,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
>   	/* Set the max frame size to HW*/
>   	i40e_aq_set_mac_config(hw, max_frame_size, TRUE, false, 0, NULL);
>   
> +	ci_flow_replay(&pf->flow_engine_conf);
> +
>   	return I40E_SUCCESS;
>   
>   tx_err:
> @@ -2715,6 +2732,10 @@ i40e_dev_close(struct rte_eth_dev *dev)
>   
>   	ret = i40e_dev_stop(dev);
>   
> +	/* free the flows and reset flow config */
> +	ci_flow_cleanup(&pf->flow_engine_conf);
> +	ci_flow_engine_conf_reset(&pf->flow_engine_conf);
> +
>   	i40e_dev_free_queues(dev);
>   
>   	/* Disable interrupt */
> diff --git a/drivers/net/intel/i40e/i40e_ethdev.h b/drivers/net/intel/i40e/i40e_ethdev.h
> index 1e64a2d2800..16b67268f7f 100644
> --- a/drivers/net/intel/i40e/i40e_ethdev.h
> +++ b/drivers/net/intel/i40e/i40e_ethdev.h
> @@ -21,6 +21,8 @@
>   #include "base/i40e_type.h"
>   #include "base/virtchnl.h"
>   
> +#include "../common/flow_engine.h" + #define I40E_AQ_LEN 32 #define I40E_AQ_BUF_SZ 4096 /* Number of 
> queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ @@ -278,6 
> +280,7 @@ enum i40e_flxpld_layer_idx { * Struct to store flow created. 
> */ struct rte_flow { + struct ci_flow base; TAILQ_ENTRY(rte_flow) 
> node; enum rte_filter_type filter_type; void *rule; @@ -1182,6 +1185,8 
> @@ struct i40e_pf { /* The floating enable flag for the specific VF */ 
> bool floating_veb_list[I40E_MAX_VF]; struct i40e_flow_list flow_list; 
> + /* flow engine configuration */ + struct ci_flow_engine_conf 
> flow_engine_conf; bool mpls_replace_flag; /* 1 - MPLS filter replace 
> is done */ bool gtp_replace_flag; /* 1 - GTP-C/U filter replace is 
> done */ bool qinq_replace_flag; /* QINQ filter replace is done */ diff 
> --git a/drivers/net/intel/i40e/i40e_flow.c 
> b/drivers/net/intel/i40e/i40e_flow.c index a017d3cd448..7d410b6c33b 
> 100644 --- a/drivers/net/intel/i40e/i40e_flow.c +++ 
> b/drivers/net/intel/i40e/i40e_flow.c @@ -26,9 +26,12 @@ #include "base/i40e_prototype.h"
>   #include "i40e_ethdev.h"
>   #include "i40e_hash.h"
> +#include "i40e_flow.h"
>   
>   #include "../common/flow_check.h"
>   
> +const struct ci_flow_engine_list i40e_flow_engine_list = {0};
> +
>   #define I40E_IPV6_TC_MASK	(0xFF << I40E_FDIR_IPv6_TC_OFFSET)
>   #define I40E_IPV6_FRAG_HEADER	44
>   #define I40E_TENANT_ARRAY_NUM	3
> @@ -1268,6 +1271,25 @@ i40e_flow_dev_dump(struct rte_eth_dev *dev,
>   	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
>   	struct rte_flow *p_flow;
>   	bool found = false;
> +	int ret;
> +
> +	/* try the new flow engine first */
> +	ret = ci_flow_dump(&pf->flow_engine_conf, flow, file, error);
> +
> +	/*
> +	 * There are multiple possible situations here:
> +	 *
> +	 * - User requested to dump all flows
> +	 * - User requested to dump a specific flow
> +	 *
> +	 * For the first case, we keep going because legacy engines might still
> +	 * have flows we want to dump.
> +	 *
> +	 * For the second case, we only keep going if the flow we were asked to
> +	 * dump was not found in the new engines.
> +	 */
> +	if (flow != NULL && ret == 0)
> +		return 0;
>   
>   	TAILQ_FOREACH(p_flow, &pf->flow_list, node) {
>   		size_t rule_size = 0;
> @@ -3892,8 +3914,15 @@ i40e_flow_validate(struct rte_eth_dev *dev,
>   		   const struct rte_flow_action actions[],
>   		   struct rte_flow_error *error)
>   {
> +	struct i40e_pf *pf = dev->data->dev_private;
>   	/* creates dummy context */
>   	struct i40e_filter_ctx filter_ctx = {0};
> +	int ret;
> +
> +	/* try the new engine first */
> +	ret = ci_flow_validate(&pf->flow_engine_conf, attr, pattern, actions, error);
> +	if (ret == 0)
> +		return 0;
>   
>   	return i40e_flow_check(dev, attr, pattern, actions, &filter_ctx, error);
>   }
> @@ -3911,6 +3940,11 @@ i40e_flow_create(struct rte_eth_dev *dev,
>   	struct i40e_fdir_info *fdir_info = &pf->fdir;
>   	int ret;
>   
> +	/* try the new engine first */
> +	flow = ci_flow_create(&pf->flow_engine_conf, attr, pattern, actions, error);
> +	if (flow != NULL)
> +		return flow;
> +
>   	ret = i40e_flow_check(dev, attr, pattern, actions, &filter_ctx, error);
>   	if (ret < 0)
>   		return NULL;
> @@ -4017,6 +4051,11 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
>   	struct i40e_fdir_info *fdir_info = &pf->fdir;
>   	int ret = 0;
>   
> +	/* try the new engine first */
> +	ret = ci_flow_destroy(&pf->flow_engine_conf, flow, error);
> +	if (ret == 0)
> +		return 0;
> +
>   	switch (filter_type) {
>   	case RTE_ETH_FILTER_ETHERTYPE:
>   		ret = i40e_flow_destroy_ethertype_filter(pf,
> @@ -4161,6 +4200,11 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
>   	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
>   	int ret;
>   
> +	/* flush the new engine first */
> +	ret = ci_flow_flush(&pf->flow_engine_conf, error);
> +	if (ret != 0)
> +		return ret;
> +
>   	ret = i40e_flow_flush_fdir_filter(pf);
>   	if (ret) {
>   		rte_flow_error_set(error, -ret,
> @@ -4310,14 +4354,21 @@ i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
>   }
>   
>   static int
> -i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
> +i40e_flow_query(struct rte_eth_dev *dev,
>   		struct rte_flow *flow,
>   		const struct rte_flow_action *actions,
>   		void *data, struct rte_flow_error *error)
>   {
> +	struct i40e_pf *pf = dev->data->dev_private;
>   	struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
>   	enum rte_filter_type filter_type = flow->filter_type;
>   	struct rte_flow_action_rss *rss_conf = data;
> +	int ret;
> +
> +	/* try the new engine first */
> +	ret = ci_flow_query(&pf->flow_engine_conf, flow, actions, data, error);
> +	if (ret == 0)
> +		return 0;
>   
>   	if (!rss_rule) {
>   		rte_flow_error_set(error, EINVAL,
> diff --git a/drivers/net/intel/i40e/i40e_flow.h b/drivers/net/intel/i40e/i40e_flow.h
> new file mode 100644
> index 00000000000..c9588686619
> --- /dev/null
> +++ b/drivers/net/intel/i40e/i40e_flow.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2026 Intel Corporation
> + */
> +
> +#ifndef _I40E_FLOW_H_
> +#define _I40E_FLOW_H_
> +
> +#include "../common/flow_engine.h"
> +
> +extern const struct ci_flow_engine_list i40e_flow_engine_list;
> +
> +#endif /* _I40E_FLOW_H_ */

-- 
Regards,
Vladimir



More information about the dev mailing list