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