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