]> www.infradead.org Git - users/jedix/linux-maple.git/commit
scripts/gen-crc-consts: add gen-crc-consts.py
authorEric Biggers <ebiggers@google.com>
Mon, 10 Feb 2025 17:26:44 +0000 (09:26 -0800)
committerEric Biggers <ebiggers@google.com>
Mon, 10 Feb 2025 17:49:18 +0000 (09:49 -0800)
commit31c89102cf39fb7a171283f35c41f57bf422a4df
tree5e7e434fe4e5d778f18fc86f4db1579918b00e04
parent968e9bc4cef87054741db81a0d94d5c1f67d518a
scripts/gen-crc-consts: add gen-crc-consts.py

Add a Python script that generates constants for computing the given CRC
variant(s) using x86's pclmulqdq or vpclmulqdq instructions.

This is specifically tuned for x86's crc-pclmul-template.S.  However,
other architectures with a 64x64 => 128-bit carryless multiplication
instruction should be able to use the generated constants too.  (Some
tweaks may be warranted based on the exact instructions available on
each arch, so the script may grow an arch argument in the future.)

The script also supports generating the tables needed for table-based
CRC computation.  Thus, it can also be used to reproduce the tables like
t10_dif_crc_table[] and crc16_table[] that are currently hardcoded in
the source with no generation script explicitly documented.

Python is used rather than C since it enables implementing the CRC math
in the simplest way possible, using arbitrary precision integers.  The
outputs of this script are intended to be checked into the repo, so
Python will continue to not be required to build the kernel, and the
script has been optimized for simplicity rather than performance.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20250210174540.161705-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
MAINTAINERS
scripts/gen-crc-consts.py [new file with mode: 0755]