1 /******************************************************************************* 2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3 * 4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided 5 *that the following conditions are met: 6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7 *following disclaimer. 8 *2. Redistributions in binary form must reproduce the above copyright notice, 9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided 10 *with the distribution. 11 * 12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20 * 21 * $FreeBSD$ 22 * 23 *******************************************************************************/ 24 /******************************************************************************* 25 ** 26 ** Version Control Information: 27 ** 28 ** $Revision: 114125 $ 29 ** $Author: lindfors $ 30 ** $Date: 2012-01-06 17:12:27 -0800 (Fri, 06 Jan 2012) $ 31 ** $Id: encrypt_ioctl.h 112360 2012-01-07 01:12:27Z mcleanda $ 32 ** 33 *******************************************************************************/ 34 #include <linux/ioctl.h> 35 36 #ifndef __ENCRYPT_IOCTL_H__ 37 #define __ENCRYPT_IOCTL_H__ 38 39 #include <dev/pms/RefTisa/tisa/api/tiapi.h> 40 #include <dev/pms/RefTisa/tisa/api/ostiapi.h> 41 #include <dev/pms/RefTisa/tisa/api/tidefs.h> 42 #include <dev/pms/RefTisa/tisa/api/tiglobal.h> 43 #include <dev/pms/RefTisa/tisa/api/titypes.h> 44 #include <dev/pms/RefTisa/tisa/sassata/common/tdioctl.h> 45 #include <dev/pms/freebsd/driver/common/osenv.h> 46 #include <dev/pms/freebsd/driver/common/ostypes.h> 47 #include <dev/pms/freebsd/driver/common/osdebug.h> 48 49 typedef struct IoctlEncryptGetInfo_s { 50 tiEncryptInfo_t tisaEncryptInfo; 51 } __attribute__ ((packed)) IoctlEncryptGetInfo_t; 52 53 typedef struct IoctlEncryptSetMode_s { 54 bit32 securityCipherMode; 55 } __attribute__ ((packed)) IoctlEncryptSetMode_t; 56 57 typedef struct IoctlEncryptKekAdd_s { 58 bit32 kekIndex; 59 bit32 wrapperKekIndex; 60 bit32 blobFormat; 61 tiEncryptKekBlob_t *EncryptKekBlob; 62 } __attribute__ ((packed)) IoctlEncryptKekAdd_t; 63 64 typedef struct IoctlEncryptDekAdd_s { 65 bit32 kekIndex; 66 bit32 dekTable; 67 bit32 dekIndex; 68 bit32 dekBlobFormat; 69 bit32 dekTableKeyEntrySize; 70 tiEncryptDekBlob_t *dekBlob; 71 } __attribute__ ((packed)) IoctlEncryptDekAdd_t; 72 73 typedef struct IoctlEncryptDekInvalidate_s { 74 tiEncryptDek_t dek; 75 } __attribute__ ((packed)) IoctlEncryptDekInvalidate_t; 76 77 typedef struct IoctlEncryptKekNVRAM_s { 78 bit32 index; 79 } __attribute__ ((packed)) IoctlEncryptKekNVRAM_t; 80 81 typedef struct IoctlEncryptDekTable_s { 82 tiMem_t DekTable1Addr; 83 tiMem_t DekTable2Addr; 84 } __attribute__ ((packed)) IoctlEncryptDekTable_t; 85 86 typedef struct EncryptDekMapEntry_s { 87 #define ENCRYPT_DEK_MAP_ENTRY_CLEAR 0x00000001UL 88 #define ENCRYPT_DEK_MAP_ENTRY_VALID 0x80000000UL 89 bit32 flags; 90 unsigned long long startLBA; 91 unsigned long long endLBA; 92 tiEncryptDek_t dek; 93 } __attribute__ ((packed)) EncryptDekMapEntry_t; 94 95 typedef struct EncryptDeviceDekMap_s { 96 bit32 host; 97 bit32 channel; 98 bit32 device; 99 bit32 lun; 100 bit32 keytag_check; 101 bit32 keytag[2]; 102 EncryptDekMapEntry_t dekMapEntry[1]; 103 } __attribute__ ((packed)) EncryptDeviceDekMap_t; 104 105 typedef struct IoctlEncryptDekMapTable_s { 106 EncryptDeviceDekMap_t dekMap[1]; 107 } __attribute__ ((packed)) IoctlEncryptDekMapTable_t; 108 109 typedef struct IoctlEncryptIOError_s { 110 bit64 error_id; 111 bit64 timestamp; 112 bit32 error_type; 113 bit32 host; 114 bit32 channel; 115 bit32 device; 116 bit32 lun; 117 bit32 scsi_cmd; 118 bit32 dek_index; 119 bit32 dek_table; 120 bit32 kek_index; 121 bit32 encrypt_mode; 122 bit32 keytag_check; 123 bit32 keytag[2]; 124 } __attribute__ ((packed)) IoctlEncryptIOError_t; 125 126 typedef struct __attribute__ ((packed)) IoctlEncryptErrorQuery_s { 127 #define ERROR_QUERY_FLAG_BLOCK 1 128 bit32 query_flag; 129 bit32 valid_mask; 130 IoctlEncryptIOError_t error[32]; 131 } __attribute__ ((packed)) IoctlEncryptErrorQuery_t; 132 133 typedef union IoctlEncryptOp_u { 134 IoctlEncryptGetInfo_t encryptGetInfo; 135 IoctlEncryptSetMode_t encryptSetMode; 136 IoctlEncryptKekAdd_t encryptKekAdd; 137 IoctlEncryptDekAdd_t encryptDekAdd; 138 IoctlEncryptDekInvalidate_t encryptDekInvalidate; 139 IoctlEncryptKekNVRAM_t encryptKekNVRAM; 140 IoctlEncryptDekMapTable_t encryptDekMap; 141 IoctlEncryptErrorQuery_t encryptErrorQuery; 142 } __attribute__ ((packed)) IoctlEncryptOp_t; 143 144 typedef struct tiIOCTLPayloadHeader_s { 145 bit32 Signature; 146 bit16 MajorFunction; 147 bit16 MinorFunction; 148 bit16 Length; 149 bit16 Status; 150 } __attribute__ ((packed)) tiIOCTLPayloadHeader_t; 151 152 typedef struct IoctlTISAEncrypt_s { 153 #define encryptGetInfo 0x00000001 154 #define encryptSetMode 0x00000002 155 #define encryptKekAdd 0x00000003 156 #define encryptDekAdd 0x00000004 157 #define encryptDekInvalidate 0x00000005 158 #define encryptKekStore 0x00000006 159 #define encryptKekLoad 0x00000007 160 #define encryptGetDekTable 0x00000008 161 #define encryptSetDekMap 0x00000009 162 #define encryptDekDump 0x0000000a 163 #define encryptErrorQuery 0x0000000c 164 bit32 encryptFunction; 165 bit32 status; 166 bit32 subEvent; 167 IoctlEncryptOp_t request; 168 } __attribute__ ((packed)) IoctlTISAEncrypt_t; 169 170 typedef struct IOCTLEncrypt_s { 171 tiIOCTLPayloadHeader_t hdr; 172 IoctlTISAEncrypt_t body; 173 } __attribute__ ((packed)) IoctlEncrypt_t; 174 175 #endif 176