From: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
To: <dev@dpdk.org>
Cc: Raslan Darawsheh <rasland@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH 2/2] net/mlx5: fix RxQ reference counting for indirect RSS
Date: Wed, 24 Nov 2021 11:35:53 +0200 [thread overview]
Message-ID: <20211124093556.3358394-3-dkozlyuk@nvidia.com> (raw)
In-Reply-To: <20211124093556.3358394-1-dkozlyuk@nvidia.com>
mlx5_ind_table_obj_modify() was not changing the reference counters
of neither the new set of RxQs, nor the old set of RxQs.
On the other hand, creation of the RSS incremented the RxQ refcnt.
If an RxQ was present in both the initial and the modified set,
its reference counter was incremented one extra time
compared to the queues that were only present in the new set.
This prevented releasing said RxQ resources on port stop:
flow indirect_action 0 create action_id 1 \
action rss queues 0 1 end / end
flow indirect_action 0 update 1 \
action rss queues 2 3 end / end
quit
...
mlx5_net: mlx5.c:1622: mlx5_dev_close():
port 0 some Rx queue objects still remain
mlx5_net: mlx5.c:1626: mlx5_dev_close():
port 0 some Rx queues still remain
Increment reference counters for the new set of RxQs
and decrement them for the old set of RxQs.
Only do this when the port is started when the port is started.
Remove explicit referencing of RxQ from mlx5_ind_table_obj_attach()
because it reuses mlx5_ind_table_obj_modify() code doing this.
Fixes: ec4e11d41d12 ("net/mlx5: preserve indirect actions on restart")
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
drivers/net/mlx5/mlx5_rxq.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 8f9a94572f..46d6536be5 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2392,7 +2392,8 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
bool standalone)
{
struct mlx5_priv *priv = dev->data->dev_private;
- unsigned int i;
+ bool dev_started = priv->dev_data->dev_started;
+ unsigned int i, j;
int ret = 0, err;
const unsigned int n = rte_is_power_of_2(queues_n) ?
log2above(queues_n) :
@@ -2402,22 +2403,30 @@ 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;
- for (i = 0; i != queues_n; ++i) {
- if (!mlx5_rxq_get(dev, queues[i])) {
- ret = -rte_errno;
- goto error;
+ if (dev_started)
+ for (i = 0; i != queues_n; ++i) {
+ if (!mlx5_rxq_ref(dev, queues[i])) {
+ ret = -rte_errno;
+ goto error;
+ }
}
- }
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 (dev_started)
+ for (i = 0; i < ind_tbl->queues_n; i++)
+ claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
ind_tbl->queues_n = queues_n;
ind_tbl->queues = queues;
return 0;
error:
- err = rte_errno;
- 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;
@@ -2438,19 +2447,14 @@ int
mlx5_ind_table_obj_attach(struct rte_eth_dev *dev,
struct mlx5_ind_table_obj *ind_tbl)
{
- unsigned int i;
int ret;
ret = mlx5_ind_table_obj_modify(dev, ind_tbl, ind_tbl->queues,
ind_tbl->queues_n, true);
- if (ret != 0) {
+ if (ret != 0)
DRV_LOG(ERR, "Port %u could not modify indirect table obj %p",
dev->data->port_id, (void *)ind_tbl);
- return ret;
- }
- for (i = 0; i < ind_tbl->queues_n; i++)
- mlx5_rxq_ref(dev, ind_tbl->queues[i]);
- return 0;
+ return ret;
}
/**
--
2.25.1
next prev parent reply other threads:[~2021-11-24 9:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 22:31 [PATCH 0/2] next/mlx5: fix indirect RSS reference counting Dmitry Kozlyuk
2021-11-23 22:31 ` [PATCH 1/2] net/mlx5: fix indirect RSS creation when port is stopped Dmitry Kozlyuk
2021-11-23 22:31 ` [PATCH 2/2] net/mlx5: fix RxQ reference counting for indirect RSS Dmitry Kozlyuk
2021-11-24 9:35 ` [PATCH 0/2] next/mlx5: fix indirect RSS reference counting Dmitry Kozlyuk
2021-11-24 9:35 ` [PATCH 1/2] net/mlx5: fix indirect RSS creation when port is stopped Dmitry Kozlyuk
2021-11-24 9:35 ` Dmitry Kozlyuk [this message]
2021-11-24 9:35 ` [PATCH v2 0/2] net/mlx5: fix indirect RSS reference counting Dmitry Kozlyuk
2021-11-24 9:35 ` [PATCH v2 1/2] net/mlx5: fix indirect RSS creation when port is stopped Dmitry Kozlyuk
2021-11-24 9:40 ` [PATCH v3 0/2] net/mlx5: fix indirect RSS reference counting Dmitry Kozlyuk
2021-11-24 9:40 ` [PATCH v3 1/2] net/mlx5: fix indirect RSS creation when port is stopped Dmitry Kozlyuk
2021-11-24 9:40 ` [PATCH v3 2/2] net/mlx5: fix RxQ reference counting for indirect RSS Dmitry Kozlyuk
2021-11-24 13:04 ` [PATCH v3 0/2] net/mlx5: fix indirect RSS reference counting 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=20211124093556.3358394-3-dkozlyuk@nvidia.com \
--to=dkozlyuk@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).