[2/2] net/mlx5: fix lack of match information in meter

Message ID 1582122664-54731-3-git-send-email-suanmingm@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: copy the item flags from prefix flow |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues
ci/travis-robot warning Travis build: failed

Commit Message

Suanming Mou Feb. 19, 2020, 2:31 p.m. UTC
  As meter flows are split into three subflows each, the prefix subflow
with meter action color the packet, the meter subflow filters out the
colored packets, the suffix subflow applies all the remaining actions
to the passed packets.

Currently, all the user defined items are matched in the prefix flow.
Flow id tag match item is the only item added to the meter suffix
subflow. Some of the remaining actions to be applied in the suffix
subflow require more information in the match item, or the suffix
subflow will not be created successfully.

Actions require the L3/L4 type in the match items as below:
RTE_FLOW_ACTION_TYPE_SET_TP_SRC
RTE_FLOW_ACTION_TYPE_SET_TP_DST
RTE_FLOW_ACTION_TYPE_DEC_TTL
RTE_FLOW_ACTION_TYPE_SET_TTL
RTE_FLOW_ACTION_TYPE_RSS
RTE_FLOW_ACTION_TYPE_QUEUE

Inherit the match item flags from meter prefix subflow to make actions
in suffix subflow get sufficient information.

Fixes: 9ea9b049a960 ("net/mlx5: split meter flow")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 22 +++++++++++----
 drivers/net/mlx5/mlx5_flow_dv.c | 62 +++++++++++++++++++++++++++++++----------
 2 files changed, 65 insertions(+), 19 deletions(-)
  

Comments

Matan Azrad Feb. 19, 2020, 3:30 p.m. UTC | #1
Hi Mou

One comment inline.

From: Suanming Mou
> As meter flows are split into three subflows each, the prefix subflow with
> meter action color the packet, the meter subflow filters out the colored
> packets, the suffix subflow applies all the remaining actions to the passed
> packets.
> 
> Currently, all the user defined items are matched in the prefix flow.
> Flow id tag match item is the only item added to the meter suffix subflow.
> Some of the remaining actions to be applied in the suffix subflow require
> more information in the match item, or the suffix subflow will not be created
> successfully.
> 
> Actions require the L3/L4 type in the match items as below:
> RTE_FLOW_ACTION_TYPE_SET_TP_SRC
> RTE_FLOW_ACTION_TYPE_SET_TP_DST
> RTE_FLOW_ACTION_TYPE_DEC_TTL
> RTE_FLOW_ACTION_TYPE_SET_TTL
> RTE_FLOW_ACTION_TYPE_RSS
> RTE_FLOW_ACTION_TYPE_QUEUE
> 
> Inherit the match item flags from meter prefix subflow to make actions in
> suffix subflow get sufficient information.
> 
> Fixes: 9ea9b049a960 ("net/mlx5: split meter flow")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c    | 22 +++++++++++----
>  drivers/net/mlx5/mlx5_flow_dv.c | 62
> +++++++++++++++++++++++++++++++----------
>  2 files changed, 65 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 2f57759..f533f78 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -3440,8 +3440,18 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,
>  	dev_flow->external = external;
>  	/* Subflow object was created, we must include one in the list. */
>  	LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
> -	if (prefix_flow)
> +	if (prefix_flow) {
> +		/*
> +		 * Some suffix subflow need the item flags and decap action
> +		 * flag to know if actions in suffix flow should be applied
> +		 * to new outer layer or not.
> +		 * Action flag will be overwritten in tanslate after using.
> +		 * No need to copy the hash_fields, as it will be generated
> +		 * by RSS action with the item layer flags.
> +		 */
>  		dev_flow->layers = prefix_flow->layers;
> +		dev_flow->actions = prefix_flow->actions;

I don't think it is good to move the actions too.
You just need to remove the outer layers here if you see decap, no?
Now we have only one needed param, it is prefix layers only.
please change all the commits to move to prefix_layers instead prefix_flow.
in case of decap:
Rss need the inner layers only and modify_actions need the inner layers only.
so you can just zero the outer layers.
please add comment on it in translate - somethink like "layers can be initiated by the user according to the prefix sub-flow in case of meter and metadata splitters".

> +	}
>  	if (sub_flow)
>  		*sub_flow = dev_flow;
>  	return flow_drv_translate(dev, dev_flow, attr, items, actions, error);
> @@ -3737,6 +3747,8 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,
>   *   Pointer to Ethernet device.
>   * @param[in] flow
>   *   Parent flow structure pointer.
> + * @param[in] prefix_flow
> + *   Prefix flow structure pointer.
>   * @param[in] attr
>   *   Flow rule attributes.
>   * @param[in] items
> @@ -3753,6 +3765,7 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,  static int
> flow_create_split_metadata(struct rte_eth_dev *dev,
>  			   struct rte_flow *flow,
> +			   struct mlx5_flow *prefix_flow,
>  			   const struct rte_flow_attr *attr,
>  			   const struct rte_flow_item items[],
>  			   const struct rte_flow_action actions[], @@ -3773,7
> +3786,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,
> int32_t priority,
>  	if (!config->dv_flow_en ||
>  	    config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
>  	    !mlx5_flow_ext_mreg_supported(dev))
> -		return flow_create_split_inner(dev, flow, NULL, NULL,
> +		return flow_create_split_inner(dev, flow, NULL, prefix_flow,
>  					       attr, items, actions, external,
>  					       error);
>  	actions_n = flow_parse_qrss_action(actions, &qrss); @@ -3856,7
> +3869,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,
> int32_t priority,
>  			goto exit;
>  	}
>  	/* Add the unmodified original or prefix subflow. */
> -	ret = flow_create_split_inner(dev, flow, &dev_flow, NULL, attr,
> +	ret = flow_create_split_inner(dev, flow, &dev_flow, prefix_flow,
> attr,
>  				      items, ext_actions ? ext_actions :
>  				      actions, external, error);
>  	if (ret < 0)
> @@ -3892,7 +3905,6 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,
>  				.type = RTE_FLOW_ACTION_TYPE_END,
>  			},
>  		};
> -		struct mlx5_flow *prefix_flow;
> 
>  		/*
>  		 * Configure the tag item only if there is no meter subflow.
> @@ -4052,7 +4064,7 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,
>  				 MLX5_FLOW_TABLE_LEVEL_SUFFIX;
>  	}
>  	/* Add the prefix subflow. */
> -	ret = flow_create_split_metadata(dev, flow, &sfx_attr,
> +	ret = flow_create_split_metadata(dev, flow, dev_flow, &sfx_attr,
>  					 sfx_items ? sfx_items : items,
>  					 sfx_actions ? sfx_actions : actions,
>  					 external, error);
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c index c958fca..359a037 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -85,16 +85,44 @@
>   *   Pointer to item specification.
>   * @param[out] attr
>   *   Pointer to flow attributes structure.
> + * @param[in] dev_flow
> + *   Pointer to the sub flow.
>   * @param[in] tunnel_decap
>   *   Whether action is after tunnel decapsulation.
>   */
>  static void
>  flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr
> *attr,
> -		  bool tunnel_decap)
> +		  struct mlx5_flow *dev_flow, bool tunnel_decap)
>  {
> +	if (dev_flow->layers) {
> +		if (dev_flow->actions & MLX5_FLOW_ACTION_DECAP) {
> +			if (dev_flow->layers &
> MLX5_FLOW_LAYER_INNER_L3_IPV4)
> +				attr->ipv4 = 1;
> +			else if (dev_flow->layers &
> +				 MLX5_FLOW_LAYER_INNER_L3_IPV6)
> +				attr->ipv6 = 1;
> +			if (dev_flow->layers &
> MLX5_FLOW_LAYER_INNER_L4_TCP)
> +				attr->tcp = 1;
> +			else if (dev_flow->layers &
> +				 MLX5_FLOW_LAYER_INNER_L4_UDP)
> +				attr->udp = 1;
> +		} else {
> +			if (dev_flow->layers &
> MLX5_FLOW_LAYER_OUTER_L3_IPV4)
> +				attr->ipv4 = 1;
> +			else if (dev_flow->layers &
> +				 MLX5_FLOW_LAYER_OUTER_L3_IPV6)
> +				attr->ipv6 = 1;
> +			if (dev_flow->layers &
> MLX5_FLOW_LAYER_OUTER_L4_TCP)
> +				attr->tcp = 1;
> +			else if (dev_flow->layers &
> +				 MLX5_FLOW_LAYER_OUTER_L4_UDP)
> +				attr->udp = 1;
> +		}
> +		attr->valid = 1;
> +		return;
> +	}
>  	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
>  		uint8_t next_protocol = 0xff;
> -
>  		switch (item->type) {
>  		case RTE_FLOW_ITEM_TYPE_GRE:
>  		case RTE_FLOW_ITEM_TYPE_NVGRE:
> @@ -640,6 +668,8 @@ struct field_modify_info modify_tcp[] = {
>   *   Pointer to rte_flow_item objects list.
>   * @param[in] attr
>   *   Pointer to flow attributes structure.
> + * @param[in] dev_flow
> + *   Pointer to the sub flow.
>   * @param[in] tunnel_decap
>   *   Whether action is after tunnel decapsulation.
>   * @param[out] error
> @@ -653,8 +683,8 @@ struct field_modify_info modify_tcp[] = {
>  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
>  			 const struct rte_flow_action *action,
>  			 const struct rte_flow_item *items,
> -			 union flow_dv_attr *attr, bool tunnel_decap,
> -			 struct rte_flow_error *error)
> +			 union flow_dv_attr *attr, struct mlx5_flow
> *dev_flow,
> +			 bool tunnel_decap, struct rte_flow_error *error)
>  {
>  	const struct rte_flow_action_set_tp *conf =
>  		(const struct rte_flow_action_set_tp *)(action->conf); @@ -
> 666,7 +696,7 @@ struct field_modify_info modify_tcp[] = {
>  	struct field_modify_info *field;
> 
>  	if (!attr->valid)
> -		flow_dv_attr_init(items, attr, tunnel_decap);
> +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
>  	if (attr->udp) {
>  		memset(&udp, 0, sizeof(udp));
>  		memset(&udp_mask, 0, sizeof(udp_mask)); @@ -716,6
> +746,8 @@ struct field_modify_info modify_tcp[] = {
>   *   Pointer to rte_flow_item objects list.
>   * @param[in] attr
>   *   Pointer to flow attributes structure.
> + * @param[in] dev_flow
> + *   Pointer to the sub flow.
>   * @param[in] tunnel_decap
>   *   Whether action is after tunnel decapsulation.
>   * @param[out] error
> @@ -729,8 +761,8 @@ struct field_modify_info modify_tcp[] = {
>  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
>  			 const struct rte_flow_action *action,
>  			 const struct rte_flow_item *items,
> -			 union flow_dv_attr *attr, bool tunnel_decap,
> -			 struct rte_flow_error *error)
> +			 union flow_dv_attr *attr, struct mlx5_flow
> *dev_flow,
> +			 bool tunnel_decap, struct rte_flow_error *error)
>  {
>  	const struct rte_flow_action_set_ttl *conf =
>  		(const struct rte_flow_action_set_ttl *)(action->conf); @@ -
> 742,7 +774,7 @@ struct field_modify_info modify_tcp[] = {
>  	struct field_modify_info *field;
> 
>  	if (!attr->valid)
> -		flow_dv_attr_init(items, attr, tunnel_decap);
> +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
>  	if (attr->ipv4) {
>  		memset(&ipv4, 0, sizeof(ipv4));
>  		memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -778,6
> +810,8 @@ struct field_modify_info modify_tcp[] = {
>   *   Pointer to rte_flow_item objects list.
>   * @param[in] attr
>   *   Pointer to flow attributes structure.
> + * @param[in] dev_flow
> + *   Pointer to the sub flow.
>   * @param[in] tunnel_decap
>   *   Whether action is after tunnel decapsulation.
>   * @param[out] error
> @@ -790,8 +824,8 @@ struct field_modify_info modify_tcp[] = {
> flow_dv_convert_action_modify_dec_ttl
>  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
>  			 const struct rte_flow_item *items,
> -			 union flow_dv_attr *attr, bool tunnel_decap,
> -			 struct rte_flow_error *error)
> +			 union flow_dv_attr *attr, struct mlx5_flow
> *dev_flow,
> +			 bool tunnel_decap, struct rte_flow_error *error)
>  {
>  	struct rte_flow_item item;
>  	struct rte_flow_item_ipv4 ipv4;
> @@ -801,7 +835,7 @@ struct field_modify_info modify_tcp[] = {
>  	struct field_modify_info *field;
> 
>  	if (!attr->valid)
> -		flow_dv_attr_init(items, attr, tunnel_decap);
> +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
>  	if (attr->ipv4) {
>  		memset(&ipv4, 0, sizeof(ipv4));
>  		memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -7505,7
> +7539,7 @@ struct field_modify_info modify_tcp[] = {
>  		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
>  			if (flow_dv_convert_action_modify_tp
>  					(mhdr_res, actions, items,
> -					 &flow_attr, !!(action_flags &
> +					 &flow_attr, dev_flow, !!(action_flags
> &
>  					 MLX5_FLOW_ACTION_DECAP),
> error))
>  				return -rte_errno;
>  			action_flags |= actions->type ==
> @@ -7515,7 +7549,7 @@ struct field_modify_info modify_tcp[] = {
>  			break;
>  		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
>  			if (flow_dv_convert_action_modify_dec_ttl
> -					(mhdr_res, items, &flow_attr,
> +					(mhdr_res, items, &flow_attr,
> dev_flow,
>  					 !!(action_flags &
>  					 MLX5_FLOW_ACTION_DECAP),
> error))
>  				return -rte_errno;
> @@ -7524,7 +7558,7 @@ struct field_modify_info modify_tcp[] = {
>  		case RTE_FLOW_ACTION_TYPE_SET_TTL:
>  			if (flow_dv_convert_action_modify_ttl
>  					(mhdr_res, actions, items,
> &flow_attr,
> -					 !!(action_flags &
> +					 dev_flow, !!(action_flags &
>  					 MLX5_FLOW_ACTION_DECAP),
> error))
>  				return -rte_errno;
>  			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
> --
> 1.8.3.1
  
Suanming Mou Feb. 20, 2020, 3:54 a.m. UTC | #2
> -----Original Message-----
> From: Matan Azrad <matan@mellanox.com>
> Sent: Wednesday, February 19, 2020 11:31 PM
> To: Suanming Mou <suanmingm@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@mellanox.com>;
> stable@dpdk.org
> Subject: RE: [PATCH 2/2] net/mlx5: fix lack of match information in meter
> 
> 
> Hi Mou
> 
> One comment inline.
> 
> From: Suanming Mou
> > As meter flows are split into three subflows each, the prefix subflow
> > with meter action color the packet, the meter subflow filters out the
> > colored packets, the suffix subflow applies all the remaining actions
> > to the passed packets.
> >
> > Currently, all the user defined items are matched in the prefix flow.
> > Flow id tag match item is the only item added to the meter suffix subflow.
> > Some of the remaining actions to be applied in the suffix subflow
> > require more information in the match item, or the suffix subflow will
> > not be created successfully.
> >
> > Actions require the L3/L4 type in the match items as below:
> > RTE_FLOW_ACTION_TYPE_SET_TP_SRC
> > RTE_FLOW_ACTION_TYPE_SET_TP_DST
> > RTE_FLOW_ACTION_TYPE_DEC_TTL
> > RTE_FLOW_ACTION_TYPE_SET_TTL
> > RTE_FLOW_ACTION_TYPE_RSS
> > RTE_FLOW_ACTION_TYPE_QUEUE
> >
> > Inherit the match item flags from meter prefix subflow to make actions
> > in suffix subflow get sufficient information.
> >
> > Fixes: 9ea9b049a960 ("net/mlx5: split meter flow")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
> > ---
> >  drivers/net/mlx5/mlx5_flow.c    | 22 +++++++++++----
> >  drivers/net/mlx5/mlx5_flow_dv.c | 62
> > +++++++++++++++++++++++++++++++----------
> >  2 files changed, 65 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow.c
> > b/drivers/net/mlx5/mlx5_flow.c index 2f57759..f533f78 100644
> > --- a/drivers/net/mlx5/mlx5_flow.c
> > +++ b/drivers/net/mlx5/mlx5_flow.c
> > @@ -3440,8 +3440,18 @@ uint32_t mlx5_flow_adjust_priority(struct
> > rte_eth_dev *dev, int32_t priority,
> >  	dev_flow->external = external;
> >  	/* Subflow object was created, we must include one in the list. */
> >  	LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
> > -	if (prefix_flow)
> > +	if (prefix_flow) {
> > +		/*
> > +		 * Some suffix subflow need the item flags and decap action
> > +		 * flag to know if actions in suffix flow should be applied
> > +		 * to new outer layer or not.
> > +		 * Action flag will be overwritten in tanslate after using.
> > +		 * No need to copy the hash_fields, as it will be generated
> > +		 * by RSS action with the item layer flags.
> > +		 */
> >  		dev_flow->layers = prefix_flow->layers;
> > +		dev_flow->actions = prefix_flow->actions;
> 
> I don't think it is good to move the actions too.
> You just need to remove the outer layers here if you see decap, no?
> Now we have only one needed param, it is prefix layers only.
> please change all the commits to move to prefix_layers instead prefix_flow.
> in case of decap:
> Rss need the inner layers only and modify_actions need the inner layers only.
> so you can just zero the outer layers.
> please add comment on it in translate - somethink like "layers can be initiated
> by the user according to the prefix sub-flow in case of meter and metadata
> splitters".
Good suggestion, will update the V2 version.

> 
> > +	}
> >  	if (sub_flow)
> >  		*sub_flow = dev_flow;
> >  	return flow_drv_translate(dev, dev_flow, attr, items, actions,
> > error); @@ -3737,6 +3747,8 @@ uint32_t
> > mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
> >   *   Pointer to Ethernet device.
> >   * @param[in] flow
> >   *   Parent flow structure pointer.
> > + * @param[in] prefix_flow
> > + *   Prefix flow structure pointer.
> >   * @param[in] attr
> >   *   Flow rule attributes.
> >   * @param[in] items
> > @@ -3753,6 +3765,7 @@ uint32_t mlx5_flow_adjust_priority(struct
> > rte_eth_dev *dev, int32_t priority,  static int
> > flow_create_split_metadata(struct rte_eth_dev *dev,
> >  			   struct rte_flow *flow,
> > +			   struct mlx5_flow *prefix_flow,
> >  			   const struct rte_flow_attr *attr,
> >  			   const struct rte_flow_item items[],
> >  			   const struct rte_flow_action actions[], @@ -3773,7
> > +3786,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,
> > int32_t priority,
> >  	if (!config->dv_flow_en ||
> >  	    config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
> >  	    !mlx5_flow_ext_mreg_supported(dev))
> > -		return flow_create_split_inner(dev, flow, NULL, NULL,
> > +		return flow_create_split_inner(dev, flow, NULL, prefix_flow,
> >  					       attr, items, actions, external,
> >  					       error);
> >  	actions_n = flow_parse_qrss_action(actions, &qrss); @@ -3856,7
> > +3869,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,
> > int32_t priority,
> >  			goto exit;
> >  	}
> >  	/* Add the unmodified original or prefix subflow. */
> > -	ret = flow_create_split_inner(dev, flow, &dev_flow, NULL, attr,
> > +	ret = flow_create_split_inner(dev, flow, &dev_flow, prefix_flow,
> > attr,
> >  				      items, ext_actions ? ext_actions :
> >  				      actions, external, error);
> >  	if (ret < 0)
> > @@ -3892,7 +3905,6 @@ uint32_t mlx5_flow_adjust_priority(struct
> > rte_eth_dev *dev, int32_t priority,
> >  				.type = RTE_FLOW_ACTION_TYPE_END,
> >  			},
> >  		};
> > -		struct mlx5_flow *prefix_flow;
> >
> >  		/*
> >  		 * Configure the tag item only if there is no meter subflow.
> > @@ -4052,7 +4064,7 @@ uint32_t mlx5_flow_adjust_priority(struct
> > rte_eth_dev *dev, int32_t priority,
> >  				 MLX5_FLOW_TABLE_LEVEL_SUFFIX;
> >  	}
> >  	/* Add the prefix subflow. */
> > -	ret = flow_create_split_metadata(dev, flow, &sfx_attr,
> > +	ret = flow_create_split_metadata(dev, flow, dev_flow, &sfx_attr,
> >  					 sfx_items ? sfx_items : items,
> >  					 sfx_actions ? sfx_actions : actions,
> >  					 external, error);
> > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> > b/drivers/net/mlx5/mlx5_flow_dv.c index c958fca..359a037 100644
> > --- a/drivers/net/mlx5/mlx5_flow_dv.c
> > +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> > @@ -85,16 +85,44 @@
> >   *   Pointer to item specification.
> >   * @param[out] attr
> >   *   Pointer to flow attributes structure.
> > + * @param[in] dev_flow
> > + *   Pointer to the sub flow.
> >   * @param[in] tunnel_decap
> >   *   Whether action is after tunnel decapsulation.
> >   */
> >  static void
> >  flow_dv_attr_init(const struct rte_flow_item *item, union
> > flow_dv_attr *attr,
> > -		  bool tunnel_decap)
> > +		  struct mlx5_flow *dev_flow, bool tunnel_decap)
> >  {
> > +	if (dev_flow->layers) {
> > +		if (dev_flow->actions & MLX5_FLOW_ACTION_DECAP) {
> > +			if (dev_flow->layers &
> > MLX5_FLOW_LAYER_INNER_L3_IPV4)
> > +				attr->ipv4 = 1;
> > +			else if (dev_flow->layers &
> > +				 MLX5_FLOW_LAYER_INNER_L3_IPV6)
> > +				attr->ipv6 = 1;
> > +			if (dev_flow->layers &
> > MLX5_FLOW_LAYER_INNER_L4_TCP)
> > +				attr->tcp = 1;
> > +			else if (dev_flow->layers &
> > +				 MLX5_FLOW_LAYER_INNER_L4_UDP)
> > +				attr->udp = 1;
> > +		} else {
> > +			if (dev_flow->layers &
> > MLX5_FLOW_LAYER_OUTER_L3_IPV4)
> > +				attr->ipv4 = 1;
> > +			else if (dev_flow->layers &
> > +				 MLX5_FLOW_LAYER_OUTER_L3_IPV6)
> > +				attr->ipv6 = 1;
> > +			if (dev_flow->layers &
> > MLX5_FLOW_LAYER_OUTER_L4_TCP)
> > +				attr->tcp = 1;
> > +			else if (dev_flow->layers &
> > +				 MLX5_FLOW_LAYER_OUTER_L4_UDP)
> > +				attr->udp = 1;
> > +		}
> > +		attr->valid = 1;
> > +		return;
> > +	}
> >  	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> >  		uint8_t next_protocol = 0xff;
> > -
> >  		switch (item->type) {
> >  		case RTE_FLOW_ITEM_TYPE_GRE:
> >  		case RTE_FLOW_ITEM_TYPE_NVGRE:
> > @@ -640,6 +668,8 @@ struct field_modify_info modify_tcp[] = {
> >   *   Pointer to rte_flow_item objects list.
> >   * @param[in] attr
> >   *   Pointer to flow attributes structure.
> > + * @param[in] dev_flow
> > + *   Pointer to the sub flow.
> >   * @param[in] tunnel_decap
> >   *   Whether action is after tunnel decapsulation.
> >   * @param[out] error
> > @@ -653,8 +683,8 @@ struct field_modify_info modify_tcp[] = {
> >  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
> >  			 const struct rte_flow_action *action,
> >  			 const struct rte_flow_item *items,
> > -			 union flow_dv_attr *attr, bool tunnel_decap,
> > -			 struct rte_flow_error *error)
> > +			 union flow_dv_attr *attr, struct mlx5_flow
> > *dev_flow,
> > +			 bool tunnel_decap, struct rte_flow_error *error)
> >  {
> >  	const struct rte_flow_action_set_tp *conf =
> >  		(const struct rte_flow_action_set_tp *)(action->conf); @@ -
> > 666,7 +696,7 @@ struct field_modify_info modify_tcp[] = {
> >  	struct field_modify_info *field;
> >
> >  	if (!attr->valid)
> > -		flow_dv_attr_init(items, attr, tunnel_decap);
> > +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
> >  	if (attr->udp) {
> >  		memset(&udp, 0, sizeof(udp));
> >  		memset(&udp_mask, 0, sizeof(udp_mask)); @@ -716,6
> > +746,8 @@ struct field_modify_info modify_tcp[] = {
> >   *   Pointer to rte_flow_item objects list.
> >   * @param[in] attr
> >   *   Pointer to flow attributes structure.
> > + * @param[in] dev_flow
> > + *   Pointer to the sub flow.
> >   * @param[in] tunnel_decap
> >   *   Whether action is after tunnel decapsulation.
> >   * @param[out] error
> > @@ -729,8 +761,8 @@ struct field_modify_info modify_tcp[] = {
> >  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
> >  			 const struct rte_flow_action *action,
> >  			 const struct rte_flow_item *items,
> > -			 union flow_dv_attr *attr, bool tunnel_decap,
> > -			 struct rte_flow_error *error)
> > +			 union flow_dv_attr *attr, struct mlx5_flow
> > *dev_flow,
> > +			 bool tunnel_decap, struct rte_flow_error *error)
> >  {
> >  	const struct rte_flow_action_set_ttl *conf =
> >  		(const struct rte_flow_action_set_ttl *)(action->conf); @@ -
> > 742,7 +774,7 @@ struct field_modify_info modify_tcp[] = {
> >  	struct field_modify_info *field;
> >
> >  	if (!attr->valid)
> > -		flow_dv_attr_init(items, attr, tunnel_decap);
> > +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
> >  	if (attr->ipv4) {
> >  		memset(&ipv4, 0, sizeof(ipv4));
> >  		memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -778,6
> > +810,8 @@ struct field_modify_info modify_tcp[] = {
> >   *   Pointer to rte_flow_item objects list.
> >   * @param[in] attr
> >   *   Pointer to flow attributes structure.
> > + * @param[in] dev_flow
> > + *   Pointer to the sub flow.
> >   * @param[in] tunnel_decap
> >   *   Whether action is after tunnel decapsulation.
> >   * @param[out] error
> > @@ -790,8 +824,8 @@ struct field_modify_info modify_tcp[] = {
> > flow_dv_convert_action_modify_dec_ttl
> >  			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
> >  			 const struct rte_flow_item *items,
> > -			 union flow_dv_attr *attr, bool tunnel_decap,
> > -			 struct rte_flow_error *error)
> > +			 union flow_dv_attr *attr, struct mlx5_flow
> > *dev_flow,
> > +			 bool tunnel_decap, struct rte_flow_error *error)
> >  {
> >  	struct rte_flow_item item;
> >  	struct rte_flow_item_ipv4 ipv4;
> > @@ -801,7 +835,7 @@ struct field_modify_info modify_tcp[] = {
> >  	struct field_modify_info *field;
> >
> >  	if (!attr->valid)
> > -		flow_dv_attr_init(items, attr, tunnel_decap);
> > +		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
> >  	if (attr->ipv4) {
> >  		memset(&ipv4, 0, sizeof(ipv4));
> >  		memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -7505,7
> > +7539,7 @@ struct field_modify_info modify_tcp[] = {
> >  		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
> >  			if (flow_dv_convert_action_modify_tp
> >  					(mhdr_res, actions, items,
> > -					 &flow_attr, !!(action_flags &
> > +					 &flow_attr, dev_flow, !!(action_flags
> > &
> >  					 MLX5_FLOW_ACTION_DECAP),
> > error))
> >  				return -rte_errno;
> >  			action_flags |= actions->type ==
> > @@ -7515,7 +7549,7 @@ struct field_modify_info modify_tcp[] = {
> >  			break;
> >  		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
> >  			if (flow_dv_convert_action_modify_dec_ttl
> > -					(mhdr_res, items, &flow_attr,
> > +					(mhdr_res, items, &flow_attr,
> > dev_flow,
> >  					 !!(action_flags &
> >  					 MLX5_FLOW_ACTION_DECAP),
> > error))
> >  				return -rte_errno;
> > @@ -7524,7 +7558,7 @@ struct field_modify_info modify_tcp[] = {
> >  		case RTE_FLOW_ACTION_TYPE_SET_TTL:
> >  			if (flow_dv_convert_action_modify_ttl
> >  					(mhdr_res, actions, items,
> > &flow_attr,
> > -					 !!(action_flags &
> > +					 dev_flow, !!(action_flags &
> >  					 MLX5_FLOW_ACTION_DECAP),
> > error))
> >  				return -rte_errno;
> >  			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
> > --
> > 1.8.3.1
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2f57759..f533f78 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -3440,8 +3440,18 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	dev_flow->external = external;
 	/* Subflow object was created, we must include one in the list. */
 	LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
-	if (prefix_flow)
+	if (prefix_flow) {
+		/*
+		 * Some suffix subflow need the item flags and decap action
+		 * flag to know if actions in suffix flow should be applied
+		 * to new outer layer or not.
+		 * Action flag will be overwritten in tanslate after using.
+		 * No need to copy the hash_fields, as it will be generated
+		 * by RSS action with the item layer flags.
+		 */
 		dev_flow->layers = prefix_flow->layers;
+		dev_flow->actions = prefix_flow->actions;
+	}
 	if (sub_flow)
 		*sub_flow = dev_flow;
 	return flow_drv_translate(dev, dev_flow, attr, items, actions, error);
@@ -3737,6 +3747,8 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
  *   Pointer to Ethernet device.
  * @param[in] flow
  *   Parent flow structure pointer.
+ * @param[in] prefix_flow
+ *   Prefix flow structure pointer.
  * @param[in] attr
  *   Flow rule attributes.
  * @param[in] items
@@ -3753,6 +3765,7 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 static int
 flow_create_split_metadata(struct rte_eth_dev *dev,
 			   struct rte_flow *flow,
+			   struct mlx5_flow *prefix_flow,
 			   const struct rte_flow_attr *attr,
 			   const struct rte_flow_item items[],
 			   const struct rte_flow_action actions[],
@@ -3773,7 +3786,7 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	if (!config->dv_flow_en ||
 	    config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
 	    !mlx5_flow_ext_mreg_supported(dev))
-		return flow_create_split_inner(dev, flow, NULL, NULL,
+		return flow_create_split_inner(dev, flow, NULL, prefix_flow,
 					       attr, items, actions, external,
 					       error);
 	actions_n = flow_parse_qrss_action(actions, &qrss);
@@ -3856,7 +3869,7 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 			goto exit;
 	}
 	/* Add the unmodified original or prefix subflow. */
-	ret = flow_create_split_inner(dev, flow, &dev_flow, NULL, attr,
+	ret = flow_create_split_inner(dev, flow, &dev_flow, prefix_flow, attr,
 				      items, ext_actions ? ext_actions :
 				      actions, external, error);
 	if (ret < 0)
@@ -3892,7 +3905,6 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				.type = RTE_FLOW_ACTION_TYPE_END,
 			},
 		};
-		struct mlx5_flow *prefix_flow;
 
 		/*
 		 * Configure the tag item only if there is no meter subflow.
@@ -4052,7 +4064,7 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				 MLX5_FLOW_TABLE_LEVEL_SUFFIX;
 	}
 	/* Add the prefix subflow. */
-	ret = flow_create_split_metadata(dev, flow, &sfx_attr,
+	ret = flow_create_split_metadata(dev, flow, dev_flow, &sfx_attr,
 					 sfx_items ? sfx_items : items,
 					 sfx_actions ? sfx_actions : actions,
 					 external, error);
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index c958fca..359a037 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -85,16 +85,44 @@ 
  *   Pointer to item specification.
  * @param[out] attr
  *   Pointer to flow attributes structure.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
  * @param[in] tunnel_decap
  *   Whether action is after tunnel decapsulation.
  */
 static void
 flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr,
-		  bool tunnel_decap)
+		  struct mlx5_flow *dev_flow, bool tunnel_decap)
 {
+	if (dev_flow->layers) {
+		if (dev_flow->actions & MLX5_FLOW_ACTION_DECAP) {
+			if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L3_IPV4)
+				attr->ipv4 = 1;
+			else if (dev_flow->layers &
+				 MLX5_FLOW_LAYER_INNER_L3_IPV6)
+				attr->ipv6 = 1;
+			if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L4_TCP)
+				attr->tcp = 1;
+			else if (dev_flow->layers &
+				 MLX5_FLOW_LAYER_INNER_L4_UDP)
+				attr->udp = 1;
+		} else {
+			if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L3_IPV4)
+				attr->ipv4 = 1;
+			else if (dev_flow->layers &
+				 MLX5_FLOW_LAYER_OUTER_L3_IPV6)
+				attr->ipv6 = 1;
+			if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L4_TCP)
+				attr->tcp = 1;
+			else if (dev_flow->layers &
+				 MLX5_FLOW_LAYER_OUTER_L4_UDP)
+				attr->udp = 1;
+		}
+		attr->valid = 1;
+		return;
+	}
 	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
 		uint8_t next_protocol = 0xff;
-
 		switch (item->type) {
 		case RTE_FLOW_ITEM_TYPE_GRE:
 		case RTE_FLOW_ITEM_TYPE_NVGRE:
@@ -640,6 +668,8 @@  struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
  * @param[in] tunnel_decap
  *   Whether action is after tunnel decapsulation.
  * @param[out] error
@@ -653,8 +683,8 @@  struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr, bool tunnel_decap,
-			 struct rte_flow_error *error)
+			 union flow_dv_attr *attr, struct mlx5_flow *dev_flow,
+			 bool tunnel_decap, struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_tp *conf =
 		(const struct rte_flow_action_set_tp *)(action->conf);
@@ -666,7 +696,7 @@  struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr, tunnel_decap);
+		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
 	if (attr->udp) {
 		memset(&udp, 0, sizeof(udp));
 		memset(&udp_mask, 0, sizeof(udp_mask));
@@ -716,6 +746,8 @@  struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
  * @param[in] tunnel_decap
  *   Whether action is after tunnel decapsulation.
  * @param[out] error
@@ -729,8 +761,8 @@  struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr, bool tunnel_decap,
-			 struct rte_flow_error *error)
+			 union flow_dv_attr *attr, struct mlx5_flow *dev_flow,
+			 bool tunnel_decap, struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_ttl *conf =
 		(const struct rte_flow_action_set_ttl *)(action->conf);
@@ -742,7 +774,7 @@  struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr, tunnel_decap);
+		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -778,6 +810,8 @@  struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
  * @param[in] tunnel_decap
  *   Whether action is after tunnel decapsulation.
  * @param[out] error
@@ -790,8 +824,8 @@  struct field_modify_info modify_tcp[] = {
 flow_dv_convert_action_modify_dec_ttl
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr, bool tunnel_decap,
-			 struct rte_flow_error *error)
+			 union flow_dv_attr *attr, struct mlx5_flow *dev_flow,
+			 bool tunnel_decap, struct rte_flow_error *error)
 {
 	struct rte_flow_item item;
 	struct rte_flow_item_ipv4 ipv4;
@@ -801,7 +835,7 @@  struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr, tunnel_decap);
+		flow_dv_attr_init(items, attr, dev_flow, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -7505,7 +7539,7 @@  struct field_modify_info modify_tcp[] = {
 		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
 			if (flow_dv_convert_action_modify_tp
 					(mhdr_res, actions, items,
-					 &flow_attr, !!(action_flags &
+					 &flow_attr, dev_flow, !!(action_flags &
 					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= actions->type ==
@@ -7515,7 +7549,7 @@  struct field_modify_info modify_tcp[] = {
 			break;
 		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
 			if (flow_dv_convert_action_modify_dec_ttl
-					(mhdr_res, items, &flow_attr,
+					(mhdr_res, items, &flow_attr, dev_flow,
 					 !!(action_flags &
 					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
@@ -7524,7 +7558,7 @@  struct field_modify_info modify_tcp[] = {
 		case RTE_FLOW_ACTION_TYPE_SET_TTL:
 			if (flow_dv_convert_action_modify_ttl
 					(mhdr_res, actions, items, &flow_attr,
-					 !!(action_flags &
+					 dev_flow, !!(action_flags &
 					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;