git: aef4c3eb31d9 - main - mana: Initialize ports with the common RSS key

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Fri, 18 Sep 2026 23:02:08 UTC
The branch main has been updated by kbowling:

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

commit aef4c3eb31d9c29c6aeb08023b1c9d2457d817e3
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-18 08:29:20 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-18 23:01:09 +0000

    mana: Initialize ports with the common RSS key
    
    Use rss_getkey() for each port's initial key instead of a lazily generated
    driver-global random key.  Remove the obsolete helper and its unsynchronized
    initialization flag.  Make the common-key declaration available without
    options RSS.
    
    The port still retains the key used for hardware programming and the
    existing SIOCGIFRSSKEY response.  Leave hash types and queue placement
    unchanged.
    
    Reviewed by:    gallatin
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D59799
---
 sys/dev/mana/mana_en.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index bc8c172bab69..2c6007dff909 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -49,9 +49,7 @@
 #include <net/if_var.h>
 #include <net/if_types.h>
 #include <net/if_vlan_var.h>
-#ifdef RSS
 #include <net/rss_config.h>
-#endif
 
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
@@ -71,22 +69,6 @@ extern unsigned int mana_tx_req_size;
 extern unsigned int mana_rx_req_size;
 extern unsigned int mana_rx_refill_threshold;
 
-static void
-mana_rss_key_fill(void *k, size_t size)
-{
-	static bool rss_key_generated = false;
-	static uint8_t rss_key[MANA_HASH_KEY_SIZE];
-
-	KASSERT(size <= MANA_HASH_KEY_SIZE,
-	    ("Request more buytes than MANA RSS key can hold"));
-
-	if (!rss_key_generated) {
-		arc4random_buf(rss_key, MANA_HASH_KEY_SIZE);
-		rss_key_generated = true;
-	}
-	memcpy(k, rss_key, size);
-}
-
 static int
 mana_ifmedia_change(if_t ifp __unused)
 {
@@ -2958,7 +2940,9 @@ mana_probe_port(struct mana_context *ac, int port_idx,
 	if_setmtu(ndev, apc->mtu);
 	if_setbaudrate(ndev, IF_Gbps(100));
 
-	mana_rss_key_fill(apc->hashkey, MANA_HASH_KEY_SIZE);
+	_Static_assert(sizeof(apc->hashkey) == RSS_KEYSIZE,
+	    "RSS key size mismatch");
+	rss_getkey(apc->hashkey);
 
 	err = mana_init_port(ndev);
 	if (err)