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 * 22 *******************************************************************************/ 23 /******************************************************************************* 24 ** 25 ** Version Control Information: 26 ** 27 ** $Revision: 114125 $ 28 ** $Author: lindfors $ 29 ** $Date: 2012-01-06 17:12:27 -0800 (Fri, 06 Jan 2012) $ 30 ** $Id: encrypt_ioctl.h 112360 2012-01-07 01:12:27Z mcleanda $ 31 ** 32 *******************************************************************************/ 33 #include <linux/ioctl.h> 34 35 #ifndef __ENCRYPT_IOCTL_H__ 36 #define __ENCRYPT_IOCTL_H__ 37 38 #include <dev/pms/RefTisa/tisa/api/tiapi.h> 39 #include <dev/pms/RefTisa/tisa/api/ostiapi.h> 40 #include <dev/pms/RefTisa/tisa/api/tidefs.h> 41 #include <dev/pms/RefTisa/tisa/api/tiglobal.h> 42 #include <dev/pms/RefTisa/tisa/api/titypes.h> 43 #include <dev/pms/RefTisa/tisa/sassata/common/tdioctl.h> 44 #include <dev/pms/freebsd/driver/common/osenv.h> 45 #include <dev/pms/freebsd/driver/common/ostypes.h> 46 #include <dev/pms/freebsd/driver/common/osdebug.h> 47 48 typedef struct IoctlEncryptGetInfo_s { 49 tiEncryptInfo_t tisaEncryptInfo; 50 } __attribute__ ((packed)) IoctlEncryptGetInfo_t; 51 52 typedef struct IoctlEncryptSetMode_s { 53 bit32 securityCipherMode; 54 } __attribute__ ((packed)) IoctlEncryptSetMode_t; 55 56 typedef struct IoctlEncryptKekAdd_s { 57 bit32 kekIndex; 58 bit32 wrapperKekIndex; 59 bit32 blobFormat; 60 tiEncryptKekBlob_t *EncryptKekBlob; 61 } __attribute__ ((packed)) IoctlEncryptKekAdd_t; 62 63 typedef struct IoctlEncryptDekAdd_s { 64 bit32 kekIndex; 65 bit32 dekTable; 66 bit32 dekIndex; 67 bit32 dekBlobFormat; 68 bit32 dekTableKeyEntrySize; 69 tiEncryptDekBlob_t *dekBlob; 70 } __attribute__ ((packed)) IoctlEncryptDekAdd_t; 71 72 typedef struct IoctlEncryptDekInvalidate_s { 73 tiEncryptDek_t dek; 74 } __attribute__ ((packed)) IoctlEncryptDekInvalidate_t; 75 76 typedef struct IoctlEncryptKekNVRAM_s { 77 bit32 index; 78 } __attribute__ ((packed)) IoctlEncryptKekNVRAM_t; 79 80 typedef struct IoctlEncryptDekTable_s { 81 tiMem_t DekTable1Addr; 82 tiMem_t DekTable2Addr; 83 } __attribute__ ((packed)) IoctlEncryptDekTable_t; 84 85 typedef struct EncryptDekMapEntry_s { 86 #define ENCRYPT_DEK_MAP_ENTRY_CLEAR 0x00000001UL 87 #define ENCRYPT_DEK_MAP_ENTRY_VALID 0x80000000UL 88 bit32 flags; 89 unsigned long long startLBA; 90 unsigned long long endLBA; 91 tiEncryptDek_t dek; 92 } __attribute__ ((packed)) EncryptDekMapEntry_t; 93 94 typedef struct EncryptDeviceDekMap_s { 95 bit32 host; 96 bit32 channel; 97 bit32 device; 98 bit32 lun; 99 bit32 keytag_check; 100 bit32 keytag[2]; 101 EncryptDekMapEntry_t dekMapEntry[1]; 102 } __attribute__ ((packed)) EncryptDeviceDekMap_t; 103 104 typedef struct IoctlEncryptDekMapTable_s { 105 EncryptDeviceDekMap_t dekMap[1]; 106 } __attribute__ ((packed)) IoctlEncryptDekMapTable_t; 107 108 typedef struct IoctlEncryptIOError_s { 109 bit64 error_id; 110 bit64 timestamp; 111 bit32 error_type; 112 bit32 host; 113 bit32 channel; 114 bit32 device; 115 bit32 lun; 116 bit32 scsi_cmd; 117 bit32 dek_index; 118 bit32 dek_table; 119 bit32 kek_index; 120 bit32 encrypt_mode; 121 bit32 keytag_check; 122 bit32 keytag[2]; 123 } __attribute__ ((packed)) IoctlEncryptIOError_t; 124 125 typedef struct __attribute__ ((packed)) IoctlEncryptErrorQuery_s { 126 #define ERROR_QUERY_FLAG_BLOCK 1 127 bit32 query_flag; 128 bit32 valid_mask; 129 IoctlEncryptIOError_t error[32]; 130 } __attribute__ ((packed)) IoctlEncryptErrorQuery_t; 131 132 typedef union IoctlEncryptOp_u { 133 IoctlEncryptGetInfo_t encryptGetInfo; 134 IoctlEncryptSetMode_t encryptSetMode; 135 IoctlEncryptKekAdd_t encryptKekAdd; 136 IoctlEncryptDekAdd_t encryptDekAdd; 137 IoctlEncryptDekInvalidate_t encryptDekInvalidate; 138 IoctlEncryptKekNVRAM_t encryptKekNVRAM; 139 IoctlEncryptDekMapTable_t encryptDekMap; 140 IoctlEncryptErrorQuery_t encryptErrorQuery; 141 } __attribute__ ((packed)) IoctlEncryptOp_t; 142 143 typedef struct tiIOCTLPayloadHeader_s { 144 bit32 Signature; 145 bit16 MajorFunction; 146 bit16 MinorFunction; 147 bit16 Length; 148 bit16 Status; 149 } __attribute__ ((packed)) tiIOCTLPayloadHeader_t; 150 151 typedef struct IoctlTISAEncrypt_s { 152 #define encryptGetInfo 0x00000001 153 #define encryptSetMode 0x00000002 154 #define encryptKekAdd 0x00000003 155 #define encryptDekAdd 0x00000004 156 #define encryptDekInvalidate 0x00000005 157 #define encryptKekStore 0x00000006 158 #define encryptKekLoad 0x00000007 159 #define encryptGetDekTable 0x00000008 160 #define encryptSetDekMap 0x00000009 161 #define encryptDekDump 0x0000000a 162 #define encryptErrorQuery 0x0000000c 163 bit32 encryptFunction; 164 bit32 status; 165 bit32 subEvent; 166 IoctlEncryptOp_t request; 167 } __attribute__ ((packed)) IoctlTISAEncrypt_t; 168 169 typedef struct IOCTLEncrypt_s { 170 tiIOCTLPayloadHeader_t hdr; 171 IoctlTISAEncrypt_t body; 172 } __attribute__ ((packed)) IoctlEncrypt_t; 173 174 #endif 175