Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: ix(4): fix rss hashing on big endian archs
To:
David Gwynne <david@gwynne.id.au>
Cc:
tech@openbsd.org
Date:
Wed, 22 Apr 2026 10:42:31 +0200

Download raw body.

Thread
On Wed, Apr 22, 2026 at 01:08:54PM +1000, David Gwynne wrote:
> i noticed that packets seem to be hashed differently by ix(4) and the
> network stack on sparc64. the diff below seems to fix it, and it still
> works as expected on arm64.

How did you notice this?
 
> ok?

Now this screams for bus_space_write_raw_4() but I see that the macro zoo
does not make this a good option.

I would expect this to be a le32toh() so we end up with htole32(le32toh())
combo but for all archs we care htole32(x) == le32toh(x) so it really is a
bikeshed.

OK claudio@

Are ixl and ice affected as well?
 
> Index: if_ix.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_ix.c,v
> diff -u -p -r1.223 if_ix.c
> --- if_ix.c	26 Feb 2026 23:38:10 -0000	1.223
> +++ if_ix.c	22 Apr 2026 03:04:16 -0000
> @@ -3061,8 +3059,13 @@ ixgbe_initialize_rss_mapping(struct ix_s
>  	}
>  
>  	/* Now fill our hash function seeds */
> -	for (i = 0; i < 10; i++)
> -		IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), rss_key[i]);
> +	for (i = 0; i < nitems(rss_key); i++) {
> +		/*
> +		 * twist the words so the rss key will be handled
> +		 * as bytes regardless of the hosts endianness.
> +		 */
> +		IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), htole32(rss_key[i]));
> +	}
>  
>  	/*
>  	 * Disable UDP - IP fragments aren't currently being handled
> 

-- 
:wq Claudio