xref: /freebsd/sys/dev/mps/mpi/mpi2_raid.h (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2007-2015 LSI Corp.
5  * Copyright (c) 2013-2015 Avago Technologies
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
30  *
31  * $FreeBSD$
32  */
33 
34 /*
35  *  Copyright (c) 2007-2015 LSI Corporation.
36  *  Copyright (c) 2013-2015 Avago Technologies
37  *
38  *
39  *           Name:  mpi2_raid.h
40  *          Title:  MPI Integrated RAID messages and structures
41  *  Creation Date:  April 26, 2007
42  *
43  *    mpi2_raid.h Version:  02.00.05
44  *
45  *  Version History
46  *  ---------------
47  *
48  *  Date      Version   Description
49  *  --------  --------  ------------------------------------------------------
50  *  04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
51  *  08-31-07  02.00.01  Modifications to RAID Action request and reply,
52  *                      including the Actions and ActionData.
53  *  02-29-08  02.00.02  Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
54  *  05-21-08  02.00.03  Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
55  *                      the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
56  *                      can be sized by the build environment.
57  *  07-30-09  02.00.04  Added proper define for the Use Default Settings bit of
58  *                      VolumeCreationFlags and marked the old one as obsolete.
59  *  05-12-10  02.00.05  Added MPI2_RAID_VOL_FLAGS_OP_MDC define.
60  *  --------------------------------------------------------------------------
61  */
62 
63 #ifndef MPI2_RAID_H
64 #define MPI2_RAID_H
65 
66 /*****************************************************************************
67 *
68 *               Integrated RAID Messages
69 *
70 *****************************************************************************/
71 
72 /****************************************************************************
73 *  RAID Action messages
74 ****************************************************************************/
75 
76 /* ActionDataWord defines for use with MPI2_RAID_ACTION_DELETE_VOLUME action */
77 #define MPI2_RAID_ACTION_ADATA_KEEP_LBA0            (0x00000000)
78 #define MPI2_RAID_ACTION_ADATA_ZERO_LBA0            (0x00000001)
79 
80 /* use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
81 
82 /* ActionDataWord defines for use with MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES action */
83 #define MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD  (0x00000001)
84 
85 /* ActionDataWord for MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE Action */
86 typedef struct _MPI2_RAID_ACTION_RATE_DATA
87 {
88     U8              RateToChange;               /* 0x00 */
89     U8              RateOrMode;                 /* 0x01 */
90     U16             DataScrubDuration;          /* 0x02 */
91 } MPI2_RAID_ACTION_RATE_DATA, MPI2_POINTER PTR_MPI2_RAID_ACTION_RATE_DATA,
92   Mpi2RaidActionRateData_t, MPI2_POINTER pMpi2RaidActionRateData_t;
93 
94 #define MPI2_RAID_ACTION_SET_RATE_RESYNC            (0x00)
95 #define MPI2_RAID_ACTION_SET_RATE_DATA_SCRUB        (0x01)
96 #define MPI2_RAID_ACTION_SET_RATE_POWERSAVE_MODE    (0x02)
97 
98 /* ActionDataWord for MPI2_RAID_ACTION_START_RAID_FUNCTION Action */
99 typedef struct _MPI2_RAID_ACTION_START_RAID_FUNCTION
100 {
101     U8              RAIDFunction;                       /* 0x00 */
102     U8              Flags;                              /* 0x01 */
103     U16             Reserved1;                          /* 0x02 */
104 } MPI2_RAID_ACTION_START_RAID_FUNCTION,
105   MPI2_POINTER PTR_MPI2_RAID_ACTION_START_RAID_FUNCTION,
106   Mpi2RaidActionStartRaidFunction_t,
107   MPI2_POINTER pMpi2RaidActionStartRaidFunction_t;
108 
109 /* defines for the RAIDFunction field */
110 #define MPI2_RAID_ACTION_START_BACKGROUND_INIT      (0x00)
111 #define MPI2_RAID_ACTION_START_ONLINE_CAP_EXPANSION (0x01)
112 #define MPI2_RAID_ACTION_START_CONSISTENCY_CHECK    (0x02)
113 
114 /* defines for the Flags field */
115 #define MPI2_RAID_ACTION_START_NEW                  (0x00)
116 #define MPI2_RAID_ACTION_START_RESUME               (0x01)
117 
118 /* ActionDataWord for MPI2_RAID_ACTION_STOP_RAID_FUNCTION Action */
119 typedef struct _MPI2_RAID_ACTION_STOP_RAID_FUNCTION
120 {
121     U8              RAIDFunction;                       /* 0x00 */
122     U8              Flags;                              /* 0x01 */
123     U16             Reserved1;                          /* 0x02 */
124 } MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
125   MPI2_POINTER PTR_MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
126   Mpi2RaidActionStopRaidFunction_t,
127   MPI2_POINTER pMpi2RaidActionStopRaidFunction_t;
128 
129 /* defines for the RAIDFunction field */
130 #define MPI2_RAID_ACTION_STOP_BACKGROUND_INIT       (0x00)
131 #define MPI2_RAID_ACTION_STOP_ONLINE_CAP_EXPANSION  (0x01)
132 #define MPI2_RAID_ACTION_STOP_CONSISTENCY_CHECK     (0x02)
133 
134 /* defines for the Flags field */
135 #define MPI2_RAID_ACTION_STOP_ABORT                 (0x00)
136 #define MPI2_RAID_ACTION_STOP_PAUSE                 (0x01)
137 
138 /* ActionDataWord for MPI2_RAID_ACTION_CREATE_HOT_SPARE Action */
139 typedef struct _MPI2_RAID_ACTION_HOT_SPARE
140 {
141     U8              HotSparePool;               /* 0x00 */
142     U8              Reserved1;                  /* 0x01 */
143     U16             DevHandle;                  /* 0x02 */
144 } MPI2_RAID_ACTION_HOT_SPARE, MPI2_POINTER PTR_MPI2_RAID_ACTION_HOT_SPARE,
145   Mpi2RaidActionHotSpare_t, MPI2_POINTER pMpi2RaidActionHotSpare_t;
146 
147 /* ActionDataWord for MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE Action */
148 typedef struct _MPI2_RAID_ACTION_FW_UPDATE_MODE
149 {
150     U8              Flags;                              /* 0x00 */
151     U8              DeviceFirmwareUpdateModeTimeout;    /* 0x01 */
152     U16             Reserved1;                          /* 0x02 */
153 } MPI2_RAID_ACTION_FW_UPDATE_MODE,
154   MPI2_POINTER PTR_MPI2_RAID_ACTION_FW_UPDATE_MODE,
155   Mpi2RaidActionFwUpdateMode_t, MPI2_POINTER pMpi2RaidActionFwUpdateMode_t;
156 
157 /* ActionDataWord defines for use with MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE action */
158 #define MPI2_RAID_ACTION_ADATA_DISABLE_FW_UPDATE        (0x00)
159 #define MPI2_RAID_ACTION_ADATA_ENABLE_FW_UPDATE         (0x01)
160 
161 typedef union _MPI2_RAID_ACTION_DATA
162 {
163     U32                                     Word;
164     MPI2_RAID_ACTION_RATE_DATA              Rates;
165     MPI2_RAID_ACTION_START_RAID_FUNCTION    StartRaidFunction;
166     MPI2_RAID_ACTION_STOP_RAID_FUNCTION     StopRaidFunction;
167     MPI2_RAID_ACTION_HOT_SPARE              HotSpare;
168     MPI2_RAID_ACTION_FW_UPDATE_MODE         FwUpdateMode;
169 } MPI2_RAID_ACTION_DATA, MPI2_POINTER PTR_MPI2_RAID_ACTION_DATA,
170   Mpi2RaidActionData_t, MPI2_POINTER pMpi2RaidActionData_t;
171 
172 
173 /* RAID Action Request Message */
174 typedef struct _MPI2_RAID_ACTION_REQUEST
175 {
176     U8                      Action;                         /* 0x00 */
177     U8                      Reserved1;                      /* 0x01 */
178     U8                      ChainOffset;                    /* 0x02 */
179     U8                      Function;                       /* 0x03 */
180     U16                     VolDevHandle;                   /* 0x04 */
181     U8                      PhysDiskNum;                    /* 0x06 */
182     U8                      MsgFlags;                       /* 0x07 */
183     U8                      VP_ID;                          /* 0x08 */
184     U8                      VF_ID;                          /* 0x09 */
185     U16                     Reserved2;                      /* 0x0A */
186     U32                     Reserved3;                      /* 0x0C */
187     MPI2_RAID_ACTION_DATA   ActionDataWord;                 /* 0x10 */
188     MPI2_SGE_SIMPLE_UNION   ActionDataSGE;                  /* 0x14 */
189 } MPI2_RAID_ACTION_REQUEST, MPI2_POINTER PTR_MPI2_RAID_ACTION_REQUEST,
190   Mpi2RaidActionRequest_t, MPI2_POINTER pMpi2RaidActionRequest_t;
191 
192 /* RAID Action request Action values */
193 
194 #define MPI2_RAID_ACTION_INDICATOR_STRUCT           (0x01)
195 #define MPI2_RAID_ACTION_CREATE_VOLUME              (0x02)
196 #define MPI2_RAID_ACTION_DELETE_VOLUME              (0x03)
197 #define MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES        (0x04)
198 #define MPI2_RAID_ACTION_ENABLE_ALL_VOLUMES         (0x05)
199 #define MPI2_RAID_ACTION_PHYSDISK_OFFLINE           (0x0A)
200 #define MPI2_RAID_ACTION_PHYSDISK_ONLINE            (0x0B)
201 #define MPI2_RAID_ACTION_FAIL_PHYSDISK              (0x0F)
202 #define MPI2_RAID_ACTION_ACTIVATE_VOLUME            (0x11)
203 #define MPI2_RAID_ACTION_DEVICE_FW_UPDATE_MODE      (0x15)
204 #define MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE     (0x17)
205 #define MPI2_RAID_ACTION_SET_VOLUME_NAME            (0x18)
206 #define MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE     (0x19)
207 #define MPI2_RAID_ACTION_ENABLE_FAILED_VOLUME       (0x1C)
208 #define MPI2_RAID_ACTION_CREATE_HOT_SPARE           (0x1D)
209 #define MPI2_RAID_ACTION_DELETE_HOT_SPARE           (0x1E)
210 #define MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED  (0x20)
211 #define MPI2_RAID_ACTION_START_RAID_FUNCTION        (0x21)
212 #define MPI2_RAID_ACTION_STOP_RAID_FUNCTION         (0x22)
213 
214 
215 /* RAID Volume Creation Structure */
216 
217 /*
218  * The following define can be customized for the targeted product.
219  */
220 #ifndef MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS
221 #define MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS        (1)
222 #endif
223 
224 typedef struct _MPI2_RAID_VOLUME_PHYSDISK
225 {
226     U8                      RAIDSetNum;                     /* 0x00 */
227     U8                      PhysDiskMap;                    /* 0x01 */
228     U16                     PhysDiskDevHandle;              /* 0x02 */
229 } MPI2_RAID_VOLUME_PHYSDISK, MPI2_POINTER PTR_MPI2_RAID_VOLUME_PHYSDISK,
230   Mpi2RaidVolumePhysDisk_t, MPI2_POINTER pMpi2RaidVolumePhysDisk_t;
231 
232 /* defines for the PhysDiskMap field */
233 #define MPI2_RAIDACTION_PHYSDISK_PRIMARY            (0x01)
234 #define MPI2_RAIDACTION_PHYSDISK_SECONDARY          (0x02)
235 
236 typedef struct _MPI2_RAID_VOLUME_CREATION_STRUCT
237 {
238     U8                          NumPhysDisks;               /* 0x00 */
239     U8                          VolumeType;                 /* 0x01 */
240     U16                         Reserved1;                  /* 0x02 */
241     U32                         VolumeCreationFlags;        /* 0x04 */
242     U32                         VolumeSettings;             /* 0x08 */
243     U8                          Reserved2;                  /* 0x0C */
244     U8                          ResyncRate;                 /* 0x0D */
245     U16                         DataScrubDuration;          /* 0x0E */
246     U64                         VolumeMaxLBA;               /* 0x10 */
247     U32                         StripeSize;                 /* 0x18 */
248     U8                          Name[16];                   /* 0x1C */
249     MPI2_RAID_VOLUME_PHYSDISK   PhysDisk[MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS];/* 0x2C */
250 } MPI2_RAID_VOLUME_CREATION_STRUCT,
251   MPI2_POINTER PTR_MPI2_RAID_VOLUME_CREATION_STRUCT,
252   Mpi2RaidVolumeCreationStruct_t, MPI2_POINTER pMpi2RaidVolumeCreationStruct_t;
253 
254 /* use MPI2_RAID_VOL_TYPE_ defines from mpi2_cnfg.h for VolumeType */
255 
256 /* defines for the VolumeCreationFlags field */
257 #define MPI2_RAID_VOL_CREATION_DEFAULT_SETTINGS     (0x80000000)
258 #define MPI2_RAID_VOL_CREATION_BACKGROUND_INIT      (0x00000004)
259 #define MPI2_RAID_VOL_CREATION_LOW_LEVEL_INIT       (0x00000002)
260 #define MPI2_RAID_VOL_CREATION_MIGRATE_DATA         (0x00000001)
261 /* The following is an obsolete define.
262  * It must be shifted left 24 bits in order to set the proper bit.
263  */
264 #define MPI2_RAID_VOL_CREATION_USE_DEFAULT_SETTINGS (0x80)
265 
266 
267 /* RAID Online Capacity Expansion Structure */
268 
269 typedef struct _MPI2_RAID_ONLINE_CAPACITY_EXPANSION
270 {
271     U32                     Flags;                          /* 0x00 */
272     U16                     DevHandle0;                     /* 0x04 */
273     U16                     Reserved1;                      /* 0x06 */
274     U16                     DevHandle1;                     /* 0x08 */
275     U16                     Reserved2;                      /* 0x0A */
276 } MPI2_RAID_ONLINE_CAPACITY_EXPANSION,
277   MPI2_POINTER PTR_MPI2_RAID_ONLINE_CAPACITY_EXPANSION,
278   Mpi2RaidOnlineCapacityExpansion_t,
279   MPI2_POINTER pMpi2RaidOnlineCapacityExpansion_t;
280 
281 
282 /* RAID Volume Indicator Structure */
283 
284 typedef struct _MPI2_RAID_VOL_INDICATOR
285 {
286     U64                     TotalBlocks;                    /* 0x00 */
287     U64                     BlocksRemaining;                /* 0x08 */
288     U32                     Flags;                          /* 0x10 */
289 } MPI2_RAID_VOL_INDICATOR, MPI2_POINTER PTR_MPI2_RAID_VOL_INDICATOR,
290   Mpi2RaidVolIndicator_t, MPI2_POINTER pMpi2RaidVolIndicator_t;
291 
292 /* defines for RAID Volume Indicator Flags field */
293 #define MPI2_RAID_VOL_FLAGS_OP_MASK                 (0x0000000F)
294 #define MPI2_RAID_VOL_FLAGS_OP_BACKGROUND_INIT      (0x00000000)
295 #define MPI2_RAID_VOL_FLAGS_OP_ONLINE_CAP_EXPANSION (0x00000001)
296 #define MPI2_RAID_VOL_FLAGS_OP_CONSISTENCY_CHECK    (0x00000002)
297 #define MPI2_RAID_VOL_FLAGS_OP_RESYNC               (0x00000003)
298 #define MPI2_RAID_VOL_FLAGS_OP_MDC                  (0x00000004)
299 
300 
301 /* RAID Action Reply ActionData union */
302 typedef union _MPI2_RAID_ACTION_REPLY_DATA
303 {
304     U32                     Word[5];
305     MPI2_RAID_VOL_INDICATOR RaidVolumeIndicator;
306     U16                     VolDevHandle;
307     U8                      VolumeState;
308     U8                      PhysDiskNum;
309 } MPI2_RAID_ACTION_REPLY_DATA, MPI2_POINTER PTR_MPI2_RAID_ACTION_REPLY_DATA,
310   Mpi2RaidActionReplyData_t, MPI2_POINTER pMpi2RaidActionReplyData_t;
311 
312 /* use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
313 
314 
315 /* RAID Action Reply Message */
316 typedef struct _MPI2_RAID_ACTION_REPLY
317 {
318     U8                          Action;                     /* 0x00 */
319     U8                          Reserved1;                  /* 0x01 */
320     U8                          MsgLength;                  /* 0x02 */
321     U8                          Function;                   /* 0x03 */
322     U16                         VolDevHandle;               /* 0x04 */
323     U8                          PhysDiskNum;                /* 0x06 */
324     U8                          MsgFlags;                   /* 0x07 */
325     U8                          VP_ID;                      /* 0x08 */
326     U8                          VF_ID;                      /* 0x09 */
327     U16                         Reserved2;                  /* 0x0A */
328     U16                         Reserved3;                  /* 0x0C */
329     U16                         IOCStatus;                  /* 0x0E */
330     U32                         IOCLogInfo;                 /* 0x10 */
331     MPI2_RAID_ACTION_REPLY_DATA ActionData;                 /* 0x14 */
332 } MPI2_RAID_ACTION_REPLY, MPI2_POINTER PTR_MPI2_RAID_ACTION_REPLY,
333   Mpi2RaidActionReply_t, MPI2_POINTER pMpi2RaidActionReply_t;
334 
335 
336 #endif
337 
338