git: 66ff9289b041 - main - igc: make the hardware RSS hash agree with the stack's configuration

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Sun, 04 Oct 2026 12:02:46 UTC
The branch main has been updated by rcm:

URL: https://cgit.FreeBSD.org/src/commit/?id=66ff9289b041720f29205f179337f81b5dd0c365

commit 66ff9289b041720f29205f179337f81b5dd0c365
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-10-04 12:00:51 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-10-04 12:00:51 +0000

    igc: make the hardware RSS hash agree with the stack's configuration
    
    rss_gethashconfig() is available without options RSS since d9c55b2e8cd6.
    Use it to program MRQC, as ixl(4), ice(4) and iavf(4) do, instead of a
    fixed field set that included UDP 4-tuple, which the configuration
    excludes unless net.inet.rss.udp_4tuple is set.  UDP is now hashed on
    addresses only by default.
    
    Also report the UDP hash types on receive; they were passed up as
    M_HASHTYPE_NONE.
    
    Reviewed by:            kbowling
    Fixes:                  517904de5cca ("igc(4): Introduce new driver for the Intel I225 Ethernet controller.")
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D60284
---
 sys/dev/igc/if_igc.c   | 30 +++++++++++++++++++++---------
 sys/dev/igc/igc_txrx.c |  6 ++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c
index ed90021573ab..bc24849693e1 100644
--- a/sys/dev/igc/if_igc.c
+++ b/sys/dev/igc/if_igc.c
@@ -2243,6 +2243,7 @@ igc_initialize_rss_mapping(struct igc_softc *sc)
 	int queue_id;
 	u32 reta;
 	u32 rss_key[RSSKEYLEN], mrqc, shift = 0;
+	u32 rss_hash_config;
 
 	/*
 	 * The redirection table controls which destination
@@ -2308,16 +2309,27 @@ igc_initialize_rss_mapping(struct igc_softc *sc)
 		IGC_WRITE_REG_ARRAY(hw, IGC_RSSRK(0), i, rss_key[i]);
 
 	/*
-	 * Configure the RSS fields to hash upon.
+	 * Configure the RSS fields to hash upon.  Hash exactly what the
+	 * stack hashes, so that hardware and software agree on the hash
+	 * of a flow.
 	 */
-	mrqc |= (IGC_MRQC_RSS_FIELD_IPV4 |
-	    IGC_MRQC_RSS_FIELD_IPV4_TCP);
-	mrqc |= (IGC_MRQC_RSS_FIELD_IPV6 |
-	    IGC_MRQC_RSS_FIELD_IPV6_TCP);
-	mrqc |=( IGC_MRQC_RSS_FIELD_IPV4_UDP |
-	    IGC_MRQC_RSS_FIELD_IPV6_UDP);
-	mrqc |=( IGC_MRQC_RSS_FIELD_IPV6_UDP_EX |
-	    IGC_MRQC_RSS_FIELD_IPV6_TCP_EX);
+	rss_hash_config = rss_gethashconfig();
+	if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV4;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV4_TCP;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV6;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV6_TCP;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6_EX)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV6_TCP_EX;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV4_UDP;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV6_UDP;
+	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)
+		mrqc |= IGC_MRQC_RSS_FIELD_IPV6_UDP_EX;
 
 	IGC_WRITE_REG(hw, IGC_MRQC, mrqc);
 }
diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c
index 0f88a0a5acd5..ef17978244ef 100644
--- a/sys/dev/igc/igc_txrx.c
+++ b/sys/dev/igc/igc_txrx.c
@@ -611,6 +611,12 @@ igc_determine_rsstype(uint16_t pkt_info)
 		return M_HASHTYPE_RSS_IPV6;
 	case IGC_RXDADV_RSSTYPE_IPV6_TCP_EX:
 		return M_HASHTYPE_RSS_TCP_IPV6_EX;
+	case IGC_RXDADV_RSSTYPE_IPV4_UDP:
+		return M_HASHTYPE_RSS_UDP_IPV4;
+	case IGC_RXDADV_RSSTYPE_IPV6_UDP:
+		return M_HASHTYPE_RSS_UDP_IPV6;
+	case IGC_RXDADV_RSSTYPE_IPV6_UDP_EX:
+		return M_HASHTYPE_RSS_UDP_IPV6_EX;
 	default:
 		return M_HASHTYPE_NONE;
 	}