Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kohei Enju <enjuk@amazon.com>
To: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, <kohei.enju@gmail.com>,
	Kohei Enju <enjuk@amazon.com>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 3/3] igc: allow configuring RSS key via ethtool set_rxfh
Date: Sun, 26 Oct 2025 00:01:32 +0900	[thread overview]
Message-ID: <20251025150136.47618-4-enjuk@amazon.com> (raw)
In-Reply-To: <20251025150136.47618-1-enjuk@amazon.com>

Change igc_ethtool_set_rxfh() to accept and save a userspace-provided
RSS key. When a key is provided, store it in the adapter and write the
RSSRK registers accordingly.

This can be tested using `ethtool -X <dev> hkey <key>`.

Signed-off-by: Kohei Enju <enjuk@amazon.com>
---
 drivers/net/ethernet/intel/igc/igc.h         |  1 +
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 31 ++++++++++++--------
 drivers/net/ethernet/intel/igc/igc_main.c    |  3 +-
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index dd159397d191..c894a5a99fc0 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -304,6 +304,7 @@ struct igc_adapter {
 
 	u8 rss_indir_tbl[IGC_RETA_SIZE];
 	u8 rss_key[IGC_RSS_KEY_SIZE];
+	bool has_user_rss_key;
 
 	unsigned long link_check_timeout;
 	struct igc_info ei;
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 0482e590bc5a..64eac1ccb3ff 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1527,24 +1527,29 @@ static int igc_ethtool_set_rxfh(struct net_device *netdev,
 	int i;
 
 	/* We do not allow change in unsupported parameters */
-	if (rxfh->key ||
-	    (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
-	     rxfh->hfunc != ETH_RSS_HASH_TOP))
+	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
+	    rxfh->hfunc != ETH_RSS_HASH_TOP)
 		return -EOPNOTSUPP;
-	if (!rxfh->indir)
-		return 0;
 
-	num_queues = adapter->rss_queues;
+	if (rxfh->indir) {
+		num_queues = adapter->rss_queues;
 
-	/* Verify user input. */
-	for (i = 0; i < IGC_RETA_SIZE; i++)
-		if (rxfh->indir[i] >= num_queues)
-			return -EINVAL;
+		/* Verify user input. */
+		for (i = 0; i < IGC_RETA_SIZE; i++)
+			if (rxfh->indir[i] >= num_queues)
+				return -EINVAL;
 
-	for (i = 0; i < IGC_RETA_SIZE; i++)
-		adapter->rss_indir_tbl[i] = rxfh->indir[i];
+		for (i = 0; i < IGC_RETA_SIZE; i++)
+			adapter->rss_indir_tbl[i] = rxfh->indir[i];
 
-	igc_write_rss_indir_tbl(adapter);
+		igc_write_rss_indir_tbl(adapter);
+	}
+
+	if (rxfh->key) {
+		adapter->has_user_rss_key = true;
+		memcpy(adapter->rss_key, rxfh->key, sizeof(adapter->rss_key));
+		igc_write_rss_key(adapter);
+	}
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 1f0a601cbcef..e977661bed2f 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -779,7 +779,8 @@ static void igc_setup_mrqc(struct igc_adapter *adapter)
 	u32 j, num_rx_queues;
 	u32 mrqc, rxcsum;
 
-	netdev_rss_key_fill(adapter->rss_key, sizeof(adapter->rss_key));
+	if (!adapter->has_user_rss_key)
+		netdev_rss_key_fill(adapter->rss_key, sizeof(adapter->rss_key));
 	igc_write_rss_key(adapter);
 
 	num_rx_queues = adapter->rss_queues;
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 15:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-25 15:01 [Intel-wired-lan] [PATCH iwl-next v1 0/3] igc: add RSS key get/set support Kohei Enju
2025-10-25 15:01 ` [Intel-wired-lan] [PATCH iwl-next v1 1/3] igc: prepare for " Kohei Enju
2025-10-27  7:15   ` Loktionov, Aleksandr
2025-10-28 18:12   ` Simon Horman
2025-11-02  8:44     ` Lifshits, Vitaly
2025-12-21 10:34   ` Avigail Dahan
2026-02-24 12:56   ` Dahan, AvigailX
2025-10-25 15:01 ` [Intel-wired-lan] [PATCH iwl-next v1 2/3] igc: expose RSS key via ethtool get_rxfh Kohei Enju
2025-10-27  7:16   ` Loktionov, Aleksandr
2025-10-28 18:12   ` Simon Horman
2025-11-02  8:43     ` Lifshits, Vitaly
2025-12-21 10:35   ` Avigail Dahan
2025-10-25 15:01 ` Kohei Enju [this message]
2025-10-27  7:16   ` [Intel-wired-lan] [PATCH iwl-next v1 3/3] igc: allow configuring RSS key via ethtool set_rxfh Loktionov, Aleksandr
2025-10-28 18:12   ` Simon Horman
2025-11-02  8:43     ` Lifshits, Vitaly
2025-12-21 13:20   ` Avigail Dahan

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=20251025150136.47618-4-enjuk@amazon.com \
    --to=enjuk@amazon.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kohei.enju@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.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