DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] net/mlx5: external RxQ fixes
@ 2022-03-02  7:47 Michael Baum
  2022-03-02  7:48 ` [PATCH 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:47 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

Some fixes about external RxQ support.
They fix missing refcnt updating in some places.

Michael Baum (2):
  net/mlx5: fix external RQ dereferencing
  net/mlx5: fix external RQ refrencing

 drivers/net/mlx5/mlx5_rxq.c | 158 ++++++++++++++++++++++--------------
 1 file changed, 97 insertions(+), 61 deletions(-)

-- 
2.25.1


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

* [PATCH 1/2] net/mlx5: fix external RQ dereferencing
  2022-03-02  7:47 [PATCH 0/2] net/mlx5: external RxQ fixes Michael Baum
@ 2022-03-02  7:48 ` Michael Baum
  2022-03-02  7:48 ` [PATCH 2/2] net/mlx5: fix external RQ refrencing Michael Baum
  2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:48 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

When an indirection table is destroyed, each RX queue related to it,
should be dereferenced.

The regular queues are indeed dereferenced. However, the external RxQs
are not.

This patch adds dereferencing for external RxQs too.

Fixes: 311b17e669ab ("net/mlx5: support queue/RSS actions for external Rx queue")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 41 ++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index ff293d9d56..19c75b7b32 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2143,6 +2143,30 @@ mlx5_ext_rxq_get(struct rte_eth_dev *dev, uint16_t idx)
 	return &priv->ext_rxqs[idx - MLX5_EXTERNAL_RX_QUEUE_ID_MIN];
 }
 
+/**
+ * Dereference a list of Rx queues.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queues
+ *   List of Rx queues to deref.
+ * @param queues_n
+ *   Number of queues in the array.
+ */
+static void
+mlx5_rxqs_deref(struct rte_eth_dev *dev, uint16_t *queues,
+		const uint32_t queues_n)
+{
+	uint32_t i;
+
+	for (i = 0; i < queues_n; i++) {
+		if (mlx5_is_external_rxq(dev, queues[i]))
+			claim_nonzero(mlx5_ext_rxq_deref(dev, queues[i]));
+		else
+			claim_nonzero(mlx5_rxq_deref(dev, queues[i]));
+	}
+}
+
 /**
  * Release a Rx queue.
  *
@@ -2377,7 +2401,7 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev,
 			   bool deref_rxqs)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	unsigned int i, ret;
+	unsigned int ret;
 
 	rte_rwlock_write_lock(&priv->ind_tbls_lock);
 	ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
@@ -2387,10 +2411,8 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev,
 	if (ret)
 		return 1;
 	priv->obj_ops.ind_table_destroy(ind_tbl);
-	if (deref_rxqs) {
-		for (i = 0; i != ind_tbl->queues_n; ++i)
-			claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
-	}
+	if (deref_rxqs)
+		mlx5_rxqs_deref(dev, ind_tbl->queues, ind_tbl->queues_n);
 	mlx5_free(ind_tbl);
 	return 0;
 }
@@ -2443,7 +2465,7 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t queues_n = ind_tbl->queues_n;
 	uint16_t *queues = ind_tbl->queues;
-	unsigned int i = 0, j;
+	unsigned int i = 0;
 	int ret = 0, err;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
@@ -2471,12 +2493,7 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 error:
 	if (ref_qs) {
 		err = rte_errno;
-		for (j = 0; j < i; j++) {
-			if (mlx5_is_external_rxq(dev, queues[j]))
-				mlx5_ext_rxq_deref(dev, queues[j]);
-			else
-				mlx5_rxq_deref(dev, queues[j]);
-		}
+		mlx5_rxqs_deref(dev, queues, i);
 		rte_errno = err;
 	}
 	DRV_LOG(DEBUG, "Port %u cannot setup indirection table.",
-- 
2.25.1


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

* [PATCH 2/2] net/mlx5: fix external RQ refrencing
  2022-03-02  7:47 [PATCH 0/2] net/mlx5: external RxQ fixes Michael Baum
  2022-03-02  7:48 ` [PATCH 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
@ 2022-03-02  7:48 ` Michael Baum
  2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:48 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

When an indirection table object is modified, it updates the reference
counter for each RX queue related to it.

The reference counter for regular queues are indeed updated. However,
the reference counter for external RxQs are not.

This patch adds updating for external RxQs too.

Fixes: 311b17e669ab ("net/mlx5: support queue/RSS actions for external Rx queue")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 121 +++++++++++++++++++++---------------
 1 file changed, 70 insertions(+), 51 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 19c75b7b32..f16795bac3 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2167,6 +2167,41 @@ mlx5_rxqs_deref(struct rte_eth_dev *dev, uint16_t *queues,
 	}
 }
 
+/**
+ * Increase reference count for list of Rx queues.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queues
+ *   List of Rx queues to ref.
+ * @param queues_n
+ *   Number of queues in the array.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_rxqs_ref(struct rte_eth_dev *dev, uint16_t *queues,
+	      const uint32_t queues_n)
+{
+	uint32_t i;
+
+	for (i = 0; i != queues_n; ++i) {
+		if (mlx5_is_external_rxq(dev, queues[i])) {
+			if (mlx5_ext_rxq_ref(dev, queues[i]) == NULL)
+				goto error;
+		} else {
+			if (mlx5_rxq_ref(dev, queues[i]) == NULL)
+				goto error;
+		}
+	}
+	return 0;
+error:
+	mlx5_rxqs_deref(dev, queues, i);
+	rte_errno = EINVAL;
+	return -rte_errno;
+}
+
 /**
  * Release a Rx queue.
  *
@@ -2464,41 +2499,30 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t queues_n = ind_tbl->queues_n;
-	uint16_t *queues = ind_tbl->queues;
-	unsigned int i = 0;
-	int ret = 0, err;
+	int ret;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
 			       log2above(priv->sh->dev_cap.ind_table_max_size);
 
-	if (ref_qs)
-		for (i = 0; i != queues_n; ++i) {
-			if (mlx5_is_external_rxq(dev, queues[i])) {
-				if (mlx5_ext_rxq_ref(dev, queues[i]) == NULL) {
-					ret = -rte_errno;
-					goto error;
-				}
-			} else {
-				if (mlx5_rxq_ref(dev, queues[i]) == NULL) {
-					ret = -rte_errno;
-					goto error;
-				}
-			}
-		}
+	if (ref_qs && mlx5_rxqs_ref(dev, ind_tbl->queues, queues_n) < 0) {
+		DRV_LOG(DEBUG, "Port %u invalid indirection table queues.",
+			dev->data->port_id);
+		return -rte_errno;
+	}
 	ret = priv->obj_ops.ind_table_new(dev, n, ind_tbl);
-	if (ret)
-		goto error;
+	if (ret) {
+		DRV_LOG(DEBUG, "Port %u cannot create a new indirection table.",
+			dev->data->port_id);
+		if (ref_qs) {
+			int err = rte_errno;
+
+			mlx5_rxqs_deref(dev, ind_tbl->queues, queues_n);
+			rte_errno = err;
+		}
+		return ret;
+	}
 	__atomic_fetch_add(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
 	return 0;
-error:
-	if (ref_qs) {
-		err = rte_errno;
-		mlx5_rxqs_deref(dev, queues, i);
-		rte_errno = err;
-	}
-	DRV_LOG(DEBUG, "Port %u cannot setup indirection table.",
-		dev->data->port_id);
-	return ret;
 }
 
 /**
@@ -2603,8 +2627,7 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 			  bool standalone, bool ref_new_qs, bool deref_old_qs)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	unsigned int i = 0, j;
-	int ret = 0, err;
+	int ret;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
 			       log2above(priv->sh->dev_cap.ind_table_max_size);
@@ -2613,33 +2636,29 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 	RTE_SET_USED(standalone);
 	if (mlx5_ind_table_obj_check_standalone(dev, ind_tbl) < 0)
 		return -rte_errno;
-	if (ref_new_qs)
-		for (i = 0; i != queues_n; ++i) {
-			if (!mlx5_rxq_ref(dev, queues[i])) {
-				ret = -rte_errno;
-				goto error;
-			}
-		}
+	if (ref_new_qs && mlx5_rxqs_ref(dev, queues, queues_n) < 0) {
+		DRV_LOG(DEBUG, "Port %u invalid indirection table queues.",
+			dev->data->port_id);
+		return -rte_errno;
+	}
 	MLX5_ASSERT(priv->obj_ops.ind_table_modify);
 	ret = priv->obj_ops.ind_table_modify(dev, n, queues, queues_n, ind_tbl);
-	if (ret)
-		goto error;
+	if (ret) {
+		DRV_LOG(DEBUG, "Port %u cannot modify indirection table.",
+			dev->data->port_id);
+		if (ref_new_qs) {
+			int err = rte_errno;
+
+			mlx5_rxqs_deref(dev, queues, queues_n);
+			rte_errno = err;
+		}
+		return ret;
+	}
 	if (deref_old_qs)
-		for (i = 0; i < ind_tbl->queues_n; i++)
-			claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
+		mlx5_rxqs_deref(dev, ind_tbl->queues, ind_tbl->queues_n);
 	ind_tbl->queues_n = queues_n;
 	ind_tbl->queues = queues;
 	return 0;
-error:
-	if (ref_new_qs) {
-		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;
 }
 
 /**
-- 
2.25.1


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

* [PATCH v2 0/2] net/mlx5: external RxQ fixes
  2022-03-02  7:47 [PATCH 0/2] net/mlx5: external RxQ fixes Michael Baum
  2022-03-02  7:48 ` [PATCH 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
  2022-03-02  7:48 ` [PATCH 2/2] net/mlx5: fix external RQ refrencing Michael Baum
@ 2022-03-02  7:58 ` Michael Baum
  2022-03-02  7:58   ` [PATCH v2 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
                     ` (2 more replies)
  2 siblings, 3 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:58 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

Some fixes about external RxQ support.
They fix missing refcnt updating in some places.

v2: fix typo refrencing -> referencing.

Michael Baum (2):
  net/mlx5: fix external RQ dereferencing
  net/mlx5: fix external RQ referencing

 drivers/net/mlx5/mlx5_rxq.c | 158 ++++++++++++++++++++++--------------
 1 file changed, 97 insertions(+), 61 deletions(-)

-- 
2.25.1


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

* [PATCH v2 1/2] net/mlx5: fix external RQ dereferencing
  2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
@ 2022-03-02  7:58   ` Michael Baum
  2022-03-02  7:58   ` [PATCH v2 2/2] net/mlx5: fix external RQ referencing Michael Baum
  2022-03-07 10:29   ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Raslan Darawsheh
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:58 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

When an indirection table is destroyed, each RX queue related to it,
should be dereferenced.

The regular queues are indeed dereferenced. However, the external RxQs
are not.

This patch adds dereferencing for external RxQs too.

Fixes: 311b17e669ab ("net/mlx5: support queue/RSS actions for external Rx queue")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 41 ++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index ff293d9d56..19c75b7b32 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2143,6 +2143,30 @@ mlx5_ext_rxq_get(struct rte_eth_dev *dev, uint16_t idx)
 	return &priv->ext_rxqs[idx - MLX5_EXTERNAL_RX_QUEUE_ID_MIN];
 }
 
+/**
+ * Dereference a list of Rx queues.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queues
+ *   List of Rx queues to deref.
+ * @param queues_n
+ *   Number of queues in the array.
+ */
+static void
+mlx5_rxqs_deref(struct rte_eth_dev *dev, uint16_t *queues,
+		const uint32_t queues_n)
+{
+	uint32_t i;
+
+	for (i = 0; i < queues_n; i++) {
+		if (mlx5_is_external_rxq(dev, queues[i]))
+			claim_nonzero(mlx5_ext_rxq_deref(dev, queues[i]));
+		else
+			claim_nonzero(mlx5_rxq_deref(dev, queues[i]));
+	}
+}
+
 /**
  * Release a Rx queue.
  *
@@ -2377,7 +2401,7 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev,
 			   bool deref_rxqs)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	unsigned int i, ret;
+	unsigned int ret;
 
 	rte_rwlock_write_lock(&priv->ind_tbls_lock);
 	ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
@@ -2387,10 +2411,8 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev,
 	if (ret)
 		return 1;
 	priv->obj_ops.ind_table_destroy(ind_tbl);
-	if (deref_rxqs) {
-		for (i = 0; i != ind_tbl->queues_n; ++i)
-			claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
-	}
+	if (deref_rxqs)
+		mlx5_rxqs_deref(dev, ind_tbl->queues, ind_tbl->queues_n);
 	mlx5_free(ind_tbl);
 	return 0;
 }
@@ -2443,7 +2465,7 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t queues_n = ind_tbl->queues_n;
 	uint16_t *queues = ind_tbl->queues;
-	unsigned int i = 0, j;
+	unsigned int i = 0;
 	int ret = 0, err;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
@@ -2471,12 +2493,7 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 error:
 	if (ref_qs) {
 		err = rte_errno;
-		for (j = 0; j < i; j++) {
-			if (mlx5_is_external_rxq(dev, queues[j]))
-				mlx5_ext_rxq_deref(dev, queues[j]);
-			else
-				mlx5_rxq_deref(dev, queues[j]);
-		}
+		mlx5_rxqs_deref(dev, queues, i);
 		rte_errno = err;
 	}
 	DRV_LOG(DEBUG, "Port %u cannot setup indirection table.",
-- 
2.25.1


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

* [PATCH v2 2/2] net/mlx5: fix external RQ referencing
  2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
  2022-03-02  7:58   ` [PATCH v2 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
@ 2022-03-02  7:58   ` Michael Baum
  2022-03-07 10:29   ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Raslan Darawsheh
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Baum @ 2022-03-02  7:58 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko

When an indirection table object is modified, it updates the reference
counter for each RX queue related to it.

The reference counter for regular queues are indeed updated. However,
the reference counter for external RxQs are not.

This patch adds updating for external RxQs too.

Fixes: 311b17e669ab ("net/mlx5: support queue/RSS actions for external Rx queue")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 121 +++++++++++++++++++++---------------
 1 file changed, 70 insertions(+), 51 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 19c75b7b32..f16795bac3 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2167,6 +2167,41 @@ mlx5_rxqs_deref(struct rte_eth_dev *dev, uint16_t *queues,
 	}
 }
 
+/**
+ * Increase reference count for list of Rx queues.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queues
+ *   List of Rx queues to ref.
+ * @param queues_n
+ *   Number of queues in the array.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_rxqs_ref(struct rte_eth_dev *dev, uint16_t *queues,
+	      const uint32_t queues_n)
+{
+	uint32_t i;
+
+	for (i = 0; i != queues_n; ++i) {
+		if (mlx5_is_external_rxq(dev, queues[i])) {
+			if (mlx5_ext_rxq_ref(dev, queues[i]) == NULL)
+				goto error;
+		} else {
+			if (mlx5_rxq_ref(dev, queues[i]) == NULL)
+				goto error;
+		}
+	}
+	return 0;
+error:
+	mlx5_rxqs_deref(dev, queues, i);
+	rte_errno = EINVAL;
+	return -rte_errno;
+}
+
 /**
  * Release a Rx queue.
  *
@@ -2464,41 +2499,30 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev,
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t queues_n = ind_tbl->queues_n;
-	uint16_t *queues = ind_tbl->queues;
-	unsigned int i = 0;
-	int ret = 0, err;
+	int ret;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
 			       log2above(priv->sh->dev_cap.ind_table_max_size);
 
-	if (ref_qs)
-		for (i = 0; i != queues_n; ++i) {
-			if (mlx5_is_external_rxq(dev, queues[i])) {
-				if (mlx5_ext_rxq_ref(dev, queues[i]) == NULL) {
-					ret = -rte_errno;
-					goto error;
-				}
-			} else {
-				if (mlx5_rxq_ref(dev, queues[i]) == NULL) {
-					ret = -rte_errno;
-					goto error;
-				}
-			}
-		}
+	if (ref_qs && mlx5_rxqs_ref(dev, ind_tbl->queues, queues_n) < 0) {
+		DRV_LOG(DEBUG, "Port %u invalid indirection table queues.",
+			dev->data->port_id);
+		return -rte_errno;
+	}
 	ret = priv->obj_ops.ind_table_new(dev, n, ind_tbl);
-	if (ret)
-		goto error;
+	if (ret) {
+		DRV_LOG(DEBUG, "Port %u cannot create a new indirection table.",
+			dev->data->port_id);
+		if (ref_qs) {
+			int err = rte_errno;
+
+			mlx5_rxqs_deref(dev, ind_tbl->queues, queues_n);
+			rte_errno = err;
+		}
+		return ret;
+	}
 	__atomic_fetch_add(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
 	return 0;
-error:
-	if (ref_qs) {
-		err = rte_errno;
-		mlx5_rxqs_deref(dev, queues, i);
-		rte_errno = err;
-	}
-	DRV_LOG(DEBUG, "Port %u cannot setup indirection table.",
-		dev->data->port_id);
-	return ret;
 }
 
 /**
@@ -2603,8 +2627,7 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 			  bool standalone, bool ref_new_qs, bool deref_old_qs)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	unsigned int i = 0, j;
-	int ret = 0, err;
+	int ret;
 	const unsigned int n = rte_is_power_of_2(queues_n) ?
 			       log2above(queues_n) :
 			       log2above(priv->sh->dev_cap.ind_table_max_size);
@@ -2613,33 +2636,29 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 	RTE_SET_USED(standalone);
 	if (mlx5_ind_table_obj_check_standalone(dev, ind_tbl) < 0)
 		return -rte_errno;
-	if (ref_new_qs)
-		for (i = 0; i != queues_n; ++i) {
-			if (!mlx5_rxq_ref(dev, queues[i])) {
-				ret = -rte_errno;
-				goto error;
-			}
-		}
+	if (ref_new_qs && mlx5_rxqs_ref(dev, queues, queues_n) < 0) {
+		DRV_LOG(DEBUG, "Port %u invalid indirection table queues.",
+			dev->data->port_id);
+		return -rte_errno;
+	}
 	MLX5_ASSERT(priv->obj_ops.ind_table_modify);
 	ret = priv->obj_ops.ind_table_modify(dev, n, queues, queues_n, ind_tbl);
-	if (ret)
-		goto error;
+	if (ret) {
+		DRV_LOG(DEBUG, "Port %u cannot modify indirection table.",
+			dev->data->port_id);
+		if (ref_new_qs) {
+			int err = rte_errno;
+
+			mlx5_rxqs_deref(dev, queues, queues_n);
+			rte_errno = err;
+		}
+		return ret;
+	}
 	if (deref_old_qs)
-		for (i = 0; i < ind_tbl->queues_n; i++)
-			claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
+		mlx5_rxqs_deref(dev, ind_tbl->queues, ind_tbl->queues_n);
 	ind_tbl->queues_n = queues_n;
 	ind_tbl->queues = queues;
 	return 0;
-error:
-	if (ref_new_qs) {
-		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;
 }
 
 /**
-- 
2.25.1


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

* RE: [PATCH v2 0/2] net/mlx5: external RxQ fixes
  2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
  2022-03-02  7:58   ` [PATCH v2 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
  2022-03-02  7:58   ` [PATCH v2 2/2] net/mlx5: fix external RQ referencing Michael Baum
@ 2022-03-07 10:29   ` Raslan Darawsheh
  2 siblings, 0 replies; 7+ messages in thread
From: Raslan Darawsheh @ 2022-03-07 10:29 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: Matan Azrad, Slava Ovsiienko

Hi,

> -----Original Message-----
> From: Michael Baum <michaelba@nvidia.com>
> Sent: Wednesday, March 2, 2022 9:58 AM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Subject: [PATCH v2 0/2] net/mlx5: external RxQ fixes
> 
> Some fixes about external RxQ support.
> They fix missing refcnt updating in some places.
> 
> v2: fix typo refrencing -> referencing.
> 
> Michael Baum (2):
>   net/mlx5: fix external RQ dereferencing
>   net/mlx5: fix external RQ referencing
> 
>  drivers/net/mlx5/mlx5_rxq.c | 158 ++++++++++++++++++++++--------------
>  1 file changed, 97 insertions(+), 61 deletions(-)
> 
> --
> 2.25.1

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2022-03-07 10:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02  7:47 [PATCH 0/2] net/mlx5: external RxQ fixes Michael Baum
2022-03-02  7:48 ` [PATCH 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
2022-03-02  7:48 ` [PATCH 2/2] net/mlx5: fix external RQ refrencing Michael Baum
2022-03-02  7:58 ` [PATCH v2 0/2] net/mlx5: external RxQ fixes Michael Baum
2022-03-02  7:58   ` [PATCH v2 1/2] net/mlx5: fix external RQ dereferencing Michael Baum
2022-03-02  7:58   ` [PATCH v2 2/2] net/mlx5: fix external RQ referencing Michael Baum
2022-03-07 10:29   ` [PATCH v2 0/2] net/mlx5: external RxQ fixes 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).