DPDK patches and discussions
 help / color / mirror / Atom feed
From: Joshua Washington <joshwash@google.com>
To: Junfeng Guo <junfeng.guo@intel.com>,
	Jeroen de Borst <jeroendb@google.com>,
	Rushil Gupta <rushilg@google.com>,
	Joshua Washington <joshwash@google.com>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@amd.com>
Subject: [PATCH 5/7] net/gve: RSS redirection table update support
Date: Mon, 22 Jan 2024 16:16:42 -0800	[thread overview]
Message-ID: <20240123001645.1507779-6-joshwash@google.com> (raw)
In-Reply-To: <20240123001645.1507779-1-joshwash@google.com>

This patch introduces support for updating the RSS redirection table in
the GVE PMD through the implementation of rss_reta_update and
rss_reta_query.

Due to an infrastructure limitation, the RSS hash key must be manually
configured before the redirection table can be updated or queried. The
redirection table is expected to be exactly 128 bytes.
---
 drivers/net/gve/gve_ethdev.c | 95 ++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index 76405120b2..aa9b3d8372 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -770,6 +770,97 @@ gve_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+gve_rss_reta_update(struct rte_eth_dev *dev,
+	struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size)
+{
+	struct gve_priv *priv = dev->data->dev_private;
+	struct gve_rss_config gve_rss_conf;
+	int table_id;
+	int err;
+	int i;
+
+	// 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 "
+			"redirection table can be updated.");
+		return -ENOTSUP;
+	}
+
+	if (reta_size != GVE_RSS_INDIR_SIZE) {
+		PMD_DRV_LOG(ERR, "Redirection table must have %hu elements",
+			GVE_RSS_INDIR_SIZE);
+		return -EINVAL;
+	}
+
+	err = gve_init_rss_config_from_priv(priv, &gve_rss_conf);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Error allocating new RSS config.");
+		return err;
+	}
+
+	table_id = 0;
+	for (i = 0; i < priv->rss_config.indir_size; i++) {
+		int table_entry = i % RTE_ETH_RETA_GROUP_SIZE;
+		if (reta_conf[table_id].mask & (1ULL << table_entry))
+			gve_rss_conf.indir[i] =
+				reta_conf[table_id].reta[table_entry];
+
+		if (table_entry == RTE_ETH_RETA_GROUP_SIZE - 1)
+			table_id ++;
+	}
+
+	err = gve_adminq_configure_rss(priv, &gve_rss_conf);
+	if (err)
+		PMD_DRV_LOG(ERR, "Problem configuring RSS with device.");
+	else
+		gve_update_priv_rss_config(priv, &gve_rss_conf);
+
+	gve_free_rss_config(&gve_rss_conf);
+	return err;
+}
+
+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_priv *priv = dev->data->dev_private;
+	int table_id;
+	int i;
+
+	if (!(dev->data->dev_conf.rxmode.offloads &
+		RTE_ETH_RX_OFFLOAD_RSS_HASH)) {
+		PMD_DRV_LOG(ERR, "RSS not configured.");
+		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.");
+		return -ENOTSUP;
+	}
+
+	if (reta_size != priv->rss_config.indir_size) {
+		PMD_DRV_LOG(ERR, "RSS redirection table must have %d entries.",
+			priv->rss_config.indir_size);
+		return -EINVAL;
+	}
+
+	table_id = 0;
+	for (i = 0; i < priv->rss_config.indir_size; i++) {
+		int table_entry = i % RTE_ETH_RETA_GROUP_SIZE;
+		if (reta_conf[table_id].mask & (1ULL << table_entry))
+			reta_conf[table_id].reta[table_entry]
+				= priv->rss_config.indir[i];
+
+		if (table_entry == RTE_ETH_RETA_GROUP_SIZE - 1)
+			table_id ++;
+	}
+
+	return 0;
+}
+
 static const struct eth_dev_ops gve_eth_dev_ops = {
 	.dev_configure        = gve_dev_configure,
 	.dev_start            = gve_dev_start,
@@ -792,6 +883,8 @@ static const struct eth_dev_ops gve_eth_dev_ops = {
 	.xstats_get_names     = gve_xstats_get_names,
 	.rss_hash_update      = gve_rss_hash_update,
 	.rss_hash_conf_get    = gve_rss_hash_conf_get,
+	.reta_update          = gve_rss_reta_update,
+	.reta_query           = gve_rss_reta_query,
 };
 
 static const struct eth_dev_ops gve_eth_dev_ops_dqo = {
@@ -816,6 +909,8 @@ static const struct eth_dev_ops gve_eth_dev_ops_dqo = {
 	.xstats_get_names     = gve_xstats_get_names,
 	.rss_hash_update      = gve_rss_hash_update,
 	.rss_hash_conf_get    = gve_rss_hash_conf_get,
+	.reta_update          = gve_rss_reta_update,
+	.reta_query           = gve_rss_reta_query,
 };
 
 static void
-- 
2.43.0.429.g432eaa2c6b-goog


  parent reply	other threads:[~2024-01-23  0:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23  0:16 [PATCH 0/7] net/gve: RSS Support for GVE Driver Joshua Washington
2024-01-23  0:16 ` [PATCH 1/7] net/gve: fully expose RSS offload support in dev_info Joshua Washington
2024-01-23  0:16 ` [PATCH 2/7] net/gve: RSS adminq command changes Joshua Washington
2024-01-23  0:16 ` [PATCH 3/7] net/gve: add gve_rss library for handling RSS-related behaviors Joshua Washington
2024-01-23  0:16 ` [PATCH 4/7] net/gve: RSS configuration update support Joshua Washington
2024-01-23  0:16 ` Joshua Washington [this message]
2024-01-23  0:16 ` [PATCH 6/7] net/gve: update gve.ini with RSS capabilities Joshua Washington
2024-01-23  0:16 ` [PATCH 7/7] net/gve: update GVE documentation with RSS support Joshua Washington

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=20240123001645.1507779-6-joshwash@google.com \
    --to=joshwash@google.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=jeroendb@google.com \
    --cc=junfeng.guo@intel.com \
    --cc=rushilg@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;
as well as URLs for NNTP newsgroup(s).