Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Routines supporting VMX instructions on the Power 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2015 International Business Machines Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/cpufeature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/crypto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/cputable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <crypto/internal/skcipher.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern struct shash_alg p8_ghash_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern struct crypto_alg p8_aes_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern struct skcipher_alg p8_aes_cbc_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern struct skcipher_alg p8_aes_ctr_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern struct skcipher_alg p8_aes_xts_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static int __init p8_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	ret = crypto_register_shash(&p8_ghash_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	ret = crypto_register_alg(&p8_aes_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		goto err_unregister_ghash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	ret = crypto_register_skcipher(&p8_aes_cbc_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		goto err_unregister_aes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	ret = crypto_register_skcipher(&p8_aes_ctr_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		goto err_unregister_aes_cbc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	ret = crypto_register_skcipher(&p8_aes_xts_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		goto err_unregister_aes_ctr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) err_unregister_aes_ctr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) err_unregister_aes_cbc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) err_unregister_aes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	crypto_unregister_alg(&p8_aes_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) err_unregister_ghash:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	crypto_unregister_shash(&p8_ghash_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static void __exit p8_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	crypto_unregister_skcipher(&p8_aes_xts_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	crypto_unregister_alg(&p8_aes_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	crypto_unregister_shash(&p8_ghash_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) module_exit(p8_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) MODULE_AUTHOR("Marcelo Cerri<mhcerri@br.ibm.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		   "support on Power 8");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) MODULE_VERSION("1.0.0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) MODULE_IMPORT_NS(CRYPTO_INTERNAL);