DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/1] net/mlx5: fix flow memory allocation size
@ 2020-06-08 16:01 Gregory Etelson
  2020-06-08 16:01 ` [dpdk-dev] [PATCH 1/1] " Gregory Etelson
  0 siblings, 1 reply; 3+ messages in thread
From: Gregory Etelson @ 2020-06-08 16:01 UTC (permalink / raw)
  To: dev; +Cc: getelson, matan, rasland

Gregory Etelson (1):
  net/mlx5: fix flow memory allocation size

 drivers/net/mlx5/mlx5.c | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH 1/1] net/mlx5: fix flow memory allocation size
  2020-06-08 16:01 [dpdk-dev] [PATCH 0/1] net/mlx5: fix flow memory allocation size Gregory Etelson
@ 2020-06-08 16:01 ` Gregory Etelson
  2020-06-14 10:28   ` Raslan Darawsheh
  0 siblings, 1 reply; 3+ messages in thread
From: Gregory Etelson @ 2020-06-08 16:01 UTC (permalink / raw)
  To: dev; +Cc: getelson, matan, rasland

In DV enabled MLX5 PMD build mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size
was initiated for DV structure. If RTE initialization encountered MLX5
PCI function with disabled DV support
mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size was reduced to match legacy
verbs flow size.  Since mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW] is a
global variable that change reflected on DV enabled MLX5 PCI functions
too.

Running flow with invalid ipool size crashes PMD.

The patch adjusts ipool flow size for each active PCI function.

Fixes: b88341ca35fc ("net/mlx5: convert flow dev handle to indexed")

Signed-off-by: Gregory Etelson <getelson@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.c | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5589772eb8..145021ef0f 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -198,7 +198,7 @@ struct mlx5_dev_spawn_data {
 static LIST_HEAD(, mlx5_ibv_shared) mlx5_ibv_list = LIST_HEAD_INITIALIZER();
 static pthread_mutex_t mlx5_ibv_list_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-static struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
+static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
 	{
 		.size = sizeof(struct mlx5_flow_dv_encap_decap_resource),
@@ -290,7 +290,11 @@ static struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
 		.type = "mlx5_hrxq_ipool",
 	},
 	{
-		.size = sizeof(struct mlx5_flow_handle),
+		/*
+		 * MLX5_IPOOL_MLX5_FLOW size varies for DV and VERBS flows.
+		 * It set in run time according to PCI function configuration.
+		 */
+		.size = 0,
 		.trunk_size = 64,
 		.grow_trunk = 3,
 		.grow_shift = 2,
@@ -562,22 +566,28 @@ mlx5_flow_counters_mng_close(struct mlx5_ibv_shared *sh)
  */
 static void
 mlx5_flow_ipool_create(struct mlx5_ibv_shared *sh,
-		       const struct mlx5_dev_config *config __rte_unused)
+		       const struct mlx5_dev_config *config)
 {
 	uint8_t i;
+	struct mlx5_indexed_pool_config cfg;
 
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
-	/*
-	 * While DV is supported, user chooses the verbs mode,
-	 * the mlx5 flow handle size is different with the
-	 * MLX5_FLOW_HANDLE_VERBS_SIZE.
-	 */
-	if (!config->dv_flow_en)
-		mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size =
-					MLX5_FLOW_HANDLE_VERBS_SIZE;
-#endif
-	for (i = 0; i < MLX5_IPOOL_MAX; ++i)
-		sh->ipool[i] = mlx5_ipool_create(&mlx5_ipool_cfg[i]);
+	for (i = 0; i < MLX5_IPOOL_MAX; ++i) {
+		cfg = mlx5_ipool_cfg[i];
+		switch (i) {
+		default:
+			break;
+		/*
+		 * Set MLX5_IPOOL_MLX5_FLOW ipool size
+		 * according to PCI function flow configuration.
+		 */
+		case MLX5_IPOOL_MLX5_FLOW:
+			cfg.size = config->dv_flow_en ?
+				sizeof(struct mlx5_flow_handle) :
+				MLX5_FLOW_HANDLE_VERBS_SIZE;
+			break;
+		}
+		sh->ipool[i] = mlx5_ipool_create(&cfg);
+	}
 }
 
 /**
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH 1/1] net/mlx5: fix flow memory allocation size
  2020-06-08 16:01 ` [dpdk-dev] [PATCH 1/1] " Gregory Etelson
@ 2020-06-14 10:28   ` Raslan Darawsheh
  0 siblings, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2020-06-14 10:28 UTC (permalink / raw)
  To: Gregory Etelson, dev; +Cc: Matan Azrad

Hi,

> -----Original Message-----
> From: Gregory Etelson <getelson@mellanox.com>
> Sent: Monday, June 8, 2020 7:02 PM
> To: dev@dpdk.org
> Cc: Gregory Etelson <getelson@mellanox.com>; Matan Azrad
> <matan@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>
> Subject: [PATCH 1/1] net/mlx5: fix flow memory allocation size
> 
> In DV enabled MLX5 PMD build
> mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size
> was initiated for DV structure. If RTE initialization encountered MLX5
> PCI function with disabled DV support
> mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size was reduced to match
> legacy
> verbs flow size.  Since mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW] is a
> global variable that change reflected on DV enabled MLX5 PCI functions
> too.
> 
> Running flow with invalid ipool size crashes PMD.
> 
> The patch adjusts ipool flow size for each active PCI function.
> 
> Fixes: b88341ca35fc ("net/mlx5: convert flow dev handle to indexed")
> 
> Signed-off-by: Gregory Etelson <getelson@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5.c | 40 +++++++++++++++++++++++++---------------
>  1 file changed, 25 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index 5589772eb8..145021ef0f 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -198,7 +198,7 @@ struct mlx5_dev_spawn_data {
>  static LIST_HEAD(, mlx5_ibv_shared) mlx5_ibv_list =
> LIST_HEAD_INITIALIZER();
>  static pthread_mutex_t mlx5_ibv_list_mutex =
> PTHREAD_MUTEX_INITIALIZER;
> 
> -static struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
> +static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
>  #ifdef HAVE_IBV_FLOW_DV_SUPPORT
>  	{
>  		.size = sizeof(struct mlx5_flow_dv_encap_decap_resource),
> @@ -290,7 +290,11 @@ static struct mlx5_indexed_pool_config
> mlx5_ipool_cfg[] = {
>  		.type = "mlx5_hrxq_ipool",
>  	},
>  	{
> -		.size = sizeof(struct mlx5_flow_handle),
> +		/*
> +		 * MLX5_IPOOL_MLX5_FLOW size varies for DV and VERBS
> flows.
> +		 * It set in run time according to PCI function configuration.
> +		 */
> +		.size = 0,
>  		.trunk_size = 64,
>  		.grow_trunk = 3,
>  		.grow_shift = 2,
> @@ -562,22 +566,28 @@ mlx5_flow_counters_mng_close(struct
> mlx5_ibv_shared *sh)
>   */
>  static void
>  mlx5_flow_ipool_create(struct mlx5_ibv_shared *sh,
> -		       const struct mlx5_dev_config *config __rte_unused)
> +		       const struct mlx5_dev_config *config)
>  {
>  	uint8_t i;
> +	struct mlx5_indexed_pool_config cfg;
> 
> -#ifdef HAVE_IBV_FLOW_DV_SUPPORT
> -	/*
> -	 * While DV is supported, user chooses the verbs mode,
> -	 * the mlx5 flow handle size is different with the
> -	 * MLX5_FLOW_HANDLE_VERBS_SIZE.
> -	 */
> -	if (!config->dv_flow_en)
> -		mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size =
> -					MLX5_FLOW_HANDLE_VERBS_SIZE;
> -#endif
> -	for (i = 0; i < MLX5_IPOOL_MAX; ++i)
> -		sh->ipool[i] = mlx5_ipool_create(&mlx5_ipool_cfg[i]);
> +	for (i = 0; i < MLX5_IPOOL_MAX; ++i) {
> +		cfg = mlx5_ipool_cfg[i];
> +		switch (i) {
> +		default:
> +			break;
> +		/*
> +		 * Set MLX5_IPOOL_MLX5_FLOW ipool size
> +		 * according to PCI function flow configuration.
> +		 */
> +		case MLX5_IPOOL_MLX5_FLOW:
> +			cfg.size = config->dv_flow_en ?
> +				sizeof(struct mlx5_flow_handle) :
> +				MLX5_FLOW_HANDLE_VERBS_SIZE;
> +			break;
> +		}
> +		sh->ipool[i] = mlx5_ipool_create(&cfg);
> +	}
>  }
> 
>  /**
> --
> 2.25.1



Patch rebased and applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-14 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 16:01 [dpdk-dev] [PATCH 0/1] net/mlx5: fix flow memory allocation size Gregory Etelson
2020-06-08 16:01 ` [dpdk-dev] [PATCH 1/1] " Gregory Etelson
2020-06-14 10:28   ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).