1229677Sgonzo/*- 2229677Sgonzo * Copyright (c) 2011, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3229677Sgonzo * All rights reserved. 4229677Sgonzo * 5229677Sgonzo * Redistribution and use in source and binary forms, with or without 6229677Sgonzo * modification, are permitted provided that the following conditions 7229677Sgonzo * are met: 8229677Sgonzo * 1. Redistributions of source code must retain the above copyright 9229677Sgonzo * notice unmodified, this list of conditions, and the following 10229677Sgonzo * disclaimer. 11229677Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 12229677Sgonzo * notice, this list of conditions and the following disclaimer in the 13229677Sgonzo * documentation and/or other materials provided with the distribution. 14229677Sgonzo * 15229677Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16229677Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17229677Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18229677Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19229677Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20229677Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21229677Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22229677Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23229677Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24229677Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25229677Sgonzo * SUCH DAMAGE. 26229677Sgonzo * 27229677Sgonzo * $FreeBSD$ 28229677Sgonzo * 29229677Sgonzo */ 30229677Sgonzo 31229677Sgonzo#ifndef __OCTEON_COP2_H__ 32229677Sgonzo#define __OCTEON_COP2_H__ 33229677Sgonzo 34229677Sgonzo/* 35229677Sgonzo * COP2 registers of interest 36229677Sgonzo */ 37229677Sgonzo#define COP2_CRC_IV 0x201 38229677Sgonzo#define COP2_CRC_IV_SET COP2_CRC_IV 39229677Sgonzo#define COP2_CRC_LENGTH 0x202 40229677Sgonzo#define COP2_CRC_LENGTH_SET 0x1202 41229677Sgonzo#define COP2_CRC_POLY 0x200 42229677Sgonzo#define COP2_CRC_POLY_SET 0x4200 43229677Sgonzo#define COP2_LLM_DAT0 0x402 44229677Sgonzo#define COP2_LLM_DAT0_SET COP2_LLM_DAT0 45229677Sgonzo#define COP2_LLM_DAT1 0x40A 46229677Sgonzo#define COP2_LLM_DAT1_SET COP2_LLM_DAT1 47229677Sgonzo#define COP2_3DES_IV 0x084 48229677Sgonzo#define COP2_3DES_IV_SET COP2_3DES_IV 49229677Sgonzo#define COP2_3DES_KEY0 0x080 50229677Sgonzo#define COP2_3DES_KEY0_SET COP2_3DES_KEY0 51229677Sgonzo#define COP2_3DES_KEY1 0x081 52229677Sgonzo#define COP2_3DES_KEY1_SET COP2_3DES_KEY1 53229677Sgonzo#define COP2_3DES_KEY2 0x082 54229677Sgonzo#define COP2_3DES_KEY2_SET COP2_3DES_KEY2 55229677Sgonzo#define COP2_3DES_RESULT 0x088 56229677Sgonzo#define COP2_3DES_RESULT_SET 0x098 57229677Sgonzo#define COP2_AES_INP0 0x111 58229677Sgonzo#define COP2_AES_INP0_SET COP2_AES_INP0 59229677Sgonzo#define COP2_AES_IV0 0x102 60229677Sgonzo#define COP2_AES_IV0_SET COP2_AES_IV0 61229677Sgonzo#define COP2_AES_IV1 0x103 62229677Sgonzo#define COP2_AES_IV1_SET COP2_AES_IV1 63229677Sgonzo#define COP2_AES_KEY0 0x104 64229677Sgonzo#define COP2_AES_KEY0_SET COP2_AES_KEY0 65229677Sgonzo#define COP2_AES_KEY1 0x105 66229677Sgonzo#define COP2_AES_KEY1_SET COP2_AES_KEY1 67229677Sgonzo#define COP2_AES_KEY2 0x106 68229677Sgonzo#define COP2_AES_KEY2_SET COP2_AES_KEY2 69229677Sgonzo#define COP2_AES_KEY3 0x107 70229677Sgonzo#define COP2_AES_KEY3_SET COP2_AES_KEY3 71229677Sgonzo#define COP2_AES_KEYLEN 0x110 72229677Sgonzo#define COP2_AES_KEYLEN_SET COP2_AES_KEYLEN 73229677Sgonzo#define COP2_AES_RESULT0 0x100 74229677Sgonzo#define COP2_AES_RESULT0_SET COP2_AES_RESULT0 75229677Sgonzo#define COP2_AES_RESULT1 0x101 76229677Sgonzo#define COP2_AES_RESULT1_SET COP2_AES_RESULT1 77229677Sgonzo#define COP2_HSH_DATW0 0x240 78229677Sgonzo#define COP2_HSH_DATW0_SET COP2_HSH_DATW0 79229677Sgonzo#define COP2_HSH_DATW1 0x241 80229677Sgonzo#define COP2_HSH_DATW1_SET COP2_HSH_DATW1 81229677Sgonzo#define COP2_HSH_DATW2 0x242 82229677Sgonzo#define COP2_HSH_DATW2_SET COP2_HSH_DATW2 83229677Sgonzo#define COP2_HSH_DATW3 0x243 84229677Sgonzo#define COP2_HSH_DATW3_SET COP2_HSH_DATW3 85229677Sgonzo#define COP2_HSH_DATW4 0x244 86229677Sgonzo#define COP2_HSH_DATW4_SET COP2_HSH_DATW4 87229677Sgonzo#define COP2_HSH_DATW5 0x245 88229677Sgonzo#define COP2_HSH_DATW5_SET COP2_HSH_DATW5 89229677Sgonzo#define COP2_HSH_DATW6 0x246 90229677Sgonzo#define COP2_HSH_DATW6_SET COP2_HSH_DATW6 91229677Sgonzo#define COP2_HSH_DATW7 0x247 92229677Sgonzo#define COP2_HSH_DATW7_SET COP2_HSH_DATW7 93229677Sgonzo#define COP2_HSH_DATW8 0x248 94229677Sgonzo#define COP2_HSH_DATW8_SET COP2_HSH_DATW8 95229677Sgonzo#define COP2_HSH_DATW9 0x249 96229677Sgonzo#define COP2_HSH_DATW9_SET COP2_HSH_DATW9 97229677Sgonzo#define COP2_HSH_DATW10 0x24A 98229677Sgonzo#define COP2_HSH_DATW10_SET COP2_HSH_DATW10 99229677Sgonzo#define COP2_HSH_DATW11 0x24B 100229677Sgonzo#define COP2_HSH_DATW11_SET COP2_HSH_DATW11 101229677Sgonzo#define COP2_HSH_DATW12 0x24C 102229677Sgonzo#define COP2_HSH_DATW12_SET COP2_HSH_DATW12 103229677Sgonzo#define COP2_HSH_DATW13 0x24D 104229677Sgonzo#define COP2_HSH_DATW13_SET COP2_HSH_DATW13 105229677Sgonzo#define COP2_HSH_DATW14 0x24E 106229677Sgonzo#define COP2_HSH_DATW14_SET COP2_HSH_DATW14 107229677Sgonzo#define COP2_HSH_IVW0 0x250 108229677Sgonzo#define COP2_HSH_IVW0_SET COP2_HSH_IVW0 109229677Sgonzo#define COP2_HSH_IVW1 0x251 110229677Sgonzo#define COP2_HSH_IVW1_SET COP2_HSH_IVW1 111229677Sgonzo#define COP2_HSH_IVW2 0x252 112229677Sgonzo#define COP2_HSH_IVW2_SET COP2_HSH_IVW2 113229677Sgonzo#define COP2_HSH_IVW3 0x253 114229677Sgonzo#define COP2_HSH_IVW3_SET COP2_HSH_IVW3 115229677Sgonzo#define COP2_HSH_IVW4 0x254 116229677Sgonzo#define COP2_HSH_IVW4_SET COP2_HSH_IVW4 117229677Sgonzo#define COP2_HSH_IVW5 0x255 118229677Sgonzo#define COP2_HSH_IVW5_SET COP2_HSH_IVW5 119229677Sgonzo#define COP2_HSH_IVW6 0x256 120229677Sgonzo#define COP2_HSH_IVW6_SET COP2_HSH_IVW6 121229677Sgonzo#define COP2_HSH_IVW7 0x257 122229677Sgonzo#define COP2_HSH_IVW7_SET COP2_HSH_IVW7 123229677Sgonzo#define COP2_GFM_MULT0 0x258 124229677Sgonzo#define COP2_GFM_MULT0_SET COP2_GFM_MULT0 125229677Sgonzo#define COP2_GFM_MULT1 0x259 126229677Sgonzo#define COP2_GFM_MULT1_SET COP2_GFM_MULT1 127229677Sgonzo#define COP2_GFM_POLY 0x25E 128229677Sgonzo#define COP2_GFM_POLY_SET COP2_GFM_POLY 129229677Sgonzo#define COP2_GFM_RESULT0 0x25A 130229677Sgonzo#define COP2_GFM_RESULT0_SET COP2_GFM_RESULT0 131229677Sgonzo#define COP2_GFM_RESULT1 0x25B 132229677Sgonzo#define COP2_GFM_RESULT1_SET COP2_GFM_RESULT1 133229677Sgonzo#define COP2_HSH_DATW0_PASS1 0x040 134229677Sgonzo#define COP2_HSH_DATW0_PASS1_SET COP2_HSH_DATW0_PASS1 135229677Sgonzo#define COP2_HSH_DATW1_PASS1 0x041 136229677Sgonzo#define COP2_HSH_DATW1_PASS1_SET COP2_HSH_DATW1_PASS1 137229677Sgonzo#define COP2_HSH_DATW2_PASS1 0x042 138229677Sgonzo#define COP2_HSH_DATW2_PASS1_SET COP2_HSH_DATW2_PASS1 139229677Sgonzo#define COP2_HSH_DATW3_PASS1 0x043 140229677Sgonzo#define COP2_HSH_DATW3_PASS1_SET COP2_HSH_DATW3_PASS1 141229677Sgonzo#define COP2_HSH_DATW4_PASS1 0x044 142229677Sgonzo#define COP2_HSH_DATW4_PASS1_SET COP2_HSH_DATW4_PASS1 143229677Sgonzo#define COP2_HSH_DATW5_PASS1 0x045 144229677Sgonzo#define COP2_HSH_DATW5_PASS1_SET COP2_HSH_DATW5_PASS1 145229677Sgonzo#define COP2_HSH_DATW6_PASS1 0x046 146229677Sgonzo#define COP2_HSH_DATW6_PASS1_SET COP2_HSH_DATW6_PASS1 147229677Sgonzo#define COP2_HSH_IVW0_PASS1 0x048 148229677Sgonzo#define COP2_HSH_IVW0_PASS1_SET COP2_HSH_IVW0_PASS1 149229677Sgonzo#define COP2_HSH_IVW1_PASS1 0x049 150229677Sgonzo#define COP2_HSH_IVW1_PASS1_SET COP2_HSH_IVW1_PASS1 151229677Sgonzo#define COP2_HSH_IVW2_PASS1 0x04A 152229677Sgonzo#define COP2_HSH_IVW2_PASS1_SET COP2_HSH_IVW2_PASS1 153229677Sgonzo 154229677Sgonzo#ifndef LOCORE 155229677Sgonzo 156229677Sgonzostruct octeon_cop2_state { 157229677Sgonzo /* 3DES */ 158229677Sgonzo /* 0x0084 */ 159229677Sgonzo unsigned long _3des_iv; 160229677Sgonzo /* 0x0080..0x0082 */ 161229677Sgonzo unsigned long _3des_key[3]; 162229677Sgonzo /* 0x0088, set: 0x0098 */ 163229677Sgonzo unsigned long _3des_result; 164229677Sgonzo 165229677Sgonzo /* AES */ 166229677Sgonzo /* 0x0111 */ 167229677Sgonzo unsigned long aes_inp0; 168229677Sgonzo /* 0x0102..0x0103 */ 169229677Sgonzo unsigned long aes_iv[2]; 170229677Sgonzo /* 0x0104..0x0107 */ 171229677Sgonzo unsigned long aes_key[4]; 172229677Sgonzo /* 0x0110 */ 173229677Sgonzo unsigned long aes_keylen; 174229677Sgonzo /* 0x0100..0x0101 */ 175229677Sgonzo unsigned long aes_result[2]; 176229677Sgonzo 177229677Sgonzo /* CRC */ 178229677Sgonzo /* 0x0201 */ 179229677Sgonzo unsigned long crc_iv; 180229677Sgonzo /* 0x0202, set: 0x1202 */ 181229677Sgonzo unsigned long crc_length; 182229677Sgonzo /* 0x0200, set: 0x4200 */ 183229677Sgonzo unsigned long crc_poly; 184229677Sgonzo 185229677Sgonzo /* Low-latency memory stuff */ 186229677Sgonzo /* 0x0402, 0x040A */ 187229677Sgonzo unsigned long llm_dat[2]; 188229677Sgonzo 189229677Sgonzo /* SHA & MD5 */ 190229677Sgonzo /* 0x0240..0x024E */ 191229677Sgonzo unsigned long hsh_datw[15]; 192229677Sgonzo /* 0x0250..0x0257 */ 193229677Sgonzo unsigned long hsh_ivw[8]; 194229677Sgonzo 195229677Sgonzo /* GFM */ 196229677Sgonzo /* 0x0258..0x0259 */ 197229677Sgonzo unsigned long gfm_mult[2]; 198229677Sgonzo /* 0x025E */ 199229677Sgonzo unsigned long gfm_poly; 200229677Sgonzo /* 0x025A..0x025B */ 201229677Sgonzo unsigned long gfm_result[2]; 202229677Sgonzo}; 203229677Sgonzo 204229677Sgonzo/* Prototypes */ 205229677Sgonzo 206229677Sgonzostruct octeon_cop2_state* octeon_cop2_alloc_ctx(void); 207229677Sgonzovoid octeon_cop2_free_ctx(struct octeon_cop2_state *); 208229677Sgonzo/* 209229677Sgonzo * Save/restore part 210229677Sgonzo */ 211229677Sgonzovoid octeon_cop2_save(struct octeon_cop2_state *); 212229677Sgonzovoid octeon_cop2_restore(struct octeon_cop2_state *); 213229677Sgonzo 214229677Sgonzo#endif /* LOCORE */ 215229677Sgonzo#endif /* __OCTEON_COP2_H__ */ 216