xref: /freebsd/sys/dev/mpt/mpilib/mpi.h (revision c4f6a2a9e1b1879b618c436ab4f56ff75c73a0f5)
1 /* $FreeBSD$ */
2 /*
3  *  Copyright (c) 2000-2001 LSI Logic Corporation.
4  *
5  *
6  *           Name:  MPI.H
7  *          Title:  MPI Message independent structures and definitions
8  *  Creation Date:  July 27, 2000
9  *
10  *    MPI Version:  01.02.03
11  *
12  *  Version History
13  *  ---------------
14  *
15  *  Date      Version   Description
16  *  --------  --------  ------------------------------------------------------
17  *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
18  *  05-24-00  00.10.02  Added MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH definition.
19  *  06-06-00  01.00.01  Update MPI_VERSION_MAJOR and MPI_VERSION_MINOR.
20  *  06-22-00  01.00.02  Added MPI_IOCSTATUS_LAN_ definitions.
21  *                      Removed LAN_SUSPEND function definition.
22  *                      Added MPI_MSGFLAGS_CONTINUATION_REPLY definition.
23  *  06-30-00  01.00.03  Added MPI_CONTEXT_REPLY_TYPE_LAN definition.
24  *                      Added MPI_GET/SET_CONTEXT_REPLY_TYPE macros.
25  *  07-27-00  01.00.04  Added MPI_FAULT_ definitions.
26  *                      Removed MPI_IOCSTATUS_MSG/DATA_XFER_ERROR definitions.
27  *                      Added MPI_IOCSTATUS_INTERNAL_ERROR definition.
28  *                      Added MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH.
29  *  11-02-00  01.01.01  Original release for post 1.0 work.
30  *  12-04-00  01.01.02  Added new function codes.
31  *  01-09-01  01.01.03  Added more definitions to the system interface section
32  *                      Added MPI_IOCSTATUS_TARGET_STS_DATA_NOT_SENT.
33  *  01-25-01  01.01.04  Changed MPI_VERSION_MINOR from 0x00 to 0x01.
34  *  02-20-01  01.01.05  Started using MPI_POINTER.
35  *                      Fixed value for MPI_DIAG_RW_ENABLE.
36  *                      Added defines for MPI_DIAG_PREVENT_IOC_BOOT and
37  *                      MPI_DIAG_CLEAR_FLASH_BAD_SIG.
38  *                      Obsoleted MPI_IOCSTATUS_TARGET_FC_ defines.
39  *  02-27-01  01.01.06  Removed MPI_HOST_INDEX_REGISTER define.
40  *                      Added function codes for RAID.
41  *  04-09-01  01.01.07  Added alternate define for MPI_DOORBELL_ACTIVE,
42  *                      MPI_DOORBELL_USED, to better match the spec.
43  *  08-08-01  01.02.01  Original release for v1.2 work.
44  *                      Changed MPI_VERSION_MINOR from 0x01 to 0x02.
45  *                      Added define MPI_FUNCTION_TOOLBOX.
46  *  09-28-01  01.02.02  New function code MPI_SCSI_ENCLOSURE_PROCESSOR.
47  *  11-01-01  01.02.03  Changed name to MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR.
48  *  --------------------------------------------------------------------------
49  */
50 
51 #ifndef MPI_H
52 #define MPI_H
53 
54 
55 /*****************************************************************************
56 *
57 *        M P I    V e r s i o n    D e f i n i t i o n s
58 *
59 *****************************************************************************/
60 
61 #define MPI_VERSION_MAJOR                   (0x01)
62 #define MPI_VERSION_MINOR                   (0x02)
63 #define MPI_VERSION            ((MPI_VERSION_MAJOR << 8) | MPI_VERSION_MINOR)
64 
65 /* Note: The major versions of 0xe0 through 0xff are reserved */
66 
67 /*****************************************************************************
68 *
69 *        I O C    S t a t e    D e f i n i t i o n s
70 *
71 *****************************************************************************/
72 
73 #define MPI_IOC_STATE_RESET                 (0x00000000)
74 #define MPI_IOC_STATE_READY                 (0x10000000)
75 #define MPI_IOC_STATE_OPERATIONAL           (0x20000000)
76 #define MPI_IOC_STATE_FAULT                 (0x40000000)
77 
78 #define MPI_IOC_STATE_MASK                  (0xF0000000)
79 #define MPI_IOC_STATE_SHIFT                 (28)
80 
81 /* Fault state codes (product independent range 0x8000-0xFFFF) */
82 
83 #define MPI_FAULT_REQUEST_MESSAGE_PCI_PARITY_ERROR  (0x8111)
84 #define MPI_FAULT_REQUEST_MESSAGE_PCI_BUS_FAULT     (0x8112)
85 #define MPI_FAULT_REPLY_MESSAGE_PCI_PARITY_ERROR    (0x8113)
86 #define MPI_FAULT_REPLY_MESSAGE_PCI_BUS_FAULT       (0x8114)
87 #define MPI_FAULT_DATA_SEND_PCI_PARITY_ERROR        (0x8115)
88 #define MPI_FAULT_DATA_SEND_PCI_BUS_FAULT           (0x8116)
89 #define MPI_FAULT_DATA_RECEIVE_PCI_PARITY_ERROR     (0x8117)
90 #define MPI_FAULT_DATA_RECEIVE_PCI_BUS_FAULT        (0x8118)
91 
92 
93 /*****************************************************************************
94 *
95 *        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
96 *
97 *****************************************************************************/
98 
99 /* S y s t e m    D o o r b e l l */
100 #define MPI_DOORBELL_OFFSET                 (0x00000000)
101 #define MPI_DOORBELL_ACTIVE                 (0x08000000) /* DoorbellUsed */
102 #define MPI_DOORBELL_USED                   (MPI_DOORBELL_ACTIVE)
103 #define MPI_DOORBELL_ACTIVE_SHIFT           (27)
104 #define MPI_DOORBELL_WHO_INIT_MASK          (0x07000000)
105 #define MPI_DOORBELL_WHO_INIT_SHIFT         (24)
106 #define MPI_DOORBELL_FUNCTION_MASK          (0xFF000000)
107 #define MPI_DOORBELL_FUNCTION_SHIFT         (24)
108 #define MPI_DOORBELL_ADD_DWORDS_MASK        (0x00FF0000)
109 #define MPI_DOORBELL_ADD_DWORDS_SHIFT       (16)
110 #define MPI_DOORBELL_DATA_MASK              (0x0000FFFF)
111 
112 
113 #define MPI_WRITE_SEQUENCE_OFFSET           (0x00000004)
114 #define MPI_WRSEQ_KEY_VALUE_MASK            (0x0000000F)
115 #define MPI_WRSEQ_1ST_KEY_VALUE             (0x04)
116 #define MPI_WRSEQ_2ND_KEY_VALUE             (0x0B)
117 #define MPI_WRSEQ_3RD_KEY_VALUE             (0x02)
118 #define MPI_WRSEQ_4TH_KEY_VALUE             (0x07)
119 #define MPI_WRSEQ_5TH_KEY_VALUE             (0x0D)
120 
121 #define MPI_DIAGNOSTIC_OFFSET               (0x00000008)
122 #define MPI_DIAG_CLEAR_FLASH_BAD_SIG        (0x00000400)
123 #define MPI_DIAG_PREVENT_IOC_BOOT           (0x00000200)
124 #define MPI_DIAG_DRWE                       (0x00000080)
125 #define MPI_DIAG_FLASH_BAD_SIG              (0x00000040)
126 #define MPI_DIAG_RESET_HISTORY              (0x00000020)
127 #define MPI_DIAG_RW_ENABLE                  (0x00000010)
128 #define MPI_DIAG_RESET_ADAPTER              (0x00000004)
129 #define MPI_DIAG_DISABLE_ARM                (0x00000002)
130 #define MPI_DIAG_MEM_ENABLE                 (0x00000001)
131 
132 #define MPI_TEST_BASE_ADDRESS_OFFSET        (0x0000000C)
133 
134 #define MPI_DIAG_RW_DATA_OFFSET             (0x00000010)
135 
136 #define MPI_DIAG_RW_ADDRESS_OFFSET          (0x00000014)
137 
138 #define MPI_HOST_INTERRUPT_STATUS_OFFSET    (0x00000030)
139 #define MPI_HIS_IOP_DOORBELL_STATUS         (0x80000000)
140 #define MPI_HIS_REPLY_MESSAGE_INTERRUPT     (0x00000008)
141 #define MPI_HIS_DOORBELL_INTERRUPT          (0x00000001)
142 
143 #define MPI_HOST_INTERRUPT_MASK_OFFSET      (0x00000034)
144 #define MPI_HIM_RIM                         (0x00000008)
145 #define MPI_HIM_DIM                         (0x00000001)
146 
147 #define MPI_REQUEST_QUEUE_OFFSET            (0x00000040)
148 #define MPI_REQUEST_POST_FIFO_OFFSET        (0x00000040)
149 
150 #define MPI_REPLY_QUEUE_OFFSET              (0x00000044)
151 #define MPI_REPLY_POST_FIFO_OFFSET          (0x00000044)
152 #define MPI_REPLY_FREE_FIFO_OFFSET          (0x00000044)
153 
154 
155 
156 /*****************************************************************************
157 *
158 *        M e s s a g e    F r a m e    D e s c r i p t o r s
159 *
160 *****************************************************************************/
161 
162 #define MPI_REQ_MF_DESCRIPTOR_NB_MASK       (0x00000003)
163 #define MPI_REQ_MF_DESCRIPTOR_F_BIT         (0x00000004)
164 #define MPI_REQ_MF_DESCRIPTOR_ADDRESS_MASK  (0xFFFFFFF8)
165 
166 #define MPI_ADDRESS_REPLY_A_BIT             (0x80000000)
167 #define MPI_ADDRESS_REPLY_ADDRESS_MASK      (0x7FFFFFFF)
168 
169 #define MPI_CONTEXT_REPLY_A_BIT             (0x80000000)
170 #define MPI_CONTEXT_REPLY_TYPE_MASK         (0x60000000)
171 #define MPI_CONTEXT_REPLY_TYPE_SCSI_INIT    (0x00)
172 #define MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET  (0x01)
173 #define MPI_CONTEXT_REPLY_TYPE_LAN          (0x02)
174 #define MPI_CONTEXT_REPLY_TYPE_SHIFT        (29)
175 #define MPI_CONTEXT_REPLY_CONTEXT_MASK      (0x1FFFFFFF)
176 
177 
178 /****************************************************************************/
179 /* Context Reply macros                                                     */
180 /****************************************************************************/
181 
182 #define MPI_GET_CONTEXT_REPLY_TYPE(x)  (((x) & MPI_CONTEXT_REPLY_TYPE_MASK) \
183                                           >> MPI_CONTEXT_REPLY_TYPE_SHIFT)
184 
185 #define MPI_SET_CONTEXT_REPLY_TYPE(x, typ)                                  \
186             ((x) = ((x) & ~MPI_CONTEXT_REPLY_TYPE_MASK) |                   \
187                             (((typ) << MPI_CONTEXT_REPLY_TYPE_SHIFT) &      \
188                                         MPI_CONTEXT_REPLY_TYPE_MASK))
189 
190 
191 /*****************************************************************************
192 *
193 *        M e s s a g e    F u n c t i o n s
194 *              0x80 -> 0x8F reserved for private message use per product
195 *
196 *
197 *****************************************************************************/
198 
199 #define MPI_FUNCTION_SCSI_IO_REQUEST                (0x00)
200 #define MPI_FUNCTION_SCSI_TASK_MGMT                 (0x01)
201 #define MPI_FUNCTION_IOC_INIT                       (0x02)
202 #define MPI_FUNCTION_IOC_FACTS                      (0x03)
203 #define MPI_FUNCTION_CONFIG                         (0x04)
204 #define MPI_FUNCTION_PORT_FACTS                     (0x05)
205 #define MPI_FUNCTION_PORT_ENABLE                    (0x06)
206 #define MPI_FUNCTION_EVENT_NOTIFICATION             (0x07)
207 #define MPI_FUNCTION_EVENT_ACK                      (0x08)
208 #define MPI_FUNCTION_FW_DOWNLOAD                    (0x09)
209 #define MPI_FUNCTION_TARGET_CMD_BUFFER_POST         (0x0A)
210 #define MPI_FUNCTION_TARGET_ASSIST                  (0x0B)
211 #define MPI_FUNCTION_TARGET_STATUS_SEND             (0x0C)
212 #define MPI_FUNCTION_TARGET_MODE_ABORT              (0x0D)
213 #define MPI_FUNCTION_TARGET_FC_BUF_POST_LINK_SRVC   (0x0E) /* obsolete name */
214 #define MPI_FUNCTION_TARGET_FC_RSP_LINK_SRVC        (0x0F) /* obsolete name */
215 #define MPI_FUNCTION_TARGET_FC_EX_SEND_LINK_SRVC    (0x10) /* obsolete name */
216 #define MPI_FUNCTION_TARGET_FC_ABORT                (0x11) /* obsolete name */
217 #define MPI_FUNCTION_FC_LINK_SRVC_BUF_POST          (0x0E)
218 #define MPI_FUNCTION_FC_LINK_SRVC_RSP               (0x0F)
219 #define MPI_FUNCTION_FC_EX_LINK_SRVC_SEND           (0x10)
220 #define MPI_FUNCTION_FC_ABORT                       (0x11)
221 #define MPI_FUNCTION_FW_UPLOAD                      (0x12)
222 #define MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND       (0x13)
223 #define MPI_FUNCTION_FC_PRIMITIVE_SEND              (0x14)
224 
225 #define MPI_FUNCTION_RAID_ACTION                    (0x15)
226 #define MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH       (0x16)
227 
228 #define MPI_FUNCTION_TOOLBOX                        (0x17)
229 
230 #define MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR       (0x18)
231 
232 #define MPI_FUNCTION_LAN_SEND                       (0x20)
233 #define MPI_FUNCTION_LAN_RECEIVE                    (0x21)
234 #define MPI_FUNCTION_LAN_RESET                      (0x22)
235 
236 #define MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET         (0x40)
237 #define MPI_FUNCTION_IO_UNIT_RESET                  (0x41)
238 #define MPI_FUNCTION_HANDSHAKE                      (0x42)
239 #define MPI_FUNCTION_REPLY_FRAME_REMOVAL            (0x43)
240 
241 
242 
243 /*****************************************************************************
244 *
245 *        S c a t t e r    G a t h e r    E l e m e n t s
246 *
247 *****************************************************************************/
248 
249 /****************************************************************************/
250 /*  Simple element structures                                               */
251 /****************************************************************************/
252 
253 typedef struct _SGE_SIMPLE32
254 {
255     U32                     FlagsLength;
256     U32                     Address;
257 } SGE_SIMPLE32, MPI_POINTER PTR_SGE_SIMPLE32,
258   SGESimple32_t, MPI_POINTER pSGESimple32_t;
259 
260 typedef struct _SGE_SIMPLE64
261 {
262     U32                     FlagsLength;
263     U64                     Address;
264 } SGE_SIMPLE64, MPI_POINTER PTR_SGE_SIMPLE64,
265   SGESimple64_t, MPI_POINTER pSGESimple64_t;
266 
267 typedef struct _SGE_SIMPLE_UNION
268 {
269     U32                     FlagsLength;
270     union
271     {
272         U32                 Address32;
273         U64                 Address64;
274     } _u;
275 } SGESimpleUnion_t, MPI_POINTER pSGESimpleUnion_t,
276   SGE_SIMPLE_UNION, MPI_POINTER PTR_SGE_SIMPLE_UNION;
277 
278 /****************************************************************************/
279 /*  Chain element structures                                                */
280 /****************************************************************************/
281 
282 typedef struct _SGE_CHAIN32
283 {
284     U16                     Length;
285     U8                      NextChainOffset;
286     U8                      Flags;
287     U32                     Address;
288 } SGE_CHAIN32, MPI_POINTER PTR_SGE_CHAIN32,
289   SGEChain32_t, MPI_POINTER pSGEChain32_t;
290 
291 typedef struct _SGE_CHAIN64
292 {
293     U16                     Length;
294     U8                      NextChainOffset;
295     U8                      Flags;
296     U64                     Address;
297 } SGE_CHAIN64, MPI_POINTER PTR_SGE_CHAIN64,
298   SGEChain64_t, MPI_POINTER pSGEChain64_t;
299 
300 typedef struct _SGE_CHAIN_UNION
301 {
302     U16                     Length;
303     U8                      NextChainOffset;
304     U8                      Flags;
305     union
306     {
307         U32                 Address32;
308         U64                 Address64;
309     } _u;
310 } SGE_CHAIN_UNION, MPI_POINTER PTR_SGE_CHAIN_UNION,
311   SGEChainUnion_t, MPI_POINTER pSGEChainUnion_t;
312 
313 /****************************************************************************/
314 /*  Transaction Context element                                             */
315 /****************************************************************************/
316 
317 typedef struct _SGE_TRANSACTION32
318 {
319     U8                      Reserved;
320     U8                      ContextSize;
321     U8                      DetailsLength;
322     U8                      Flags;
323     U32                     TransactionContext[1];
324     U32                     TransactionDetails[1];
325 } SGE_TRANSACTION32, MPI_POINTER PTR_SGE_TRANSACTION32,
326   SGETransaction32_t, MPI_POINTER pSGETransaction32_t;
327 
328 typedef struct _SGE_TRANSACTION64
329 {
330     U8                      Reserved;
331     U8                      ContextSize;
332     U8                      DetailsLength;
333     U8                      Flags;
334     U32                     TransactionContext[2];
335     U32                     TransactionDetails[1];
336 } SGE_TRANSACTION64, MPI_POINTER PTR_SGE_TRANSACTION64,
337   SGETransaction64_t, MPI_POINTER pSGETransaction64_t;
338 
339 typedef struct _SGE_TRANSACTION96
340 {
341     U8                      Reserved;
342     U8                      ContextSize;
343     U8                      DetailsLength;
344     U8                      Flags;
345     U32                     TransactionContext[3];
346     U32                     TransactionDetails[1];
347 } SGE_TRANSACTION96, MPI_POINTER PTR_SGE_TRANSACTION96,
348   SGETransaction96_t, MPI_POINTER pSGETransaction96_t;
349 
350 typedef struct _SGE_TRANSACTION128
351 {
352     U8                      Reserved;
353     U8                      ContextSize;
354     U8                      DetailsLength;
355     U8                      Flags;
356     U32                     TransactionContext[4];
357     U32                     TransactionDetails[1];
358 } SGE_TRANSACTION128, MPI_POINTER PTR_SGE_TRANSACTION128,
359   SGETransaction_t128, MPI_POINTER pSGETransaction_t128;
360 
361 typedef struct _SGE_TRANSACTION_UNION
362 {
363     U8                      Reserved;
364     U8                      ContextSize;
365     U8                      DetailsLength;
366     U8                      Flags;
367     union
368     {
369         U32                 TransactionContext32[1];
370         U32                 TransactionContext64[2];
371         U32                 TransactionContext96[3];
372         U32                 TransactionContext128[4];
373     } _u;
374     U32                     TransactionDetails[1];
375 } SGE_TRANSACTION_UNION, MPI_POINTER PTR_SGE_TRANSACTION_UNION,
376   SGETransactionUnion_t, MPI_POINTER pSGETransactionUnion_t;
377 
378 
379 /****************************************************************************/
380 /*  SGE IO types union  for IO SGL's                                        */
381 /****************************************************************************/
382 
383 typedef struct _SGE_IO_UNION
384 {
385     union
386     {
387         SGE_SIMPLE_UNION    Simple;
388         SGE_CHAIN_UNION     Chain;
389     } _u;
390 } SGE_IO_UNION, MPI_POINTER PTR_SGE_IO_UNION,
391   SGEIOUnion_t, MPI_POINTER pSGEIOUnion_t;
392 
393 /****************************************************************************/
394 /*  SGE union for SGL's with Simple and Transaction elements                */
395 /****************************************************************************/
396 
397 typedef struct _SGE_TRANS_SIMPLE_UNION
398 {
399     union
400     {
401         SGE_SIMPLE_UNION        Simple;
402         SGE_TRANSACTION_UNION   Transaction;
403     } _u;
404 } SGE_TRANS_SIMPLE_UNION, MPI_POINTER PTR_SGE_TRANS_SIMPLE_UNION,
405   SGETransSimpleUnion_t, MPI_POINTER pSGETransSimpleUnion_t;
406 
407 /****************************************************************************/
408 /*  All SGE types union                                                     */
409 /****************************************************************************/
410 
411 typedef struct _SGE_MPI_UNION
412 {
413     union
414     {
415         SGE_SIMPLE_UNION        Simple;
416         SGE_CHAIN_UNION         Chain;
417         SGE_TRANSACTION_UNION   Transaction;
418     } _u;
419 } SGE_MPI_UNION, MPI_POINTER PTR_SGE_MPI_UNION,
420   MPI_SGE_UNION_t, MPI_POINTER pMPI_SGE_UNION_t,
421   SGEAllUnion_t, MPI_POINTER pSGEAllUnion_t;
422 
423 
424 /****************************************************************************/
425 /*  SGE field definition and masks                                          */
426 /****************************************************************************/
427 
428 /* Flags field bit definitions */
429 
430 #define MPI_SGE_FLAGS_LAST_ELEMENT              (0x80)
431 #define MPI_SGE_FLAGS_END_OF_BUFFER             (0x40)
432 #define MPI_SGE_FLAGS_ELEMENT_TYPE_MASK         (0x30)
433 #define MPI_SGE_FLAGS_LOCAL_ADDRESS             (0x08)
434 #define MPI_SGE_FLAGS_DIRECTION                 (0x04)
435 #define MPI_SGE_FLAGS_ADDRESS_SIZE              (0x02)
436 #define MPI_SGE_FLAGS_END_OF_LIST               (0x01)
437 
438 #define MPI_SGE_FLAGS_SHIFT                     (24)
439 
440 #define MPI_SGE_LENGTH_MASK                     (0x00FFFFFF)
441 #define MPI_SGE_CHAIN_LENGTH_MASK               (0x0000FFFF)
442 
443 /* Element Type */
444 
445 #define MPI_SGE_FLAGS_TRANSACTION_ELEMENT       (0x00)
446 #define MPI_SGE_FLAGS_SIMPLE_ELEMENT            (0x10)
447 #define MPI_SGE_FLAGS_CHAIN_ELEMENT             (0x30)
448 #define MPI_SGE_FLAGS_ELEMENT_MASK              (0x30)
449 
450 /* Address location */
451 
452 #define MPI_SGE_FLAGS_SYSTEM_ADDRESS            (0x00)
453 
454 /* Direction */
455 
456 #define MPI_SGE_FLAGS_IOC_TO_HOST               (0x00)
457 #define MPI_SGE_FLAGS_HOST_TO_IOC               (0x04)
458 
459 /* Address Size */
460 
461 #define MPI_SGE_FLAGS_32_BIT_ADDRESSING         (0x00)
462 #define MPI_SGE_FLAGS_64_BIT_ADDRESSING         (0x02)
463 
464 /* Context Size */
465 
466 #define MPI_SGE_FLAGS_32_BIT_CONTEXT            (0x00)
467 #define MPI_SGE_FLAGS_64_BIT_CONTEXT            (0x02)
468 #define MPI_SGE_FLAGS_96_BIT_CONTEXT            (0x04)
469 #define MPI_SGE_FLAGS_128_BIT_CONTEXT           (0x06)
470 
471 #define MPI_SGE_CHAIN_OFFSET_MASK               (0x00FF0000)
472 #define MPI_SGE_CHAIN_OFFSET_SHIFT              (16)
473 
474 
475 /****************************************************************************/
476 /*  SGE operation Macros                                                    */
477 /****************************************************************************/
478 
479          /* SIMPLE FlagsLength manipulations... */
480 #define  MPI_SGE_SET_FLAGS(f)           ((U32)(f) << MPI_SGE_FLAGS_SHIFT)
481 #define  MPI_SGE_GET_FLAGS(fl)          (((fl) & ~MPI_SGE_LENGTH_MASK) >> MPI_SGE_FLAGS_SHIFT)
482 #define  MPI_SGE_LENGTH(fl)             ((fl) & MPI_SGE_LENGTH_MASK)
483 #define  MPI_SGE_CHAIN_LENGTH(fl)       ((fl) & MPI_SGE_CHAIN_LENGTH_MASK)
484 
485 #define  MPI_SGE_SET_FLAGS_LENGTH(f,l)  (MPI_SGE_SET_FLAGS(f) | MPI_SGE_LENGTH(l))
486 
487 #define  MPI_pSGE_GET_FLAGS(psg)        MPI_SGE_GET_FLAGS((psg)->FlagsLength)
488 #define  MPI_pSGE_GET_LENGTH(psg)       MPI_SGE_LENGTH((psg)->FlagsLength)
489 #define  MPI_pSGE_SET_FLAGS_LENGTH(psg,f,l)  (psg)->FlagsLength = MPI_SGE_SET_FLAGS_LENGTH(f,l)
490          /* CAUTION - The following are READ-MODIFY-WRITE! */
491 #define  MPI_pSGE_SET_FLAGS(psg,f)      (psg)->FlagsLength |= MPI_SGE_SET_FLAGS(f)
492 #define  MPI_pSGE_SET_LENGTH(psg,l)     (psg)->FlagsLength |= MPI_SGE_LENGTH(l)
493 
494 #define  MPI_GET_CHAIN_OFFSET(x) ((x&MPI_SGE_CHAIN_OFFSET_MASK)>>MPI_SGE_CHAIN_OFFSET_SHIFT)
495 
496 
497 
498 /*****************************************************************************
499 *
500 *        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
501 *
502 *****************************************************************************/
503 
504 /****************************************************************************/
505 /* Standard message request header for all request messages                 */
506 /****************************************************************************/
507 
508 typedef struct _MSG_REQUEST_HEADER
509 {
510     U8                      Reserved[2];      /* function specific */
511     U8                      ChainOffset;
512     U8                      Function;
513     U8                      Reserved1[3];     /* function specific */
514     U8                      MsgFlags;
515     U32                     MsgContext;
516 } MSG_REQUEST_HEADER, MPI_POINTER PTR_MSG_REQUEST_HEADER,
517   MPIHeader_t, MPI_POINTER pMPIHeader_t;
518 
519 
520 /****************************************************************************/
521 /*  Default Reply                                                           */
522 /****************************************************************************/
523 
524 typedef struct _MSG_DEFAULT_REPLY
525 {
526     U8                      Reserved[2];      /* function specific */
527     U8                      MsgLength;
528     U8                      Function;
529     U8                      Reserved1[3];     /* function specific */
530     U8                      MsgFlags;
531     U32                     MsgContext;
532     U8                      Reserved2[2];     /* function specific */
533     U16                     IOCStatus;
534     U32                     IOCLogInfo;
535 } MSG_DEFAULT_REPLY, MPI_POINTER PTR_MSG_DEFAULT_REPLY,
536   MPIDefaultReply_t, MPI_POINTER pMPIDefaultReply_t;
537 
538 
539 /* MsgFlags definition for all replies */
540 
541 #define MPI_MSGFLAGS_CONTINUATION_REPLY         (0x80)
542 
543 
544 /*****************************************************************************
545 *
546 *               I O C    S t a t u s   V a l u e s
547 *
548 *****************************************************************************/
549 
550 /****************************************************************************/
551 /*  Common IOCStatus values for all replies                                 */
552 /****************************************************************************/
553 
554 #define MPI_IOCSTATUS_SUCCESS                  (0x0000)
555 #define MPI_IOCSTATUS_INVALID_FUNCTION         (0x0001)
556 #define MPI_IOCSTATUS_BUSY                     (0x0002)
557 #define MPI_IOCSTATUS_INVALID_SGL              (0x0003)
558 #define MPI_IOCSTATUS_INTERNAL_ERROR           (0x0004)
559 #define MPI_IOCSTATUS_RESERVED                 (0x0005)
560 #define MPI_IOCSTATUS_INSUFFICIENT_RESOURCES   (0x0006)
561 #define MPI_IOCSTATUS_INVALID_FIELD            (0x0007)
562 #define MPI_IOCSTATUS_INVALID_STATE            (0x0008)
563 
564 /****************************************************************************/
565 /*  Config IOCStatus values                                                 */
566 /****************************************************************************/
567 
568 #define MPI_IOCSTATUS_CONFIG_INVALID_ACTION    (0x0020)
569 #define MPI_IOCSTATUS_CONFIG_INVALID_TYPE      (0x0021)
570 #define MPI_IOCSTATUS_CONFIG_INVALID_PAGE      (0x0022)
571 #define MPI_IOCSTATUS_CONFIG_INVALID_DATA      (0x0023)
572 #define MPI_IOCSTATUS_CONFIG_NO_DEFAULTS       (0x0024)
573 #define MPI_IOCSTATUS_CONFIG_CANT_COMMIT       (0x0025)
574 
575 /****************************************************************************/
576 /*  SCSIIO Reply (SPI & FCP) initiator values                               */
577 /****************************************************************************/
578 
579 #define MPI_IOCSTATUS_SCSI_RECOVERED_ERROR     (0x0040)
580 #define MPI_IOCSTATUS_SCSI_INVALID_BUS         (0x0041)
581 #define MPI_IOCSTATUS_SCSI_INVALID_TARGETID    (0x0042)
582 #define MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE    (0x0043)
583 #define MPI_IOCSTATUS_SCSI_DATA_OVERRUN        (0x0044)
584 #define MPI_IOCSTATUS_SCSI_DATA_UNDERRUN       (0x0045)
585 #define MPI_IOCSTATUS_SCSI_IO_DATA_ERROR       (0x0046)
586 #define MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR      (0x0047)
587 #define MPI_IOCSTATUS_SCSI_TASK_TERMINATED     (0x0048)
588 #define MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH   (0x0049)
589 #define MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED    (0x004A)
590 #define MPI_IOCSTATUS_SCSI_IOC_TERMINATED      (0x004B)
591 #define MPI_IOCSTATUS_SCSI_EXT_TERMINATED      (0x004C)
592 
593 /****************************************************************************/
594 /*  SCSI (SPI & FCP) target values                                          */
595 /****************************************************************************/
596 
597 #define MPI_IOCSTATUS_TARGET_PRIORITY_IO         (0x0060)
598 #define MPI_IOCSTATUS_TARGET_INVALID_PORT        (0x0061)
599 #define MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX    (0x0062)
600 #define MPI_IOCSTATUS_TARGET_ABORTED             (0x0063)
601 #define MPI_IOCSTATUS_TARGET_NO_CONN_RETRYABLE   (0x0064)
602 #define MPI_IOCSTATUS_TARGET_NO_CONNECTION       (0x0065)
603 #define MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH (0x006A)
604 #define MPI_IOCSTATUS_TARGET_STS_DATA_NOT_SENT   (0x006B)
605 
606 /****************************************************************************/
607 /*  Additional FCP target values                                            */
608 /****************************************************************************/
609 
610 #define MPI_IOCSTATUS_TARGET_FC_ABORTED         (0x0066)    /* obsolete */
611 #define MPI_IOCSTATUS_TARGET_FC_RX_ID_INVALID   (0x0067)    /* obsolete */
612 #define MPI_IOCSTATUS_TARGET_FC_DID_INVALID     (0x0068)    /* obsolete */
613 #define MPI_IOCSTATUS_TARGET_FC_NODE_LOGGED_OUT (0x0069)    /* obsolete */
614 
615 /****************************************************************************/
616 /*  Fibre Channel Direct Access values                                      */
617 /****************************************************************************/
618 
619 #define MPI_IOCSTATUS_FC_ABORTED                (0x0066)
620 #define MPI_IOCSTATUS_FC_RX_ID_INVALID          (0x0067)
621 #define MPI_IOCSTATUS_FC_DID_INVALID            (0x0068)
622 #define MPI_IOCSTATUS_FC_NODE_LOGGED_OUT        (0x0069)
623 
624 /****************************************************************************/
625 /*  LAN values                                                              */
626 /****************************************************************************/
627 
628 #define MPI_IOCSTATUS_LAN_DEVICE_NOT_FOUND      (0x0080)
629 #define MPI_IOCSTATUS_LAN_DEVICE_FAILURE        (0x0081)
630 #define MPI_IOCSTATUS_LAN_TRANSMIT_ERROR        (0x0082)
631 #define MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED      (0x0083)
632 #define MPI_IOCSTATUS_LAN_RECEIVE_ERROR         (0x0084)
633 #define MPI_IOCSTATUS_LAN_RECEIVE_ABORTED       (0x0085)
634 #define MPI_IOCSTATUS_LAN_PARTIAL_PACKET        (0x0086)
635 #define MPI_IOCSTATUS_LAN_CANCELED              (0x0087)
636 
637 
638 /****************************************************************************/
639 /*  IOCStatus flag to indicate that log info is available                   */
640 /****************************************************************************/
641 
642 #define MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE   (0x8000)
643 #define MPI_IOCSTATUS_MASK                      (0x7FFF)
644 
645 /****************************************************************************/
646 /*  LogInfo Types                                                           */
647 /****************************************************************************/
648 
649 #define MPI_IOCLOGINFO_TYPE_MASK                (0xF0000000)
650 #define MPI_IOCLOGINFO_TYPE_NONE                (0x0)
651 #define MPI_IOCLOGINFO_TYPE_SCSI                (0x1)
652 #define MPI_IOCLOGINFO_TYPE_FC                  (0x2)
653 #define MPI_IOCLOGINFO_LOG_DATA_MASK            (0x0FFFFFFF)
654 
655 
656 #endif
657