git: 8c25b70120e8 - main - vnic nicvf: Program the common RSS key in network word order

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

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

commit 8c25b70120e8838135cb356c94d350105f45ff7c
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-18 08:56:00 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-18 23:11:48 +0000

    vnic nicvf: Program the common RSS key in network word order
    
    Replace the repeated hardware-reset key with rss_getkey().  Decode each
    eight-byte chunk with be64dec() into the register-word array before
    programming the five key registers.
    
    This matches the key serialization in DPDK's nicvf_rss_set_key(), added
    by commit 7694fab264ac666d62a4cae04f2979991ce64259
    ("net/thunderx/base: add RSS and RETA configuration").  A raw copy into
    the word array on little-endian hosts would reverse bytes within each
    register relative to that convention.
    
    Preserve the CPI-algorithm gate, enabled hash fields, and round-robin
    indirection table.
    
    Reviewed by:    gallatin
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D59806
---
 sys/dev/vnic/nicvf_main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c
index 59f7abeacdd5..b6858a73b978 100644
--- a/sys/dev/vnic/nicvf_main.c
+++ b/sys/dev/vnic/nicvf_main.c
@@ -60,6 +60,7 @@
 #include <net/if_media.h>
 #include <net/if_types.h>
 #include <net/if_vlan_var.h>
+#include <net/rss_config.h>
 
 #include <netinet/in.h>
 #include <netinet/ip.h>
@@ -1055,6 +1056,7 @@ static int
 nicvf_rss_init(struct nicvf *nic)
 {
 	struct nicvf_rss_info *rss;
+	uint8_t rss_key[RSS_KEYSIZE];
 	int idx;
 
 	nicvf_get_rss_size(nic);
@@ -1068,12 +1070,12 @@ nicvf_rss_init(struct nicvf *nic)
 
 	rss->enable = TRUE;
 
-	/* Using the HW reset value for now */
-	rss->key[0] = 0xFEED0BADFEED0BADUL;
-	rss->key[1] = 0xFEED0BADFEED0BADUL;
-	rss->key[2] = 0xFEED0BADFEED0BADUL;
-	rss->key[3] = 0xFEED0BADFEED0BADUL;
-	rss->key[4] = 0xFEED0BADFEED0BADUL;
+	_Static_assert(sizeof(rss->key) == RSS_KEYSIZE,
+	    "RSS key size mismatch");
+	rss_getkey(rss_key);
+	/* Each key register holds eight bytes in network order. */
+	for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++)
+		rss->key[idx] = be64dec(rss_key + idx * sizeof(uint64_t));
 
 	nicvf_set_rss_key(nic);