From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: getelson@nvidia.com, <mkashani@nvidia.com>,
rasland@nvidia.com, "Dariusz Sosnowski" <dsosnowski@nvidia.com>,
"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
"Bing Zhao" <bingz@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
"Suanming Mou" <suanmingm@nvidia.com>,
"Matan Azrad" <matan@nvidia.com>,
"Michael Baum" <michaelba@nvidia.com>
Subject: [PATCH] net/mlx5: fix external Rx and Tx queues access
Date: Thu, 31 Jul 2025 09:08:49 +0300 [thread overview]
Message-ID: <20250731060849.18117-1-getelson@nvidia.com> (raw)
mlx5_ext_rxq_get() and mlx5_ext_txq_get() functions did not return
NULL value if query index was not referencing external queue.
As a result, calling functions did not expect the NULL on return.
External Rx queue:
- In mlx5_ext_rxq_get() remove assert and return NULL if a queue index
does not point to a valid external queue.
- In mlx5_ext_rxq_verify() validate that probed queue index references
a valid extern queue.
External Tx queue:
- In mlx5_ext_txq_get() remove assert and return NULL if a queue index
does not point to a valid external queue.
- In mlx5_ext_txq_verify() validate that probed queue index references
a valid extern queue.
Fixes: 311b17e669ab ("net/mlx5: support queue/RSS actions for external Rx queue")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
drivers/net/mlx5/mlx5_rxq.c | 10 +++++-----
drivers/net/mlx5/mlx5_txq.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 77c5848c37..c615a5c64b 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2250,8 +2250,8 @@ mlx5_ext_rxq_get(struct rte_eth_dev *dev, uint16_t idx)
{
struct mlx5_priv *priv = dev->data->dev_private;
- MLX5_ASSERT(mlx5_is_external_rxq(dev, idx));
- return &priv->ext_rxqs[idx - RTE_PMD_MLX5_EXTERNAL_RX_QUEUE_ID_MIN];
+ return mlx5_is_external_rxq(dev, idx) ?
+ &priv->ext_rxqs[idx - RTE_PMD_MLX5_EXTERNAL_RX_QUEUE_ID_MIN] : NULL;
}
/**
@@ -2413,7 +2413,6 @@ int
mlx5_ext_rxq_verify(struct rte_eth_dev *dev)
{
struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_external_q *rxq;
uint32_t i;
int ret = 0;
@@ -2421,8 +2420,9 @@ mlx5_ext_rxq_verify(struct rte_eth_dev *dev)
return 0;
for (i = RTE_PMD_MLX5_EXTERNAL_RX_QUEUE_ID_MIN; i <= UINT16_MAX ; ++i) {
- rxq = mlx5_ext_rxq_get(dev, i);
- if (rxq->refcnt < 2)
+ struct mlx5_external_q *rxq = mlx5_ext_rxq_get(dev, i);
+
+ if (rxq == NULL || rxq->refcnt < 2)
continue;
DRV_LOG(DEBUG, "Port %u external RxQ %u still referenced.",
dev->data->port_id, i);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index b090d8274d..2aa2475a8a 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1281,8 +1281,8 @@ mlx5_ext_txq_get(struct rte_eth_dev *dev, uint16_t idx)
{
struct mlx5_priv *priv = dev->data->dev_private;
- MLX5_ASSERT(mlx5_is_external_txq(dev, idx));
- return &priv->ext_txqs[idx - MLX5_EXTERNAL_TX_QUEUE_ID_MIN];
+ return mlx5_is_external_txq(dev, idx) ?
+ &priv->ext_txqs[idx - MLX5_EXTERNAL_TX_QUEUE_ID_MIN] : NULL;
}
/**
@@ -1298,7 +1298,6 @@ int
mlx5_ext_txq_verify(struct rte_eth_dev *dev)
{
struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_external_q *txq;
uint32_t i;
int ret = 0;
@@ -1306,8 +1305,9 @@ mlx5_ext_txq_verify(struct rte_eth_dev *dev)
return 0;
for (i = MLX5_EXTERNAL_TX_QUEUE_ID_MIN; i <= UINT16_MAX ; ++i) {
- txq = mlx5_ext_txq_get(dev, i);
- if (txq->refcnt < 2)
+ struct mlx5_external_q *txq = mlx5_ext_txq_get(dev, i);
+
+ if (txq == NULL || txq->refcnt < 2)
continue;
DRV_LOG(DEBUG, "Port %u external TxQ %u still referenced.",
dev->data->port_id, i);
--
2.48.1
reply other threads:[~2025-07-31 6:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250731060849.18117-1-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=michaelba@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=suanmingm@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).