From: Yerden Zhumabekov Date: Thu, 29 Jan 2015 08:48:59 +0000 (+0600) Subject: hash: add assembly implementation of CRC32 intrinsics X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=00bf774bab0beec54427bacb09137c7d6d83e819;p=dpdk.git hash: add assembly implementation of CRC32 intrinsics Added: - crc32c_sse42_u32() emits 'crc32l' asm instruction; - crc32c_sse42_u64() emits 'crc32q' asm instruction; - crc32c_sse42_u64_mimic(), wrapper in case of run on 32-bit platform. Signed-off-by: Yerden Zhumabekov Acked-by: Bruce Richardson --- diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h index 4da7ca432b..fe35996616 100644 --- a/lib/librte_hash/rte_hash_crc.h +++ b/lib/librte_hash/rte_hash_crc.h @@ -363,6 +363,40 @@ crc32c_2words(uint64_t data, uint32_t init_val) return crc; } +static inline uint32_t +crc32c_sse42_u32(uint32_t data, uint32_t init_val) +{ + __asm__ volatile( + "crc32l %[data], %[init_val];" + : [init_val] "+r" (init_val) + : [data] "rm" (data)); + return init_val; +} + +static inline uint32_t +crc32c_sse42_u64(uint64_t data, uint64_t init_val) +{ + __asm__ volatile( + "crc32q %[data], %[init_val];" + : [init_val] "+r" (init_val) + : [data] "rm" (data)); + return init_val; +} + +static inline uint32_t +crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val) +{ + union { + uint32_t u32[2]; + uint64_t u64; + } d; + + d.u64 = data; + init_val = crc32c_sse42_u32(d.u32[0], init_val); + init_val = crc32c_sse42_u32(d.u32[1], init_val); + return init_val; +} + /** * Use single crc32 instruction to perform a hash on a 4 byte value. *