DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Washington <joshwash@google.com>
To: Joshua Washington <joshwash@google.com>
Cc: dev@dpdk.org, blasko@google.com, jtranoleary@google.com
Subject: [PATCH v3 7/8] net/gve: add RSS cache boolean flag
Date: Fri,  9 Oct 2026 17:59:39 -0700	[thread overview]
Message-ID: <20261010005942.560881-8-joshwash@google.com> (raw)
In-Reply-To: <20261010005942.560881-1-joshwash@google.com>

Introduce a flag that determines whether the RSS configuration stored in
priv is the latest from the device or not.

This functionality is contingent on query support. If RSS queries are
supported, then when sending a control plane message to configure RSS,
the cache will be invalidated. Upon storing the latest configuration in
priv, the cache will be considered clean and ready to be read.

If RSS queries are not supported, as is the case for the current admin
queue implementation, the RSS cache is not cleared when sending a
configuration update to avoid causing the cache to become permanently
stale.

The RSS configuration should never be read if the cache is dirty.

Signed-off-by: Joshua Washington <joshwash@google.com>
---
v3:
  - Avoid clearing the RSS cache, as the driver is the source of truth.
v2:
  - Remove -ENODATA return for Freebsd compatibility.
---
 drivers/net/gve/gve_ethdev.c | 81 +++++++++++++++++++++++++++++-------
 drivers/net/gve/gve_ethdev.h |  1 +
 drivers/net/gve/gve_rss.c    |  2 +
 3 files changed, 69 insertions(+), 15 deletions(-)

diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index d117b28dd0..31698bc38a 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -217,6 +217,32 @@ gve_teardown_queue_page_list(struct gve_priv *priv,
 	return 0;
 }
 
+static int
+gve_rss_update_cache(struct gve_priv *priv)
+{
+	struct gve_process_private *process_priv;
+
+	process_priv = rte_eth_devices[priv->port_id].process_private;
+
+	if (priv->rss_cache_dirty) {
+		int err;
+
+		if (process_priv->ctrl_ops->query_rss == NULL) {
+			PMD_DRV_LOG(ERR,
+				    "No RSS query functionality present in ops table");
+			return -ENOENT;
+		}
+
+		err = process_priv->ctrl_ops->query_rss(priv);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Failed to query device for RSS info.");
+			return err;
+		}
+	}
+
+	return 0;
+}
+
 static int
 gve_dev_configure(struct rte_eth_dev *dev)
 {
@@ -241,19 +267,25 @@ gve_dev_configure(struct rte_eth_dev *dev)
 		}
 	}
 
-	/* Reset RSS RETA in case number of queues changed. */
+	/* Reset RSS RETA in case number of queues changed, but don't fail
+	 * configure if the cache cannot be updated.
+	 */
 	if (priv->rss_config.indir) {
-		struct gve_rss_config update_reta_config;
-		gve_init_rss_config_from_priv(priv, &update_reta_config);
-		gve_generate_rss_reta(dev, &update_reta_config);
+		err = gve_rss_update_cache(priv);
+		if (err == 0) {
+			struct gve_rss_config update_reta_config;
 
-		err = process_priv->ctrl_ops->configure_rss(priv, &update_reta_config);
-		if (err)
-			PMD_DRV_LOG(ERR,
-				"Could not reconfigure RSS redirection table.");
+			gve_init_rss_config_from_priv(priv, &update_reta_config);
+			gve_generate_rss_reta(dev, &update_reta_config);
 
-		gve_free_rss_config(&update_reta_config);
-		return err;
+			err = process_priv->ctrl_ops->configure_rss(priv, &update_reta_config);
+			if (err)
+				PMD_DRV_LOG(ERR,
+					"Could not reconfigure RSS redirection table.");
+
+			gve_free_rss_config(&update_reta_config);
+			return err;
+		}
 	}
 
 	return 0;
@@ -1118,7 +1150,6 @@ gve_xstats_get_names(struct rte_eth_dev *dev,
 	return count;
 }
 
-
 static int
 gve_rss_hash_update(struct rte_eth_dev *dev,
 			struct rte_eth_rss_conf *rss_conf)
@@ -1169,6 +1200,10 @@ gve_rss_hash_update(struct rte_eth_dev *dev,
 	if (err)
 		return err;
 
+	err = gve_rss_update_cache(priv);
+	if (err)
+		goto err;
+
 	gve_rss_conf.alg = GVE_RSS_HASH_TOEPLITZ;
 	err = gve_update_rss_hash_types(priv, &gve_rss_conf, rss_conf);
 	if (err)
@@ -1196,6 +1231,7 @@ gve_rss_hash_conf_get(struct rte_eth_dev *dev,
 			struct rte_eth_rss_conf *rss_conf)
 {
 	struct gve_priv *priv = dev->data->dev_private;
+	int err;
 
 	if (!(dev->data->dev_conf.rxmode.offloads &
 			RTE_ETH_RX_OFFLOAD_RSS_HASH)) {
@@ -1203,6 +1239,9 @@ gve_rss_hash_conf_get(struct rte_eth_dev *dev,
 		return -ENOTSUP;
 	}
 
+	err = gve_rss_update_cache(priv);
+	if (err)
+		return err;
 
 	gve_to_rte_rss_hf(priv->rss_config.hash_types, rss_conf);
 	rss_conf->rss_key_len = priv->rss_config.key_size;
@@ -1229,6 +1268,10 @@ gve_rss_reta_update(struct rte_eth_dev *dev,
 	int err;
 	int i;
 
+	err = gve_rss_update_cache(priv);
+	if (err)
+		return err;
+
 	/* RSS key must be set before the redirection table can be set. */
 	if (!priv->rss_config.key || priv->rss_config.key_size == 0) {
 		PMD_DRV_LOG(ERR, "RSS hash key msut be set before the "
@@ -1271,8 +1314,10 @@ static int
 gve_rss_reta_query(struct rte_eth_dev *dev,
 	struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size)
 {
+	struct gve_process_private *process_priv = dev->process_private;
 	struct gve_priv *priv = dev->data->dev_private;
 	int table_id;
+	int err;
 	int i;
 
 	if (!(dev->data->dev_conf.rxmode.offloads &
@@ -1281,10 +1326,14 @@ gve_rss_reta_query(struct rte_eth_dev *dev,
 		return -ENOTSUP;
 	}
 
-	/* RSS key must be set before the redirection table can be queried. */
-	if (!priv->rss_config.key) {
-		PMD_DRV_LOG(ERR, "RSS hash key must be set before the "
-			"redirection table can be initialized.");
+	err = gve_rss_update_cache(priv);
+	if (err != 0)
+		return err;
+
+	if (process_priv->ctrl_ops->query_rss == NULL &&
+	    priv->rss_config.key == NULL) {
+		/* RSS key must be set before the redirection table can be queried. */
+		PMD_DRV_LOG(ERR, "RSS hash key must be set before the redirection table can be initialized.");
 		return -ENOTSUP;
 	}
 
@@ -1686,6 +1735,8 @@ gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
 		    priv->max_nb_txq, priv->max_nb_rxq);
 
 setup_device:
+	if (process_priv->ctrl_ops->query_rss != NULL)
+		priv->rss_cache_dirty = true;
 	if (priv->max_flow_rules) {
 		err = gve_setup_flow_subsystem(priv);
 		if (err)
diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h
index 5d4797bfd6..b6c06cd82d 100644
--- a/drivers/net/gve/gve_ethdev.h
+++ b/drivers/net/gve/gve_ethdev.h
@@ -395,6 +395,7 @@ struct gve_priv {
 	uint16_t stats_end_idx; /* end index of array of stats written by NIC */
 
 	struct gve_rss_config rss_config;
+	bool rss_cache_dirty;
 	struct gve_ptype_lut *ptype_lut_dqo;
 
 	/* Flow rule management */
diff --git a/drivers/net/gve/gve_rss.c b/drivers/net/gve/gve_rss.c
index 4084d7955f..691ec6dab1 100644
--- a/drivers/net/gve/gve_rss.c
+++ b/drivers/net/gve/gve_rss.c
@@ -119,6 +119,8 @@ gve_update_priv_rss_config(struct gve_priv *priv, struct gve_rss_config *config)
 	memcpy(priv_config->key, config->key,
 		config->key_size * sizeof(*priv_config->key));
 
+	priv->rss_cache_dirty = false;
+
 	return 0;
 }
 
-- 
2.56.0.170.g584c36229d-goog


  parent reply	other threads:[~2026-10-10  1:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03  2:51 [PATCH 0/8] gve: precursor control plane changes before bare-metal support Joshua Washington
2026-10-03  2:51 ` [PATCH 1/8] net/gve: refactor ethdev for control ops interface Joshua Washington
2026-10-03  2:51 ` [PATCH 2/8] net/gve: rename doorbell BAR variable to be more generic Joshua Washington
2026-10-03  2:51 ` [PATCH 3/8] net/gve: split default queue counts into Tx and Rx Joshua Washington
2026-10-03  2:51 ` [PATCH 4/8] net/gve: clean Tx queue directly in dqo Joshua Washington
2026-10-03  2:51 ` [PATCH 5/8] net/gve: update RSS config just after successful programming Joshua Washington
2026-10-03  2:51 ` [PATCH 6/8] net/gve: add RSS cache boolean flag Joshua Washington
2026-10-03  2:51 ` [PATCH 7/8] net/gve: fix RSS config memory leak on close Joshua Washington
2026-10-03  2:51 ` [PATCH 8/8] net/gve: refactor timestamp support to clock read type Joshua Washington
2026-10-03 16:29 ` [PATCH 0/8] gve: precursor control plane changes before bare-metal support Stephen Hemminger
2026-10-05 19:39 ` [PATCH v2 " Joshua Washington
2026-10-05 19:39   ` [PATCH v2 1/8] net/gve: refactor ethdev for control ops interface Joshua Washington
2026-10-05 19:39   ` [PATCH v2 2/8] net/gve: rename doorbell BAR variable to be more generic Joshua Washington
2026-10-05 19:39   ` [PATCH v2 3/8] net/gve: split default queue counts into Tx and Rx Joshua Washington
2026-10-05 19:39   ` [PATCH v2 4/8] net/gve: clean Tx queue directly in dqo Joshua Washington
2026-10-05 19:39   ` [PATCH v2 5/8] net/gve: update RSS config just after successful programming Joshua Washington
2026-10-05 19:39   ` [PATCH v2 6/8] net/gve: add RSS cache boolean flag Joshua Washington
2026-10-05 19:39   ` [PATCH v2 7/8] net/gve: fix RSS config memory leak on close Joshua Washington
2026-10-05 19:39   ` [PATCH v2 8/8] net/gve: refactor timestamp support to clock read type Joshua Washington
2026-10-06 14:19   ` [PATCH v2 0/8] gve: precursor control plane changes before bare-metal support Stephen Hemminger
2026-10-06 15:10   ` Stephen Hemminger
2026-10-07 20:11     ` Joshua Washington
2026-10-10  0:59   ` [PATCH v3 " Joshua Washington
2026-10-10  0:59     ` [PATCH v3 1/8] net/gve: fix RSS config memory leak on close Joshua Washington
2026-10-10  0:59     ` [PATCH v3 2/8] net/gve: refactor ethdev for control ops interface Joshua Washington
2026-10-10  0:59     ` [PATCH v3 3/8] net/gve: rename doorbell BAR variable to be more generic Joshua Washington
2026-10-10  0:59     ` [PATCH v3 4/8] net/gve: split default queue counts into Tx and Rx Joshua Washington
2026-10-10  0:59     ` [PATCH v3 5/8] net/gve: clean Tx queue directly in dqo Joshua Washington
2026-10-10  0:59     ` [PATCH v3 6/8] net/gve: update RSS config just after successful programming Joshua Washington
2026-10-10  0:59     ` Joshua Washington [this message]
2026-10-10  0:59     ` [PATCH v3 8/8] net/gve: refactor timestamp support to clock read type Joshua Washington
2026-10-10 18:24     ` [PATCH v3 0/8] gve: precursor control plane changes before bare-metal 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=20261010005942.560881-8-joshwash@google.com \
    --to=joshwash@google.com \
    --cc=blasko@google.com \
    --cc=dev@dpdk.org \
    --cc=jtranoleary@google.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