lib/crc/arm/crc32.h
Source file repositories/reference/linux-study-clean/lib/crc/arm/crc32.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crc/arm/crc32.h- Extension
.h- Size
- 2503 bytes
- Lines
- 97
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
Dependency Surface
linux/cpufeature.hasm/hwcap.hasm/simd.h
Detected Declarations
function crc32_le_scalarfunction crc32_le_archfunction crc32c_scalarfunction crc32c_archfunction crc32_mod_init_archfunction crc32_optimizations_arch
Annotated Snippet
static_branch_likely(&have_pmull) && likely(may_use_simd())) {
size_t n = -(uintptr_t)p & 15;
/* align p to 16-byte boundary */
if (n) {
crc = crc32_le_scalar(crc, p, n);
p += n;
len -= n;
}
n = round_down(len, 16);
scoped_ksimd()
crc = crc32_pmull_le(p, n, crc);
p += n;
len -= n;
}
return crc32_le_scalar(crc, p, len);
}
static inline u32 crc32c_scalar(u32 crc, const u8 *p, size_t len)
{
if (static_branch_likely(&have_crc32))
return crc32c_armv8_le(crc, p, len);
return crc32c_base(crc, p, len);
}
static inline u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
{
if (len >= PMULL_MIN_LEN + 15 &&
static_branch_likely(&have_pmull) && likely(may_use_simd())) {
size_t n = -(uintptr_t)p & 15;
/* align p to 16-byte boundary */
if (n) {
crc = crc32c_scalar(crc, p, n);
p += n;
len -= n;
}
n = round_down(len, 16);
scoped_ksimd()
crc = crc32c_pmull_le(p, n, crc);
p += n;
len -= n;
}
return crc32c_scalar(crc, p, len);
}
#define crc32_be_arch crc32_be_base /* not implemented on this arch */
#define crc32_mod_init_arch crc32_mod_init_arch
static void crc32_mod_init_arch(void)
{
if (elf_hwcap2 & HWCAP2_CRC32)
static_branch_enable(&have_crc32);
if (elf_hwcap2 & HWCAP2_PMULL)
static_branch_enable(&have_pmull);
}
static inline u32 crc32_optimizations_arch(void)
{
if (elf_hwcap2 & (HWCAP2_CRC32 | HWCAP2_PMULL))
return CRC32_LE_OPTIMIZATION | CRC32C_OPTIMIZATION;
return 0;
}
Annotation
- Immediate include surface: `linux/cpufeature.h`, `asm/hwcap.h`, `asm/simd.h`.
- Detected declarations: `function crc32_le_scalar`, `function crc32_le_arch`, `function crc32c_scalar`, `function crc32c_arch`, `function crc32_mod_init_arch`, `function crc32_optimizations_arch`.
- Atlas domain: Kernel Services / lib.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.