DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
	Raslan Darawsheh <rasland@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH 1/2] net/mlx5: fix external RQ dereferencing
Date: Wed, 2 Mar 2022 09:48:00 +0200	[thread overview]
Message-ID: <20220302074801.4140079-2-michaelba@nvidia.com> (raw)
In-Reply-To: <20220302074801.4140079-1-michaelba@nvidia.com>

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


  reply	other threads:[~2022-03-02  7:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02  7:47 [PATCH 0/2] net/mlx5: external RxQ fixes Michael Baum
2022-03-02  7:48 ` Michael Baum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220302074801.4140079-2-michaelba@nvidia.com \
    --to=michaelba@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).