xref: /freebsd/sys/dev/mpt/mpilib/mpi.h (revision f4f33ea0c752ff0f9bfad34991d5bbb54e71133d)
1 /* $FreeBSD$ */
2 /*-
3  * SPDX-License-Identifier: BSD-3-Clause
4  *
5  * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors.
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 are
10  * 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 at minimum a disclaimer
14  *    substantially similar to the "NO WARRANTY" disclaimer below
15  *    ("Disclaimer") and any redistribution must be conditioned upon including
16  *    a substantially similar Disclaimer requirement for further binary
17  *    redistribution.
18  * 3. Neither the name of the LSI Logic Corporation nor the names of its
19  *    contributors may be used to endorse or promote products derived from
20  *    this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
32  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *           Name:  mpi.h
35  *          Title:  MPI Message independent structures and definitions
36  *  Creation Date:  July 27, 2000
37  *
38  *    mpi.h Version:  01.05.17
39  *
40  *  Version History
41  *  ---------------
42  *
43  *  Date      Version   Description
44  *  --------  --------  ------------------------------------------------------
45  *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
46  *  05-24-00  00.10.02  Added MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH definition.
47  *  06-06-00  01.00.01  Update MPI_VERSION_MAJOR and MPI_VERSION_MINOR.
48  *  06-22-00  01.00.02  Added MPI_IOCSTATUS_LAN_ definitions.
49  *                      Removed LAN_SUSPEND function definition.
50  *                      Added MPI_MSGFLAGS_CONTINUATION_REPLY definition.
51  *  06-30-00  01.00.03  Added MPI_CONTEXT_REPLY_TYPE_LAN definition.
52  *                      Added MPI_GET/SET_CONTEXT_REPLY_TYPE macros.
53  *  07-27-00  01.00.04  Added MPI_FAULT_ definitions.
54  *                      Removed MPI_IOCSTATUS_MSG/DATA_XFER_ERROR definitions.
55  *                      Added MPI_IOCSTATUS_INTERNAL_ERROR definition.
56  *                      Added MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH.
57  *  11-02-00  01.01.01  Original release for post 1.0 work.
58  *  12-04-00  01.01.02  Added new function codes.
59  *  01-09-01  01.01.03  Added more definitions to the system interface section
60  *                      Added MPI_IOCSTATUS_TARGET_STS_DATA_NOT_SENT.
61  *  01-25-01  01.01.04  Changed MPI_VERSION_MINOR from 0x00 to 0x01.
62  *  02-20-01  01.01.05  Started using MPI_POINTER.
63  *                      Fixed value for MPI_DIAG_RW_ENABLE.
64  *                      Added defines for MPI_DIAG_PREVENT_IOC_BOOT and
65  *                      MPI_DIAG_CLEAR_FLASH_BAD_SIG.
66  *                      Obsoleted MPI_IOCSTATUS_TARGET_FC_ defines.
67  *  02-27-01  01.01.06  Removed MPI_HOST_INDEX_REGISTER define.
68  *                      Added function codes for RAID.
69  *  04-09-01  01.01.07  Added alternate define for MPI_DOORBELL_ACTIVE,
70  *                      MPI_DOORBELL_USED, to better match the spec.
71  *  08-08-01  01.02.01  Original release for v1.2 work.
72  *                      Changed MPI_VERSION_MINOR from 0x01 to 0x02.
73  *                      Added define MPI_FUNCTION_TOOLBOX.
74  *  09-28-01  01.02.02  New function code MPI_SCSI_ENCLOSURE_PROCESSOR.
75  *  11-01-01  01.02.03  Changed name to MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR.
76  *  03-14-02  01.02.04  Added MPI_HEADER_VERSION_ defines.
77  *  05-31-02  01.02.05  Bumped MPI_HEADER_VERSION_UNIT.
78  *  07-12-02  01.02.06  Added define for MPI_FUNCTION_MAILBOX.
79  *  09-16-02  01.02.07  Bumped value for MPI_HEADER_VERSION_UNIT.
80  *  11-15-02  01.02.08  Added define MPI_IOCSTATUS_TARGET_INVALID_IO_INDEX and
81  *                      obsoleted define MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX.
82  *  04-01-03  01.02.09  New IOCStatus code: MPI_IOCSTATUS_FC_EXCHANGE_CANCELED
83  *  06-26-03  01.02.10  Bumped MPI_HEADER_VERSION_UNIT value.
84  *  01-16-04  01.02.11  Added define for MPI_IOCLOGINFO_TYPE_SHIFT.
85  *  04-29-04  01.02.12  Added function codes for MPI_FUNCTION_DIAG_BUFFER_POST
86  *                      and MPI_FUNCTION_DIAG_RELEASE.
87  *                      Added MPI_IOCSTATUS_DIAGNOSTIC_RELEASED define.
88  *                      Bumped MPI_HEADER_VERSION_UNIT value.
89  *  05-11-04  01.03.01  Bumped MPI_VERSION_MINOR for MPI v1.3.
90  *                      Added codes for Inband.
91  *  08-19-04  01.05.01  Added defines for Host Buffer Access Control doorbell.
92  *                      Added define for offset of High Priority Request Queue.
93  *                      Added new function codes and new IOCStatus codes.
94  *                      Added a IOCLogInfo type of SAS.
95  *  12-07-04  01.05.02  Bumped MPI_HEADER_VERSION_UNIT.
96  *  12-09-04  01.05.03  Bumped MPI_HEADER_VERSION_UNIT.
97  *  01-15-05  01.05.04  Bumped MPI_HEADER_VERSION_UNIT.
98  *  02-09-05  01.05.05  Bumped MPI_HEADER_VERSION_UNIT.
99  *  02-22-05  01.05.06  Bumped MPI_HEADER_VERSION_UNIT.
100  *  03-11-05  01.05.07  Removed function codes for SCSI IO 32 and
101  *                      TargetAssistExtended requests.
102  *                      Removed EEDP IOCStatus codes.
103  *  06-24-05  01.05.08  Added function codes for SCSI IO 32 and
104  *                      TargetAssistExtended requests.
105  *                      Added EEDP IOCStatus codes.
106  *  08-03-05  01.05.09  Bumped MPI_HEADER_VERSION_UNIT.
107  *  08-30-05  01.05.10  Added 2 new IOCStatus codes for Target.
108  *  03-27-06  01.05.11  Bumped MPI_HEADER_VERSION_UNIT.
109  *  10-11-06  01.05.12  Bumped MPI_HEADER_VERSION_UNIT.
110  *  05-24-07  01.05.13  Bumped MPI_HEADER_VERSION_UNIT.
111  *  08-07-07  01.05.14  Bumped MPI_HEADER_VERSION_UNIT.
112  *  01-15-08  01.05.15  Bumped MPI_HEADER_VERSION_UNIT.
113  *  03-28-08  01.05.16  Bumped MPI_HEADER_VERSION_UNIT.
114  *  07-11-08  01.05.17  Bumped MPI_HEADER_VERSION_UNIT.
115  *  --------------------------------------------------------------------------
116  */
117 
118 #ifndef MPI_H
119 #define MPI_H
120 
121 
122 /*****************************************************************************
123 *
124 *        M P I    V e r s i o n    D e f i n i t i o n s
125 *
126 *****************************************************************************/
127 
128 #define MPI_VERSION_MAJOR                   (0x01)
129 #define MPI_VERSION_MINOR                   (0x05)
130 #define MPI_VERSION_MAJOR_MASK              (0xFF00)
131 #define MPI_VERSION_MAJOR_SHIFT             (8)
132 #define MPI_VERSION_MINOR_MASK              (0x00FF)
133 #define MPI_VERSION_MINOR_SHIFT             (0)
134 #define MPI_VERSION ((MPI_VERSION_MAJOR << MPI_VERSION_MAJOR_SHIFT) |   \
135                                       MPI_VERSION_MINOR)
136 
137 #define MPI_VERSION_01_00                   (0x0100)
138 #define MPI_VERSION_01_01                   (0x0101)
139 #define MPI_VERSION_01_02                   (0x0102)
140 #define MPI_VERSION_01_03                   (0x0103)
141 #define MPI_VERSION_01_05                   (0x0105)
142 /* Note: The major versions of 0xe0 through 0xff are reserved */
143 
144 /* versioning for this MPI header set */
145 #define MPI_HEADER_VERSION_UNIT             (0x14)
146 #define MPI_HEADER_VERSION_DEV              (0x00)
147 #define MPI_HEADER_VERSION_UNIT_MASK        (0xFF00)
148 #define MPI_HEADER_VERSION_UNIT_SHIFT       (8)
149 #define MPI_HEADER_VERSION_DEV_MASK         (0x00FF)
150 #define MPI_HEADER_VERSION_DEV_SHIFT        (0)
151 #define MPI_HEADER_VERSION ((MPI_HEADER_VERSION_UNIT << 8) | MPI_HEADER_VERSION_DEV)
152 
153 /*****************************************************************************
154 *
155 *        I O C    S t a t e    D e f i n i t i o n s
156 *
157 *****************************************************************************/
158 
159 #define MPI_IOC_STATE_RESET                 (0x00000000)
160 #define MPI_IOC_STATE_READY                 (0x10000000)
161 #define MPI_IOC_STATE_OPERATIONAL           (0x20000000)
162 #define MPI_IOC_STATE_FAULT                 (0x40000000)
163 
164 #define MPI_IOC_STATE_MASK                  (0xF0000000)
165 #define MPI_IOC_STATE_SHIFT                 (28)
166 
167 /* Fault state codes (product independent range 0x8000-0xFFFF) */
168 
169 #define MPI_FAULT_REQUEST_MESSAGE_PCI_PARITY_ERROR  (0x8111)
170 #define MPI_FAULT_REQUEST_MESSAGE_PCI_BUS_FAULT     (0x8112)
171 #define MPI_FAULT_REPLY_MESSAGE_PCI_PARITY_ERROR    (0x8113)
172 #define MPI_FAULT_REPLY_MESSAGE_PCI_BUS_FAULT       (0x8114)
173 #define MPI_FAULT_DATA_SEND_PCI_PARITY_ERROR        (0x8115)
174 #define MPI_FAULT_DATA_SEND_PCI_BUS_FAULT           (0x8116)
175 #define MPI_FAULT_DATA_RECEIVE_PCI_PARITY_ERROR     (0x8117)
176 #define MPI_FAULT_DATA_RECEIVE_PCI_BUS_FAULT        (0x8118)
177 
178 
179 /*****************************************************************************
180 *
181 *        P C I    S y s t e m    I n t e r f a c e    R e g i s t e r s
182 *
183 *****************************************************************************/
184 
185 /*
186  * Defines for working with the System Doorbell register.
187  * Values for doorbell function codes are included in the section that defines
188  * all the function codes (further on in this file).
189  */
190 #define MPI_DOORBELL_OFFSET                 (0x00000000)
191 #define MPI_DOORBELL_ACTIVE                 (0x08000000) /* DoorbellUsed */
192 #define MPI_DOORBELL_USED                   (MPI_DOORBELL_ACTIVE)
193 #define MPI_DOORBELL_ACTIVE_SHIFT           (27)
194 #define MPI_DOORBELL_WHO_INIT_MASK          (0x07000000)
195 #define MPI_DOORBELL_WHO_INIT_SHIFT         (24)
196 #define MPI_DOORBELL_FUNCTION_MASK          (0xFF000000)
197 #define MPI_DOORBELL_FUNCTION_SHIFT         (24)
198 #define MPI_DOORBELL_ADD_DWORDS_MASK        (0x00FF0000)
199 #define MPI_DOORBELL_ADD_DWORDS_SHIFT       (16)
200 #define MPI_DOORBELL_DATA_MASK              (0x0000FFFF)
201 #define MPI_DOORBELL_FUNCTION_SPECIFIC_MASK (0x0000FFFF)
202 
203 /* values for Host Buffer Access Control doorbell function */
204 #define MPI_DB_HPBAC_VALUE_MASK             (0x0000F000)
205 #define MPI_DB_HPBAC_ENABLE_ACCESS          (0x01)
206 #define MPI_DB_HPBAC_DISABLE_ACCESS         (0x02)
207 #define MPI_DB_HPBAC_FREE_BUFFER            (0x03)
208 
209 
210 #define MPI_WRITE_SEQUENCE_OFFSET           (0x00000004)
211 #define MPI_WRSEQ_KEY_VALUE_MASK            (0x0000000F)
212 #define MPI_WRSEQ_1ST_KEY_VALUE             (0x04)
213 #define MPI_WRSEQ_2ND_KEY_VALUE             (0x0B)
214 #define MPI_WRSEQ_3RD_KEY_VALUE             (0x02)
215 #define MPI_WRSEQ_4TH_KEY_VALUE             (0x07)
216 #define MPI_WRSEQ_5TH_KEY_VALUE             (0x0D)
217 
218 #define MPI_DIAGNOSTIC_OFFSET               (0x00000008)
219 #define MPI_DIAG_CLEAR_FLASH_BAD_SIG        (0x00000400)
220 #define MPI_DIAG_PREVENT_IOC_BOOT           (0x00000200)
221 #define MPI_DIAG_DRWE                       (0x00000080)
222 #define MPI_DIAG_FLASH_BAD_SIG              (0x00000040)
223 #define MPI_DIAG_RESET_HISTORY              (0x00000020)
224 #define MPI_DIAG_RW_ENABLE                  (0x00000010)
225 #define MPI_DIAG_RESET_ADAPTER              (0x00000004)
226 #define MPI_DIAG_DISABLE_ARM                (0x00000002)
227 #define MPI_DIAG_MEM_ENABLE                 (0x00000001)
228 
229 #define MPI_TEST_BASE_ADDRESS_OFFSET        (0x0000000C)
230 
231 #define MPI_DIAG_RW_DATA_OFFSET             (0x00000010)
232 
233 #define MPI_DIAG_RW_ADDRESS_OFFSET          (0x00000014)
234 
235 #define MPI_HOST_INTERRUPT_STATUS_OFFSET    (0x00000030)
236 #define MPI_HIS_IOP_DOORBELL_STATUS         (0x80000000)
237 #define MPI_HIS_REPLY_MESSAGE_INTERRUPT     (0x00000008)
238 #define MPI_HIS_DOORBELL_INTERRUPT          (0x00000001)
239 
240 #define MPI_HOST_INTERRUPT_MASK_OFFSET      (0x00000034)
241 #define MPI_HIM_RIM                         (0x00000008)
242 #define MPI_HIM_DIM                         (0x00000001)
243 
244 #define MPI_REQUEST_QUEUE_OFFSET            (0x00000040)
245 #define MPI_REQUEST_POST_FIFO_OFFSET        (0x00000040)
246 
247 #define MPI_REPLY_QUEUE_OFFSET              (0x00000044)
248 #define MPI_REPLY_POST_FIFO_OFFSET          (0x00000044)
249 #define MPI_REPLY_FREE_FIFO_OFFSET          (0x00000044)
250 
251 #define MPI_HI_PRI_REQUEST_QUEUE_OFFSET     (0x00000048)
252 
253 
254 
255 /*****************************************************************************
256 *
257 *        M e s s a g e    F r a m e    D e s c r i p t o r s
258 *
259 *****************************************************************************/
260 
261 #define MPI_REQ_MF_DESCRIPTOR_NB_MASK       (0x00000003)
262 #define MPI_REQ_MF_DESCRIPTOR_F_BIT         (0x00000004)
263 #define MPI_REQ_MF_DESCRIPTOR_ADDRESS_MASK  (0xFFFFFFF8)
264 
265 #define MPI_ADDRESS_REPLY_A_BIT             (0x80000000)
266 #define MPI_ADDRESS_REPLY_ADDRESS_MASK      (0x7FFFFFFF)
267 
268 #define MPI_CONTEXT_REPLY_A_BIT             (0x80000000)
269 #define MPI_CONTEXT_REPLY_TYPE_MASK         (0x60000000)
270 #define MPI_CONTEXT_REPLY_TYPE_SCSI_INIT    (0x00)
271 #define MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET  (0x01)
272 #define MPI_CONTEXT_REPLY_TYPE_LAN          (0x02)
273 #define MPI_CONTEXT_REPLY_TYPE_SHIFT        (29)
274 #define MPI_CONTEXT_REPLY_CONTEXT_MASK      (0x1FFFFFFF)
275 
276 
277 /****************************************************************************/
278 /* Context Reply macros                                                     */
279 /****************************************************************************/
280 
281 #define MPI_GET_CONTEXT_REPLY_TYPE(x)  (((x) & MPI_CONTEXT_REPLY_TYPE_MASK) \
282                                           >> MPI_CONTEXT_REPLY_TYPE_SHIFT)
283 
284 #define MPI_SET_CONTEXT_REPLY_TYPE(x, typ)                                  \
285             ((x) = ((x) & ~MPI_CONTEXT_REPLY_TYPE_MASK) |                   \
286                             (((typ) << MPI_CONTEXT_REPLY_TYPE_SHIFT) &      \
287                                         MPI_CONTEXT_REPLY_TYPE_MASK))
288 
289 
290 /*****************************************************************************
291 *
292 *        M e s s a g e    F u n c t i o n s
293 *              0x80 -> 0x8F reserved for private message use per product
294 *
295 *
296 *****************************************************************************/
297 
298 #define MPI_FUNCTION_SCSI_IO_REQUEST                (0x00)
299 #define MPI_FUNCTION_SCSI_TASK_MGMT                 (0x01)
300 #define MPI_FUNCTION_IOC_INIT                       (0x02)
301 #define MPI_FUNCTION_IOC_FACTS                      (0x03)
302 #define MPI_FUNCTION_CONFIG                         (0x04)
303 #define MPI_FUNCTION_PORT_FACTS                     (0x05)
304 #define MPI_FUNCTION_PORT_ENABLE                    (0x06)
305 #define MPI_FUNCTION_EVENT_NOTIFICATION             (0x07)
306 #define MPI_FUNCTION_EVENT_ACK                      (0x08)
307 #define MPI_FUNCTION_FW_DOWNLOAD                    (0x09)
308 #define MPI_FUNCTION_TARGET_CMD_BUFFER_POST         (0x0A)
309 #define MPI_FUNCTION_TARGET_ASSIST                  (0x0B)
310 #define MPI_FUNCTION_TARGET_STATUS_SEND             (0x0C)
311 #define MPI_FUNCTION_TARGET_MODE_ABORT              (0x0D)
312 #define MPI_FUNCTION_FC_LINK_SRVC_BUF_POST          (0x0E)
313 #define MPI_FUNCTION_FC_LINK_SRVC_RSP               (0x0F)
314 #define MPI_FUNCTION_FC_EX_LINK_SRVC_SEND           (0x10)
315 #define MPI_FUNCTION_FC_ABORT                       (0x11)
316 #define MPI_FUNCTION_FW_UPLOAD                      (0x12)
317 #define MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND       (0x13)
318 #define MPI_FUNCTION_FC_PRIMITIVE_SEND              (0x14)
319 
320 #define MPI_FUNCTION_RAID_ACTION                    (0x15)
321 #define MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH       (0x16)
322 
323 #define MPI_FUNCTION_TOOLBOX                        (0x17)
324 
325 #define MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR       (0x18)
326 
327 #define MPI_FUNCTION_MAILBOX                        (0x19)
328 
329 #define MPI_FUNCTION_SMP_PASSTHROUGH                (0x1A)
330 #define MPI_FUNCTION_SAS_IO_UNIT_CONTROL            (0x1B)
331 #define MPI_FUNCTION_SATA_PASSTHROUGH               (0x1C)
332 
333 #define MPI_FUNCTION_DIAG_BUFFER_POST               (0x1D)
334 #define MPI_FUNCTION_DIAG_RELEASE                   (0x1E)
335 
336 #define MPI_FUNCTION_SCSI_IO_32                     (0x1F)
337 
338 #define MPI_FUNCTION_LAN_SEND                       (0x20)
339 #define MPI_FUNCTION_LAN_RECEIVE                    (0x21)
340 #define MPI_FUNCTION_LAN_RESET                      (0x22)
341 
342 #define MPI_FUNCTION_TARGET_ASSIST_EXTENDED         (0x23)
343 #define MPI_FUNCTION_TARGET_CMD_BUF_BASE_POST       (0x24)
344 #define MPI_FUNCTION_TARGET_CMD_BUF_LIST_POST       (0x25)
345 
346 #define MPI_FUNCTION_INBAND_BUFFER_POST             (0x28)
347 #define MPI_FUNCTION_INBAND_SEND                    (0x29)
348 #define MPI_FUNCTION_INBAND_RSP                     (0x2A)
349 #define MPI_FUNCTION_INBAND_ABORT                   (0x2B)
350 
351 #define MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET         (0x40)
352 #define MPI_FUNCTION_IO_UNIT_RESET                  (0x41)
353 #define MPI_FUNCTION_HANDSHAKE                      (0x42)
354 #define MPI_FUNCTION_REPLY_FRAME_REMOVAL            (0x43)
355 #define MPI_FUNCTION_HOST_PAGEBUF_ACCESS_CONTROL    (0x44)
356 
357 
358 /* standard version format */
359 typedef struct _MPI_VERSION_STRUCT
360 {
361     U8                      Dev;                        /* 00h */
362     U8                      Unit;                       /* 01h */
363     U8                      Minor;                      /* 02h */
364     U8                      Major;                      /* 03h */
365 } MPI_VERSION_STRUCT, MPI_POINTER PTR_MPI_VERSION_STRUCT,
366   MpiVersionStruct_t, MPI_POINTER pMpiVersionStruct;
367 
368 typedef union _MPI_VERSION_FORMAT
369 {
370     MPI_VERSION_STRUCT      Struct;
371     U32                     Word;
372 } MPI_VERSION_FORMAT, MPI_POINTER PTR_MPI_VERSION_FORMAT,
373   MpiVersionFormat_t, MPI_POINTER pMpiVersionFormat_t;
374 
375 
376 /*****************************************************************************
377 *
378 *        S c a t t e r    G a t h e r    E l e m e n t s
379 *
380 *****************************************************************************/
381 
382 /****************************************************************************/
383 /*  Simple element structures                                               */
384 /****************************************************************************/
385 
386 typedef struct _SGE_SIMPLE32
387 {
388     U32                     FlagsLength;
389     U32                     Address;
390 } SGE_SIMPLE32, MPI_POINTER PTR_SGE_SIMPLE32,
391   SGESimple32_t, MPI_POINTER pSGESimple32_t;
392 
393 typedef struct _SGE_SIMPLE64
394 {
395     U32                     FlagsLength;
396     U64                     Address;
397 } SGE_SIMPLE64, MPI_POINTER PTR_SGE_SIMPLE64,
398   SGESimple64_t, MPI_POINTER pSGESimple64_t;
399 
400 typedef struct _SGE_SIMPLE_UNION
401 {
402     U32                     FlagsLength;
403     union
404     {
405         U32                 Address32;
406         U64                 Address64;
407     }u;
408 } SGE_SIMPLE_UNION, MPI_POINTER PTR_SGE_SIMPLE_UNION,
409   SGESimpleUnion_t, MPI_POINTER pSGESimpleUnion_t;
410 
411 /****************************************************************************/
412 /*  Chain element structures                                                */
413 /****************************************************************************/
414 
415 typedef struct _SGE_CHAIN32
416 {
417     U16                     Length;
418     U8                      NextChainOffset;
419     U8                      Flags;
420     U32                     Address;
421 } SGE_CHAIN32, MPI_POINTER PTR_SGE_CHAIN32,
422   SGEChain32_t, MPI_POINTER pSGEChain32_t;
423 
424 typedef struct _SGE_CHAIN64
425 {
426     U16                     Length;
427     U8                      NextChainOffset;
428     U8                      Flags;
429     U64                     Address;
430 } SGE_CHAIN64, MPI_POINTER PTR_SGE_CHAIN64,
431   SGEChain64_t, MPI_POINTER pSGEChain64_t;
432 
433 typedef struct _SGE_CHAIN_UNION
434 {
435     U16                     Length;
436     U8                      NextChainOffset;
437     U8                      Flags;
438     union
439     {
440         U32                 Address32;
441         U64                 Address64;
442     }u;
443 } SGE_CHAIN_UNION, MPI_POINTER PTR_SGE_CHAIN_UNION,
444   SGEChainUnion_t, MPI_POINTER pSGEChainUnion_t;
445 
446 /****************************************************************************/
447 /*  Transaction Context element                                             */
448 /****************************************************************************/
449 
450 typedef struct _SGE_TRANSACTION32
451 {
452     U8                      Reserved;
453     U8                      ContextSize;
454     U8                      DetailsLength;
455     U8                      Flags;
456     U32                     TransactionContext[1];
457     U32                     TransactionDetails[1];
458 } SGE_TRANSACTION32, MPI_POINTER PTR_SGE_TRANSACTION32,
459   SGETransaction32_t, MPI_POINTER pSGETransaction32_t;
460 
461 typedef struct _SGE_TRANSACTION64
462 {
463     U8                      Reserved;
464     U8                      ContextSize;
465     U8                      DetailsLength;
466     U8                      Flags;
467     U32                     TransactionContext[2];
468     U32                     TransactionDetails[1];
469 } SGE_TRANSACTION64, MPI_POINTER PTR_SGE_TRANSACTION64,
470   SGETransaction64_t, MPI_POINTER pSGETransaction64_t;
471 
472 typedef struct _SGE_TRANSACTION96
473 {
474     U8                      Reserved;
475     U8                      ContextSize;
476     U8                      DetailsLength;
477     U8                      Flags;
478     U32                     TransactionContext[3];
479     U32                     TransactionDetails[1];
480 } SGE_TRANSACTION96, MPI_POINTER PTR_SGE_TRANSACTION96,
481   SGETransaction96_t, MPI_POINTER pSGETransaction96_t;
482 
483 typedef struct _SGE_TRANSACTION128
484 {
485     U8                      Reserved;
486     U8                      ContextSize;
487     U8                      DetailsLength;
488     U8                      Flags;
489     U32                     TransactionContext[4];
490     U32                     TransactionDetails[1];
491 } SGE_TRANSACTION128, MPI_POINTER PTR_SGE_TRANSACTION128,
492   SGETransaction_t128, MPI_POINTER pSGETransaction_t128;
493 
494 typedef struct _SGE_TRANSACTION_UNION
495 {
496     U8                      Reserved;
497     U8                      ContextSize;
498     U8                      DetailsLength;
499     U8                      Flags;
500     union
501     {
502         U32                 TransactionContext32[1];
503         U32                 TransactionContext64[2];
504         U32                 TransactionContext96[3];
505         U32                 TransactionContext128[4];
506     }u;
507     U32                     TransactionDetails[1];
508 } SGE_TRANSACTION_UNION, MPI_POINTER PTR_SGE_TRANSACTION_UNION,
509   SGETransactionUnion_t, MPI_POINTER pSGETransactionUnion_t;
510 
511 
512 /****************************************************************************/
513 /*  SGE IO types union  for IO SGL's                                        */
514 /****************************************************************************/
515 
516 typedef struct _SGE_IO_UNION
517 {
518     union
519     {
520         SGE_SIMPLE_UNION    Simple;
521         SGE_CHAIN_UNION     Chain;
522     } u;
523 } SGE_IO_UNION, MPI_POINTER PTR_SGE_IO_UNION,
524   SGEIOUnion_t, MPI_POINTER pSGEIOUnion_t;
525 
526 /****************************************************************************/
527 /*  SGE union for SGL's with Simple and Transaction elements                */
528 /****************************************************************************/
529 
530 typedef struct _SGE_TRANS_SIMPLE_UNION
531 {
532     union
533     {
534         SGE_SIMPLE_UNION        Simple;
535         SGE_TRANSACTION_UNION   Transaction;
536     } u;
537 } SGE_TRANS_SIMPLE_UNION, MPI_POINTER PTR_SGE_TRANS_SIMPLE_UNION,
538   SGETransSimpleUnion_t, MPI_POINTER pSGETransSimpleUnion_t;
539 
540 /****************************************************************************/
541 /*  All SGE types union                                                     */
542 /****************************************************************************/
543 
544 typedef struct _SGE_MPI_UNION
545 {
546     union
547     {
548         SGE_SIMPLE_UNION        Simple;
549         SGE_CHAIN_UNION         Chain;
550         SGE_TRANSACTION_UNION   Transaction;
551     } u;
552 } SGE_MPI_UNION, MPI_POINTER PTR_SGE_MPI_UNION,
553   MPI_SGE_UNION_t, MPI_POINTER pMPI_SGE_UNION_t,
554   SGEAllUnion_t, MPI_POINTER pSGEAllUnion_t;
555 
556 
557 /****************************************************************************/
558 /*  SGE field definition and masks                                          */
559 /****************************************************************************/
560 
561 /* Flags field bit definitions */
562 
563 #define MPI_SGE_FLAGS_LAST_ELEMENT              (0x80)
564 #define MPI_SGE_FLAGS_END_OF_BUFFER             (0x40)
565 #define MPI_SGE_FLAGS_ELEMENT_TYPE_MASK         (0x30)
566 #define MPI_SGE_FLAGS_LOCAL_ADDRESS             (0x08)
567 #define MPI_SGE_FLAGS_DIRECTION                 (0x04)
568 #define MPI_SGE_FLAGS_ADDRESS_SIZE              (0x02)
569 #define MPI_SGE_FLAGS_END_OF_LIST               (0x01)
570 
571 #define MPI_SGE_FLAGS_SHIFT                     (24)
572 
573 #define MPI_SGE_LENGTH_MASK                     (0x00FFFFFF)
574 #define MPI_SGE_CHAIN_LENGTH_MASK               (0x0000FFFF)
575 
576 /* Element Type */
577 
578 #define MPI_SGE_FLAGS_TRANSACTION_ELEMENT       (0x00)
579 #define MPI_SGE_FLAGS_SIMPLE_ELEMENT            (0x10)
580 #define MPI_SGE_FLAGS_CHAIN_ELEMENT             (0x30)
581 #define MPI_SGE_FLAGS_ELEMENT_MASK              (0x30)
582 
583 /* Address location */
584 
585 #define MPI_SGE_FLAGS_SYSTEM_ADDRESS            (0x00)
586 
587 /* Direction */
588 
589 #define MPI_SGE_FLAGS_IOC_TO_HOST               (0x00)
590 #define MPI_SGE_FLAGS_HOST_TO_IOC               (0x04)
591 
592 /* Address Size */
593 
594 #define MPI_SGE_FLAGS_32_BIT_ADDRESSING         (0x00)
595 #define MPI_SGE_FLAGS_64_BIT_ADDRESSING         (0x02)
596 
597 /* Context Size */
598 
599 #define MPI_SGE_FLAGS_32_BIT_CONTEXT            (0x00)
600 #define MPI_SGE_FLAGS_64_BIT_CONTEXT            (0x02)
601 #define MPI_SGE_FLAGS_96_BIT_CONTEXT            (0x04)
602 #define MPI_SGE_FLAGS_128_BIT_CONTEXT           (0x06)
603 
604 #define MPI_SGE_CHAIN_OFFSET_MASK               (0x00FF0000)
605 #define MPI_SGE_CHAIN_OFFSET_SHIFT              (16)
606 
607 
608 /****************************************************************************/
609 /*  SGE operation Macros                                                    */
610 /****************************************************************************/
611 
612          /* SIMPLE FlagsLength manipulations... */
613 #define  MPI_SGE_SET_FLAGS(f)           ((U32)(f) << MPI_SGE_FLAGS_SHIFT)
614 #define  MPI_SGE_GET_FLAGS(fl)          (((fl) & ~MPI_SGE_LENGTH_MASK) >> MPI_SGE_FLAGS_SHIFT)
615 #define  MPI_SGE_LENGTH(fl)             ((fl) & MPI_SGE_LENGTH_MASK)
616 #define  MPI_SGE_CHAIN_LENGTH(fl)       ((fl) & MPI_SGE_CHAIN_LENGTH_MASK)
617 
618 #define  MPI_SGE_SET_FLAGS_LENGTH(f,l)  (MPI_SGE_SET_FLAGS(f) | MPI_SGE_LENGTH(l))
619 
620 #define  MPI_pSGE_GET_FLAGS(psg)        MPI_SGE_GET_FLAGS((psg)->FlagsLength)
621 #define  MPI_pSGE_GET_LENGTH(psg)       MPI_SGE_LENGTH((psg)->FlagsLength)
622 #define  MPI_pSGE_SET_FLAGS_LENGTH(psg,f,l)  (psg)->FlagsLength = MPI_SGE_SET_FLAGS_LENGTH(f,l)
623          /* CAUTION - The following are READ-MODIFY-WRITE! */
624 #define  MPI_pSGE_SET_FLAGS(psg,f)      (psg)->FlagsLength |= MPI_SGE_SET_FLAGS(f)
625 #define  MPI_pSGE_SET_LENGTH(psg,l)     (psg)->FlagsLength |= MPI_SGE_LENGTH(l)
626 
627 #define  MPI_GET_CHAIN_OFFSET(x) ((x&MPI_SGE_CHAIN_OFFSET_MASK)>>MPI_SGE_CHAIN_OFFSET_SHIFT)
628 
629 
630 
631 /*****************************************************************************
632 *
633 *        S t a n d a r d    M e s s a g e    S t r u c t u r e s
634 *
635 *****************************************************************************/
636 
637 /****************************************************************************/
638 /* Standard message request header for all request messages                 */
639 /****************************************************************************/
640 
641 typedef struct _MSG_REQUEST_HEADER
642 {
643     U8                      Reserved[2];      /* function specific */
644     U8                      ChainOffset;
645     U8                      Function;
646     U8                      Reserved1[3];     /* function specific */
647     U8                      MsgFlags;
648     U32                     MsgContext;
649 } MSG_REQUEST_HEADER, MPI_POINTER PTR_MSG_REQUEST_HEADER,
650   MPIHeader_t, MPI_POINTER pMPIHeader_t;
651 
652 
653 /****************************************************************************/
654 /*  Default Reply                                                           */
655 /****************************************************************************/
656 
657 typedef struct _MSG_DEFAULT_REPLY
658 {
659     U8                      Reserved[2];      /* function specific */
660     U8                      MsgLength;
661     U8                      Function;
662     U8                      Reserved1[3];     /* function specific */
663     U8                      MsgFlags;
664     U32                     MsgContext;
665     U8                      Reserved2[2];     /* function specific */
666     U16                     IOCStatus;
667     U32                     IOCLogInfo;
668 } MSG_DEFAULT_REPLY, MPI_POINTER PTR_MSG_DEFAULT_REPLY,
669   MPIDefaultReply_t, MPI_POINTER pMPIDefaultReply_t;
670 
671 
672 /* MsgFlags definition for all replies */
673 
674 #define MPI_MSGFLAGS_CONTINUATION_REPLY         (0x80)
675 
676 
677 /*****************************************************************************
678 *
679 *               I O C    S t a t u s   V a l u e s
680 *
681 *****************************************************************************/
682 
683 /****************************************************************************/
684 /*  Common IOCStatus values for all replies                                 */
685 /****************************************************************************/
686 
687 #define MPI_IOCSTATUS_SUCCESS                   (0x0000)
688 #define MPI_IOCSTATUS_INVALID_FUNCTION          (0x0001)
689 #define MPI_IOCSTATUS_BUSY                      (0x0002)
690 #define MPI_IOCSTATUS_INVALID_SGL               (0x0003)
691 #define MPI_IOCSTATUS_INTERNAL_ERROR            (0x0004)
692 #define MPI_IOCSTATUS_RESERVED                  (0x0005)
693 #define MPI_IOCSTATUS_INSUFFICIENT_RESOURCES    (0x0006)
694 #define MPI_IOCSTATUS_INVALID_FIELD             (0x0007)
695 #define MPI_IOCSTATUS_INVALID_STATE             (0x0008)
696 #define MPI_IOCSTATUS_OP_STATE_NOT_SUPPORTED    (0x0009)
697 
698 /****************************************************************************/
699 /*  Config IOCStatus values                                                 */
700 /****************************************************************************/
701 
702 #define MPI_IOCSTATUS_CONFIG_INVALID_ACTION     (0x0020)
703 #define MPI_IOCSTATUS_CONFIG_INVALID_TYPE       (0x0021)
704 #define MPI_IOCSTATUS_CONFIG_INVALID_PAGE       (0x0022)
705 #define MPI_IOCSTATUS_CONFIG_INVALID_DATA       (0x0023)
706 #define MPI_IOCSTATUS_CONFIG_NO_DEFAULTS        (0x0024)
707 #define MPI_IOCSTATUS_CONFIG_CANT_COMMIT        (0x0025)
708 
709 /****************************************************************************/
710 /*  SCSIIO Reply (SPI & FCP) initiator values                               */
711 /****************************************************************************/
712 
713 #define MPI_IOCSTATUS_SCSI_RECOVERED_ERROR      (0x0040)
714 #define MPI_IOCSTATUS_SCSI_INVALID_BUS          (0x0041)
715 #define MPI_IOCSTATUS_SCSI_INVALID_TARGETID     (0x0042)
716 #define MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE     (0x0043)
717 #define MPI_IOCSTATUS_SCSI_DATA_OVERRUN         (0x0044)
718 #define MPI_IOCSTATUS_SCSI_DATA_UNDERRUN        (0x0045)
719 #define MPI_IOCSTATUS_SCSI_IO_DATA_ERROR        (0x0046)
720 #define MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR       (0x0047)
721 #define MPI_IOCSTATUS_SCSI_TASK_TERMINATED      (0x0048)
722 #define MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH    (0x0049)
723 #define MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED     (0x004A)
724 #define MPI_IOCSTATUS_SCSI_IOC_TERMINATED       (0x004B)
725 #define MPI_IOCSTATUS_SCSI_EXT_TERMINATED       (0x004C)
726 
727 /****************************************************************************/
728 /*  For use by SCSI Initiator and SCSI Target end-to-end data protection    */
729 /****************************************************************************/
730 
731 #define MPI_IOCSTATUS_EEDP_GUARD_ERROR          (0x004D)
732 #define MPI_IOCSTATUS_EEDP_REF_TAG_ERROR        (0x004E)
733 #define MPI_IOCSTATUS_EEDP_APP_TAG_ERROR        (0x004F)
734 
735 
736 /****************************************************************************/
737 /*  SCSI Target values                                                      */
738 /****************************************************************************/
739 
740 #define MPI_IOCSTATUS_TARGET_PRIORITY_IO         (0x0060)
741 #define MPI_IOCSTATUS_TARGET_INVALID_PORT        (0x0061)
742 #define MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX    (0x0062)   /* obsolete name */
743 #define MPI_IOCSTATUS_TARGET_INVALID_IO_INDEX    (0x0062)
744 #define MPI_IOCSTATUS_TARGET_ABORTED             (0x0063)
745 #define MPI_IOCSTATUS_TARGET_NO_CONN_RETRYABLE   (0x0064)
746 #define MPI_IOCSTATUS_TARGET_NO_CONNECTION       (0x0065)
747 #define MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH (0x006A)
748 #define MPI_IOCSTATUS_TARGET_STS_DATA_NOT_SENT   (0x006B)
749 #define MPI_IOCSTATUS_TARGET_DATA_OFFSET_ERROR   (0x006D)
750 #define MPI_IOCSTATUS_TARGET_TOO_MUCH_WRITE_DATA (0x006E)
751 #define MPI_IOCSTATUS_TARGET_IU_TOO_SHORT        (0x006F)
752 #define MPI_IOCSTATUS_TARGET_ACK_NAK_TIMEOUT     (0x0070)
753 #define MPI_IOCSTATUS_TARGET_NAK_RECEIVED        (0x0071)
754 
755 /****************************************************************************/
756 /*  Additional FCP target values (obsolete)                                 */
757 /****************************************************************************/
758 
759 #define MPI_IOCSTATUS_TARGET_FC_ABORTED         (0x0066)    /* obsolete */
760 #define MPI_IOCSTATUS_TARGET_FC_RX_ID_INVALID   (0x0067)    /* obsolete */
761 #define MPI_IOCSTATUS_TARGET_FC_DID_INVALID     (0x0068)    /* obsolete */
762 #define MPI_IOCSTATUS_TARGET_FC_NODE_LOGGED_OUT (0x0069)    /* obsolete */
763 
764 /****************************************************************************/
765 /*  Fibre Channel Direct Access values                                      */
766 /****************************************************************************/
767 
768 #define MPI_IOCSTATUS_FC_ABORTED                (0x0066)
769 #define MPI_IOCSTATUS_FC_RX_ID_INVALID          (0x0067)
770 #define MPI_IOCSTATUS_FC_DID_INVALID            (0x0068)
771 #define MPI_IOCSTATUS_FC_NODE_LOGGED_OUT        (0x0069)
772 #define MPI_IOCSTATUS_FC_EXCHANGE_CANCELED      (0x006C)
773 
774 /****************************************************************************/
775 /*  LAN values                                                              */
776 /****************************************************************************/
777 
778 #define MPI_IOCSTATUS_LAN_DEVICE_NOT_FOUND      (0x0080)
779 #define MPI_IOCSTATUS_LAN_DEVICE_FAILURE        (0x0081)
780 #define MPI_IOCSTATUS_LAN_TRANSMIT_ERROR        (0x0082)
781 #define MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED      (0x0083)
782 #define MPI_IOCSTATUS_LAN_RECEIVE_ERROR         (0x0084)
783 #define MPI_IOCSTATUS_LAN_RECEIVE_ABORTED       (0x0085)
784 #define MPI_IOCSTATUS_LAN_PARTIAL_PACKET        (0x0086)
785 #define MPI_IOCSTATUS_LAN_CANCELED              (0x0087)
786 
787 /****************************************************************************/
788 /*  Serial Attached SCSI values                                             */
789 /****************************************************************************/
790 
791 #define MPI_IOCSTATUS_SAS_SMP_REQUEST_FAILED    (0x0090)
792 #define MPI_IOCSTATUS_SAS_SMP_DATA_OVERRUN      (0x0091)
793 
794 /****************************************************************************/
795 /*  Inband values                                                           */
796 /****************************************************************************/
797 
798 #define MPI_IOCSTATUS_INBAND_ABORTED            (0x0098)
799 #define MPI_IOCSTATUS_INBAND_NO_CONNECTION      (0x0099)
800 
801 /****************************************************************************/
802 /*  Diagnostic Tools values                                                 */
803 /****************************************************************************/
804 
805 #define MPI_IOCSTATUS_DIAGNOSTIC_RELEASED       (0x00A0)
806 
807 
808 /****************************************************************************/
809 /*  IOCStatus flag to indicate that log info is available                   */
810 /****************************************************************************/
811 
812 #define MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE   (0x8000)
813 #define MPI_IOCSTATUS_MASK                      (0x7FFF)
814 
815 /****************************************************************************/
816 /*  LogInfo Types                                                           */
817 /****************************************************************************/
818 
819 #define MPI_IOCLOGINFO_TYPE_MASK                (0xF0000000)
820 #define MPI_IOCLOGINFO_TYPE_SHIFT               (28)
821 #define MPI_IOCLOGINFO_TYPE_NONE                (0x0)
822 #define MPI_IOCLOGINFO_TYPE_SCSI                (0x1)
823 #define MPI_IOCLOGINFO_TYPE_FC                  (0x2)
824 #define MPI_IOCLOGINFO_TYPE_SAS                 (0x3)
825 #define MPI_IOCLOGINFO_TYPE_ISCSI               (0x4)
826 #define MPI_IOCLOGINFO_LOG_DATA_MASK            (0x0FFFFFFF)
827 
828 
829 #endif
830