[dpdk-dev] net/mlx5: fix default RSS level

Message ID 20180515132324.192750-1-shahafs@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Shahaf Shuler May 15, 2018, 1:23 p.m. UTC
  Using inner RSS by default for GRE leads to memory corruption as the
extra flow items added for the inner RSS are not counted in the flow
attributes buffer size.

Fixing by enforcing the default RSS level to be outer. This much
simplify the flow engine and more robust.
Future optimization for out of the box RSS can be done on subsequent
commits.

Fixes: d4a405186b73 ("net/mlx5: support tunnel RSS level")
Cc: xuemingl@mellanox.com
Cc: matan@mellanox.com

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
  

Comments

Nélio Laranjeiro May 17, 2018, 1:32 p.m. UTC | #1
On Tue, May 15, 2018 at 04:23:24PM +0300, Shahaf Shuler wrote:
> Using inner RSS by default for GRE leads to memory corruption as the
> extra flow items added for the inner RSS are not counted in the flow
> attributes buffer size.
> 
> Fixing by enforcing the default RSS level to be outer. This much
> simplify the flow engine and more robust.
> Future optimization for out of the box RSS can be done on subsequent
> commits.
> 
> Fixes: d4a405186b73 ("net/mlx5: support tunnel RSS level")
> Cc: xuemingl@mellanox.com
> Cc: matan@mellanox.com
> 
> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  drivers/net/mlx5/mlx5_flow.c | 22 ++--------------------
>  1 file changed, 2 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 0c0d6f99ad..994be05be6 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -805,7 +805,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
>  			}
>  			parser->rss_conf = (struct rte_flow_action_rss){
>  				.func = RTE_ETH_HASH_FUNCTION_DEFAULT,
> -				.level = rss->level,
> +				.level = rss->level ? rss->level : 1,
>  				.types = rss->types,
>  				.key_len = rss_key_len,
>  				.queue_num = rss->queue_num,
> @@ -1166,9 +1166,6 @@ mlx5_flow_convert_rss(struct mlx5_flow_parse *parser)
>  	int outer = parser->tunnel && parser->rss_conf.level < 2;
>  	uint64_t rss = parser->rss_conf.types;
>  
> -	/* Default to outer RSS. */
> -	if (!parser->rss_conf.level)
> -		parser->rss_conf.level = 1;
>  	layer = outer ? parser->out_layer : parser->layer;
>  	if (layer == HASH_RXQ_TUNNEL)
>  		layer = HASH_RXQ_ETH;
> @@ -1801,9 +1798,6 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item,
>  	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN)];
>  	parser->out_layer = parser->layer;
>  	parser->layer = HASH_RXQ_TUNNEL;
> -	/* Default VXLAN to outer RSS. */
> -	if (!parser->rss_conf.level)
> -		parser->rss_conf.level = 1;
>  	if (spec) {
>  		if (!mask)
>  			mask = default_mask;
> @@ -1876,9 +1870,6 @@ mlx5_flow_create_vxlan_gpe(const struct rte_flow_item *item,
>  	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN_GPE)];
>  	parser->out_layer = parser->layer;
>  	parser->layer = HASH_RXQ_TUNNEL;
> -	/* Default VXLAN-GPE to outer RSS. */
> -	if (!parser->rss_conf.level)
> -		parser->rss_conf.level = 1;
>  	if (spec) {
>  		if (!mask)
>  			mask = default_mask;
> @@ -1956,9 +1947,6 @@ mlx5_flow_create_gre(const struct rte_flow_item *item,
>  	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_GRE)];
>  	parser->out_layer = parser->layer;
>  	parser->layer = HASH_RXQ_TUNNEL;
> -	/* Default GRE to inner RSS. */
> -	if (!parser->rss_conf.level)
> -		parser->rss_conf.level = 2;
>  #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
>  	if (spec) {
>  		if (!mask)
> @@ -2052,12 +2040,6 @@ mlx5_flow_create_mpls(const struct rte_flow_item *item,
>  		/* parser->out_layer stays as in GRE out_layer. */
>  	}
>  	parser->layer = HASH_RXQ_TUNNEL;
> -	/*
> -	 * For MPLS-in-GRE, RSS level should have been set.
> -	 * For MPLS-in-UDP, use outer RSS.
> -	 */
> -	if (!parser->rss_conf.level)
> -		parser->rss_conf.level = 1;
>  	if (spec) {
>  		if (!mask)
>  			mask = default_mask;
> @@ -2501,7 +2483,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev,
>  	flow->tunnel = parser.tunnel;
>  	flow->rss_conf = (struct rte_flow_action_rss){
>  		.func = RTE_ETH_HASH_FUNCTION_DEFAULT,
> -		.level = 0,
> +		.level = parser.rss_conf.level,
>  		.types = parser.rss_conf.types,
>  		.key_len = parser.rss_conf.key_len,
>  		.queue_num = parser.rss_conf.queue_num,
> -- 
> 2.12.0
>
  
Shahaf Shuler May 17, 2018, 3:45 p.m. UTC | #2
Thursday, May 17, 2018 4:32 PM, Nélio Laranjeiro:
> Subject: Re: [PATCH] net/mlx5: fix default RSS level
> 
> On Tue, May 15, 2018 at 04:23:24PM +0300, Shahaf Shuler wrote:
> > Using inner RSS by default for GRE leads to memory corruption as the
> > extra flow items added for the inner RSS are not counted in the flow
> > attributes buffer size.
> >
> > Fixing by enforcing the default RSS level to be outer. This much
> > simplify the flow engine and more robust.
> > Future optimization for out of the box RSS can be done on subsequent
> > commits.
> >
> > Fixes: d4a405186b73 ("net/mlx5: support tunnel RSS level")
> > Cc: xuemingl@mellanox.com
> > Cc: matan@mellanox.com
> >
> > Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> 
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 


Applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 0c0d6f99ad..994be05be6 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -805,7 +805,7 @@  mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 			}
 			parser->rss_conf = (struct rte_flow_action_rss){
 				.func = RTE_ETH_HASH_FUNCTION_DEFAULT,
-				.level = rss->level,
+				.level = rss->level ? rss->level : 1,
 				.types = rss->types,
 				.key_len = rss_key_len,
 				.queue_num = rss->queue_num,
@@ -1166,9 +1166,6 @@  mlx5_flow_convert_rss(struct mlx5_flow_parse *parser)
 	int outer = parser->tunnel && parser->rss_conf.level < 2;
 	uint64_t rss = parser->rss_conf.types;
 
-	/* Default to outer RSS. */
-	if (!parser->rss_conf.level)
-		parser->rss_conf.level = 1;
 	layer = outer ? parser->out_layer : parser->layer;
 	if (layer == HASH_RXQ_TUNNEL)
 		layer = HASH_RXQ_ETH;
@@ -1801,9 +1798,6 @@  mlx5_flow_create_vxlan(const struct rte_flow_item *item,
 	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN)];
 	parser->out_layer = parser->layer;
 	parser->layer = HASH_RXQ_TUNNEL;
-	/* Default VXLAN to outer RSS. */
-	if (!parser->rss_conf.level)
-		parser->rss_conf.level = 1;
 	if (spec) {
 		if (!mask)
 			mask = default_mask;
@@ -1876,9 +1870,6 @@  mlx5_flow_create_vxlan_gpe(const struct rte_flow_item *item,
 	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN_GPE)];
 	parser->out_layer = parser->layer;
 	parser->layer = HASH_RXQ_TUNNEL;
-	/* Default VXLAN-GPE to outer RSS. */
-	if (!parser->rss_conf.level)
-		parser->rss_conf.level = 1;
 	if (spec) {
 		if (!mask)
 			mask = default_mask;
@@ -1956,9 +1947,6 @@  mlx5_flow_create_gre(const struct rte_flow_item *item,
 	parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_GRE)];
 	parser->out_layer = parser->layer;
 	parser->layer = HASH_RXQ_TUNNEL;
-	/* Default GRE to inner RSS. */
-	if (!parser->rss_conf.level)
-		parser->rss_conf.level = 2;
 #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
 	if (spec) {
 		if (!mask)
@@ -2052,12 +2040,6 @@  mlx5_flow_create_mpls(const struct rte_flow_item *item,
 		/* parser->out_layer stays as in GRE out_layer. */
 	}
 	parser->layer = HASH_RXQ_TUNNEL;
-	/*
-	 * For MPLS-in-GRE, RSS level should have been set.
-	 * For MPLS-in-UDP, use outer RSS.
-	 */
-	if (!parser->rss_conf.level)
-		parser->rss_conf.level = 1;
 	if (spec) {
 		if (!mask)
 			mask = default_mask;
@@ -2501,7 +2483,7 @@  mlx5_flow_list_create(struct rte_eth_dev *dev,
 	flow->tunnel = parser.tunnel;
 	flow->rss_conf = (struct rte_flow_action_rss){
 		.func = RTE_ETH_HASH_FUNCTION_DEFAULT,
-		.level = 0,
+		.level = parser.rss_conf.level,
 		.types = parser.rss_conf.types,
 		.key_len = parser.rss_conf.key_len,
 		.queue_num = parser.rss_conf.queue_num,