[1/2] net/mlx5: fix indirect RSS creation when port is stopped

Message ID 20211124093556.3358394-2-dkozlyuk@nvidia.com (mailing list archive)
State Superseded, archived
Headers
Series [1/2] net/mlx5: fix indirect RSS creation when port is stopped |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dmitry Kozlyuk Nov. 24, 2021, 9:35 a.m. UTC
  mlx5_ind_table_obj_setup() was incrementing RxQ reference counters
even when the port was stopped, which prevented RxQ release
and triggered an internal assertion.
Only increment reference counter when the port is started.

Fixes: ec4e11d41d12 ("net/mlx5: preserve indirect actions on restart")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 47dc24793b..8f9a94572f 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2270,6 +2270,7 @@  mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 			 struct mlx5_ind_table_obj *ind_tbl)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	bool dev_started = priv->dev_data->dev_started;
 	uint32_t queues_n = ind_tbl->queues_n;
 	uint16_t *queues = ind_tbl->queues;
 	unsigned int i, j;
@@ -2278,22 +2279,25 @@  mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 			       log2above(queues_n) :
 			       log2above(priv->config.ind_table_max_size);
 
-	for (i = 0; i != queues_n; ++i) {
-		if (mlx5_rxq_ref(dev, queues[i]) == NULL) {
-			ret = -rte_errno;
-			goto error;
+	if (dev_started)
+		for (i = 0; i != queues_n; ++i) {
+			if (mlx5_rxq_ref(dev, queues[i]) == NULL) {
+				ret = -rte_errno;
+				goto error;
+			}
 		}
-	}
 	ret = priv->obj_ops.ind_table_new(dev, n, ind_tbl);
 	if (ret)
 		goto error;
 	__atomic_fetch_add(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
 	return 0;
 error:
-	err = rte_errno;
-	for (j = 0; j < i; j++)
-		mlx5_rxq_deref(dev, ind_tbl->queues[j]);
-	rte_errno = err;
+	if (dev_started) {
+		err = rte_errno;
+		for (j = 0; j < i; j++)
+			mlx5_rxq_deref(dev, queues[j]);
+		rte_errno = err;
+	}
 	DRV_LOG(DEBUG, "Port %u cannot setup indirection table.",
 		dev->data->port_id);
 	return ret;