Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Routines supporting VMX instructions on the Power 8
0004  *
0005  * Copyright (C) 2015 International Business Machines Inc.
0006  *
0007  * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
0008  */
0009 
0010 #include <linux/module.h>
0011 #include <linux/moduleparam.h>
0012 #include <linux/types.h>
0013 #include <linux/err.h>
0014 #include <linux/cpufeature.h>
0015 #include <linux/crypto.h>
0016 #include <asm/cputable.h>
0017 #include <crypto/internal/hash.h>
0018 #include <crypto/internal/skcipher.h>
0019 
0020 #include "aesp8-ppc.h"
0021 
0022 static int __init p8_init(void)
0023 {
0024     int ret;
0025 
0026     ret = crypto_register_shash(&p8_ghash_alg);
0027     if (ret)
0028         goto err;
0029 
0030     ret = crypto_register_alg(&p8_aes_alg);
0031     if (ret)
0032         goto err_unregister_ghash;
0033 
0034     ret = crypto_register_skcipher(&p8_aes_cbc_alg);
0035     if (ret)
0036         goto err_unregister_aes;
0037 
0038     ret = crypto_register_skcipher(&p8_aes_ctr_alg);
0039     if (ret)
0040         goto err_unregister_aes_cbc;
0041 
0042     ret = crypto_register_skcipher(&p8_aes_xts_alg);
0043     if (ret)
0044         goto err_unregister_aes_ctr;
0045 
0046     return 0;
0047 
0048 err_unregister_aes_ctr:
0049     crypto_unregister_skcipher(&p8_aes_ctr_alg);
0050 err_unregister_aes_cbc:
0051     crypto_unregister_skcipher(&p8_aes_cbc_alg);
0052 err_unregister_aes:
0053     crypto_unregister_alg(&p8_aes_alg);
0054 err_unregister_ghash:
0055     crypto_unregister_shash(&p8_ghash_alg);
0056 err:
0057     return ret;
0058 }
0059 
0060 static void __exit p8_exit(void)
0061 {
0062     crypto_unregister_skcipher(&p8_aes_xts_alg);
0063     crypto_unregister_skcipher(&p8_aes_ctr_alg);
0064     crypto_unregister_skcipher(&p8_aes_cbc_alg);
0065     crypto_unregister_alg(&p8_aes_alg);
0066     crypto_unregister_shash(&p8_ghash_alg);
0067 }
0068 
0069 module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
0070 module_exit(p8_exit);
0071 
0072 MODULE_AUTHOR("Marcelo Cerri<mhcerri@br.ibm.com>");
0073 MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions "
0074            "support on Power 8");
0075 MODULE_LICENSE("GPL");
0076 MODULE_VERSION("1.0.0");
0077 MODULE_IMPORT_NS(CRYPTO_INTERNAL);