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