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