xref: /freebsd/sys/dev/mpt/mpilib/mpi_targ.h (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
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_targ.h
35  *          Title:  MPI Target mode messages and structures
36  *  Creation Date:  June 22, 2000
37  *
38  *    mpi_targ.h Version:  01.05.06
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  *  06-06-00  01.00.01  Update version number for 1.0 release.
47  *  06-22-00  01.00.02  Added _MSG_TARGET_CMD_BUFFER_POST_REPLY structure.
48  *                      Corrected DECSRIPTOR typo to DESCRIPTOR.
49  *  11-02-00  01.01.01  Original release for post 1.0 work
50  *                      Modified target mode to use IoIndex instead of
51  *                      HostIndex and IocIndex. Added Alias.
52  *  01-09-01  01.01.02  Added defines for TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER
53  *                      and TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER.
54  *  02-20-01  01.01.03  Started using MPI_POINTER.
55  *                      Added structures for MPI_TARGET_SCSI_SPI_CMD_BUFFER and
56  *                      MPI_TARGET_FCP_CMD_BUFFER.
57  *  03-27-01  01.01.04  Added structure offset comments.
58  *  08-08-01  01.02.01  Original release for v1.2 work.
59  *  09-28-01  01.02.02  Added structure for MPI_TARGET_SCSI_SPI_STATUS_IU.
60  *                      Added PriorityReason field to some replies and
61  *                      defined more PriorityReason codes.
62  *                      Added some defines for to support previous version
63  *                      of MPI.
64  *  10-04-01  01.02.03  Added PriorityReason to MSG_TARGET_ERROR_REPLY.
65  *  11-01-01  01.02.04  Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY.
66  *  03-14-02  01.02.05  Modified MPI_TARGET_FCP_RSP_BUFFER to get the proper
67  *                      byte ordering.
68  *  05-31-02  01.02.06  Modified TARGET_MODE_REPLY_ALIAS_MASK to only include
69  *                      one bit.
70  *                      Added AliasIndex field to MPI_TARGET_FCP_CMD_BUFFER.
71  *  09-16-02  01.02.07  Added flags for confirmed completion.
72  *                      Added PRIORITY_REASON_TARGET_BUSY.
73  *  11-15-02  01.02.08  Added AliasID field to MPI_TARGET_SCSI_SPI_CMD_BUFFER.
74  *  04-01-03  01.02.09  Added OptionalOxid field to MPI_TARGET_FCP_CMD_BUFFER.
75  *  05-11-04  01.03.01  Original release for MPI v1.3.
76  *  08-19-04  01.05.01  Added new request message structures for
77  *                      MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
78  *                      MSG_TARGET_CMD_BUF_POST_LIST_REQUEST, and
79  *                      MSG_TARGET_ASSIST_EXT_REQUEST.
80  *                      Added new structures for SAS SSP Command buffer, SSP
81  *                      Task buffer, and SSP Status IU.
82  *  10-05-04  01.05.02  MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY added.
83  *  02-22-05  01.05.03  Changed a comment.
84  *  03-11-05  01.05.04  Removed TargetAssistExtended Request.
85  *  06-24-05  01.05.05  Added TargetAssistExtended structures and defines.
86  *  03-27-06  01.05.06  Added a comment.
87  *  --------------------------------------------------------------------------
88  */
89 
90 #ifndef MPI_TARG_H
91 #define MPI_TARG_H
92 
93 
94 /******************************************************************************
95 *
96 *        S C S I    T a r g e t    M e s s a g e s
97 *
98 *******************************************************************************/
99 
100 typedef struct _CMD_BUFFER_DESCRIPTOR
101 {
102     U16                     IoIndex;                    /* 00h */
103     U16                     Reserved;                   /* 02h */
104     union                                               /* 04h */
105     {
106         U32                 PhysicalAddress32;
107         U64                 PhysicalAddress64;
108     } u;
109 } CMD_BUFFER_DESCRIPTOR, MPI_POINTER PTR_CMD_BUFFER_DESCRIPTOR,
110   CmdBufferDescriptor_t, MPI_POINTER pCmdBufferDescriptor_t;
111 
112 
113 /****************************************************************************/
114 /* Target Command Buffer Post Request                                       */
115 /****************************************************************************/
116 
117 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REQUEST
118 {
119     U8                      BufferPostFlags;            /* 00h */
120     U8                      BufferCount;                /* 01h */
121     U8                      ChainOffset;                /* 02h */
122     U8                      Function;                   /* 03h */
123     U8                      BufferLength;               /* 04h */
124     U8                      Reserved;                   /* 05h */
125     U8                      Reserved1;                  /* 06h */
126     U8                      MsgFlags;                   /* 07h */
127     U32                     MsgContext;                 /* 08h */
128     CMD_BUFFER_DESCRIPTOR   Buffer[1];                  /* 0Ch */
129 } MSG_TARGET_CMD_BUFFER_POST_REQUEST, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REQUEST,
130   TargetCmdBufferPostRequest_t, MPI_POINTER pTargetCmdBufferPostRequest_t;
131 
132 #define CMD_BUFFER_POST_FLAGS_PORT_MASK         (0x01)
133 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_MASK    (0x80)
134 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_32      (0)
135 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_64      (1)
136 #define CMD_BUFFER_POST_FLAGS_64_BIT_ADDR       (0x80)
137 
138 #define CMD_BUFFER_POST_IO_INDEX_MASK           (0x00003FFF)
139 #define CMD_BUFFER_POST_IO_INDEX_MASK_0100      (0x000003FF) /* obsolete */
140 
141 
142 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REPLY
143 {
144     U8                      BufferPostFlags;            /* 00h */
145     U8                      BufferCount;                /* 01h */
146     U8                      MsgLength;                  /* 02h */
147     U8                      Function;                   /* 03h */
148     U8                      BufferLength;               /* 04h */
149     U8                      Reserved;                   /* 05h */
150     U8                      Reserved1;                  /* 06h */
151     U8                      MsgFlags;                   /* 07h */
152     U32                     MsgContext;                 /* 08h */
153     U16                     Reserved2;                  /* 0Ch */
154     U16                     IOCStatus;                  /* 0Eh */
155     U32                     IOCLogInfo;                 /* 10h */
156 } MSG_TARGET_CMD_BUFFER_POST_REPLY, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REPLY,
157   TargetCmdBufferPostReply_t, MPI_POINTER pTargetCmdBufferPostReply_t;
158 
159 /* the following structure is obsolete as of MPI v1.2 */
160 typedef struct _MSG_PRIORITY_CMD_RECEIVED_REPLY
161 {
162     U16                     Reserved;                   /* 00h */
163     U8                      MsgLength;                  /* 02h */
164     U8                      Function;                   /* 03h */
165     U16                     Reserved1;                  /* 04h */
166     U8                      Reserved2;                  /* 06h */
167     U8                      MsgFlags;                   /* 07h */
168     U32                     MsgContext;                 /* 08h */
169     U8                      PriorityReason;             /* 0Ch */
170     U8                      Reserved3;                  /* 0Dh */
171     U16                     IOCStatus;                  /* 0Eh */
172     U32                     IOCLogInfo;                 /* 10h */
173     U32                     ReplyWord;                  /* 14h */
174 } MSG_PRIORITY_CMD_RECEIVED_REPLY, MPI_POINTER PTR_MSG_PRIORITY_CMD_RECEIVED_REPLY,
175   PriorityCommandReceivedReply_t, MPI_POINTER pPriorityCommandReceivedReply_t;
176 
177 
178 typedef struct _MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY
179 {
180     U16                     Reserved;                   /* 00h */
181     U8                      MsgLength;                  /* 02h */
182     U8                      Function;                   /* 03h */
183     U16                     Reserved1;                  /* 04h */
184     U8                      Reserved2;                  /* 06h */
185     U8                      MsgFlags;                   /* 07h */
186     U32                     MsgContext;                 /* 08h */
187     U8                      PriorityReason;             /* 0Ch */
188     U8                      Reserved3;                  /* 0Dh */
189     U16                     IOCStatus;                  /* 0Eh */
190     U32                     IOCLogInfo;                 /* 10h */
191     U32                     ReplyWord;                  /* 14h */
192 } MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
193   MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
194   TargetCmdBufferPostErrorReply_t, MPI_POINTER pTargetCmdBufferPostErrorReply_t;
195 
196 #define PRIORITY_REASON_NO_DISCONNECT           (0x00)
197 #define PRIORITY_REASON_SCSI_TASK_MANAGEMENT    (0x01)
198 #define PRIORITY_REASON_CMD_PARITY_ERR          (0x02)
199 #define PRIORITY_REASON_MSG_OUT_PARITY_ERR      (0x03)
200 #define PRIORITY_REASON_LQ_CRC_ERR              (0x04)
201 #define PRIORITY_REASON_CMD_CRC_ERR             (0x05)
202 #define PRIORITY_REASON_PROTOCOL_ERR            (0x06)
203 #define PRIORITY_REASON_DATA_OUT_PARITY_ERR     (0x07)
204 #define PRIORITY_REASON_DATA_OUT_CRC_ERR        (0x08)
205 #define PRIORITY_REASON_TARGET_BUSY             (0x09)
206 #define PRIORITY_REASON_UNKNOWN                 (0xFF)
207 
208 
209 /****************************************************************************/
210 /* Target Command Buffer Post Base Request                                  */
211 /****************************************************************************/
212 
213 typedef struct _MSG_TARGET_CMD_BUF_POST_BASE_REQUEST
214 {
215     U8                      BufferPostFlags;            /* 00h */
216     U8                      PortNumber;                 /* 01h */
217     U8                      ChainOffset;                /* 02h */
218     U8                      Function;                   /* 03h */
219     U16                     TotalCmdBuffers;            /* 04h */
220     U8                      Reserved;                   /* 06h */
221     U8                      MsgFlags;                   /* 07h */
222     U32                     MsgContext;                 /* 08h */
223     U32                     Reserved1;                  /* 0Ch */
224     U16                     CmdBufferLength;            /* 10h */
225     U16                     NextCmdBufferOffset;        /* 12h */
226     U32                     BaseAddressLow;             /* 14h */
227     U32                     BaseAddressHigh;            /* 18h */
228 } MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
229   MPI_POINTER PTR__MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
230   TargetCmdBufferPostBaseRequest_t,
231   MPI_POINTER pTargetCmdBufferPostBaseRequest_t;
232 
233 #define CMD_BUFFER_POST_BASE_FLAGS_AUTO_POST_ALL    (0x01)
234 
235 
236 typedef struct _MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY
237 {
238     U16                     Reserved;                   /* 00h */
239     U8                      MsgLength;                  /* 02h */
240     U8                      Function;                   /* 03h */
241     U16                     Reserved1;                  /* 04h */
242     U8                      Reserved2;                  /* 06h */
243     U8                      MsgFlags;                   /* 07h */
244     U32                     MsgContext;                 /* 08h */
245     U16                     Reserved3;                  /* 0Ch */
246     U16                     IOCStatus;                  /* 0Eh */
247     U32                     IOCLogInfo;                 /* 10h */
248 } MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY,
249   MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY,
250   TargetCmdBufferPostBaseListReply_t,
251   MPI_POINTER pTargetCmdBufferPostBaseListReply_t;
252 
253 
254 /****************************************************************************/
255 /* Target Command Buffer Post List Request                                  */
256 /****************************************************************************/
257 
258 typedef struct _MSG_TARGET_CMD_BUF_POST_LIST_REQUEST
259 {
260     U8                      Reserved;                   /* 00h */
261     U8                      PortNumber;                 /* 01h */
262     U8                      ChainOffset;                /* 02h */
263     U8                      Function;                   /* 03h */
264     U16                     CmdBufferCount;             /* 04h */
265     U8                      Reserved1;                  /* 06h */
266     U8                      MsgFlags;                   /* 07h */
267     U32                     MsgContext;                 /* 08h */
268     U32                     Reserved2;                  /* 0Ch */
269     U16                     IoIndex[2];                 /* 10h */
270 } MSG_TARGET_CMD_BUF_POST_LIST_REQUEST,
271   MPI_POINTER PTR_MSG_TARGET_CMD_BUF_POST_LIST_REQUEST,
272   TargetCmdBufferPostListRequest_t,
273   MPI_POINTER pTargetCmdBufferPostListRequest_t;
274 
275 
276 /****************************************************************************/
277 /* Command Buffer Formats (with 16 byte CDB)                                */
278 /****************************************************************************/
279 
280 typedef struct _MPI_TARGET_FCP_CMD_BUFFER
281 {
282     U8      FcpLun[8];                                  /* 00h */
283     U8      FcpCntl[4];                                 /* 08h */
284     U8      FcpCdb[16];                                 /* 0Ch */
285     U32     FcpDl;                                      /* 1Ch */
286     U8      AliasIndex;                                 /* 20h */
287     U8      Reserved1;                                  /* 21h */
288     U16     OptionalOxid;                               /* 22h */
289 } MPI_TARGET_FCP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_CMD_BUFFER,
290   MpiTargetFcpCmdBuffer, MPI_POINTER pMpiTargetFcpCmdBuffer;
291 
292 
293 typedef struct _MPI_TARGET_SCSI_SPI_CMD_BUFFER
294 {
295     /* SPI L_Q information unit */
296     U8      L_QType;                                    /* 00h */
297     U8      Reserved;                                   /* 01h */
298     U16     Tag;                                        /* 02h */
299     U8      LogicalUnitNumber[8];                       /* 04h */
300     U32     DataLength;                                 /* 0Ch */
301     /* SPI command information unit */
302     U8      ReservedFirstByteOfCommandIU;               /* 10h */
303     U8      TaskAttribute;                              /* 11h */
304     U8      TaskManagementFlags;                        /* 12h */
305     U8      AdditionalCDBLength;                        /* 13h */
306     U8      CDB[16];                                    /* 14h */
307     /* Alias ID */
308     U8      AliasID;                                    /* 24h */
309     U8      Reserved1;                                  /* 25h */
310     U16     Reserved2;                                  /* 26h */
311 } MPI_TARGET_SCSI_SPI_CMD_BUFFER,
312   MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER,
313   MpiTargetScsiSpiCmdBuffer, MPI_POINTER pMpiTargetScsiSpiCmdBuffer;
314 
315 
316 typedef struct _MPI_TARGET_SSP_CMD_BUFFER
317 {
318     U8      FrameType;                                  /* 00h */
319     U8      Reserved1;                                  /* 01h */
320     U16     Reserved2;                                  /* 02h */
321     U16     InitiatorTag;                               /* 04h */
322     U16     DevHandle;                                  /* 06h */
323     /* COMMAND information unit starts here */
324     U8      LogicalUnitNumber[8];                       /* 08h */
325     U8      Reserved3;                                  /* 10h */
326     U8      TaskAttribute; /* lower 3 bits */           /* 11h */
327     U8      Reserved4;                                  /* 12h */
328     U8      AdditionalCDBLength; /* upper 5 bits */     /* 13h */
329     U8      CDB[16];                                    /* 14h */
330     /* Additional CDB bytes extend past the CDB field */
331 } MPI_TARGET_SSP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_SSP_CMD_BUFFER,
332   MpiTargetSspCmdBuffer, MPI_POINTER pMpiTargetSspCmdBuffer;
333 
334 typedef struct _MPI_TARGET_SSP_TASK_BUFFER
335 {
336     U8      FrameType;                                  /* 00h */
337     U8      Reserved1;                                  /* 01h */
338     U16     Reserved2;                                  /* 02h */
339     U16     InitiatorTag;                               /* 04h */
340     U16     DevHandle;                                  /* 06h */
341     /* TASK information unit starts here */
342     U8      LogicalUnitNumber[8];                       /* 08h */
343     U8      Reserved3;                                  /* 10h */
344     U8      Reserved4;                                  /* 11h */
345     U8      TaskManagementFunction;                     /* 12h */
346     U8      Reserved5;                                  /* 13h */
347     U16     ManagedTaskTag;                             /* 14h */
348     U16     Reserved6;                                  /* 16h */
349     U32     Reserved7;                                  /* 18h */
350     U32     Reserved8;                                  /* 1Ch */
351     U32     Reserved9;                                  /* 20h */
352 } MPI_TARGET_SSP_TASK_BUFFER, MPI_POINTER PTR_MPI_TARGET_SSP_TASK_BUFFER,
353   MpiTargetSspTaskBuffer, MPI_POINTER pMpiTargetSspTaskBuffer;
354 
355 
356 /****************************************************************************/
357 /* Target Assist Request                                                    */
358 /****************************************************************************/
359 
360 typedef struct _MSG_TARGET_ASSIST_REQUEST
361 {
362     U8                      StatusCode;                 /* 00h */
363     U8                      TargetAssistFlags;          /* 01h */
364     U8                      ChainOffset;                /* 02h */
365     U8                      Function;                   /* 03h */
366     U16                     QueueTag;                   /* 04h */
367     U8                      Reserved;                   /* 06h */
368     U8                      MsgFlags;                   /* 07h */
369     U32                     MsgContext;                 /* 08h */
370     U32                     ReplyWord;                  /* 0Ch */
371     U8                      LUN[8];                     /* 10h */
372     U32                     RelativeOffset;             /* 18h */
373     U32                     DataLength;                 /* 1Ch */
374     SGE_IO_UNION            SGL[1];                     /* 20h */
375 } MSG_TARGET_ASSIST_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_REQUEST,
376   TargetAssistRequest_t, MPI_POINTER pTargetAssistRequest_t;
377 
378 #define TARGET_ASSIST_FLAGS_DATA_DIRECTION          (0x01)
379 #define TARGET_ASSIST_FLAGS_AUTO_STATUS             (0x02)
380 #define TARGET_ASSIST_FLAGS_HIGH_PRIORITY           (0x04)
381 #define TARGET_ASSIST_FLAGS_CONFIRMED               (0x08)
382 #define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER       (0x80)
383 
384 /* Standard Target Mode Reply message */
385 typedef struct _MSG_TARGET_ERROR_REPLY
386 {
387     U16                     Reserved;                   /* 00h */
388     U8                      MsgLength;                  /* 02h */
389     U8                      Function;                   /* 03h */
390     U16                     Reserved1;                  /* 04h */
391     U8                      Reserved2;                  /* 06h */
392     U8                      MsgFlags;                   /* 07h */
393     U32                     MsgContext;                 /* 08h */
394     U8                      PriorityReason;             /* 0Ch */
395     U8                      Reserved3;                  /* 0Dh */
396     U16                     IOCStatus;                  /* 0Eh */
397     U32                     IOCLogInfo;                 /* 10h */
398     U32                     ReplyWord;                  /* 14h */
399     U32                     TransferCount;              /* 18h */
400 } MSG_TARGET_ERROR_REPLY, MPI_POINTER PTR_MSG_TARGET_ERROR_REPLY,
401   TargetErrorReply_t, MPI_POINTER pTargetErrorReply_t;
402 
403 
404 /****************************************************************************/
405 /* Target Assist Extended Request                                           */
406 /****************************************************************************/
407 
408 typedef struct _MSG_TARGET_ASSIST_EXT_REQUEST
409 {
410     U8                      StatusCode;                     /* 00h */
411     U8                      TargetAssistFlags;              /* 01h */
412     U8                      ChainOffset;                    /* 02h */
413     U8                      Function;                       /* 03h */
414     U16                     QueueTag;                       /* 04h */
415     U8                      Reserved1;                      /* 06h */
416     U8                      MsgFlags;                       /* 07h */
417     U32                     MsgContext;                     /* 08h */
418     U32                     ReplyWord;                      /* 0Ch */
419     U8                      LUN[8];                         /* 10h */
420     U32                     RelativeOffset;                 /* 18h */
421     U32                     Reserved2;                      /* 1Ch */
422     U32                     Reserved3;                      /* 20h */
423     U32                     PrimaryReferenceTag;            /* 24h */
424     U16                     PrimaryApplicationTag;          /* 28h */
425     U16                     PrimaryApplicationTagMask;      /* 2Ah */
426     U32                     Reserved4;                      /* 2Ch */
427     U32                     DataLength;                     /* 30h */
428     U32                     BidirectionalDataLength;        /* 34h */
429     U32                     SecondaryReferenceTag;          /* 38h */
430     U16                     SecondaryApplicationTag;        /* 3Ch */
431     U16                     Reserved5;                      /* 3Eh */
432     U16                     EEDPFlags;                      /* 40h */
433     U16                     ApplicationTagTranslationMask;  /* 42h */
434     U32                     EEDPBlockSize;                  /* 44h */
435     U8                      SGLOffset0;                     /* 48h */
436     U8                      SGLOffset1;                     /* 49h */
437     U8                      SGLOffset2;                     /* 4Ah */
438     U8                      SGLOffset3;                     /* 4Bh */
439     U32                     Reserved6;                      /* 4Ch */
440     SGE_IO_UNION            SGL[1];                         /* 50h */
441 } MSG_TARGET_ASSIST_EXT_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_EXT_REQUEST,
442   TargetAssistExtRequest_t, MPI_POINTER pTargetAssistExtRequest_t;
443 
444 /* see the defines after MSG_TARGET_ASSIST_REQUEST for TargetAssistFlags */
445 
446 /* defines for the MsgFlags field */
447 #define TARGET_ASSIST_EXT_MSGFLAGS_BIDIRECTIONAL        (0x20)
448 #define TARGET_ASSIST_EXT_MSGFLAGS_MULTICAST            (0x10)
449 #define TARGET_ASSIST_EXT_MSGFLAGS_SGL_OFFSET_CHAINS    (0x08)
450 
451 /* defines for the EEDPFlags field */
452 #define TARGET_ASSIST_EXT_EEDP_MASK_OP          (0x0007)
453 #define TARGET_ASSIST_EXT_EEDP_NOOP_OP          (0x0000)
454 #define TARGET_ASSIST_EXT_EEDP_CHK_OP           (0x0001)
455 #define TARGET_ASSIST_EXT_EEDP_STRIP_OP         (0x0002)
456 #define TARGET_ASSIST_EXT_EEDP_CHKRM_OP         (0x0003)
457 #define TARGET_ASSIST_EXT_EEDP_INSERT_OP        (0x0004)
458 #define TARGET_ASSIST_EXT_EEDP_REPLACE_OP       (0x0006)
459 #define TARGET_ASSIST_EXT_EEDP_CHKREGEN_OP      (0x0007)
460 
461 #define TARGET_ASSIST_EXT_EEDP_PASS_REF_TAG     (0x0008)
462 
463 #define TARGET_ASSIST_EXT_EEDP_T10_CHK_MASK     (0x0700)
464 #define TARGET_ASSIST_EXT_EEDP_T10_CHK_GUARD    (0x0100)
465 #define TARGET_ASSIST_EXT_EEDP_T10_CHK_APPTAG   (0x0200)
466 #define TARGET_ASSIST_EXT_EEDP_T10_CHK_REFTAG   (0x0400)
467 #define TARGET_ASSIST_EXT_EEDP_T10_CHK_SHIFT    (8)
468 
469 #define TARGET_ASSIST_EXT_EEDP_INC_SEC_APPTAG   (0x1000)
470 #define TARGET_ASSIST_EXT_EEDP_INC_PRI_APPTAG   (0x2000)
471 #define TARGET_ASSIST_EXT_EEDP_INC_SEC_REFTAG   (0x4000)
472 #define TARGET_ASSIST_EXT_EEDP_INC_PRI_REFTAG   (0x8000)
473 
474 
475 /****************************************************************************/
476 /* Target Status Send Request                                               */
477 /****************************************************************************/
478 
479 typedef struct _MSG_TARGET_STATUS_SEND_REQUEST
480 {
481     U8                      StatusCode;                 /* 00h */
482     U8                      StatusFlags;                /* 01h */
483     U8                      ChainOffset;                /* 02h */
484     U8                      Function;                   /* 03h */
485     U16                     QueueTag;                   /* 04h */
486     U8                      Reserved;                   /* 06h */
487     U8                      MsgFlags;                   /* 07h */
488     U32                     MsgContext;                 /* 08h */
489     U32                     ReplyWord;                  /* 0Ch */
490     U8                      LUN[8];                     /* 10h */
491     SGE_SIMPLE_UNION        StatusDataSGE;              /* 18h */
492 } MSG_TARGET_STATUS_SEND_REQUEST, MPI_POINTER PTR_MSG_TARGET_STATUS_SEND_REQUEST,
493   TargetStatusSendRequest_t, MPI_POINTER pTargetStatusSendRequest_t;
494 
495 #define TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS   (0x01)
496 #define TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY      (0x04)
497 #define TARGET_STATUS_SEND_FLAGS_CONFIRMED          (0x08)
498 #define TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER  (0x80)
499 
500 /*
501  * NOTE: FCP_RSP data is big-endian. When used on a little-endian system, this
502  * structure properly orders the bytes.
503  */
504 typedef struct _MPI_TARGET_FCP_RSP_BUFFER
505 {
506     U8      Reserved0[8];                               /* 00h */
507     U8      Reserved1[2];                               /* 08h */
508     U8      FcpFlags;                                   /* 0Ah */
509     U8      FcpStatus;                                  /* 0Bh */
510     U32     FcpResid;                                   /* 0Ch */
511     U32     FcpSenseLength;                             /* 10h */
512     U32     FcpResponseLength;                          /* 14h */
513     U8      FcpResponseData[8];                         /* 18h */
514     U8      FcpSenseData[32]; /* Pad to 64 bytes */     /* 20h */
515 } MPI_TARGET_FCP_RSP_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_RSP_BUFFER,
516   MpiTargetFcpRspBuffer, MPI_POINTER pMpiTargetFcpRspBuffer;
517 
518 /*
519  * NOTE: The SPI status IU is big-endian. When used on a little-endian system,
520  * this structure properly orders the bytes.
521  */
522 typedef struct _MPI_TARGET_SCSI_SPI_STATUS_IU
523 {
524     U8      Reserved0;                                  /* 00h */
525     U8      Reserved1;                                  /* 01h */
526     U8      Valid;                                      /* 02h */
527     U8      Status;                                     /* 03h */
528     U32     SenseDataListLength;                        /* 04h */
529     U32     PktFailuresListLength;                      /* 08h */
530     U8      SenseData[52]; /* Pad the IU to 64 bytes */ /* 0Ch */
531 } MPI_TARGET_SCSI_SPI_STATUS_IU, MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_STATUS_IU,
532   TargetScsiSpiStatusIU_t, MPI_POINTER pTargetScsiSpiStatusIU_t;
533 
534 /*
535  * NOTE: The SSP status IU is big-endian. When used on a little-endian system,
536  * this structure properly orders the bytes.
537  */
538 typedef struct _MPI_TARGET_SSP_RSP_IU
539 {
540     U32     Reserved0[6]; /* reserved for SSP header */ /* 00h */
541     /* start of RESPONSE information unit */
542     U32     Reserved1;                                  /* 18h */
543     U32     Reserved2;                                  /* 1Ch */
544     U16     Reserved3;                                  /* 20h */
545     U8      DataPres; /* lower 2 bits */                /* 22h */
546     U8      Status;                                     /* 23h */
547     U32     Reserved4;                                  /* 24h */
548     U32     SenseDataLength;                            /* 28h */
549     U32     ResponseDataLength;                         /* 2Ch */
550     U8      ResponseSenseData[4];                       /* 30h */
551 } MPI_TARGET_SSP_RSP_IU, MPI_POINTER PTR_MPI_TARGET_SSP_RSP_IU,
552   MpiTargetSspRspIu_t, MPI_POINTER pMpiTargetSspRspIu_t;
553 
554 
555 /****************************************************************************/
556 /* Target Mode Abort Request                                                */
557 /****************************************************************************/
558 
559 typedef struct _MSG_TARGET_MODE_ABORT_REQUEST
560 {
561     U8                      AbortType;                  /* 00h */
562     U8                      Reserved;                   /* 01h */
563     U8                      ChainOffset;                /* 02h */
564     U8                      Function;                   /* 03h */
565     U16                     Reserved1;                  /* 04h */
566     U8                      Reserved2;                  /* 06h */
567     U8                      MsgFlags;                   /* 07h */
568     U32                     MsgContext;                 /* 08h */
569     U32                     ReplyWord;                  /* 0Ch */
570     U32                     MsgContextToAbort;          /* 10h */
571 } MSG_TARGET_MODE_ABORT, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT,
572   TargetModeAbort_t, MPI_POINTER pTargetModeAbort_t;
573 
574 #define TARGET_MODE_ABORT_TYPE_ALL_CMD_BUFFERS      (0x00)
575 #define TARGET_MODE_ABORT_TYPE_ALL_IO               (0x01)
576 #define TARGET_MODE_ABORT_TYPE_EXACT_IO             (0x02)
577 #define TARGET_MODE_ABORT_TYPE_EXACT_IO_REQUEST     (0x03)
578 
579 /* Target Mode Abort Reply */
580 
581 typedef struct _MSG_TARGET_MODE_ABORT_REPLY
582 {
583     U16                     Reserved;                   /* 00h */
584     U8                      MsgLength;                  /* 02h */
585     U8                      Function;                   /* 03h */
586     U16                     Reserved1;                  /* 04h */
587     U8                      Reserved2;                  /* 06h */
588     U8                      MsgFlags;                   /* 07h */
589     U32                     MsgContext;                 /* 08h */
590     U16                     Reserved3;                  /* 0Ch */
591     U16                     IOCStatus;                  /* 0Eh */
592     U32                     IOCLogInfo;                 /* 10h */
593     U32                     AbortCount;                 /* 14h */
594 } MSG_TARGET_MODE_ABORT_REPLY, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT_REPLY,
595   TargetModeAbortReply_t, MPI_POINTER pTargetModeAbortReply_t;
596 
597 
598 /****************************************************************************/
599 /* Target Mode Context Reply                                                */
600 /****************************************************************************/
601 
602 #define TARGET_MODE_REPLY_IO_INDEX_MASK         (0x00003FFF)
603 #define TARGET_MODE_REPLY_IO_INDEX_SHIFT        (0)
604 #define TARGET_MODE_REPLY_INITIATOR_INDEX_MASK  (0x03FFC000)
605 #define TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT (14)
606 #define TARGET_MODE_REPLY_ALIAS_MASK            (0x04000000)
607 #define TARGET_MODE_REPLY_ALIAS_SHIFT           (26)
608 #define TARGET_MODE_REPLY_PORT_MASK             (0x10000000)
609 #define TARGET_MODE_REPLY_PORT_SHIFT            (28)
610 
611 
612 #define GET_IO_INDEX(x)     (((x) & TARGET_MODE_REPLY_IO_INDEX_MASK)           \
613                                     >> TARGET_MODE_REPLY_IO_INDEX_SHIFT)
614 
615 #define SET_IO_INDEX(t, i)                                                     \
616             ((t) = ((t) & ~TARGET_MODE_REPLY_IO_INDEX_MASK) |                  \
617                               (((i) << TARGET_MODE_REPLY_IO_INDEX_SHIFT) &     \
618                                              TARGET_MODE_REPLY_IO_INDEX_MASK))
619 
620 #define GET_INITIATOR_INDEX(x) (((x) & TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) \
621                                    >> TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT)
622 
623 #define SET_INITIATOR_INDEX(t, ii)                                             \
624         ((t) = ((t) & ~TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) |               \
625                         (((ii) << TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT) &   \
626                                       TARGET_MODE_REPLY_INITIATOR_INDEX_MASK))
627 
628 #define GET_ALIAS(x) (((x) & TARGET_MODE_REPLY_ALIAS_MASK)                     \
629                                                >> TARGET_MODE_REPLY_ALIAS_SHIFT)
630 
631 #define SET_ALIAS(t, a)  ((t) = ((t) & ~TARGET_MODE_REPLY_ALIAS_MASK) |        \
632                                     (((a) << TARGET_MODE_REPLY_ALIAS_SHIFT) &  \
633                                                  TARGET_MODE_REPLY_ALIAS_MASK))
634 
635 #define GET_PORT(x) (((x) & TARGET_MODE_REPLY_PORT_MASK)                       \
636                                                >> TARGET_MODE_REPLY_PORT_SHIFT)
637 
638 #define SET_PORT(t, p)  ((t) = ((t) & ~TARGET_MODE_REPLY_PORT_MASK) |          \
639                                     (((p) << TARGET_MODE_REPLY_PORT_SHIFT) &   \
640                                                   TARGET_MODE_REPLY_PORT_MASK))
641 
642 /* the following obsolete values are for MPI v1.0 support */
643 #define TARGET_MODE_REPLY_0100_MASK_HOST_INDEX       (0x000003FF)
644 #define TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX      (0)
645 #define TARGET_MODE_REPLY_0100_MASK_IOC_INDEX        (0x001FF800)
646 #define TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX       (11)
647 #define TARGET_MODE_REPLY_0100_PORT_MASK             (0x00400000)
648 #define TARGET_MODE_REPLY_0100_PORT_SHIFT            (22)
649 #define TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX  (0x1F800000)
650 #define TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX (23)
651 
652 #define GET_HOST_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) \
653                                   >> TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX)
654 
655 #define SET_HOST_INDEX_0100(t, hi)                                             \
656             ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) |           \
657                          (((hi) << TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX) &  \
658                                       TARGET_MODE_REPLY_0100_MASK_HOST_INDEX))
659 
660 #define GET_IOC_INDEX_0100(x)   (((x) & TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) \
661                                   >> TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX)
662 
663 #define SET_IOC_INDEX_0100(t, ii)                                              \
664             ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) |            \
665                         (((ii) << TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX) &    \
666                                      TARGET_MODE_REPLY_0100_MASK_IOC_INDEX))
667 
668 #define GET_INITIATOR_INDEX_0100(x)                                            \
669             (((x) & TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX)               \
670                               >> TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX)
671 
672 #define SET_INITIATOR_INDEX_0100(t, ii)                                        \
673         ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) |          \
674                    (((ii) << TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX) &   \
675                                 TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX))
676 
677 
678 #endif
679 
680