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 * sm.h 26 * 27 * Abstract: This module defines the contants, enum and #define definition used 28 * by SAT Moduled (SM). 29 * 30 ********************************************************************************/ 31 32 #ifndef SM_H 33 #define SM_H 34 35 /************************************************* 36 * constants for type field in smMem_t 37 *************************************************/ 38 #define SM_CACHED_MEM 0x00 /**< CACHED memory type */ 39 #define SM_DMA_MEM 0x01 /**< DMA memory type */ 40 #define SM_CACHED_DMA_MEM 0x02 /**< CACHED DMA memory type */ 41 42 /************************************************* 43 * constants for API return values 44 *************************************************/ 45 typedef enum 46 { 47 SM_RC_SUCCESS, 48 SM_RC_FAILURE, 49 SM_RC_BUSY, 50 SM_RC_NODEVICE, 51 SM_RC_VERSION_INCOMPATIBLE, 52 SM_RC_VERSION_UNTESTED, 53 SM_RC_RSV1, 54 SM_RC_RSV2, 55 SM_RC_RSV3, 56 SM_RC_RSV4, 57 SM_RC_DEVICE_BUSY, /* must be the same as tiDeviceBusy */ 58 59 } smStatus_t; 60 61 typedef enum 62 { 63 smIOSuccess, 64 smIOOverRun, 65 smIOUnderRun, 66 smIOFailed, 67 smIODifError, 68 smIOEncryptError, 69 smIORetry, /* open retry timeout */ 70 smIOSTPResourceBusy, /* stp resource busy */ 71 } smIOStatus_t; 72 73 typedef enum 74 { 75 smDetailBusy, 76 smDetailNotValid, 77 smDetailNoLogin, 78 smDetailAbortLogin, 79 smDetailAbortReset, 80 smDetailAborted, 81 smDetailDifMismatch, 82 smDetailDifAppTagMismatch, 83 smDetailDifRefTagMismatch, 84 smDetailDifCrcMismatch, 85 smDetailDekKeyCacheMiss, 86 smDetailCipherModeInvalid, 87 smDetailDekIVMismatch, 88 smDetailDekRamInterfaceError, 89 smDetailDekIndexOutofBounds, 90 smDetailOtherError 91 } smIOStatusDetail_t; 92 93 /* 94 * Data direction for I/O request 95 */ 96 typedef enum 97 { 98 smDirectionIn = 0x0000, 99 smDirectionOut = 0x0001 100 }smDataDirection_t; 101 102 /* 103 * Event types for tdsmEventCB() 104 * do not change: Needs to be in sync with TISA API 105 */ 106 typedef enum 107 { 108 smIntrEventTypeCnxError, 109 smIntrEventTypeDiscovery, 110 smIntrEventTypeTransportRecovery, 111 smIntrEventTypeTaskManagement, 112 smIntrEventTypeDeviceChange, 113 smIntrEventTypeLogin, 114 smIntrEventTypeLocalAbort 115 } smIntrEventType_t; 116 117 typedef enum 118 { 119 smTMOK, 120 smTMFailed 121 } smTMEventStatus_t; 122 123 /* 124 * Flags in smSuperScsiInitiatorRequest_t 125 */ 126 #define SM_SCSI_INITIATOR_DIF 0x00000001 127 #define SM_SCSI_INITIATOR_ENCRYPT 0x00000002 128 129 /* 130 * Flags in smSuperScsiInitiatorRequest_t 131 */ 132 #define SM_SCSI_TARGET_DIF 0x00000001 133 #define SM_SCSI_TARGET_MIRROR 0x00000002 134 #define SM_SCSI_TARGET_ENCRYPT 0x00000004 135 136 typedef struct { 137 void *tdData; 138 void *smData; 139 } smContext_t; 140 141 142 typedef smContext_t smDeviceHandle_t; 143 144 typedef smContext_t smIORequest_t; 145 146 typedef smContext_t smRoot_t; 147 148 typedef struct 149 { 150 bit8 lun[8]; /* logical unit number */ 151 } smLUN_t; 152 153 typedef struct{ 154 smLUN_t lun; 155 bit32 expDataLength; 156 bit32 taskAttribute; 157 bit32 crn; 158 bit8 cdb[16]; 159 } smIniScsiCmnd_t; 160 161 162 163 typedef struct{ 164 void *virtPtr; 165 void *osHandle; 166 bit32 physAddrUpper; 167 bit32 physAddrLower; 168 bit32 totalLength; 169 bit32 numElements; 170 bit32 singleElementLength; 171 bit32 alignment; 172 bit32 type; 173 bit32 reserved; 174 } smMem_t; 175 176 #define SM_NUM_MEM_CHUNKS 8 177 178 typedef struct{ 179 bit32 count; 180 smMem_t smMemory[SM_NUM_MEM_CHUNKS]; 181 } smMemoryRequirement_t; 182 183 typedef struct{ 184 bit32 lower; 185 bit32 upper; 186 bit32 len; 187 bit32 type; 188 } smSgl_t; 189 190 /* 191 * DIF operation 192 */ 193 #define DIF_INSERT 0 194 #define DIF_VERIFY_FORWARD 1 195 #define DIF_VERIFY_DELETE 2 196 #define DIF_VERIFY_REPLACE 3 197 #define DIF_VERIFY_UDT_REPLACE_CRC 5 198 #define DIF_REPLACE_UDT_REPLACE_CRC 7 199 200 #define DIF_UDT_SIZE 6 201 202 typedef struct smDif 203 { 204 agBOOLEAN enableDIFPerLA; 205 bit32 flag; 206 bit16 initialIOSeed; 207 bit16 reserved; 208 bit32 DIFPerLAAddrLo; 209 bit32 DIFPerLAAddrHi; 210 bit16 DIFPerLARegion0SecCount; 211 bit16 DIFPerLANumOfRegions; 212 bit8 udtArray[DIF_UDT_SIZE]; 213 bit8 udrtArray[DIF_UDT_SIZE]; 214 } smDif_t; 215 216 typedef struct smEncryptDek { 217 bit32 dekTable; 218 bit32 dekIndex; 219 } smEncryptDek_t; 220 221 typedef struct smEncrypt { 222 smEncryptDek_t dekInfo; 223 bit32 kekIndex; 224 agBOOLEAN keyTagCheck; 225 agBOOLEAN enableEncryptionPerLA; 226 bit32 sectorSizeIndex; 227 bit32 encryptMode; 228 bit32 keyTag_W0; 229 bit32 keyTag_W1; 230 bit32 tweakVal_W0; 231 bit32 tweakVal_W1; 232 bit32 tweakVal_W2; 233 bit32 tweakVal_W3; 234 bit32 EncryptionPerLAAddrLo; 235 bit32 EncryptionPerLAAddrHi; 236 bit16 EncryptionPerLRegion0SecCount; 237 bit16 reserved; 238 } smEncrypt_t; 239 240 typedef struct smScsiInitiatorRequest { 241 void *sglVirtualAddr; 242 smIniScsiCmnd_t scsiCmnd; 243 smSgl_t smSgl1; 244 smDataDirection_t dataDirection; 245 } smScsiInitiatorRequest_t; 246 247 typedef struct smSuperScsiInitiatorRequest 248 { 249 void *sglVirtualAddr; 250 smIniScsiCmnd_t scsiCmnd; 251 smSgl_t smSgl1; 252 smDataDirection_t dataDirection; 253 bit32 flags; /* 254 bit 0-1: reserved 255 bit 2: enable encryption 256 bit 3: enable dif 257 bit 4-7: reserved 258 bit 8-23: DIF SKIP Bytes 259 bit 24-31: Reserved 260 */ 261 smDif_t Dif; 262 smEncrypt_t Encrypt; 263 } smSuperScsiInitiatorRequest_t; 264 265 typedef struct{ 266 void *senseData; 267 bit8 senseLen; 268 } smSenseData_t; 269 270 typedef struct{ 271 bit32 maxActiveIOs; 272 bit32 numDevHandles; 273 #ifdef SM_DEBUG 274 bit32 SMDebugLevel; 275 #endif 276 } smSwConfig_t; 277 278 279 #define smBOOLEAN bit32 280 281 282 283 284 285 286 287 288 289 290 #endif /* SM_H */ 291 292