STRUCT CRC_VARIANT(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct crc_variant(9) πŸ’–

okay so real talk β€” we're in the Kernel API Manual bestie, and this page is all about struct crc_variant, which (spoiler) describes a CRC variant. that's it, that's the whole vibe. she's a little struct with big main character energy πŸ‘‘


✨ NAME ✨

struct crc_variant β€” literally just describes a CRC variant, no cap πŸŽ€


🌸 SYNOPSIS 🌸

struct crc_variant {
    int bits;
    bool le;
    u64 poly;
    u64 (*func)(u64 crc, const u8 *p, size_t len);
 };

look at her. iconic. four members. not one of them extra πŸ¦‹


🫢 Members 🫢

  • bits β€” the number of bits in the CRC, and the range is 1 <= bits <= 64. so like, anywhere from bebe CRC-1 all the way up to the big girl CRC-64 πŸ‘‘
  • le β€” true if it's a "little endian" CRC (that's the reversed mapping between bits and polynomial coefficients in each byte), or false if it's a "big endian" CRC (the natural mapping between bits and polynomial coefficients in each byte). so basically this flag is the vibe check on which way your bits are facing πŸ’…
  • poly β€” the generator polynomial, but with the highest-order term omitted (she's humble like that, she leaves the top term at home). and bit-reversed if le is true β€” do not forget this part bestie, it matters 😭
  • func β€” the function that actually computes a CRC πŸ”₯. its type signature uses u64 so that it can fit any CRC up to CRC-64. the CRC comes in as an argument, and it's expected to be returned in, the least significant bits of the u64. and heads up, the function is expected to not invert the CRC at the beginning and end β€” like, none of that, leave the inverting alone πŸ™ˆ
fr fr, that last bit about func is the one people get wrong. no inverting at the start, no inverting at the end, periodt πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./lib/crc/tests/crc_kunit.c β€” go read it, iykyk πŸ‘€


okay that's the whole page!! ✨ source lives in ./lib/crc/tests and this lil cutie is dated October 2026 β€” stay slay, stay byte-aligned, drink water πŸ’–πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from