DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Washington <joshwash@google.com>
To: Joshua Washington <joshwash@google.com>,
	Junfeng Guo <junfengg@nvidia.com>,
	Jeroen de Borst <jeroendb@google.com>,
	Rushil Gupta <rushilg@google.com>
Cc: dev@dpdk.org, "Jasper Tran O'Leary" <jtranoleary@google.com>,
	stable@dpdk.org
Subject: [PATCH 08/12] net/gve: reject non-power-of-2 ring sizes on DQO
Date: Thu,  3 Dec 2026 15:26:31 -0800	[thread overview]
Message-ID: <20261203232637.1044501-9-joshwash@google.com> (raw)
In-Reply-To: <20261203232637.1044501-1-joshwash@google.com>

From: Jasper Tran O'Leary <jtranoleary@google.com>

Both DQO RX and TX datapaths wrap ring indices by bitmasking with one
less than the ring size, and the hardware specification requires all
descriptor, buffer, and completion rings to be power-of-2 sized. While
GQI queue setup enforces this requirement, DQO RX and TX queue setup
omit the check.

Fix DQO RX and TX queue setup by rejecting non-power-of-2 descriptor
counts. Also validate TX descriptor thresholds before releasing an
existing queue or allocating queue state so invalid thresholds do not
leak memory.

Fixes: 1dc00f4fc74b ("net/gve: add Rx queue setup for DQO")
Fixes: a14d391c7d99 ("net/gve: add Tx queue setup for DQO")
Cc: stable@dpdk.org

Signed-off-by: Jasper Tran O'Leary <jtranoleary@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
---
 drivers/net/gve/gve_rx_dqo.c |  7 +++++++
 drivers/net/gve/gve_tx_dqo.c | 23 +++++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c
index 0d6665307b..c4fe9692a7 100644
--- a/drivers/net/gve/gve_rx_dqo.c
+++ b/drivers/net/gve/gve_rx_dqo.c
@@ -358,6 +358,13 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id,
 	uint16_t rx_buf_len;
 	int err = 0;
 
+	/* Ring size is required to be a power of two. */
+	if (!rte_is_power_of_2(nb_desc)) {
+		PMD_DRV_LOG(ERR, "Invalid ring size %u. GVE ring size must be a power of 2.",
+			    nb_desc);
+		return -EINVAL;
+	}
+
 	/* Without Rx scatter support on DQO, each Rx buffer must fit any
 	 * incoming frame up to the device maximum MTU.
 	 */
diff --git a/drivers/net/gve/gve_tx_dqo.c b/drivers/net/gve/gve_tx_dqo.c
index db432fd2f6..45559d78ce 100644
--- a/drivers/net/gve/gve_tx_dqo.c
+++ b/drivers/net/gve/gve_tx_dqo.c
@@ -595,6 +595,21 @@ gve_tx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id,
 	uint16_t sw_size;
 	int err = 0;
 
+	/* Ring size is required to be a power of two. */
+	if (!rte_is_power_of_2(nb_desc)) {
+		PMD_DRV_LOG(ERR, "Invalid ring size %u. GVE ring size must be a power of 2.",
+			    nb_desc);
+		return -EINVAL;
+	}
+
+	/* need to check free_thresh here */
+	free_thresh = conf->tx_free_thresh ?
+			conf->tx_free_thresh : GVE_DEFAULT_TX_FREE_THRESH;
+	rs_thresh = conf->tx_rs_thresh ?
+			conf->tx_rs_thresh : GVE_DEFAULT_TX_RS_THRESH;
+	if (check_tx_thresh_dqo(nb_desc, rs_thresh, free_thresh))
+		return -EINVAL;
+
 	/* Free memory if needed. */
 	if (dev->data->tx_queues[queue_id]) {
 		gve_tx_queue_release_dqo(dev, queue_id);
@@ -610,14 +625,6 @@ gve_tx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id,
 		return -ENOMEM;
 	}
 
-	/* need to check free_thresh here */
-	free_thresh = conf->tx_free_thresh ?
-			conf->tx_free_thresh : GVE_DEFAULT_TX_FREE_THRESH;
-	rs_thresh = conf->tx_rs_thresh ?
-			conf->tx_rs_thresh : GVE_DEFAULT_TX_RS_THRESH;
-	if (check_tx_thresh_dqo(nb_desc, rs_thresh, free_thresh))
-		return -EINVAL;
-
 	txq->nb_tx_desc = nb_desc;
 	txq->nb_complq_desc = nb_desc * DQO_TX_MULTIPLIER;
 	txq->free_thresh = free_thresh;
-- 
2.56.1.915.g69d5ec7298-goog


  parent reply	other threads:[~2026-12-03 23:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 23:26 [PATCH 00/12] net/gve: stability fixes and DQO scattered Rx support Joshua Washington
2026-12-03 23:26 ` [PATCH 01/12] net/gve: disable queue start and stop Joshua Washington
2026-12-03 23:26 ` [PATCH 02/12] net/gve: free partially received GQI Rx packet Joshua Washington
2026-12-03 23:26 ` [PATCH 03/12] net/gve: fix integer underflow in GQI Rx path Joshua Washington
2026-12-03 23:26 ` [PATCH 04/12] net/gve: fix integer truncation in GQI QPL Tx path Joshua Washington
2026-12-03 23:26 ` [PATCH 05/12] net/gve: do not count unsent DQO Tx packets as oerrors Joshua Washington
2026-12-03 23:26 ` [PATCH 06/12] net/gve: disable unsupported TCP LRO offload Joshua Washington
2026-12-03 23:26 ` [PATCH 07/12] net/gve: drop multi-seg Rx packets if scatter is off Joshua Washington
2026-12-03 23:26 ` Joshua Washington [this message]
2026-12-03 23:26 ` [PATCH 09/12] net/gve: properly handle RSS realloc failures Joshua Washington
2026-12-03 23:26 ` [PATCH 10/12] net/gve: reject unsupported flow attributes and item masks Joshua Washington
2026-12-03 23:26 ` [PATCH 11/12] net/gve: fix mbuf leak on GQI Rx queue start Joshua Washington
2026-12-03 23:26 ` [PATCH 12/12] net/gve: support scattered Rx for DQO Joshua Washington
2026-12-04 19:13 ` [PATCH 00/12] net/gve: stability fixes and DQO scattered Rx support Stephen Hemminger

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=20261203232637.1044501-9-joshwash@google.com \
    --to=joshwash@google.com \
    --cc=dev@dpdk.org \
    --cc=jeroendb@google.com \
    --cc=jtranoleary@google.com \
    --cc=junfengg@nvidia.com \
    --cc=rushilg@google.com \
    --cc=stable@dpdk.org \
    /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