Merge branch 'vendor/GCC44'
[dragonfly.git] / sys / dev / disk / mpt / mpilib / mpi_init.h
1 /* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_init.h,v 1.1.2.2 2002/09/01 23:08:06 mjacob Exp $ */
2 /* $DragonFly: src/sys/dev/disk/mpt/mpilib/mpi_init.h,v 1.2 2003/06/17 04:28:28 dillon Exp $ */
3 /*
4  * Copyright (c) 2000, 2001 by LSI Logic Corporation
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 immediately at the beginning of the file, without modification,
11  *    this list of conditions, and the following disclaimer.
12  * 2. The name of the author may not be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
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 FOR
19  * 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  *
28  *           Name:  MPI_INIT.H
29  *          Title:  MPI initiator mode messages and structures
30  *  Creation Date:  June 8, 2000
31  *
32  *    MPI Version:  01.02.04
33  *
34  *  Version History
35  *  ---------------
36  *
37  *  Date      Version   Description
38  *  --------  --------  ------------------------------------------------------
39  *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
40  *  05-24-00  00.10.02  Added SenseBufferLength to _MSG_SCSI_IO_REPLY.
41  *  06-06-00  01.00.01  Update version number for 1.0 release.
42  *  06-08-00  01.00.02  Added MPI_SCSI_RSP_INFO_ definitions.
43  *  11-02-00  01.01.01  Original release for post 1.0 work.
44  *  12-04-00  01.01.02  Added MPI_SCSIIO_CONTROL_NO_DISCONNECT.
45  *  02-20-01  01.01.03  Started using MPI_POINTER.
46  *  03-27-01  01.01.04  Added structure offset comments.
47  *  04-10-01  01.01.05  Added new MsgFlag for MSG_SCSI_TASK_MGMT.
48  *  08-08-01  01.02.01  Original release for v1.2 work.
49  *  08-29-01  01.02.02  Added MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET.
50  *                      Added MPI_SCSI_STATE_QUEUE_TAG_REJECTED for
51  *                      MSG_SCSI_IO_REPLY.
52  *  09-28-01  01.02.03  Added structures and defines for SCSI Enclosure
53  *                      Processor messages.
54  *  10-04-01  01.02.04  Added defines for SEP request Action field.
55  *  --------------------------------------------------------------------------
56  */
57
58 #ifndef MPI_INIT_H
59 #define MPI_INIT_H
60
61
62 /*****************************************************************************
63 *
64 *               S C S I    I n i t i a t o r    M e s s a g e s
65 *
66 *****************************************************************************/
67
68 /****************************************************************************/
69 /*  SCSI IO messages and assocaited structures                              */
70 /****************************************************************************/
71
72 typedef struct _MSG_SCSI_IO_REQUEST
73 {
74     U8                      TargetID;           /* 00h */
75     U8                      Bus;                /* 01h */
76     U8                      ChainOffset;        /* 02h */
77     U8                      Function;           /* 03h */
78     U8                      CDBLength;          /* 04h */
79     U8                      SenseBufferLength;  /* 05h */
80     U8                      Reserved;           /* 06h */
81     U8                      MsgFlags;           /* 07h */
82     U32                     MsgContext;         /* 08h */
83     U8                      LUN[8];             /* 0Ch */
84     U32                     Control;            /* 14h */
85     U8                      CDB[16];            /* 18h */
86     U32                     DataLength;         /* 28h */
87     U32                     SenseBufferLowAddr; /* 2Ch */
88     SGE_IO_UNION            SGL;                /* 30h */
89 } MSG_SCSI_IO_REQUEST, MPI_POINTER PTR_MSG_SCSI_IO_REQUEST,
90   SCSIIORequest_t, MPI_POINTER pSCSIIORequest_t;
91
92
93 /* SCSIO MsgFlags bits */
94
95 #define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH          (0x01)
96 #define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32       (0x00)
97 #define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64       (0x01)
98 #define MPI_SCSIIO_MSGFLGS_SENSE_LOCATION       (0x02)
99 #define MPI_SCSIIO_MSGFLGS_SENSE_LOC_HOST       (0x00)
100 #define MPI_SCSIIO_MSGFLGS_SENSE_LOC_IOC        (0x02)
101
102 /* SCSIIO LUN fields */
103
104 #define MPI_SCSIIO_LUN_FIRST_LEVEL_ADDRESSING   (0x0000FFFF)
105 #define MPI_SCSIIO_LUN_SECOND_LEVEL_ADDRESSING  (0xFFFF0000)
106 #define MPI_SCSIIO_LUN_THIRD_LEVEL_ADDRESSING   (0x0000FFFF)
107 #define MPI_SCSIIO_LUN_FOURTH_LEVEL_ADDRESSING  (0xFFFF0000)
108 #define MPI_SCSIIO_LUN_LEVEL_1_WORD             (0xFF00)
109 #define MPI_SCSIIO_LUN_LEVEL_1_DWORD            (0x0000FF00)
110
111 /* SCSIO Control bits */
112
113 #define MPI_SCSIIO_CONTROL_DATADIRECTION_MASK   (0x03000000)
114 #define MPI_SCSIIO_CONTROL_NODATATRANSFER       (0x00000000)
115 #define MPI_SCSIIO_CONTROL_WRITE                (0x01000000)
116 #define MPI_SCSIIO_CONTROL_READ                 (0x02000000)
117
118 #define MPI_SCSIIO_CONTROL_ADDCDBLEN_MASK       (0x3C000000)
119 #define MPI_SCSIIO_CONTROL_ADDCDBLEN_SHIFT      (26)
120
121 #define MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK   (0x00000700)
122 #define MPI_SCSIIO_CONTROL_SIMPLEQ              (0x00000000)
123 #define MPI_SCSIIO_CONTROL_HEADOFQ              (0x00000100)
124 #define MPI_SCSIIO_CONTROL_ORDEREDQ             (0x00000200)
125 #define MPI_SCSIIO_CONTROL_ACAQ                 (0x00000400)
126 #define MPI_SCSIIO_CONTROL_UNTAGGED             (0x00000500)
127 #define MPI_SCSIIO_CONTROL_NO_DISCONNECT        (0x00000700)
128
129 #define MPI_SCSIIO_CONTROL_TASKMANAGE_MASK      (0x00FF0000)
130 #define MPI_SCSIIO_CONTROL_OBSOLETE             (0x00800000)
131 #define MPI_SCSIIO_CONTROL_CLEAR_ACA_RSV        (0x00400000)
132 #define MPI_SCSIIO_CONTROL_TARGET_RESET         (0x00200000)
133 #define MPI_SCSIIO_CONTROL_LUN_RESET_RSV        (0x00100000)
134 #define MPI_SCSIIO_CONTROL_RESERVED             (0x00080000)
135 #define MPI_SCSIIO_CONTROL_CLR_TASK_SET_RSV     (0x00040000)
136 #define MPI_SCSIIO_CONTROL_ABORT_TASK_SET       (0x00020000)
137 #define MPI_SCSIIO_CONTROL_RESERVED2            (0x00010000)
138
139
140 /* SCSIIO reply structure */
141 typedef struct _MSG_SCSI_IO_REPLY
142 {
143     U8                      TargetID;           /* 00h */
144     U8                      Bus;                /* 01h */
145     U8                      MsgLength;          /* 02h */
146     U8                      Function;           /* 03h */
147     U8                      CDBLength;          /* 04h */
148     U8                      SenseBufferLength;  /* 05h */
149     U8                      Reserved;           /* 06h */
150     U8                      MsgFlags;           /* 07h */
151     U32                     MsgContext;         /* 08h */
152     U8                      SCSIStatus;         /* 0Ch */
153     U8                      SCSIState;          /* 0Dh */
154     U16                     IOCStatus;          /* 0Eh */
155     U32                     IOCLogInfo;         /* 10h */
156     U32                     TransferCount;      /* 14h */
157     U32                     SenseCount;         /* 18h */
158     U32                     ResponseInfo;       /* 1Ch */
159 } MSG_SCSI_IO_REPLY, MPI_POINTER PTR_MSG_SCSI_IO_REPLY,
160   SCSIIOReply_t, MPI_POINTER pSCSIIOReply_t;
161
162
163 /* SCSIIO Reply SCSIStatus values (SAM-2 status codes) */
164
165 #define MPI_SCSI_STATUS_SUCCESS                 (0x00)
166 #define MPI_SCSI_STATUS_CHECK_CONDITION         (0x02)
167 #define MPI_SCSI_STATUS_CONDITION_MET           (0x04)
168 #define MPI_SCSI_STATUS_BUSY                    (0x08)
169 #define MPI_SCSI_STATUS_INTERMEDIATE            (0x10)
170 #define MPI_SCSI_STATUS_INTERMEDIATE_CONDMET    (0x14)
171 #define MPI_SCSI_STATUS_RESERVATION_CONFLICT    (0x18)
172 #define MPI_SCSI_STATUS_COMMAND_TERMINATED      (0x22)
173 #define MPI_SCSI_STATUS_TASK_SET_FULL           (0x28)
174 #define MPI_SCSI_STATUS_ACA_ACTIVE              (0x30)
175
176
177 /* SCSIIO Reply SCSIState values */
178
179 #define MPI_SCSI_STATE_AUTOSENSE_VALID          (0x01)
180 #define MPI_SCSI_STATE_AUTOSENSE_FAILED         (0x02)
181 #define MPI_SCSI_STATE_NO_SCSI_STATUS           (0x04)
182 #define MPI_SCSI_STATE_TERMINATED               (0x08)
183 #define MPI_SCSI_STATE_RESPONSE_INFO_VALID      (0x10)
184 #define MPI_SCSI_STATE_QUEUE_TAG_REJECTED       (0x20)
185
186 /* SCSIIO Reply ResponseInfo values */
187 /* (FCP-1 RSP_CODE values and SPI-3 Packetized Failure codes) */
188
189 #define MPI_SCSI_RSP_INFO_FUNCTION_COMPLETE     (0x00000000)
190 #define MPI_SCSI_RSP_INFO_FCP_BURST_LEN_ERROR   (0x01000000)
191 #define MPI_SCSI_RSP_INFO_CMND_FIELDS_INVALID   (0x02000000)
192 #define MPI_SCSI_RSP_INFO_FCP_DATA_RO_ERROR     (0x03000000)
193 #define MPI_SCSI_RSP_INFO_TASK_MGMT_UNSUPPORTED (0x04000000)
194 #define MPI_SCSI_RSP_INFO_TASK_MGMT_FAILED      (0x05000000)
195 #define MPI_SCSI_RSP_INFO_SPI_LQ_INVALID_TYPE   (0x06000000)
196
197
198 /****************************************************************************/
199 /*  SCSI Task Management messages                                           */
200 /****************************************************************************/
201
202 typedef struct _MSG_SCSI_TASK_MGMT
203 {
204     U8                      TargetID;           /* 00h */
205     U8                      Bus;                /* 01h */
206     U8                      ChainOffset;        /* 02h */
207     U8                      Function;           /* 03h */
208     U8                      Reserved;           /* 04h */
209     U8                      TaskType;           /* 05h */
210     U8                      Reserved1;          /* 06h */
211     U8                      MsgFlags;           /* 07h */
212     U32                     MsgContext;         /* 08h */
213     U8                      LUN[8];             /* 0Ch */
214     U32                     Reserved2[7];       /* 14h */
215     U32                     TaskMsgContext;     /* 30h */
216 } MSG_SCSI_TASK_MGMT, MPI_POINTER PTR_SCSI_TASK_MGMT,
217   SCSITaskMgmt_t, MPI_POINTER pSCSITaskMgmt_t;
218
219 /* TaskType values */
220
221 #define MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK            (0x01)
222 #define MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET         (0x02)
223 #define MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET          (0x03)
224 #define MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS             (0x04)
225 #define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET    (0x05)
226
227 /* MsgFlags bits */
228 #define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION   (0x00)
229 #define MPI_SCSITASKMGMT_MSGFLAGS_LIP_RESET_OPTION      (0x02)
230 #define MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION (0x04)
231
232 /* SCSI Task Management Reply */
233 typedef struct _MSG_SCSI_TASK_MGMT_REPLY
234 {
235     U8                      TargetID;           /* 00h */
236     U8                      Bus;                /* 01h */
237     U8                      MsgLength;          /* 02h */
238     U8                      Function;           /* 03h */
239     U8                      Reserved;           /* 04h */
240     U8                      TaskType;           /* 05h */
241     U8                      Reserved1;          /* 06h */
242     U8                      MsgFlags;           /* 07h */
243     U32                     MsgContext;         /* 08h */
244     U8                      Reserved2[2];       /* 0Ch */
245     U16                     IOCStatus;          /* 0Eh */
246     U32                     IOCLogInfo;         /* 10h */
247     U32                     TerminationCount;   /* 14h */
248 } MSG_SCSI_TASK_MGMT_REPLY, MPI_POINTER PTR_MSG_SCSI_TASK_MGMT_REPLY,
249   SCSITaskMgmtReply_t, MPI_POINTER pSCSITaskMgmtReply_t;
250
251
252 /****************************************************************************/
253 /*  SCSI Enclosure Processor messages                                       */
254 /****************************************************************************/
255
256 typedef struct _MSG_SEP_REQUEST
257 {
258     U8                      TargetID;           /* 00h */
259     U8                      Bus;                /* 01h */
260     U8                      ChainOffset;        /* 02h */
261     U8                      Function;           /* 03h */
262     U8                      Action;             /* 04h */
263     U8                      Reserved1;          /* 05h */
264     U8                      Reserved2;          /* 06h */
265     U8                      MsgFlags;           /* 07h */
266     U32                     MsgContext;         /* 08h */
267     U32                     SlotStatus;         /* 0Ch */
268 } MSG_SEP_REQUEST, MPI_POINTER PTR_MSG_SEP_REQUEST,
269   SEPRequest_t, MPI_POINTER pSEPRequest_t;
270
271 /* Action defines */
272 #define MPI_SEP_REQ_ACTION_WRITE_STATUS                 (0x00)
273 #define MPI_SEP_REQ_ACTION_READ_STATUS                  (0x01)
274
275 /* SlotStatus bits for MSG_SEP_REQUEST */
276 #define MPI_SEP_REQ_SLOTSTATUS_NO_ERROR                 (0x00000001)
277 #define MPI_SEP_REQ_SLOTSTATUS_DEV_FAULTY               (0x00000002)
278 #define MPI_SEP_REQ_SLOTSTATUS_DEV_REBUILDING           (0x00000004)
279 #define MPI_SEP_REQ_SLOTSTATUS_IN_FAILED_ARRAY          (0x00000008)
280 #define MPI_SEP_REQ_SLOTSTATUS_IN_CRITICAL_ARRAY        (0x00000010)
281 #define MPI_SEP_REQ_SLOTSTATUS_PARITY_CHECK             (0x00000020)
282 #define MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT          (0x00000040)
283 #define MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED             (0x00000080)
284 #define MPI_SEP_REQ_SLOTSTATUS_HOT_SPARE                (0x00000100)
285 #define MPI_SEP_REQ_SLOTSTATUS_REBUILD_STOPPED          (0x00000200)
286 #define MPI_SEP_REQ_SLOTSTATUS_IDENTIFY_REQUEST         (0x00020000)
287 #define MPI_SEP_REQ_SLOTSTATUS_REQUEST_REMOVE           (0x00040000)
288 #define MPI_SEP_REQ_SLOTSTATUS_REQUEST_INSERT           (0x00080000)
289 #define MPI_SEP_REQ_SLOTSTATUS_DO_NOT_MOVE              (0x00400000)
290 #define MPI_SEP_REQ_SLOTSTATUS_B_ENABLE_BYPASS          (0x04000000)
291 #define MPI_SEP_REQ_SLOTSTATUS_A_ENABLE_BYPASS          (0x08000000)
292 #define MPI_SEP_REQ_SLOTSTATUS_DEV_OFF                  (0x10000000)
293 #define MPI_SEP_REQ_SLOTSTATUS_SWAP_RESET               (0x80000000)
294
295
296 typedef struct _MSG_SEP_REPLY
297 {
298     U8                      TargetID;           /* 00h */
299     U8                      Bus;                /* 01h */
300     U8                      MsgLength;          /* 02h */
301     U8                      Function;           /* 03h */
302     U8                      Action;             /* 04h */
303     U8                      Reserved1;          /* 05h */
304     U8                      Reserved2;          /* 06h */
305     U8                      MsgFlags;           /* 07h */
306     U32                     MsgContext;         /* 08h */
307     U16                     Reserved3;          /* 0Ch */
308     U16                     IOCStatus;          /* 0Eh */
309     U32                     IOCLogInfo;         /* 10h */
310     U32                     SlotStatus;         /* 14h */
311 } MSG_SEP_REPLY, MPI_POINTER PTR_MSG_SEP_REPLY,
312   SEPReply_t, MPI_POINTER pSEPReply_t;
313
314 /* SlotStatus bits for MSG_SEP_REPLY */
315 #define MPI_SEP_REPLY_SLOTSTATUS_NO_ERROR               (0x00000001)
316 #define MPI_SEP_REPLY_SLOTSTATUS_DEV_FAULTY             (0x00000002)
317 #define MPI_SEP_REPLY_SLOTSTATUS_DEV_REBUILDING         (0x00000004)
318 #define MPI_SEP_REPLY_SLOTSTATUS_IN_FAILED_ARRAY        (0x00000008)
319 #define MPI_SEP_REPLY_SLOTSTATUS_IN_CRITICAL_ARRAY      (0x00000010)
320 #define MPI_SEP_REPLY_SLOTSTATUS_PARITY_CHECK           (0x00000020)
321 #define MPI_SEP_REPLY_SLOTSTATUS_PREDICTED_FAULT        (0x00000040)
322 #define MPI_SEP_REPLY_SLOTSTATUS_UNCONFIGURED           (0x00000080)
323 #define MPI_SEP_REPLY_SLOTSTATUS_HOT_SPARE              (0x00000100)
324 #define MPI_SEP_REPLY_SLOTSTATUS_REBUILD_STOPPED        (0x00000200)
325 #define MPI_SEP_REPLY_SLOTSTATUS_REPORT                 (0x00010000)
326 #define MPI_SEP_REPLY_SLOTSTATUS_IDENTIFY_REQUEST       (0x00020000)
327 #define MPI_SEP_REPLY_SLOTSTATUS_REMOVE_READY           (0x00040000)
328 #define MPI_SEP_REPLY_SLOTSTATUS_INSERT_READY           (0x00080000)
329 #define MPI_SEP_REPLY_SLOTSTATUS_DO_NOT_REMOVE          (0x00400000)
330 #define MPI_SEP_REPLY_SLOTSTATUS_B_BYPASS_ENABLED       (0x01000000)
331 #define MPI_SEP_REPLY_SLOTSTATUS_A_BYPASS_ENABLED       (0x02000000)
332 #define MPI_SEP_REPLY_SLOTSTATUS_B_ENABLE_BYPASS        (0x04000000)
333 #define MPI_SEP_REPLY_SLOTSTATUS_A_ENABLE_BYPASS        (0x08000000)
334 #define MPI_SEP_REPLY_SLOTSTATUS_DEV_OFF                (0x10000000)
335 #define MPI_SEP_REPLY_SLOTSTATUS_FAULT_SENSED           (0x40000000)
336 #define MPI_SEP_REPLY_SLOTSTATUS_SWAPPED                (0x80000000)
337
338 #endif