The Toeplitz hash function, used in NICs for RSS, may sometimes need to
be computed by software. DPDK already ships a scalar implementation of
this algorithm, and also includes an inline function for x86 optimized
using GFNI and AVX-512. Because the optimized function, which is very
much faster than the scalar one (on my system over an order of magnitude
faster), is an inlne one, it requires the application to itself know
when it is safe to use, i.e. that the application will be deployed on a
system with the necessary GFNI+AVX512 instruction sets. The vector
function and the scalar versions also differ in how the arguments need
to be prepared for use - specifically in terms of data endianness.

While leaving the existing code in place for backward compatibility, we
can provide a higher-level common interface for doing the calculations,
with runtime path selection to choose the best implementation - scalar
GFNI+AVX2 or GFNI+AVX512.

The path selection is managed via a thash context object, and the
decision on which set of functions to use is made once at context
creation time. The API functions to perform the actual calculation are
tied to the standard RSS protocol tuples for IPv4 and IPv6, not to
generic data lengths. While it is possible to have length-based APIs,
having the protocol based functions avoids potential performance
degradation issues in building the tuple array for hashing.
Specifially, copying data in chunks of 4 or 8 bytes to a local array and
then passing that into a vector function can lead to execution
slowdowns due to vector loads stalling on data written by scalar stores
(no store-forwarding). By having the API take the pointers to IP header
and L4 headers, the necessary vector registers can be loaded directly
from source, without any intermediate copying, avoiding any potential
store-forwarding issues in the function.

Bruce Richardson (11):
  hash: improve build-time instruction set checks for thash
  test/thash_perf: test gfni thash when platform supports
  hash: create library internal header file for thash
  hash: add functions for GFNI RSS hash calculations
  hash: add fixed-size scalar RSS hash calculations
  hash: add thash context struct for runtime path selection
  hash: implement IPv4 and IPv6 RSS hashing in SW
  hash: add explicit handling for RSS with split L3/L4 data
  test/thash: add perf tests for new RSS functions
  hash: remove extra store-load when performing RSS
  hash: add AVX2 RSS hash functions

 app/test/test_thash.c                  | 170 ++++++++++++++++++++
 app/test/test_thash_perf.c             | 150 +++++++++++++++++-
 doc/guides/rel_notes/release_27_03.rst |   6 +
 lib/hash/meson.build                   |  20 +++
 lib/hash/rte_thash.c                   |  37 ++++-
 lib/hash/rte_thash.h                   |  13 --
 lib/hash/rte_thash_gf2_poly_math.c     |   4 +-
 lib/hash/rte_thash_rss.h               | 156 +++++++++++++++++++
 lib/hash/rte_thash_x86_gfni.h          |   4 +-
 lib/hash/thash_gfni_avx2.c             | 170 ++++++++++++++++++++
 lib/hash/thash_gfni_avx512.c           | 132 ++++++++++++++++
 lib/hash/thash_private.h               | 108 +++++++++++++
 lib/hash/thash_rss.c                   | 208 +++++++++++++++++++++++++
 lib/meson.build                        |   3 +-
 14 files changed, 1155 insertions(+), 26 deletions(-)
 create mode 100644 lib/hash/rte_thash_rss.h
 create mode 100644 lib/hash/thash_gfni_avx2.c
 create mode 100644 lib/hash/thash_gfni_avx512.c
 create mode 100644 lib/hash/thash_private.h
 create mode 100644 lib/hash/thash_rss.c

--
2.55.0

Reply via email to