[dpdk-stable] patch 'net/mlx5: fix port shared data reference count' has been queued to stable release 19.11.6

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Nov 9 19:40:18 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/11/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/54a97855544b7f8bbed432e1bf7566e884957077

Thanks.

Luca Boccassi

---
>From 54a97855544b7f8bbed432e1bf7566e884957077 Mon Sep 17 00:00:00 2001
From: Xueming Li <xuemingl at nvidia.com>
Date: Wed, 21 Oct 2020 11:15:23 +0000
Subject: [PATCH] net/mlx5: fix port shared data reference count

[ upstream commit 16dbba257c9ceccb30577d189dc6ca7e1042552f ]

When probe a representor, tag cache hash table and modification cache
hash table allocated memory upon each port, overwrote previous existing
cache in shared context data.

This patch moves reference check of shared data prior to hash table
allocation to avoid such issue.

Fixes: 6801116688fe ("net/mlx5: fix multiple flow table hash list")
Fixes: 1ef4cdef2682 ("net/mlx5: fix flow tag hash list conversion")

Acked-by: Matan Azrad <matan at nvidia.com>
Signed-off-by: Xueming Li <xuemingl at nvidia.com>
---
 drivers/net/mlx5/mlx5.c         | 30 ++++++++----------------------
 drivers/net/mlx5/mlx5.h         |  2 --
 drivers/net/mlx5/mlx5_flow_dv.c |  4 ++--
 3 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 88ed5ffa5c..f2327903eb 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -951,13 +951,12 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
 {
 	struct mlx5_ibv_shared *sh = priv->sh;
 	char s[MLX5_HLIST_NAMESIZE];
-	int err = 0;
+	int err;
 
-	if (!sh->flow_tbls)
-		err = mlx5_alloc_table_hash_list(priv);
-	else
-		DRV_LOG(DEBUG, "sh->flow_tbls[%p] already created, reuse",
-			(void *)sh->flow_tbls);
+	assert(sh && sh->refcnt);
+	if (sh->refcnt > 1)
+		return 0;
+	err = mlx5_alloc_table_hash_list(priv);
 	if (err)
 		return err;
 	/* Create tags hash list table. */
@@ -971,12 +970,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
 #ifdef HAVE_MLX5DV_DR
 	void *domain;
 
-	if (sh->dv_refcnt) {
-		/* Shared DV/DR structures is already initialized. */
-		sh->dv_refcnt++;
-		priv->dr_shared = 1;
-		return 0;
-	}
 	/* Reference counter is zero, we should initialize structures. */
 	domain = mlx5_glue->dr_create_domain(sh->ctx,
 					     MLX5DV_DR_DOMAIN_TYPE_NIC_RX);
@@ -1010,8 +1003,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
 #endif
 	sh->pop_vlan_action = mlx5_glue->dr_create_flow_action_pop_vlan();
 #endif /* HAVE_MLX5DV_DR */
-	sh->dv_refcnt++;
-	priv->dr_shared = 1;
 	return 0;
 error:
 	/* Rollback the created objects. */
@@ -1053,17 +1044,12 @@ error:
 static void
 mlx5_free_shared_dr(struct mlx5_priv *priv)
 {
-	struct mlx5_ibv_shared *sh;
+	struct mlx5_ibv_shared *sh = priv->sh;
 
-	if (!priv->dr_shared)
+	assert(sh && sh->dv_refcnt);
+	if (sh->refcnt > 1)
 		return;
-	priv->dr_shared = 0;
-	sh = priv->sh;
-	assert(sh);
 #ifdef HAVE_MLX5DV_DR
-	assert(sh->dv_refcnt);
-	if (sh->dv_refcnt && --sh->dv_refcnt)
-		return;
 	if (sh->rx_domain) {
 		mlx5_glue->dr_destroy_domain(sh->rx_domain);
 		sh->rx_domain = NULL;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index fd66aaf318..2f76d162cf 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -669,7 +669,6 @@ struct mlx5_ibv_shared {
 	uint32_t dv_meta_mask; /* flow META metadata supported mask. */
 	uint32_t dv_mark_mask; /* flow MARK metadata supported mask. */
 	uint32_t dv_regc0_mask; /* available bits of metatada reg_c[0]. */
-	uint32_t dv_refcnt; /* DV/DR data reference counter. */
 	void *fdb_domain; /* FDB Direct Rules name space handle. */
 	void *rx_domain; /* RX Direct Rules name space handle. */
 	void *tx_domain; /* TX Direct Rules name space handle. */
@@ -731,7 +730,6 @@ struct mlx5_priv {
 	unsigned int isolated:1; /* Whether isolated mode is enabled. */
 	unsigned int representor:1; /* Device is a port representor. */
 	unsigned int master:1; /* Device is a E-Switch master. */
-	unsigned int dr_shared:1; /* DV/DR data is shared. */
 	unsigned int counter_fallback:1; /* Use counter fallback management. */
 	unsigned int mtr_en:1; /* Whether support meter. */
 	unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 60d6af04e2..4ba1df7027 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -280,7 +280,7 @@ flow_dv_shared_lock(struct rte_eth_dev *dev)
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 
-	if (sh->dv_refcnt > 1) {
+	if (sh->refcnt > 1) {
 		int ret;
 
 		ret = pthread_mutex_lock(&sh->dv_mutex);
@@ -295,7 +295,7 @@ flow_dv_shared_unlock(struct rte_eth_dev *dev)
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 
-	if (sh->dv_refcnt > 1) {
+	if (sh->refcnt > 1) {
 		int ret;
 
 		ret = pthread_mutex_unlock(&sh->dv_mutex);
-- 
2.27.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-11-09 18:40:12.417235841 +0000
+++ 0030-net-mlx5-fix-port-shared-data-reference-count.patch	2020-11-09 18:40:11.143311469 +0000
@@ -1 +1 @@
-From 16dbba257c9ceccb30577d189dc6ca7e1042552f Mon Sep 17 00:00:00 2001
+From 54a97855544b7f8bbed432e1bf7566e884957077 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 16dbba257c9ceccb30577d189dc6ca7e1042552f ]
+
@@ -15 +16,0 @@
-Cc: stable at dpdk.org
@@ -20,3 +21,3 @@
- drivers/net/mlx5/linux/mlx5_os.c | 30 ++++++++----------------------
- drivers/net/mlx5/mlx5.h          |  2 --
- drivers/net/mlx5/mlx5_flow_dv.c  |  4 ++--
+ drivers/net/mlx5/mlx5.c         | 30 ++++++++----------------------
+ drivers/net/mlx5/mlx5.h         |  2 --
+ drivers/net/mlx5/mlx5_flow_dv.c |  4 ++--
@@ -25,5 +26,5 @@
-diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
-index 457008ef9e..40f9446d43 100644
---- a/drivers/net/mlx5/linux/mlx5_os.c
-+++ b/drivers/net/mlx5/linux/mlx5_os.c
-@@ -226,13 +226,12 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
+diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
+index 88ed5ffa5c..f2327903eb 100644
+--- a/drivers/net/mlx5/mlx5.c
++++ b/drivers/net/mlx5/mlx5.c
+@@ -951,13 +951,12 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
@@ -31 +32 @@
- 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+ 	struct mlx5_ibv_shared *sh = priv->sh;
@@ -39 +40 @@
--		DRV_LOG(DEBUG, "sh->flow_tbls[%p] already created, reuse\n",
+-		DRV_LOG(DEBUG, "sh->flow_tbls[%p] already created, reuse",
@@ -41 +42 @@
-+	MLX5_ASSERT(sh && sh->refcnt);
++	assert(sh && sh->refcnt);
@@ -48 +49 @@
-@@ -261,12 +260,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
+@@ -971,12 +970,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
@@ -61,2 +62,2 @@
-@@ -306,8 +299,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
- 	}
+@@ -1010,8 +1003,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
+ #endif
@@ -70,3 +71,3 @@
-@@ -357,17 +348,12 @@ error:
- void
- mlx5_os_free_shared_dr(struct mlx5_priv *priv)
+@@ -1053,17 +1044,12 @@ error:
+ static void
+ mlx5_free_shared_dr(struct mlx5_priv *priv)
@@ -74,2 +75,2 @@
--	struct mlx5_dev_ctx_shared *sh;
-+	struct mlx5_dev_ctx_shared *sh = priv->sh;
+-	struct mlx5_ibv_shared *sh;
++	struct mlx5_ibv_shared *sh = priv->sh;
@@ -78 +79 @@
-+	MLX5_ASSERT(sh && sh->refcnt);
++	assert(sh && sh->dv_refcnt);
@@ -83 +84 @@
--	MLX5_ASSERT(sh);
+-	assert(sh);
@@ -85 +86 @@
--	MLX5_ASSERT(sh->dv_refcnt);
+-	assert(sh->dv_refcnt);
@@ -92 +93 @@
-index fa69c66137..c9d5d71630 100644
+index fd66aaf318..2f76d162cf 100644
@@ -95 +96 @@
-@@ -635,7 +635,6 @@ struct mlx5_dev_ctx_shared {
+@@ -669,7 +669,6 @@ struct mlx5_ibv_shared {
@@ -103 +104 @@
-@@ -823,7 +822,6 @@ struct mlx5_priv {
+@@ -731,7 +730,6 @@ struct mlx5_priv {
@@ -108 +109 @@
- 	unsigned int txpp_en:1; /* Tx packet pacing enabled. */
+ 	unsigned int counter_fallback:1; /* Use counter fallback management. */
@@ -112 +113 @@
-index 49d96362f8..15cd34e331 100644
+index 60d6af04e2..4ba1df7027 100644
@@ -115 +116 @@
-@@ -293,7 +293,7 @@ flow_dv_shared_lock(struct rte_eth_dev *dev)
+@@ -280,7 +280,7 @@ flow_dv_shared_lock(struct rte_eth_dev *dev)
@@ -117 +118 @@
- 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+ 	struct mlx5_ibv_shared *sh = priv->sh;
@@ -124 +125 @@
-@@ -308,7 +308,7 @@ flow_dv_shared_unlock(struct rte_eth_dev *dev)
+@@ -295,7 +295,7 @@ flow_dv_shared_unlock(struct rte_eth_dev *dev)
@@ -126 +127 @@
- 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+ 	struct mlx5_ibv_shared *sh = priv->sh;


More information about the stable mailing list