net/mlx5: set RSS key len 0 to indicate default RSS

Message ID 1538588246-21436-1-git-send-email-ophirmu@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: set RSS key len 0 to indicate default RSS |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Ophir Munk Oct. 3, 2018, 5:37 p.m. UTC
  Applications which add an RSS flow must supply an RSS key table and an
RSS key length. If an application needs to add the default RSS flow it
should not care about the exact RSS default key table and its length.
By setting key length to 0 - the PMD will know that it should use the
default RSS key table and length.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Yongseok Koh Oct. 3, 2018, 6:56 p.m. UTC | #1
> On Oct 3, 2018, at 10:37 AM, Ophir Munk <ophirmu@mellanox.com> wrote:
> 
> Applications which add an RSS flow must supply an RSS key table and an
> RSS key length. If an application needs to add the default RSS flow it
> should not care about the exact RSS default key table and its length.
> By setting key length to 0 - the PMD will know that it should use the
> default RSS key table and length.
> 
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_flow.c | 7 ++++---

Please rebase the code on top of the latest dpdk-next-net-mlx.
Actually, it is better to rebase on top of PR#878.

Thanks,
Yongseok

> 1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 3f548a9..18eacf5 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -2062,7 +2062,8 @@ struct mlx5_flow_tunnel_info {
> 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> 					  &rss->level,
> 					  "tunnel RSS is not supported");
> -	if (rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> +	/* key_len 0 means using default RSS key */
> +	if (rss->key_len > 0 && rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> 		return rte_flow_error_set(error, ENOTSUP,
> 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> 					  &rss->key_len,
> @@ -2106,7 +2107,7 @@ struct mlx5_flow_tunnel_info {
> 		memcpy((*flow->queue), rss->queue,
> 		       rss->queue_num * sizeof(uint16_t));
> 	flow->rss.queue_num = rss->queue_num;
> -	memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
> +	memcpy(flow->key, rss->key, rss->key_len);
> 	flow->rss.types = rss->types;
> 	flow->rss.level = rss->level;
> 	flow->fate |= MLX5_FLOW_FATE_RSS;
> @@ -2948,7 +2949,7 @@ struct mlx5_flow_tunnel_info {
> 					     flow->rss.queue_num);
> 			if (!hrxq)
> 				hrxq = mlx5_hrxq_new(dev, flow->key,
> -						     MLX5_RSS_HASH_KEY_LEN,
> +						     flow->rss.key_len,
> 						     verbs->hash_fields,
> 						     (*flow->queue),
> 						     flow->rss.queue_num,
> -- 
> 1.8.3.1
>
  
Shahaf Shuler Oct. 7, 2018, 11:21 a.m. UTC | #2
Hi Ophir,

To add on top of Koh's comment

Wednesday, October 3, 2018 9:56 PM, Yongseok Koh:
> Subject: Re: [PATCH] net/mlx5: set RSS key len 0 to indicate default RSS
> > On Oct 3, 2018, at 10:37 AM, Ophir Munk <ophirmu@mellanox.com>
> wrote:
> >
> > Applications which add an RSS flow must supply an RSS key table and an
> > RSS key length. If an application needs to add the default RSS flow it
> > should not care about the exact RSS default key table and its length.
> > By setting key length to 0 - the PMD will know that it should use the
> > default RSS key table and length.

Can you refer where in the rte_flow API this is documented?  I couldn't find it under struct rte_flow_action_rss  definition. 
I agree it is better for the PMD to behave this way, but this should be explained in the API, so for this patch to be accepted we need also doc update in rte_flow.h.

In my opinion, it is better for the key to be NULL to request from the PMD to use the default key, similar to struct rte_eth_rss_conf. 

> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> > drivers/net/mlx5/mlx5_flow.c | 7 ++++---
> 
> Please rebase the code on top of the latest dpdk-next-net-mlx.
> Actually, it is better to rebase on top of PR#878.
> 
> Thanks,
> Yongseok
> 
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow.c
> > b/drivers/net/mlx5/mlx5_flow.c index 3f548a9..18eacf5 100644
> > --- a/drivers/net/mlx5/mlx5_flow.c
> > +++ b/drivers/net/mlx5/mlx5_flow.c
> > @@ -2062,7 +2062,8 @@ struct mlx5_flow_tunnel_info {
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > 					  &rss->level,
> > 					  "tunnel RSS is not supported");
> > -	if (rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> > +	/* key_len 0 means using default RSS key */
> > +	if (rss->key_len > 0 && rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> > 		return rte_flow_error_set(error, ENOTSUP,
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > 					  &rss->key_len,
> > @@ -2106,7 +2107,7 @@ struct mlx5_flow_tunnel_info {
> > 		memcpy((*flow->queue), rss->queue,
> > 		       rss->queue_num * sizeof(uint16_t));
> > 	flow->rss.queue_num = rss->queue_num;
> > -	memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
> > +	memcpy(flow->key, rss->key, rss->key_len);

In Mellanox devices 40B of a key is a must. If you intended to copy 0 bytes, it is better to do it in other ways. 
 
> > 	flow->rss.types = rss->types;
> > 	flow->rss.level = rss->level;
> > 	flow->fate |= MLX5_FLOW_FATE_RSS;
> > @@ -2948,7 +2949,7 @@ struct mlx5_flow_tunnel_info {
> > 					     flow->rss.queue_num);
> > 			if (!hrxq)
> > 				hrxq = mlx5_hrxq_new(dev, flow->key,
> > -
> MLX5_RSS_HASH_KEY_LEN,
> > +						     flow->rss.key_len,
> > 						     verbs->hash_fields,
> > 						     (*flow->queue),
> > 						     flow->rss.queue_num,
> > --
> > 1.8.3.1
> >
  
Ophir Munk Oct. 29, 2018, 4:26 p.m. UTC | #3
Please find comments inline.

> -----Original Message-----
> From: Yongseok Koh
> Sent: Wednesday, October 03, 2018 9:56 PM
> To: Ophir Munk <ophirmu@mellanox.com>
> Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Thomas Monjalon <thomas@monjalon.net>;
> Olga Shern <olgas@mellanox.com>
> Subject: Re: [PATCH] net/mlx5: set RSS key len 0 to indicate default RSS
> 
> 
> > On Oct 3, 2018, at 10:37 AM, Ophir Munk <ophirmu@mellanox.com>
> wrote:
> >
> > Applications which add an RSS flow must supply an RSS key table and an
> > RSS key length. If an application needs to add the default RSS flow it
> > should not care about the exact RSS default key table and its length.
> > By setting key length to 0 - the PMD will know that it should use the
> > default RSS key table and length.
> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> > drivers/net/mlx5/mlx5_flow.c | 7 ++++---
> 
> Please rebase the code on top of the latest dpdk-next-net-mlx.
> Actually, it is better to rebase on top of PR#878.
> 
> Thanks,
> Yongseok

I have rebased the code on master branch dated 18.11 28-Oct-18.
After the rebase I have discovered more seg fault scenarios which are fixed in V2.

> 
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow.c
> > b/drivers/net/mlx5/mlx5_flow.c index 3f548a9..18eacf5 100644
> > --- a/drivers/net/mlx5/mlx5_flow.c
> > +++ b/drivers/net/mlx5/mlx5_flow.c
> > @@ -2062,7 +2062,8 @@ struct mlx5_flow_tunnel_info {
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > 					  &rss->level,
> > 					  "tunnel RSS is not supported");
> > -	if (rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> > +	/* key_len 0 means using default RSS key */
> > +	if (rss->key_len > 0 && rss->key_len < MLX5_RSS_HASH_KEY_LEN)
> > 		return rte_flow_error_set(error, ENOTSUP,
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > 					  &rss->key_len,
> > @@ -2106,7 +2107,7 @@ struct mlx5_flow_tunnel_info {
> > 		memcpy((*flow->queue), rss->queue,
> > 		       rss->queue_num * sizeof(uint16_t));
> > 	flow->rss.queue_num = rss->queue_num;
> > -	memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
> > +	memcpy(flow->key, rss->key, rss->key_len);
> > 	flow->rss.types = rss->types;
> > 	flow->rss.level = rss->level;
> > 	flow->fate |= MLX5_FLOW_FATE_RSS;
> > @@ -2948,7 +2949,7 @@ struct mlx5_flow_tunnel_info {
> > 					     flow->rss.queue_num);
> > 			if (!hrxq)
> > 				hrxq = mlx5_hrxq_new(dev, flow->key,
> > -
> MLX5_RSS_HASH_KEY_LEN,
> > +						     flow->rss.key_len,
> > 						     verbs->hash_fields,
> > 						     (*flow->queue),
> > 						     flow->rss.queue_num,
> > --
> > 1.8.3.1
> >
  
Ophir Munk Oct. 29, 2018, 4:37 p.m. UTC | #4
> -----Original Message-----
> From: Shahaf Shuler
> Sent: Sunday, October 07, 2018 2:21 PM
> To: Yongseok Koh <yskoh@mellanox.com>; Ophir Munk
> <ophirmu@mellanox.com>
> Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Olga Shern <olgas@mellanox.com>
> Subject: RE: [PATCH] net/mlx5: set RSS key len 0 to indicate default RSS
> 
> > > On Oct 3, 2018, at 10:37 AM, Ophir Munk <ophirmu@mellanox.com>
> > wrote:
> > >
> > > Applications which add an RSS flow must supply an RSS key table and
> > > an RSS key length. If an application needs to add the default RSS
> > > flow it should not care about the exact RSS default key table and its
> length.
> > > By setting key length to 0 - the PMD will know that it should use
> > > the default RSS key table and length.
> 
> Can you refer where in the rte_flow API this is documented?  I couldn't find it
> under struct rte_flow_action_rss  definition.
> I agree it is better for the PMD to behave this way, but this should be
> explained in the API, so for this patch to be accepted we need also doc
> update in rte_flow.h.
> 

Will update documentation in v2

> In my opinion, it is better for the key to be NULL to request from the PMD to
> use the default key, similar to struct rte_eth_rss_conf.
> 

I suggest considering both (NULL key or key_len 0) as a criteria for using default RSS key.
In addition if type==0 it will be considered a default type and mlx5 will use ETH_RSS_IP
Will update in v2

> > > diff --git a/drivers/net/mlx5/mlx5_flow.c
> > > b/drivers/net/mlx5/mlx5_flow.c index 3f548a9..18eacf5 100644
> > > --- a/drivers/net/mlx5/mlx5_flow.c
> > > +++ b/drivers/net/mlx5/mlx5_flow.c
> > > @@ -2062,7 +2062,8 @@ struct mlx5_flow_tunnel_info {
> > >
> > > @@ -2106,7 +2107,7 @@ struct mlx5_flow_tunnel_info {
> > > 		memcpy((*flow->queue), rss->queue,
> > > 		       rss->queue_num * sizeof(uint16_t));
> > > 	flow->rss.queue_num = rss->queue_num;
> > > -	memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
> > > +	memcpy(flow->key, rss->key, rss->key_len);
> 
> In Mellanox devices 40B of a key is a must. If you intended to copy 0 bytes, it
> is better to do it in other ways.

rss->key_len can be 0 or 40. Please consider this memcpy() a generic code which fits both cases.

>
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 3f548a9..18eacf5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2062,7 +2062,8 @@  struct mlx5_flow_tunnel_info {
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  &rss->level,
 					  "tunnel RSS is not supported");
-	if (rss->key_len < MLX5_RSS_HASH_KEY_LEN)
+	/* key_len 0 means using default RSS key */
+	if (rss->key_len > 0 && rss->key_len < MLX5_RSS_HASH_KEY_LEN)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  &rss->key_len,
@@ -2106,7 +2107,7 @@  struct mlx5_flow_tunnel_info {
 		memcpy((*flow->queue), rss->queue,
 		       rss->queue_num * sizeof(uint16_t));
 	flow->rss.queue_num = rss->queue_num;
-	memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
+	memcpy(flow->key, rss->key, rss->key_len);
 	flow->rss.types = rss->types;
 	flow->rss.level = rss->level;
 	flow->fate |= MLX5_FLOW_FATE_RSS;
@@ -2948,7 +2949,7 @@  struct mlx5_flow_tunnel_info {
 					     flow->rss.queue_num);
 			if (!hrxq)
 				hrxq = mlx5_hrxq_new(dev, flow->key,
-						     MLX5_RSS_HASH_KEY_LEN,
+						     flow->rss.key_len,
 						     verbs->hash_fields,
 						     (*flow->queue),
 						     flow->rss.queue_num,