From f284c14c7bd8731367ba3527cdfffa610a8c6de4 Mon Sep 17 00:00:00 2001 From: Nathan Skrzypczak Date: Wed, 2 Feb 2022 19:31:58 +0100 Subject: cnat: Add sctp support This patch adds SCTP support in the CNat translation primitives. It also exposes a clib_crc32c_with_init function allowing to set the init value to start the crc32 with instead of 0. Type: feature Change-Id: I86add4cfcac08f2a5a34d1e1841122fafd349fe7 Signed-off-by: Nathan Skrzypczak --- src/vppinfra/crc32.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/vppinfra/crc32.h') diff --git a/src/vppinfra/crc32.h b/src/vppinfra/crc32.h index 3b81daf28ca..2b20fef9027 100644 --- a/src/vppinfra/crc32.h +++ b/src/vppinfra/crc32.h @@ -76,23 +76,27 @@ clib_crc32c_u64 (u32 last, u64 data) #ifdef clib_crc32c_uses_intrinsics static_always_inline u32 -clib_crc32c (u8 * s, int len) +clib_crc32c_with_init (u8 *s, int len, u32 last) { - u32 v = 0; - for (; len >= 8; len -= 8, s += 8) - v = clib_crc32c_u64 (v, *((u64u *) s)); + last = clib_crc32c_u64 (last, *((u64u *) s)); for (; len >= 4; len -= 4, s += 4) - v = clib_crc32c_u32 (v, *((u32u *) s)); + last = clib_crc32c_u32 (last, *((u32u *) s)); for (; len >= 2; len -= 2, s += 2) - v = clib_crc32c_u16 (v, *((u16u *) s)); + last = clib_crc32c_u16 (last, *((u16u *) s)); for (; len >= 1; len -= 1, s += 1) - v = clib_crc32c_u8 (v, *((u8 *) s)); + last = clib_crc32c_u8 (last, *((u8 *) s)); + + return last; +} - return v; +static_always_inline u32 +clib_crc32c (u8 *s, int len) +{ + return clib_crc32c_with_init (s, len, 0); } #endif -- cgit 1.2.3-korg