DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v1 3/6] net/ice: standardize VOID handling in flow parsers
Date: Wed, 21 Oct 2026 10:18:06 +0100	[thread overview]
Message-ID: <atiDTvOdVy1Xw75b@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <12811edcc0860be69711f2856fbab6fe82e27b57.1792498154.git.anatoly.burakov@intel.com>

On Tue, Oct 20, 2026 at 01:11:06PM +0100, Anatoly Burakov wrote:
> VOID handling differs between pattern matching and engine parsing.
> Pattern matching relies on a temporary copy with VOID items removed,
> while engines handle them independently. This temporary copy makes memory
> management complicated, so we want to get rid of it.
> 
> However, before we can do that, we first need to standardize traversal of
> the pattern so that all engines can skip over VOID items. Add shared
> helpers to skip VOID items and iterate over non-VOID items, and use them
> in pattern matching and all engines; also use them for item counting,
> lookahead and RAW item lookup.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

This loop macro looks a very nice cleanup.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

>  drivers/net/intel/ice/ice_acl_filter.c    |  4 +---
>  drivers/net/intel/ice/ice_fdir_filter.c   |  8 +++-----
>  drivers/net/intel/ice/ice_generic_flow.c  | 11 +++++------
>  drivers/net/intel/ice/ice_generic_flow.h  | 14 ++++++++++++++
>  drivers/net/intel/ice/ice_hash.c          |  6 ++++--
>  drivers/net/intel/ice/ice_switch_filter.c |  8 ++------
>  6 files changed, 29 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/intel/ice/ice_acl_filter.c b/drivers/net/intel/ice/ice_acl_filter.c
> index eb5d88ccc5..91f684c9b9 100644
> --- a/drivers/net/intel/ice/ice_acl_filter.c
> +++ b/drivers/net/intel/ice/ice_acl_filter.c
> @@ -664,7 +664,7 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
>  	uint64_t input_set = ICE_INSET_NONE;
>  	uint8_t flow_type = ICE_FLTR_PTYPE_NONF_NONE;
>  
> -	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		item_type = item->type;
>  
>  		switch (item_type) {
> @@ -897,8 +897,6 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
>  				}
>  			}
>  			break;
> -		case RTE_FLOW_ITEM_TYPE_VOID:
> -			break;
>  		default:
>  			rte_flow_error_set(error, EINVAL,
>  				RTE_FLOW_ERROR_TYPE_ITEM,
> diff --git a/drivers/net/intel/ice/ice_fdir_filter.c b/drivers/net/intel/ice/ice_fdir_filter.c
> index 63a0d9fb1f..b1a8753e90 100644
> --- a/drivers/net/intel/ice/ice_fdir_filter.c
> +++ b/drivers/net/intel/ice/ice_fdir_filter.c
> @@ -1904,7 +1904,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  	struct ice_parser_result rslt;
>  	uint8_t item_num = 0;
>  
> -	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN)
>  			tunnel_type = ICE_FDIR_TUNNEL_TYPE_VXLAN;
>  		if (item->type == RTE_FLOW_ITEM_TYPE_L2TPV2)
> @@ -1922,7 +1922,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  	/* This loop parse flow pattern and distinguish Non-tunnel and tunnel
>  	 * flow. input_set_i is used for inner part.
>  	 */
> -	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		item_type = item->type;
>  
>  		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
> @@ -2065,7 +2065,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  			if (!rte_is_zero_ether_addr(&eth_mask->hdr.src_addr))
>  				*input_set |= ICE_INSET_SMAC;
>  
> -			next_type = (item + 1)->type;
> +			next_type = ice_pattern_skip_void(item + 1)->type;
>  			/* Ignore this field except for ICE_FLTR_PTYPE_NON_IP_L2 */
>  			if (eth_mask->hdr.ether_type == RTE_BE16(0xffff) &&
>  			    next_type == RTE_FLOW_ITEM_TYPE_END) {
> @@ -2471,8 +2471,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  				p_v6->src_port = sctp_spec->hdr.src_port;
>  			}
>  			break;
> -		case RTE_FLOW_ITEM_TYPE_VOID:
> -			break;
>  		case RTE_FLOW_ITEM_TYPE_VXLAN:
>  			l3 = RTE_FLOW_ITEM_TYPE_END;
>  			vxlan_spec = item->spec;
> diff --git a/drivers/net/intel/ice/ice_generic_flow.c b/drivers/net/intel/ice/ice_generic_flow.c
> index 76b3800545..fee048e456 100644
> --- a/drivers/net/intel/ice/ice_generic_flow.c
> +++ b/drivers/net/intel/ice/ice_generic_flow.c
> @@ -2109,16 +2109,15 @@ static bool
>  ice_match_pattern(enum rte_flow_item_type *item_array,
>  		const struct rte_flow_item *pattern)
>  {
> -	const struct rte_flow_item *item = pattern;
> +	const struct rte_flow_item *item;
>  
> -	while ((*item_array == item->type) &&
> -	       (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
> +		if (*item_array != item->type)
> +			return false;
>  		item_array++;
> -		item++;
>  	}
>  
> -	return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
> -		item->type == RTE_FLOW_ITEM_TYPE_END);
> +	return *item_array == RTE_FLOW_ITEM_TYPE_END;
>  }
>  
>  struct ice_ptype_match {
> diff --git a/drivers/net/intel/ice/ice_generic_flow.h b/drivers/net/intel/ice/ice_generic_flow.h
> index 650b43633f..983f86a5ab 100644
> --- a/drivers/net/intel/ice/ice_generic_flow.h
> +++ b/drivers/net/intel/ice/ice_generic_flow.h
> @@ -569,6 +569,20 @@ struct ice_flow_parser_node {
>  void ice_register_flow_engine(struct ice_flow_engine *engine);
>  int ice_flow_init(struct ice_adapter *ad);
>  void ice_flow_uninit(struct ice_adapter *ad);
> +
> +static inline const struct rte_flow_item *
> +ice_pattern_skip_void(const struct rte_flow_item *item)
> +{
> +	while (item->type == RTE_FLOW_ITEM_TYPE_VOID)
> +		item++;
> +	return item;
> +}
> +
> +#define ICE_FLOW_FOREACH_ITEM(item, pattern) \
> +	for ((item) = ice_pattern_skip_void(pattern); \
> +	     (item)->type != RTE_FLOW_ITEM_TYPE_END; \
> +	     (item) = ice_pattern_skip_void((item) + 1))
> +
>  struct ice_pattern_match_item *
>  ice_search_pattern_match_item(struct ice_adapter *ad,
>  			      const struct rte_flow_item pattern[],
> diff --git a/drivers/net/intel/ice/ice_hash.c b/drivers/net/intel/ice/ice_hash.c
> index 7a9a4f1a04..13bedfe90c 100644
> --- a/drivers/net/intel/ice/ice_hash.c
> +++ b/drivers/net/intel/ice/ice_hash.c
> @@ -624,7 +624,7 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
>  	const struct rte_flow_item *item = pattern;
>  	const struct rte_flow_item_gtp_psc *psc;
>  
> -	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		if (item->last) {
>  			rte_flow_error_set(error, EINVAL,
>  					RTE_FLOW_ERROR_TYPE_ITEM, item,
> @@ -1235,8 +1235,10 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
>  		goto error;
>  
>  	if (phint == ICE_PHINT_RAW) {
> +		const struct rte_flow_item *raw_item = ice_pattern_skip_void(pattern);
> +
>  		rss_meta_ptr->raw.raw_ena = true;
> -		ret = ice_hash_parse_raw_pattern(ad, pattern, error, rss_meta_ptr);
> +		ret = ice_hash_parse_raw_pattern(ad, raw_item, error, rss_meta_ptr);
>  		if (ret) {
>  			rte_flow_error_set(error, EINVAL,
>  					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
> diff --git a/drivers/net/intel/ice/ice_switch_filter.c b/drivers/net/intel/ice/ice_switch_filter.c
> index 6f5af03f6a..6bc1bdd09f 100644
> --- a/drivers/net/intel/ice/ice_switch_filter.c
> +++ b/drivers/net/intel/ice/ice_switch_filter.c
> @@ -489,8 +489,7 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
>  	    *tun_type == ICE_NON_TUN_QINQ)
>  		qinq_valid = 1;
>  
> -	for (item = pattern; item->type !=
> -			RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		if (item->last) {
>  			rte_flow_error_set(error, EINVAL,
>  					RTE_FLOW_ERROR_TYPE_ITEM,
> @@ -1378,9 +1377,6 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
>  			gtpu_psc_valid = 1;
>  			break;
>  
> -		case RTE_FLOW_ITEM_TYPE_VOID:
> -			break;
> -
>  		default:
>  			rte_flow_error_set(error, EINVAL,
>  				   RTE_FLOW_ERROR_TYPE_ITEM, pattern,
> @@ -1805,7 +1801,7 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
>  		return -rte_errno;
>  	}
>  
> -	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> +	ICE_FLOW_FOREACH_ITEM(item, pattern) {
>  		item_num++;
>  		if (item->type == RTE_FLOW_ITEM_TYPE_ETH) {
>  			const struct rte_flow_item_eth *eth_mask;
> -- 
> 2.52.0
> 

  reply	other threads:[~2026-10-21  9:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 12:11 [PATCH v1 0/6] Centralize flow memory management in ICE Anatoly Burakov
2026-10-20 12:11 ` [PATCH v1 1/6] net/ice: release ACL slot on entry creation failure Anatoly Burakov
2026-10-21  9:17   ` Bruce Richardson
2026-10-20 12:11 ` [PATCH v1 2/6] net/ice: fix inconsistent state on FDIR failure Anatoly Burakov
2026-10-21  9:17   ` Bruce Richardson
2026-10-20 12:11 ` [PATCH v1 3/6] net/ice: standardize VOID handling in flow parsers Anatoly Burakov
2026-10-21  9:18   ` Bruce Richardson [this message]
2026-10-20 12:11 ` [PATCH v1 4/6] net/ice: remove temporary flow pattern buffer Anatoly Burakov
2026-10-21  9:19   ` Bruce Richardson
2026-10-20 12:11 ` [PATCH v1 5/6] net/ice: use caller-owned pattern match storage Anatoly Burakov
2026-10-21  9:25   ` Bruce Richardson
2026-10-21  9:55     ` Burakov, Anatoly
2026-10-20 12:11 ` [PATCH v1 6/6] net/ice: centralize flow rule memory management Anatoly Burakov
2026-10-21  9:59   ` Bruce Richardson
2026-10-21 10:07     ` Burakov, Anatoly
2026-10-21 10:02 ` [PATCH v1 0/6] Centralize flow memory management in ICE Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atiDTvOdVy1Xw75b@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox