Linux-libre 3.16.85-gnu
[librecmc/linux-libre.git] / drivers / scsi / mpt3sas / mpi / mpi2_raid.h
1 /*
2  * Copyright (c) 2000-2013 LSI Corporation.
3  *
4  *
5  *          Name:  mpi2_raid.h
6  *         Title:  MPI Integrated RAID messages and structures
7  * Creation Date:  April 26, 2007
8  *
9  *   mpi2_raid.h Version:  02.00.09
10  *
11  * Version History
12  * ---------------
13  *
14  * Date      Version   Description
15  * --------  --------  ------------------------------------------------------
16  * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
17  * 08-31-07  02.00.01  Modifications to RAID Action request and reply,
18  *                     including the Actions and ActionData.
19  * 02-29-08  02.00.02  Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
20  * 05-21-08  02.00.03  Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
21  *                     the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
22  *                     can be sized by the build environment.
23  * 07-30-09  02.00.04  Added proper define for the Use Default Settings bit of
24  *                     VolumeCreationFlags and marked the old one as obsolete.
25  * 05-12-10  02.00.05  Added MPI2_RAID_VOL_FLAGS_OP_MDC define.
26  * 08-24-10  02.00.06  Added MPI2_RAID_ACTION_COMPATIBILITY_CHECK along with
27  *                     related structures and defines.
28  *                     Added product-specific range to RAID Action values.
29  * 11-18-11  02.00.07  Incorporating additions for MPI v2.5.
30  * 02-06-12  02.00.08  Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN.
31  * 07-26-12  02.00.09  Added ElapsedSeconds field to MPI2_RAID_VOL_INDICATOR.
32  *                     Added MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID define.
33  * --------------------------------------------------------------------------
34  */
35
36 #ifndef MPI2_RAID_H
37 #define MPI2_RAID_H
38
39 /*****************************************************************************
40 *
41 *              Integrated RAID Messages
42 *
43 *****************************************************************************/
44
45 /****************************************************************************
46 * RAID Action messages
47 ****************************************************************************/
48
49 /*ActionDataWord defines for use with MPI2_RAID_ACTION_DELETE_VOLUME action */
50 #define MPI2_RAID_ACTION_ADATA_KEEP_LBA0            (0x00000000)
51 #define MPI2_RAID_ACTION_ADATA_ZERO_LBA0            (0x00000001)
52
53 /*use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for
54  *MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
55
56 /*ActionDataWord defines for use with
57  *MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES action */
58 #define MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD  (0x00000001)
59
60 /*ActionDataWord for MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE Action */
61 typedef struct _MPI2_RAID_ACTION_RATE_DATA {
62         U8 RateToChange;        /*0x00 */
63         U8 RateOrMode;          /*0x01 */
64         U16 DataScrubDuration;  /*0x02 */
65 } MPI2_RAID_ACTION_RATE_DATA, *PTR_MPI2_RAID_ACTION_RATE_DATA,
66         Mpi2RaidActionRateData_t, *pMpi2RaidActionRateData_t;
67
68 #define MPI2_RAID_ACTION_SET_RATE_RESYNC            (0x00)
69 #define MPI2_RAID_ACTION_SET_RATE_DATA_SCRUB        (0x01)
70 #define MPI2_RAID_ACTION_SET_RATE_POWERSAVE_MODE    (0x02)
71
72 /*ActionDataWord for MPI2_RAID_ACTION_START_RAID_FUNCTION Action */
73 typedef struct _MPI2_RAID_ACTION_START_RAID_FUNCTION {
74         U8 RAIDFunction;        /*0x00 */
75         U8 Flags;               /*0x01 */
76         U16 Reserved1;          /*0x02 */
77 } MPI2_RAID_ACTION_START_RAID_FUNCTION,
78         *PTR_MPI2_RAID_ACTION_START_RAID_FUNCTION,
79         Mpi2RaidActionStartRaidFunction_t,
80         *pMpi2RaidActionStartRaidFunction_t;
81
82 /*defines for the RAIDFunction field */
83 #define MPI2_RAID_ACTION_START_BACKGROUND_INIT      (0x00)
84 #define MPI2_RAID_ACTION_START_ONLINE_CAP_EXPANSION (0x01)
85 #define MPI2_RAID_ACTION_START_CONSISTENCY_CHECK    (0x02)
86
87 /*defines for the Flags field */
88 #define MPI2_RAID_ACTION_START_NEW                  (0x00)
89 #define MPI2_RAID_ACTION_START_RESUME               (0x01)
90
91 /*ActionDataWord for MPI2_RAID_ACTION_STOP_RAID_FUNCTION Action */
92 typedef struct _MPI2_RAID_ACTION_STOP_RAID_FUNCTION {
93         U8 RAIDFunction;        /*0x00 */
94         U8 Flags;               /*0x01 */
95         U16 Reserved1;          /*0x02 */
96 } MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
97         *PTR_MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
98         Mpi2RaidActionStopRaidFunction_t,
99         *pMpi2RaidActionStopRaidFunction_t;
100
101 /*defines for the RAIDFunction field */
102 #define MPI2_RAID_ACTION_STOP_BACKGROUND_INIT       (0x00)
103 #define MPI2_RAID_ACTION_STOP_ONLINE_CAP_EXPANSION  (0x01)
104 #define MPI2_RAID_ACTION_STOP_CONSISTENCY_CHECK     (0x02)
105
106 /*defines for the Flags field */
107 #define MPI2_RAID_ACTION_STOP_ABORT                 (0x00)
108 #define MPI2_RAID_ACTION_STOP_PAUSE                 (0x01)
109
110 /*ActionDataWord for MPI2_RAID_ACTION_CREATE_HOT_SPARE Action */
111 typedef struct _MPI2_RAID_ACTION_HOT_SPARE {
112         U8 HotSparePool;        /*0x00 */
113         U8 Reserved1;           /*0x01 */
114         U16 DevHandle;          /*0x02 */
115 } MPI2_RAID_ACTION_HOT_SPARE, *PTR_MPI2_RAID_ACTION_HOT_SPARE,
116         Mpi2RaidActionHotSpare_t, *pMpi2RaidActionHotSpare_t;
117
118 /*ActionDataWord for MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE Action */
119 typedef struct _MPI2_RAID_ACTION_FW_UPDATE_MODE {
120         U8 Flags;               /*0x00 */
121         U8 DeviceFirmwareUpdateModeTimeout;     /*0x01 */
122         U16 Reserved1;          /*0x02 */
123 } MPI2_RAID_ACTION_FW_UPDATE_MODE,
124         *PTR_MPI2_RAID_ACTION_FW_UPDATE_MODE,
125         Mpi2RaidActionFwUpdateMode_t,
126         *pMpi2RaidActionFwUpdateMode_t;
127
128 /*ActionDataWord defines for use with
129  *MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE action */
130 #define MPI2_RAID_ACTION_ADATA_DISABLE_FW_UPDATE        (0x00)
131 #define MPI2_RAID_ACTION_ADATA_ENABLE_FW_UPDATE         (0x01)
132
133 typedef union _MPI2_RAID_ACTION_DATA {
134         U32 Word;
135         MPI2_RAID_ACTION_RATE_DATA Rates;
136         MPI2_RAID_ACTION_START_RAID_FUNCTION StartRaidFunction;
137         MPI2_RAID_ACTION_STOP_RAID_FUNCTION StopRaidFunction;
138         MPI2_RAID_ACTION_HOT_SPARE HotSpare;
139         MPI2_RAID_ACTION_FW_UPDATE_MODE FwUpdateMode;
140 } MPI2_RAID_ACTION_DATA, *PTR_MPI2_RAID_ACTION_DATA,
141         Mpi2RaidActionData_t, *pMpi2RaidActionData_t;
142
143 /*RAID Action Request Message */
144 typedef struct _MPI2_RAID_ACTION_REQUEST {
145         U8 Action;              /*0x00 */
146         U8 Reserved1;           /*0x01 */
147         U8 ChainOffset;         /*0x02 */
148         U8 Function;            /*0x03 */
149         U16 VolDevHandle;       /*0x04 */
150         U8 PhysDiskNum;         /*0x06 */
151         U8 MsgFlags;            /*0x07 */
152         U8 VP_ID;               /*0x08 */
153         U8 VF_ID;               /*0x09 */
154         U16 Reserved2;          /*0x0A */
155         U32 Reserved3;          /*0x0C */
156         MPI2_RAID_ACTION_DATA ActionDataWord;   /*0x10 */
157         MPI2_SGE_SIMPLE_UNION ActionDataSGE;    /*0x14 */
158 } MPI2_RAID_ACTION_REQUEST, *PTR_MPI2_RAID_ACTION_REQUEST,
159         Mpi2RaidActionRequest_t, *pMpi2RaidActionRequest_t;
160
161 /*RAID Action request Action values */
162
163 #define MPI2_RAID_ACTION_INDICATOR_STRUCT           (0x01)
164 #define MPI2_RAID_ACTION_CREATE_VOLUME              (0x02)
165 #define MPI2_RAID_ACTION_DELETE_VOLUME              (0x03)
166 #define MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES        (0x04)
167 #define MPI2_RAID_ACTION_ENABLE_ALL_VOLUMES         (0x05)
168 #define MPI2_RAID_ACTION_PHYSDISK_OFFLINE           (0x0A)
169 #define MPI2_RAID_ACTION_PHYSDISK_ONLINE            (0x0B)
170 #define MPI2_RAID_ACTION_FAIL_PHYSDISK              (0x0F)
171 #define MPI2_RAID_ACTION_ACTIVATE_VOLUME            (0x11)
172 #define MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE      (0x15)
173 #define MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE     (0x17)
174 #define MPI2_RAID_ACTION_SET_VOLUME_NAME            (0x18)
175 #define MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE     (0x19)
176 #define MPI2_RAID_ACTION_ENABLE_FAILED_VOLUME       (0x1C)
177 #define MPI2_RAID_ACTION_CREATE_HOT_SPARE           (0x1D)
178 #define MPI2_RAID_ACTION_DELETE_HOT_SPARE           (0x1E)
179 #define MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED  (0x20)
180 #define MPI2_RAID_ACTION_START_RAID_FUNCTION        (0x21)
181 #define MPI2_RAID_ACTION_STOP_RAID_FUNCTION         (0x22)
182 #define MPI2_RAID_ACTION_COMPATIBILITY_CHECK        (0x23)
183 #define MPI2_RAID_ACTION_PHYSDISK_HIDDEN            (0x24)
184 #define MPI2_RAID_ACTION_MIN_PRODUCT_SPECIFIC       (0x80)
185 #define MPI2_RAID_ACTION_MAX_PRODUCT_SPECIFIC       (0xFF)
186
187 /*RAID Volume Creation Structure */
188
189 /*
190  *The following define can be customized for the targeted product.
191  */
192 #ifndef MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS
193 #define MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS        (1)
194 #endif
195
196 typedef struct _MPI2_RAID_VOLUME_PHYSDISK {
197         U8 RAIDSetNum;          /*0x00 */
198         U8 PhysDiskMap;         /*0x01 */
199         U16 PhysDiskDevHandle;  /*0x02 */
200 } MPI2_RAID_VOLUME_PHYSDISK, *PTR_MPI2_RAID_VOLUME_PHYSDISK,
201         Mpi2RaidVolumePhysDisk_t, *pMpi2RaidVolumePhysDisk_t;
202
203 /*defines for the PhysDiskMap field */
204 #define MPI2_RAIDACTION_PHYSDISK_PRIMARY            (0x01)
205 #define MPI2_RAIDACTION_PHYSDISK_SECONDARY          (0x02)
206
207 typedef struct _MPI2_RAID_VOLUME_CREATION_STRUCT {
208         U8 NumPhysDisks;        /*0x00 */
209         U8 VolumeType;          /*0x01 */
210         U16 Reserved1;          /*0x02 */
211         U32 VolumeCreationFlags;        /*0x04 */
212         U32 VolumeSettings;     /*0x08 */
213         U8 Reserved2;           /*0x0C */
214         U8 ResyncRate;          /*0x0D */
215         U16 DataScrubDuration;  /*0x0E */
216         U64 VolumeMaxLBA;       /*0x10 */
217         U32 StripeSize;         /*0x18 */
218         U8 Name[16];            /*0x1C */
219         MPI2_RAID_VOLUME_PHYSDISK
220                 PhysDisk[MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS]; /*0x2C */
221 } MPI2_RAID_VOLUME_CREATION_STRUCT,
222         *PTR_MPI2_RAID_VOLUME_CREATION_STRUCT,
223         Mpi2RaidVolumeCreationStruct_t,
224         *pMpi2RaidVolumeCreationStruct_t;
225
226 /*use MPI2_RAID_VOL_TYPE_ defines from mpi2_cnfg.h for VolumeType */
227
228 /*defines for the VolumeCreationFlags field */
229 #define MPI2_RAID_VOL_CREATION_DEFAULT_SETTINGS     (0x80000000)
230 #define MPI2_RAID_VOL_CREATION_BACKGROUND_INIT      (0x00000004)
231 #define MPI2_RAID_VOL_CREATION_LOW_LEVEL_INIT       (0x00000002)
232 #define MPI2_RAID_VOL_CREATION_MIGRATE_DATA         (0x00000001)
233 /*The following is an obsolete define.
234  *It must be shifted left 24 bits in order to set the proper bit.
235  */
236 #define MPI2_RAID_VOL_CREATION_USE_DEFAULT_SETTINGS (0x80)
237
238 /*RAID Online Capacity Expansion Structure */
239
240 typedef struct _MPI2_RAID_ONLINE_CAPACITY_EXPANSION {
241         U32 Flags;              /*0x00 */
242         U16 DevHandle0;         /*0x04 */
243         U16 Reserved1;          /*0x06 */
244         U16 DevHandle1;         /*0x08 */
245         U16 Reserved2;          /*0x0A */
246 } MPI2_RAID_ONLINE_CAPACITY_EXPANSION,
247         *PTR_MPI2_RAID_ONLINE_CAPACITY_EXPANSION,
248         Mpi2RaidOnlineCapacityExpansion_t,
249         *pMpi2RaidOnlineCapacityExpansion_t;
250
251 /*RAID Compatibility Input Structure */
252
253 typedef struct _MPI2_RAID_COMPATIBILITY_INPUT_STRUCT {
254         U16 SourceDevHandle;    /*0x00 */
255         U16 CandidateDevHandle; /*0x02 */
256         U32 Flags;              /*0x04 */
257         U32 Reserved1;          /*0x08 */
258         U32 Reserved2;          /*0x0C */
259 } MPI2_RAID_COMPATIBILITY_INPUT_STRUCT,
260         *PTR_MPI2_RAID_COMPATIBILITY_INPUT_STRUCT,
261         Mpi2RaidCompatibilityInputStruct_t,
262         *pMpi2RaidCompatibilityInputStruct_t;
263
264 /*defines for RAID Compatibility Structure Flags field */
265 #define MPI2_RAID_COMPAT_SOURCE_IS_VOLUME_FLAG      (0x00000002)
266 #define MPI2_RAID_COMPAT_REPORT_SOURCE_INFO_FLAG    (0x00000001)
267
268 /*RAID Volume Indicator Structure */
269
270 typedef struct _MPI2_RAID_VOL_INDICATOR {
271         U64 TotalBlocks;        /*0x00 */
272         U64 BlocksRemaining;    /*0x08 */
273         U32 Flags;              /*0x10 */
274         U32 ElapsedSeconds;     /* 0x14 */
275 } MPI2_RAID_VOL_INDICATOR, *PTR_MPI2_RAID_VOL_INDICATOR,
276         Mpi2RaidVolIndicator_t, *pMpi2RaidVolIndicator_t;
277
278 /*defines for RAID Volume Indicator Flags field */
279 #define MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID   (0x80000000)
280 #define MPI2_RAID_VOL_FLAGS_OP_MASK                 (0x0000000F)
281 #define MPI2_RAID_VOL_FLAGS_OP_BACKGROUND_INIT      (0x00000000)
282 #define MPI2_RAID_VOL_FLAGS_OP_ONLINE_CAP_EXPANSION (0x00000001)
283 #define MPI2_RAID_VOL_FLAGS_OP_CONSISTENCY_CHECK    (0x00000002)
284 #define MPI2_RAID_VOL_FLAGS_OP_RESYNC               (0x00000003)
285 #define MPI2_RAID_VOL_FLAGS_OP_MDC                  (0x00000004)
286
287 /*RAID Compatibility Result Structure */
288
289 typedef struct _MPI2_RAID_COMPATIBILITY_RESULT_STRUCT {
290         U8 State;               /*0x00 */
291         U8 Reserved1;           /*0x01 */
292         U16 Reserved2;          /*0x02 */
293         U32 GenericAttributes;  /*0x04 */
294         U32 OEMSpecificAttributes;      /*0x08 */
295         U32 Reserved3;          /*0x0C */
296         U32 Reserved4;          /*0x10 */
297 } MPI2_RAID_COMPATIBILITY_RESULT_STRUCT,
298         *PTR_MPI2_RAID_COMPATIBILITY_RESULT_STRUCT,
299         Mpi2RaidCompatibilityResultStruct_t,
300         *pMpi2RaidCompatibilityResultStruct_t;
301
302 /*defines for RAID Compatibility Result Structure State field */
303 #define MPI2_RAID_COMPAT_STATE_COMPATIBLE           (0x00)
304 #define MPI2_RAID_COMPAT_STATE_NOT_COMPATIBLE       (0x01)
305
306 /*defines for RAID Compatibility Result Structure GenericAttributes field */
307 #define MPI2_RAID_COMPAT_GENATTRIB_4K_SECTOR            (0x00000010)
308
309 #define MPI2_RAID_COMPAT_GENATTRIB_MEDIA_MASK           (0x0000000C)
310 #define MPI2_RAID_COMPAT_GENATTRIB_SOLID_STATE_DRIVE    (0x00000008)
311 #define MPI2_RAID_COMPAT_GENATTRIB_HARD_DISK_DRIVE      (0x00000004)
312
313 #define MPI2_RAID_COMPAT_GENATTRIB_PROTOCOL_MASK        (0x00000003)
314 #define MPI2_RAID_COMPAT_GENATTRIB_SAS_PROTOCOL         (0x00000002)
315 #define MPI2_RAID_COMPAT_GENATTRIB_SATA_PROTOCOL        (0x00000001)
316
317 /*RAID Action Reply ActionData union */
318 typedef union _MPI2_RAID_ACTION_REPLY_DATA {
319         U32 Word[6];
320         MPI2_RAID_VOL_INDICATOR RaidVolumeIndicator;
321         U16 VolDevHandle;
322         U8 VolumeState;
323         U8 PhysDiskNum;
324         MPI2_RAID_COMPATIBILITY_RESULT_STRUCT RaidCompatibilityResult;
325 } MPI2_RAID_ACTION_REPLY_DATA, *PTR_MPI2_RAID_ACTION_REPLY_DATA,
326         Mpi2RaidActionReplyData_t, *pMpi2RaidActionReplyData_t;
327
328 /*use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for
329  *MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
330
331 /*RAID Action Reply Message */
332 typedef struct _MPI2_RAID_ACTION_REPLY {
333         U8 Action;              /*0x00 */
334         U8 Reserved1;           /*0x01 */
335         U8 MsgLength;           /*0x02 */
336         U8 Function;            /*0x03 */
337         U16 VolDevHandle;       /*0x04 */
338         U8 PhysDiskNum;         /*0x06 */
339         U8 MsgFlags;            /*0x07 */
340         U8 VP_ID;               /*0x08 */
341         U8 VF_ID;               /*0x09 */
342         U16 Reserved2;          /*0x0A */
343         U16 Reserved3;          /*0x0C */
344         U16 IOCStatus;          /*0x0E */
345         U32 IOCLogInfo;         /*0x10 */
346         MPI2_RAID_ACTION_REPLY_DATA ActionData; /*0x14 */
347 } MPI2_RAID_ACTION_REPLY, *PTR_MPI2_RAID_ACTION_REPLY,
348         Mpi2RaidActionReply_t, *pMpi2RaidActionReply_t;
349
350 #endif