From: David Gwynne Subject: Re: ix(4): fix rss hashing on big endian archs To: tech@openbsd.org Date: Thu, 23 Apr 2026 07:40:14 +1000 On Wed, Apr 22, 2026 at 10:42:31AM +0200, Claudio Jeker wrote: > 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? i was doing a single fast tcp transfer while looking at stuff in systat, and noticed that ix had interrupts firing on two sets of rings instead of one like i expect. txq and rxq kstats confirmed the tx and rx packets were going to different ring indexes. if you want a clearer indicator, i could add a counters to the tcp stats that says whether the flowid in rx packets matches the flowid on the tcp pcb. > > 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. i can use do this. > OK claudio@ > > Are ixl and ice affected as well? i havent moved on to looking at ixl yet and i dont have any ice. > > > 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