~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/crypto/crct10dif-ce-glue.c

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Accelerated CRC-T10DIF using arm64 NEON and Crypto Extensions instructions
  3  *
  4  * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License version 2 as
  8  * published by the Free Software Foundation.
  9  */
 10 
 11 #include <linux/cpufeature.h>
 12 #include <linux/crc-t10dif.h>
 13 #include <linux/init.h>
 14 #include <linux/kernel.h>
 15 #include <linux/module.h>
 16 #include <linux/string.h>
 17 
 18 #include <crypto/internal/hash.h>
 19 
 20 #include <asm/neon.h>
 21 
 22 #define CRC_T10DIF_PMULL_CHUNK_SIZE     16U
 23 
 24 asmlinkage u16 crc_t10dif_pmull(u16 init_crc, const u8 buf[], u64 len);
 25 
 26 static int crct10dif_init(struct shash_desc *desc)
 27 {
 28         u16 *crc = shash_desc_ctx(desc);
 29 
 30         *crc = 0;
 31         return 0;
 32 }
 33 
 34 static int crct10dif_update(struct shash_desc *desc, const u8 *data,
 35                             unsigned int length)
 36 {
 37         u16 *crc = shash_desc_ctx(desc);
 38         unsigned int l;
 39 
 40         if (unlikely((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE)) {
 41                 l = min_t(u32, length, CRC_T10DIF_PMULL_CHUNK_SIZE -
 42                           ((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE));
 43 
 44                 *crc = crc_t10dif_generic(*crc, data, l);
 45 
 46                 length -= l;
 47                 data += l;
 48         }
 49 
 50         if (length > 0) {
 51                 kernel_neon_begin_partial(14);
 52                 *crc = crc_t10dif_pmull(*crc, data, length);
 53                 kernel_neon_end();
 54         }
 55 
 56         return 0;
 57 }
 58 
 59 static int crct10dif_final(struct shash_desc *desc, u8 *out)
 60 {
 61         u16 *crc = shash_desc_ctx(desc);
 62 
 63         *(u16 *)out = *crc;
 64         return 0;
 65 }
 66 
 67 static struct shash_alg crc_t10dif_alg = {
 68         .digestsize             = CRC_T10DIF_DIGEST_SIZE,
 69         .init                   = crct10dif_init,
 70         .update                 = crct10dif_update,
 71         .final                  = crct10dif_final,
 72         .descsize               = CRC_T10DIF_DIGEST_SIZE,
 73 
 74         .base.cra_name          = "crct10dif",
 75         .base.cra_driver_name   = "crct10dif-arm64-ce",
 76         .base.cra_priority      = 200,
 77         .base.cra_blocksize     = CRC_T10DIF_BLOCK_SIZE,
 78         .base.cra_module        = THIS_MODULE,
 79 };
 80 
 81 static int __init crc_t10dif_mod_init(void)
 82 {
 83         return crypto_register_shash(&crc_t10dif_alg);
 84 }
 85 
 86 static void __exit crc_t10dif_mod_exit(void)
 87 {
 88         crypto_unregister_shash(&crc_t10dif_alg);
 89 }
 90 
 91 module_cpu_feature_match(PMULL, crc_t10dif_mod_init);
 92 module_exit(crc_t10dif_mod_exit);
 93 
 94 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 95 MODULE_LICENSE("GPL v2");
 96 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp