diff options
Diffstat (limited to 'src/crypto/zinc/poly1305/poly1305-x86_64-glue.h')
-rw-r--r-- | src/crypto/zinc/poly1305/poly1305-x86_64-glue.h | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h index 4926d27..285cb31 100644 --- a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h +++ b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h @@ -13,20 +13,14 @@ asmlinkage void poly1305_blocks_x86_64(void *ctx, const u8 *inp, const size_t len, const u32 padbit); asmlinkage void poly1305_emit_x86_64(void *ctx, u8 mac[POLY1305_MAC_SIZE], const u32 nonce[4]); -#ifdef CONFIG_AS_AVX asmlinkage void poly1305_emit_avx(void *ctx, u8 mac[POLY1305_MAC_SIZE], const u32 nonce[4]); asmlinkage void poly1305_blocks_avx(void *ctx, const u8 *inp, const size_t len, const u32 padbit); -#endif -#ifdef CONFIG_AS_AVX2 asmlinkage void poly1305_blocks_avx2(void *ctx, const u8 *inp, const size_t len, const u32 padbit); -#endif -#ifdef CONFIG_AS_AVX512 asmlinkage void poly1305_blocks_avx512(void *ctx, const u8 *inp, const size_t len, const u32 padbit); -#endif static bool poly1305_use_avx __ro_after_init; static bool poly1305_use_avx2 __ro_after_init; @@ -104,35 +98,21 @@ static inline bool poly1305_blocks_arch(void *ctx, const u8 *inp, { struct poly1305_arch_internal *state = ctx; - if (!poly1305_use_avx || + if (!IS_ENABLED(CONFIG_AS_AVX) || !poly1305_use_avx || (len < (POLY1305_BLOCK_SIZE * 18) && !state->is_base2_26) || - !simd_use(simd_context)) - goto scalar; - -#ifdef CONFIG_AS_AVX512 - if (poly1305_use_avx512) { - poly1305_blocks_avx512(ctx, inp, len, padbit); + !simd_use(simd_context)) { + convert_to_base2_64(ctx); + poly1305_blocks_x86_64(ctx, inp, len, padbit); return true; } -#endif -#ifdef CONFIG_AS_AVX2 - if (poly1305_use_avx2) { + if (IS_ENABLED(CONFIG_AS_AVX512) && poly1305_use_avx512) + poly1305_blocks_avx512(ctx, inp, len, padbit); + else if (IS_ENABLED(CONFIG_AS_AVX2) && poly1305_use_avx2) poly1305_blocks_avx2(ctx, inp, len, padbit); - return true; - } -#endif - -#ifdef CONFIG_AS_AVX - if (poly1305_use_avx) { + else poly1305_blocks_avx(ctx, inp, len, padbit); - return true; - } -#endif -scalar: - convert_to_base2_64(ctx); - poly1305_blocks_x86_64(ctx, inp, len, padbit); return true; } @@ -142,18 +122,13 @@ static inline bool poly1305_emit_arch(void *ctx, u8 mac[POLY1305_MAC_SIZE], { struct poly1305_arch_internal *state = ctx; - if (!poly1305_use_avx || !state->is_base2_26 ||!simd_use(simd_context)) - goto scalar; - -#ifdef CONFIG_AS_AVX - if (poly1305_use_avx || poly1305_use_avx2 || poly1305_use_avx512) { - poly1305_emit_avx(ctx, mac, nonce); + if (!IS_ENABLED(CONFIG_AS_AVX) || !poly1305_use_avx || + !state->is_base2_26 || !simd_use(simd_context)) { + convert_to_base2_64(ctx); + poly1305_emit_x86_64(ctx, mac, nonce); return true; } -#endif -scalar: - convert_to_base2_64(ctx); - poly1305_emit_x86_64(ctx, mac, nonce); + poly1305_emit_avx(ctx, mac, nonce); return true; } |