toeplitz_hash() tested every input bit with a branch, which
mispredicts about half the time on addresses and ports, and moved one
key bit at a time into its 32-bit window. Keep the 64 key bits from
the current input byte on instead: the 32 key bits for each bit of
that byte are then one shift away, a mask made from the input bit
selects them, and the window moves by a whole key byte per input byte.
The result is the same. Key bits past the end of the key are still 0,
and a key shorter than 4 bytes is no longer read past its end.
With per-byte tables for rss_hash() (D62531), toeplitz_hash() mostly
computes the multipath hashes of fib4_calc_software_hash() and
fib6_calc_software_hash(), which outbound connections and raw sockets
on multipath routes use. For their 16 and 40 bytes it now takes 127
and 307 ns instead of 167 and 402 on an Atom C1110, and 76 and 184 ns
instead of 100 and 241 on an Atom x7809C.
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")