62 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Shared crypto simd helpers4 */5 6#ifndef _CRYPTO_INTERNAL_SIMD_H7#define _CRYPTO_INTERNAL_SIMD_H8 9#include <linux/percpu.h>10#include <linux/types.h>11 12/* skcipher support */13 14struct simd_skcipher_alg;15struct skcipher_alg;16 17struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,18 const char *algname,19 const char *drvname,20 const char *basename);21void simd_skcipher_free(struct simd_skcipher_alg *alg);22 23int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,24 struct simd_skcipher_alg **simd_algs);25 26void simd_unregister_skciphers(struct skcipher_alg *algs, int count,27 struct simd_skcipher_alg **simd_algs);28 29/* AEAD support */30 31struct simd_aead_alg;32struct aead_alg;33 34int simd_register_aeads_compat(struct aead_alg *algs, int count,35 struct simd_aead_alg **simd_algs);36 37void simd_unregister_aeads(struct aead_alg *algs, int count,38 struct simd_aead_alg **simd_algs);39 40/*41 * crypto_simd_usable() - is it allowed at this time to use SIMD instructions or42 * access the SIMD register file?43 *44 * This delegates to may_use_simd(), except that this also returns false if SIMD45 * in crypto code has been temporarily disabled on this CPU by the crypto46 * self-tests, in order to test the no-SIMD fallback code. This override is47 * currently limited to configurations where the extra self-tests are enabled,48 * because it might be a bit too invasive to be part of the regular self-tests.49 *50 * This is a macro so that <asm/simd.h>, which some architectures don't have,51 * doesn't have to be included directly here.52 */53#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS54DECLARE_PER_CPU(bool, crypto_simd_disabled_for_test);55#define crypto_simd_usable() \56 (may_use_simd() && !this_cpu_read(crypto_simd_disabled_for_test))57#else58#define crypto_simd_usable() may_use_simd()59#endif60 61#endif /* _CRYPTO_INTERNAL_SIMD_H */62