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