1/* ********************************************************************* 2 * Broadcom Common Firmware Environment (CFE) 3 * 4 * Crypto IOCTL definitions File: cfe_crypto.h 5 * 6 * IOCTL function numbers and I/O data structures for communicating 7 * with BlueSteel/Broadcom BCM582x crypto engines. 8 * 9 ********************************************************************* 10 * 11 * Copyright 2003 12 * Broadcom Corporation. All rights reserved. 13 * 14 * This software is furnished under license and may be used and 15 * copied only in accordance with the following terms and 16 * conditions. Subject to these conditions, you may download, 17 * copy, install, use, modify and distribute modified or unmodified 18 * copies of this software in source and/or binary form. No title 19 * or ownership is transferred hereby. 20 * 21 * 1) Any source code used, modified or distributed must reproduce 22 * and retain this copyright notice and list of conditions 23 * as they appear in the source file. 24 * 25 * 2) No right is granted to use any trade name, trademark, or 26 * logo of Broadcom Corporation. The "Broadcom Corporation" 27 * name may not be used to endorse or promote products derived 28 * from this software without the prior written permission of 29 * Broadcom Corporation. 30 * 31 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 32 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 33 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 34 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 35 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 36 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 37 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 39 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 40 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 41 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 42 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 43 * THE POSSIBILITY OF SUCH DAMAGE. 44 ********************************************************************* */ 45 46#ifndef _CFE_CRYPTO_H_ 47#define _CFE_CRYPTO_H_ 48 49#define _DD_MAKEMASK1(n) (1 << (n)) 50#define _DD_MAKEMASK(v,n) ((((1)<<(v))-1) << (n)) 51#define _DD_MAKEVALUE(v,n) ((v) << (n)) 52#define _DD_GETVALUE(v,n,m) (((v) & (m)) >> (n)) 53 54/* ********************************************************************* 55 * Crypto stuff 56 ********************************************************************* */ 57 58#define IOCTL_CRYPTO_GETINFO 0 /* return crypto_info_t */ 59#define IOCTL_CRYPTO_CMD_1 1 /* run a 582x MCR1 command */ 60#define IOCTL_CRYPTO_CMD_2 2 /* run a 582x MCR2 command */ 61 62/* 63 The various implementations share a common command structure but 64 differ somewhat in the supported commands and features. For now, 65 we use the corresponding chip identifiers to indicate capabilities 66 instead of defining a feature mask. 67*/ 68 69typedef enum { 70 BCM5820, 71 BCM5821, 72 BCM5822, 73 BCM5823, 74 OCP80B 75} bs_chip_type; 76 77typedef struct crypto_info_s { 78 bs_chip_type chip; 79} crypto_info_t; 80 81 82/* 83 The CMD IOCTL's expect pointers to records describing the crypto 84 operation to be carried out. Such records are passed directly to 85 the corresponding device (see chip_type) and are limited to its 86 capabilities, which vary somewhat among the chip types. 87 88 Formats of 582x Command Record fields follow. 89*/ 90 91/* Master Command Record Header Format */ 92 93#define S_MCR_NUM_PACKETS 0 94#define M_MCR_NUM_PACKETS _DD_MAKEMASK(16,S_MCR_NUM_PACKETS) 95#define V_MCR_NUM_PACKETS(x) _DD_MAKEVALUE(x,S_MCR_NUM_PACKETS) 96#define G_MCR_NUM_PACKETS(x) _DD_GETVALUE(x,S_MCR_NUM_PACKETS,M_MCR_NUM_PACKETS) 97 98/* Input flags */ 99 100#define M_MCR_SUPPRESS_INTR _DD_MAKEMASK1(31) 101 102/* Output flags */ 103 104#define M_MCR_DONE _DD_MAKEMASK1(16) 105#define M_MCR_ERROR _DD_MAKEMASK1(17) 106 107#define S_MCR_ERROR_CODE 24 108#define M_MCR_ERROR_CODE _DD_MAKEMASK(8,S_MCR_ERROR_CODE) 109#define V_MCR_ERROR_CODE(x) _DD_MAKEVALUE(x,S_MCR_ERROR_CODE) 110#define G_MCR_ERROR_CODE(x) _DD_GETVALUE(x,S_MCR_ERROR_CODE,M_MCR_ERROR_CODE) 111#define K_MCR_ERROR_OK 0 112#define K_MCR_ERROR_UNKNOWN_OP 1 113#define K_MCR_ERROR_DSA_SHORT 2 114#define K_MCR_ERROR_PKI_SHORT 3 115#define K_MCR_ERROR_PKO_SHORT 4 /* Not 5820 */ 116#define K_MCR_ERROR_CHAIN_SHORT 5 /* Not 5820 */ 117#define K_MCR_ERROR_FIFO 6 /* Not 5820 */ 118 119/* In both cases, the header word is followed by an array of N PD entries: 120 commandContext[0] 121 dataBuffer[0] 122 pktLen[0] 123 outputBuffer[0] 124 ... 125 commandContext[N-1] 126 dataBuffer[N-1] 127 pktLen[N-1] 128 outputBuffer[N-1] 129*/ 130 131#define MCR_WORDS(n) (1+8*(n)) 132#define MCR_BYTES(n) ((1+8*(n))*4) 133 134 135/* Descriptions of PDs to be added. */ 136 137#endif /* _CFE_CRYPTO_H_ */ 138