1 /* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 * Copyright (C) 2012-2013 Cavium Inc., All Rights Reserved. 7 * 8 * MD5 instruction definitions added by Aaro Koskinen <aaro.koskinen@iki.fi>. 9 * 10 */ 11 #ifndef __LINUX_OCTEON_CRYPTO_H 12 #define __LINUX_OCTEON_CRYPTO_H 13 14 #include <linux/sched.h> 15 #include <asm/mipsregs.h> 16 17 #define OCTEON_CR_OPCODE_PRIORITY 300 18 19 extern unsigned long octeon_crypto_enable(struct octeon_cop2_state *state); 20 extern void octeon_crypto_disable(struct octeon_cop2_state *state, 21 unsigned long flags); 22 23 /* 24 * Macros needed to implement MD5: 25 */ 26 27 /* 28 * The index can be 0-1. 29 */ 30 #define write_octeon_64bit_hash_dword(value, index) \ 31 do { \ 32 __asm__ __volatile__ ( \ 33 "dmtc2 %[rt],0x0048+" STR(index) \ 34 : \ 35 : [rt] "d" (value)); \ 36 } while (0) 37 38 /* 39 * The index can be 0-1. 40 */ 41 #define read_octeon_64bit_hash_dword(index) \ 42 ({ \ 43 u64 __value; \ 44 \ 45 __asm__ __volatile__ ( \ 46 "dmfc2 %[rt],0x0048+" STR(index) \ 47 : [rt] "=d" (__value) \ 48 : ); \ 49 \ 50 __value; \ 51 }) 52 53 /* 54 * The index can be 0-6. 55 */ 56 #define write_octeon_64bit_block_dword(value, index) \ 57 do { \ 58 __asm__ __volatile__ ( \ 59 "dmtc2 %[rt],0x0040+" STR(index) \ 60 : \ 61 : [rt] "d" (value)); \ 62 } while (0) 63 64 /* 65 * The value is the final block dword (64-bit). 66 */ 67 #define octeon_md5_start(value) \ 68 do { \ 69 __asm__ __volatile__ ( \ 70 "dmtc2 %[rt],0x4047" \ 71 : \ 72 : [rt] "d" (value)); \ 73 } while (0) 74 75 #endif /* __LINUX_OCTEON_CRYPTO_H */ 76