1356290Sjkim/* $FreeBSD$ */
296593Smarkm/*-
396593Smarkm * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors.
4142429Snectar * All rights reserved.
596593Smarkm *
696593Smarkm * Redistribution and use in source and binary forms, with or without
796593Smarkm * modification, are permitted provided that the following conditions are
896593Smarkm * met:
996593Smarkm * 1. Redistributions of source code must retain the above copyright
1096593Smarkm *    notice, this list of conditions and the following disclaimer.
1196593Smarkm * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1296593Smarkm *    substantially similar to the "NO WARRANTY" disclaimer below
1396593Smarkm *    ("Disclaimer") and any redistribution must be conditioned upon including
1496593Smarkm *    a substantially similar Disclaimer requirement for further binary
1596593Smarkm *    redistribution.
1696593Smarkm * 3. Neither the name of the LSI Logic Corporation nor the names of its
1796593Smarkm *    contributors may be used to endorse or promote products derived from
1896593Smarkm *    this software without specific prior written permission.
1996593Smarkm *
20215698Ssimon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21215698Ssimon * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22215698Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23215698Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24215698Ssimon * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2596593Smarkm * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2696593Smarkm * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2796593Smarkm * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2896593Smarkm * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2996593Smarkm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
3096593Smarkm * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3196593Smarkm *
3296593Smarkm *           Name:  mpi_targ.h
3396593Smarkm *          Title:  MPI Target mode messages and structures
3496593Smarkm *  Creation Date:  June 22, 2000
3596593Smarkm *
3696593Smarkm *    mpi_targ.h Version:  01.05.06
3796593Smarkm *
3896593Smarkm *  Version History
3996593Smarkm *  ---------------
4096593Smarkm *
41276861Sjkim *  Date      Version   Description
42276861Sjkim *  --------  --------  ------------------------------------------------------
4396593Smarkm *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
4496593Smarkm *  06-06-00  01.00.01  Update version number for 1.0 release.
45215698Ssimon *  06-22-00  01.00.02  Added _MSG_TARGET_CMD_BUFFER_POST_REPLY structure.
46215698Ssimon *                      Corrected DECSRIPTOR typo to DESCRIPTOR.
47215698Ssimon *  11-02-00  01.01.01  Original release for post 1.0 work
48215698Ssimon *                      Modified target mode to use IoIndex instead of
49312826Sjkim *                      HostIndex and IocIndex. Added Alias.
50215698Ssimon *  01-09-01  01.01.02  Added defines for TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER
51142429Snectar *                      and TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER.
52142429Snectar *  02-20-01  01.01.03  Started using MPI_POINTER.
53276861Sjkim *                      Added structures for MPI_TARGET_SCSI_SPI_CMD_BUFFER and
54276861Sjkim *                      MPI_TARGET_FCP_CMD_BUFFER.
55276861Sjkim *  03-27-01  01.01.04  Added structure offset comments.
5696593Smarkm *  08-08-01  01.02.01  Original release for v1.2 work.
57344604Sjkim *  09-28-01  01.02.02  Added structure for MPI_TARGET_SCSI_SPI_STATUS_IU.
58344604Sjkim *                      Added PriorityReason field to some replies and
59344604Sjkim *                      defined more PriorityReason codes.
60344604Sjkim *                      Added some defines for to support previous version
61344604Sjkim *                      of MPI.
62344604Sjkim *  10-04-01  01.02.03  Added PriorityReason to MSG_TARGET_ERROR_REPLY.
63215698Ssimon *  11-01-01  01.02.04  Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY.
64344604Sjkim *  03-14-02  01.02.05  Modified MPI_TARGET_FCP_RSP_BUFFER to get the proper
65344604Sjkim *                      byte ordering.
66344604Sjkim *  05-31-02  01.02.06  Modified TARGET_MODE_REPLY_ALIAS_MASK to only include
67344604Sjkim *                      one bit.
68276861Sjkim *                      Added AliasIndex field to MPI_TARGET_FCP_CMD_BUFFER.
69215698Ssimon *  09-16-02  01.02.07  Added flags for confirmed completion.
70344604Sjkim *                      Added PRIORITY_REASON_TARGET_BUSY.
7196593Smarkm *  11-15-02  01.02.08  Added AliasID field to MPI_TARGET_SCSI_SPI_CMD_BUFFER.
7296593Smarkm *  04-01-03  01.02.09  Added OptionalOxid field to MPI_TARGET_FCP_CMD_BUFFER.
7396593Smarkm *  05-11-04  01.03.01  Original release for MPI v1.3.
7496593Smarkm *  08-19-04  01.05.01  Added new request message structures for
7596593Smarkm *                      MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
7696593Smarkm *                      MSG_TARGET_CMD_BUF_POST_LIST_REQUEST, and
7796593Smarkm *                      MSG_TARGET_ASSIST_EXT_REQUEST.
7896593Smarkm *                      Added new structures for SAS SSP Command buffer, SSP
7996593Smarkm *                      Task buffer, and SSP Status IU.
8096593Smarkm *  10-05-04  01.05.02  MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY added.
8196593Smarkm *  02-22-05  01.05.03  Changed a comment.
8296593Smarkm *  03-11-05  01.05.04  Removed TargetAssistExtended Request.
8396593Smarkm *  06-24-05  01.05.05  Added TargetAssistExtended structures and defines.
8496593Smarkm *  03-27-06  01.05.06  Added a comment.
8596593Smarkm *  --------------------------------------------------------------------------
8696593Smarkm */
8796593Smarkm
8896593Smarkm#ifndef MPI_TARG_H
8996593Smarkm#define MPI_TARG_H
9096593Smarkm
9196593Smarkm
9296593Smarkm/******************************************************************************
9396593Smarkm*
9496593Smarkm*        S C S I    T a r g e t    M e s s a g e s
9596593Smarkm*
9696593Smarkm*******************************************************************************/
9796593Smarkm
9896593Smarkmtypedef struct _CMD_BUFFER_DESCRIPTOR
9996593Smarkm{
10096593Smarkm    U16                     IoIndex;                    /* 00h */
10196593Smarkm    U16                     Reserved;                   /* 02h */
10296593Smarkm    union                                               /* 04h */
10396593Smarkm    {
10496593Smarkm        U32                 PhysicalAddress32;
10596593Smarkm        U64                 PhysicalAddress64;
10696593Smarkm    } u;
10796593Smarkm} CMD_BUFFER_DESCRIPTOR, MPI_POINTER PTR_CMD_BUFFER_DESCRIPTOR,
10896593Smarkm  CmdBufferDescriptor_t, MPI_POINTER pCmdBufferDescriptor_t;
10996593Smarkm
11096593Smarkm
11196593Smarkm/****************************************************************************/
11296593Smarkm/* Target Command Buffer Post Request                                       */
11396593Smarkm/****************************************************************************/
11496593Smarkm
11596593Smarkmtypedef struct _MSG_TARGET_CMD_BUFFER_POST_REQUEST
11696593Smarkm{
11796593Smarkm    U8                      BufferPostFlags;            /* 00h */
11896593Smarkm    U8                      BufferCount;                /* 01h */
11996593Smarkm    U8                      ChainOffset;                /* 02h */
12096593Smarkm    U8                      Function;                   /* 03h */
12196593Smarkm    U8                      BufferLength;               /* 04h */
12296593Smarkm    U8                      Reserved;                   /* 05h */
12396593Smarkm    U8                      Reserved1;                  /* 06h */
12496593Smarkm    U8                      MsgFlags;                   /* 07h */
12596593Smarkm    U32                     MsgContext;                 /* 08h */
12696593Smarkm    CMD_BUFFER_DESCRIPTOR   Buffer[1];                  /* 0Ch */
12796593Smarkm} MSG_TARGET_CMD_BUFFER_POST_REQUEST, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REQUEST,
12896593Smarkm  TargetCmdBufferPostRequest_t, MPI_POINTER pTargetCmdBufferPostRequest_t;
12996593Smarkm
13096593Smarkm#define CMD_BUFFER_POST_FLAGS_PORT_MASK         (0x01)
13196593Smarkm#define CMD_BUFFER_POST_FLAGS_ADDR_MODE_MASK    (0x80)
13296593Smarkm#define CMD_BUFFER_POST_FLAGS_ADDR_MODE_32      (0)
133142429Snectar#define CMD_BUFFER_POST_FLAGS_ADDR_MODE_64      (1)
13496593Smarkm#define CMD_BUFFER_POST_FLAGS_64_BIT_ADDR       (0x80)
135100946Snectar
136356290Sjkim#define CMD_BUFFER_POST_IO_INDEX_MASK           (0x00003FFF)
137215698Ssimon#define CMD_BUFFER_POST_IO_INDEX_MASK_0100      (0x000003FF) /* obsolete */
138215698Ssimon
139215698Ssimon
140215698Ssimontypedef struct _MSG_TARGET_CMD_BUFFER_POST_REPLY
14196593Smarkm{
142142429Snectar    U8                      BufferPostFlags;            /* 00h */
14396593Smarkm    U8                      BufferCount;                /* 01h */
14496593Smarkm    U8                      MsgLength;                  /* 02h */
14596593Smarkm    U8                      Function;                   /* 03h */
14696593Smarkm    U8                      BufferLength;               /* 04h */
147215698Ssimon    U8                      Reserved;                   /* 05h */
14896593Smarkm    U8                      Reserved1;                  /* 06h */
14996593Smarkm    U8                      MsgFlags;                   /* 07h */
15096593Smarkm    U32                     MsgContext;                 /* 08h */
15196593Smarkm    U16                     Reserved2;                  /* 0Ch */
15296593Smarkm    U16                     IOCStatus;                  /* 0Eh */
15396593Smarkm    U32                     IOCLogInfo;                 /* 10h */
15496593Smarkm} MSG_TARGET_CMD_BUFFER_POST_REPLY, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REPLY,
155142429Snectar  TargetCmdBufferPostReply_t, MPI_POINTER pTargetCmdBufferPostReply_t;
15696593Smarkm
15796593Smarkm/* the following structure is obsolete as of MPI v1.2 */
158100946Snectartypedef struct _MSG_PRIORITY_CMD_RECEIVED_REPLY
159100946Snectar{
160100946Snectar    U16                     Reserved;                   /* 00h */
16196593Smarkm    U8                      MsgLength;                  /* 02h */
16296593Smarkm    U8                      Function;                   /* 03h */
163344604Sjkim    U16                     Reserved1;                  /* 04h */
16496593Smarkm    U8                      Reserved2;                  /* 06h */
16596593Smarkm    U8                      MsgFlags;                   /* 07h */
16696593Smarkm    U32                     MsgContext;                 /* 08h */
167344604Sjkim    U8                      PriorityReason;             /* 0Ch */
168100946Snectar    U8                      Reserved3;                  /* 0Dh */
169100946Snectar    U16                     IOCStatus;                  /* 0Eh */
170100946Snectar    U32                     IOCLogInfo;                 /* 10h */
171100946Snectar    U32                     ReplyWord;                  /* 14h */
172100946Snectar} MSG_PRIORITY_CMD_RECEIVED_REPLY, MPI_POINTER PTR_MSG_PRIORITY_CMD_RECEIVED_REPLY,
173100946Snectar  PriorityCommandReceivedReply_t, MPI_POINTER pPriorityCommandReceivedReply_t;
174110010Smarkm
175110010Smarkm
176110010Smarkmtypedef struct _MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY
177110010Smarkm{
178110010Smarkm    U16                     Reserved;                   /* 00h */
179110010Smarkm    U8                      MsgLength;                  /* 02h */
180110010Smarkm    U8                      Function;                   /* 03h */
181110010Smarkm    U16                     Reserved1;                  /* 04h */
182110010Smarkm    U8                      Reserved2;                  /* 06h */
183110010Smarkm    U8                      MsgFlags;                   /* 07h */
184110010Smarkm    U32                     MsgContext;                 /* 08h */
185276861Sjkim    U8                      PriorityReason;             /* 0Ch */
186344604Sjkim    U8                      Reserved3;                  /* 0Dh */
187110010Smarkm    U16                     IOCStatus;                  /* 0Eh */
188110010Smarkm    U32                     IOCLogInfo;                 /* 10h */
189344604Sjkim    U32                     ReplyWord;                  /* 14h */
190110010Smarkm} MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
191110010Smarkm  MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
19296593Smarkm  TargetCmdBufferPostErrorReply_t, MPI_POINTER pTargetCmdBufferPostErrorReply_t;
19396593Smarkm
194344604Sjkim#define PRIORITY_REASON_NO_DISCONNECT           (0x00)
19596593Smarkm#define PRIORITY_REASON_SCSI_TASK_MANAGEMENT    (0x01)
19696593Smarkm#define PRIORITY_REASON_CMD_PARITY_ERR          (0x02)
197344604Sjkim#define PRIORITY_REASON_MSG_OUT_PARITY_ERR      (0x03)
198#define PRIORITY_REASON_LQ_CRC_ERR              (0x04)
199#define PRIORITY_REASON_CMD_CRC_ERR             (0x05)
200#define PRIORITY_REASON_PROTOCOL_ERR            (0x06)
201#define PRIORITY_REASON_DATA_OUT_PARITY_ERR     (0x07)
202#define PRIORITY_REASON_DATA_OUT_CRC_ERR        (0x08)
203#define PRIORITY_REASON_TARGET_BUSY             (0x09)
204#define PRIORITY_REASON_UNKNOWN                 (0xFF)
205
206
207/****************************************************************************/
208/* Target Command Buffer Post Base Request                                  */
209/****************************************************************************/
210
211typedef struct _MSG_TARGET_CMD_BUF_POST_BASE_REQUEST
212{
213    U8                      BufferPostFlags;            /* 00h */
214    U8                      PortNumber;                 /* 01h */
215    U8                      ChainOffset;                /* 02h */
216    U8                      Function;                   /* 03h */
217    U16                     TotalCmdBuffers;            /* 04h */
218    U8                      Reserved;                   /* 06h */
219    U8                      MsgFlags;                   /* 07h */
220    U32                     MsgContext;                 /* 08h */
221    U32                     Reserved1;                  /* 0Ch */
222    U16                     CmdBufferLength;            /* 10h */
223    U16                     NextCmdBufferOffset;        /* 12h */
224    U32                     BaseAddressLow;             /* 14h */
225    U32                     BaseAddressHigh;            /* 18h */
226} MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
227  MPI_POINTER PTR__MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
228  TargetCmdBufferPostBaseRequest_t,
229  MPI_POINTER pTargetCmdBufferPostBaseRequest_t;
230
231#define CMD_BUFFER_POST_BASE_FLAGS_AUTO_POST_ALL    (0x01)
232
233
234typedef struct _MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY
235{
236    U16                     Reserved;                   /* 00h */
237    U8                      MsgLength;                  /* 02h */
238    U8                      Function;                   /* 03h */
239    U16                     Reserved1;                  /* 04h */
240    U8                      Reserved2;                  /* 06h */
241    U8                      MsgFlags;                   /* 07h */
242    U32                     MsgContext;                 /* 08h */
243    U16                     Reserved3;                  /* 0Ch */
244    U16                     IOCStatus;                  /* 0Eh */
245    U32                     IOCLogInfo;                 /* 10h */
246} MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY,
247  MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY,
248  TargetCmdBufferPostBaseListReply_t,
249  MPI_POINTER pTargetCmdBufferPostBaseListReply_t;
250
251
252/****************************************************************************/
253/* Target Command Buffer Post List Request                                  */
254/****************************************************************************/
255
256typedef struct _MSG_TARGET_CMD_BUF_POST_LIST_REQUEST
257{
258    U8                      Reserved;                   /* 00h */
259    U8                      PortNumber;                 /* 01h */
260    U8                      ChainOffset;                /* 02h */
261    U8                      Function;                   /* 03h */
262    U16                     CmdBufferCount;             /* 04h */
263    U8                      Reserved1;                  /* 06h */
264    U8                      MsgFlags;                   /* 07h */
265    U32                     MsgContext;                 /* 08h */
266    U32                     Reserved2;                  /* 0Ch */
267    U16                     IoIndex[2];                 /* 10h */
268} MSG_TARGET_CMD_BUF_POST_LIST_REQUEST,
269  MPI_POINTER PTR_MSG_TARGET_CMD_BUF_POST_LIST_REQUEST,
270  TargetCmdBufferPostListRequest_t,
271  MPI_POINTER pTargetCmdBufferPostListRequest_t;
272
273
274/****************************************************************************/
275/* Command Buffer Formats (with 16 byte CDB)                                */
276/****************************************************************************/
277
278typedef struct _MPI_TARGET_FCP_CMD_BUFFER
279{
280    U8      FcpLun[8];                                  /* 00h */
281    U8      FcpCntl[4];                                 /* 08h */
282    U8      FcpCdb[16];                                 /* 0Ch */
283    U32     FcpDl;                                      /* 1Ch */
284    U8      AliasIndex;                                 /* 20h */
285    U8      Reserved1;                                  /* 21h */
286    U16     OptionalOxid;                               /* 22h */
287} MPI_TARGET_FCP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_CMD_BUFFER,
288  MpiTargetFcpCmdBuffer, MPI_POINTER pMpiTargetFcpCmdBuffer;
289
290
291typedef struct _MPI_TARGET_SCSI_SPI_CMD_BUFFER
292{
293    /* SPI L_Q information unit */
294    U8      L_QType;                                    /* 00h */
295    U8      Reserved;                                   /* 01h */
296    U16     Tag;                                        /* 02h */
297    U8      LogicalUnitNumber[8];                       /* 04h */
298    U32     DataLength;                                 /* 0Ch */
299    /* SPI command information unit */
300    U8      ReservedFirstByteOfCommandIU;               /* 10h */
301    U8      TaskAttribute;                              /* 11h */
302    U8      TaskManagementFlags;                        /* 12h */
303    U8      AdditionalCDBLength;                        /* 13h */
304    U8      CDB[16];                                    /* 14h */
305    /* Alias ID */
306    U8      AliasID;                                    /* 24h */
307    U8      Reserved1;                                  /* 25h */
308    U16     Reserved2;                                  /* 26h */
309} MPI_TARGET_SCSI_SPI_CMD_BUFFER,
310  MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER,
311  MpiTargetScsiSpiCmdBuffer, MPI_POINTER pMpiTargetScsiSpiCmdBuffer;
312
313
314typedef struct _MPI_TARGET_SSP_CMD_BUFFER
315{
316    U8      FrameType;                                  /* 00h */
317    U8      Reserved1;                                  /* 01h */
318    U16     Reserved2;                                  /* 02h */
319    U16     InitiatorTag;                               /* 04h */
320    U16     DevHandle;                                  /* 06h */
321    /* COMMAND information unit starts here */
322    U8      LogicalUnitNumber[8];                       /* 08h */
323    U8      Reserved3;                                  /* 10h */
324    U8      TaskAttribute; /* lower 3 bits */           /* 11h */
325    U8      Reserved4;                                  /* 12h */
326    U8      AdditionalCDBLength; /* upper 5 bits */     /* 13h */
327    U8      CDB[16];                                    /* 14h */
328    /* Additional CDB bytes extend past the CDB field */
329} MPI_TARGET_SSP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_SSP_CMD_BUFFER,
330  MpiTargetSspCmdBuffer, MPI_POINTER pMpiTargetSspCmdBuffer;
331
332typedef struct _MPI_TARGET_SSP_TASK_BUFFER
333{
334    U8      FrameType;                                  /* 00h */
335    U8      Reserved1;                                  /* 01h */
336    U16     Reserved2;                                  /* 02h */
337    U16     InitiatorTag;                               /* 04h */
338    U16     DevHandle;                                  /* 06h */
339    /* TASK information unit starts here */
340    U8      LogicalUnitNumber[8];                       /* 08h */
341    U8      Reserved3;                                  /* 10h */
342    U8      Reserved4;                                  /* 11h */
343    U8      TaskManagementFunction;                     /* 12h */
344    U8      Reserved5;                                  /* 13h */
345    U16     ManagedTaskTag;                             /* 14h */
346    U16     Reserved6;                                  /* 16h */
347    U32     Reserved7;                                  /* 18h */
348    U32     Reserved8;                                  /* 1Ch */
349    U32     Reserved9;                                  /* 20h */
350} MPI_TARGET_SSP_TASK_BUFFER, MPI_POINTER PTR_MPI_TARGET_SSP_TASK_BUFFER,
351  MpiTargetSspTaskBuffer, MPI_POINTER pMpiTargetSspTaskBuffer;
352
353
354/****************************************************************************/
355/* Target Assist Request                                                    */
356/****************************************************************************/
357
358typedef struct _MSG_TARGET_ASSIST_REQUEST
359{
360    U8                      StatusCode;                 /* 00h */
361    U8                      TargetAssistFlags;          /* 01h */
362    U8                      ChainOffset;                /* 02h */
363    U8                      Function;                   /* 03h */
364    U16                     QueueTag;                   /* 04h */
365    U8                      Reserved;                   /* 06h */
366    U8                      MsgFlags;                   /* 07h */
367    U32                     MsgContext;                 /* 08h */
368    U32                     ReplyWord;                  /* 0Ch */
369    U8                      LUN[8];                     /* 10h */
370    U32                     RelativeOffset;             /* 18h */
371    U32                     DataLength;                 /* 1Ch */
372    SGE_IO_UNION            SGL[1];                     /* 20h */
373} MSG_TARGET_ASSIST_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_REQUEST,
374  TargetAssistRequest_t, MPI_POINTER pTargetAssistRequest_t;
375
376#define TARGET_ASSIST_FLAGS_DATA_DIRECTION          (0x01)
377#define TARGET_ASSIST_FLAGS_AUTO_STATUS             (0x02)
378#define TARGET_ASSIST_FLAGS_HIGH_PRIORITY           (0x04)
379#define TARGET_ASSIST_FLAGS_CONFIRMED               (0x08)
380#define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER       (0x80)
381
382/* Standard Target Mode Reply message */
383typedef struct _MSG_TARGET_ERROR_REPLY
384{
385    U16                     Reserved;                   /* 00h */
386    U8                      MsgLength;                  /* 02h */
387    U8                      Function;                   /* 03h */
388    U16                     Reserved1;                  /* 04h */
389    U8                      Reserved2;                  /* 06h */
390    U8                      MsgFlags;                   /* 07h */
391    U32                     MsgContext;                 /* 08h */
392    U8                      PriorityReason;             /* 0Ch */
393    U8                      Reserved3;                  /* 0Dh */
394    U16                     IOCStatus;                  /* 0Eh */
395    U32                     IOCLogInfo;                 /* 10h */
396    U32                     ReplyWord;                  /* 14h */
397    U32                     TransferCount;              /* 18h */
398} MSG_TARGET_ERROR_REPLY, MPI_POINTER PTR_MSG_TARGET_ERROR_REPLY,
399  TargetErrorReply_t, MPI_POINTER pTargetErrorReply_t;
400
401
402/****************************************************************************/
403/* Target Assist Extended Request                                           */
404/****************************************************************************/
405
406typedef struct _MSG_TARGET_ASSIST_EXT_REQUEST
407{
408    U8                      StatusCode;                     /* 00h */
409    U8                      TargetAssistFlags;              /* 01h */
410    U8                      ChainOffset;                    /* 02h */
411    U8                      Function;                       /* 03h */
412    U16                     QueueTag;                       /* 04h */
413    U8                      Reserved1;                      /* 06h */
414    U8                      MsgFlags;                       /* 07h */
415    U32                     MsgContext;                     /* 08h */
416    U32                     ReplyWord;                      /* 0Ch */
417    U8                      LUN[8];                         /* 10h */
418    U32                     RelativeOffset;                 /* 18h */
419    U32                     Reserved2;                      /* 1Ch */
420    U32                     Reserved3;                      /* 20h */
421    U32                     PrimaryReferenceTag;            /* 24h */
422    U16                     PrimaryApplicationTag;          /* 28h */
423    U16                     PrimaryApplicationTagMask;      /* 2Ah */
424    U32                     Reserved4;                      /* 2Ch */
425    U32                     DataLength;                     /* 30h */
426    U32                     BidirectionalDataLength;        /* 34h */
427    U32                     SecondaryReferenceTag;          /* 38h */
428    U16                     SecondaryApplicationTag;        /* 3Ch */
429    U16                     Reserved5;                      /* 3Eh */
430    U16                     EEDPFlags;                      /* 40h */
431    U16                     ApplicationTagTranslationMask;  /* 42h */
432    U32                     EEDPBlockSize;                  /* 44h */
433    U8                      SGLOffset0;                     /* 48h */
434    U8                      SGLOffset1;                     /* 49h */
435    U8                      SGLOffset2;                     /* 4Ah */
436    U8                      SGLOffset3;                     /* 4Bh */
437    U32                     Reserved6;                      /* 4Ch */
438    SGE_IO_UNION            SGL[1];                         /* 50h */
439} MSG_TARGET_ASSIST_EXT_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_EXT_REQUEST,
440  TargetAssistExtRequest_t, MPI_POINTER pTargetAssistExtRequest_t;
441
442/* see the defines after MSG_TARGET_ASSIST_REQUEST for TargetAssistFlags */
443
444/* defines for the MsgFlags field */
445#define TARGET_ASSIST_EXT_MSGFLAGS_BIDIRECTIONAL        (0x20)
446#define TARGET_ASSIST_EXT_MSGFLAGS_MULTICAST            (0x10)
447#define TARGET_ASSIST_EXT_MSGFLAGS_SGL_OFFSET_CHAINS    (0x08)
448
449/* defines for the EEDPFlags field */
450#define TARGET_ASSIST_EXT_EEDP_MASK_OP          (0x0007)
451#define TARGET_ASSIST_EXT_EEDP_NOOP_OP          (0x0000)
452#define TARGET_ASSIST_EXT_EEDP_CHK_OP           (0x0001)
453#define TARGET_ASSIST_EXT_EEDP_STRIP_OP         (0x0002)
454#define TARGET_ASSIST_EXT_EEDP_CHKRM_OP         (0x0003)
455#define TARGET_ASSIST_EXT_EEDP_INSERT_OP        (0x0004)
456#define TARGET_ASSIST_EXT_EEDP_REPLACE_OP       (0x0006)
457#define TARGET_ASSIST_EXT_EEDP_CHKREGEN_OP      (0x0007)
458
459#define TARGET_ASSIST_EXT_EEDP_PASS_REF_TAG     (0x0008)
460
461#define TARGET_ASSIST_EXT_EEDP_T10_CHK_MASK     (0x0700)
462#define TARGET_ASSIST_EXT_EEDP_T10_CHK_GUARD    (0x0100)
463#define TARGET_ASSIST_EXT_EEDP_T10_CHK_APPTAG   (0x0200)
464#define TARGET_ASSIST_EXT_EEDP_T10_CHK_REFTAG   (0x0400)
465#define TARGET_ASSIST_EXT_EEDP_T10_CHK_SHIFT    (8)
466
467#define TARGET_ASSIST_EXT_EEDP_INC_SEC_APPTAG   (0x1000)
468#define TARGET_ASSIST_EXT_EEDP_INC_PRI_APPTAG   (0x2000)
469#define TARGET_ASSIST_EXT_EEDP_INC_SEC_REFTAG   (0x4000)
470#define TARGET_ASSIST_EXT_EEDP_INC_PRI_REFTAG   (0x8000)
471
472
473/****************************************************************************/
474/* Target Status Send Request                                               */
475/****************************************************************************/
476
477typedef struct _MSG_TARGET_STATUS_SEND_REQUEST
478{
479    U8                      StatusCode;                 /* 00h */
480    U8                      StatusFlags;                /* 01h */
481    U8                      ChainOffset;                /* 02h */
482    U8                      Function;                   /* 03h */
483    U16                     QueueTag;                   /* 04h */
484    U8                      Reserved;                   /* 06h */
485    U8                      MsgFlags;                   /* 07h */
486    U32                     MsgContext;                 /* 08h */
487    U32                     ReplyWord;                  /* 0Ch */
488    U8                      LUN[8];                     /* 10h */
489    SGE_SIMPLE_UNION        StatusDataSGE;              /* 18h */
490} MSG_TARGET_STATUS_SEND_REQUEST, MPI_POINTER PTR_MSG_TARGET_STATUS_SEND_REQUEST,
491  TargetStatusSendRequest_t, MPI_POINTER pTargetStatusSendRequest_t;
492
493#define TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS   (0x01)
494#define TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY      (0x04)
495#define TARGET_STATUS_SEND_FLAGS_CONFIRMED          (0x08)
496#define TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER  (0x80)
497
498/*
499 * NOTE: FCP_RSP data is big-endian. When used on a little-endian system, this
500 * structure properly orders the bytes.
501 */
502typedef struct _MPI_TARGET_FCP_RSP_BUFFER
503{
504    U8      Reserved0[8];                               /* 00h */
505    U8      Reserved1[2];                               /* 08h */
506    U8      FcpFlags;                                   /* 0Ah */
507    U8      FcpStatus;                                  /* 0Bh */
508    U32     FcpResid;                                   /* 0Ch */
509    U32     FcpSenseLength;                             /* 10h */
510    U32     FcpResponseLength;                          /* 14h */
511    U8      FcpResponseData[8];                         /* 18h */
512    U8      FcpSenseData[32]; /* Pad to 64 bytes */     /* 20h */
513} MPI_TARGET_FCP_RSP_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_RSP_BUFFER,
514  MpiTargetFcpRspBuffer, MPI_POINTER pMpiTargetFcpRspBuffer;
515
516/*
517 * NOTE: The SPI status IU is big-endian. When used on a little-endian system,
518 * this structure properly orders the bytes.
519 */
520typedef struct _MPI_TARGET_SCSI_SPI_STATUS_IU
521{
522    U8      Reserved0;                                  /* 00h */
523    U8      Reserved1;                                  /* 01h */
524    U8      Valid;                                      /* 02h */
525    U8      Status;                                     /* 03h */
526    U32     SenseDataListLength;                        /* 04h */
527    U32     PktFailuresListLength;                      /* 08h */
528    U8      SenseData[52]; /* Pad the IU to 64 bytes */ /* 0Ch */
529} MPI_TARGET_SCSI_SPI_STATUS_IU, MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_STATUS_IU,
530  TargetScsiSpiStatusIU_t, MPI_POINTER pTargetScsiSpiStatusIU_t;
531
532/*
533 * NOTE: The SSP status IU is big-endian. When used on a little-endian system,
534 * this structure properly orders the bytes.
535 */
536typedef struct _MPI_TARGET_SSP_RSP_IU
537{
538    U32     Reserved0[6]; /* reserved for SSP header */ /* 00h */
539    /* start of RESPONSE information unit */
540    U32     Reserved1;                                  /* 18h */
541    U32     Reserved2;                                  /* 1Ch */
542    U16     Reserved3;                                  /* 20h */
543    U8      DataPres; /* lower 2 bits */                /* 22h */
544    U8      Status;                                     /* 23h */
545    U32     Reserved4;                                  /* 24h */
546    U32     SenseDataLength;                            /* 28h */
547    U32     ResponseDataLength;                         /* 2Ch */
548    U8      ResponseSenseData[4];                       /* 30h */
549} MPI_TARGET_SSP_RSP_IU, MPI_POINTER PTR_MPI_TARGET_SSP_RSP_IU,
550  MpiTargetSspRspIu_t, MPI_POINTER pMpiTargetSspRspIu_t;
551
552
553/****************************************************************************/
554/* Target Mode Abort Request                                                */
555/****************************************************************************/
556
557typedef struct _MSG_TARGET_MODE_ABORT_REQUEST
558{
559    U8                      AbortType;                  /* 00h */
560    U8                      Reserved;                   /* 01h */
561    U8                      ChainOffset;                /* 02h */
562    U8                      Function;                   /* 03h */
563    U16                     Reserved1;                  /* 04h */
564    U8                      Reserved2;                  /* 06h */
565    U8                      MsgFlags;                   /* 07h */
566    U32                     MsgContext;                 /* 08h */
567    U32                     ReplyWord;                  /* 0Ch */
568    U32                     MsgContextToAbort;          /* 10h */
569} MSG_TARGET_MODE_ABORT, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT,
570  TargetModeAbort_t, MPI_POINTER pTargetModeAbort_t;
571
572#define TARGET_MODE_ABORT_TYPE_ALL_CMD_BUFFERS      (0x00)
573#define TARGET_MODE_ABORT_TYPE_ALL_IO               (0x01)
574#define TARGET_MODE_ABORT_TYPE_EXACT_IO             (0x02)
575#define TARGET_MODE_ABORT_TYPE_EXACT_IO_REQUEST     (0x03)
576
577/* Target Mode Abort Reply */
578
579typedef struct _MSG_TARGET_MODE_ABORT_REPLY
580{
581    U16                     Reserved;                   /* 00h */
582    U8                      MsgLength;                  /* 02h */
583    U8                      Function;                   /* 03h */
584    U16                     Reserved1;                  /* 04h */
585    U8                      Reserved2;                  /* 06h */
586    U8                      MsgFlags;                   /* 07h */
587    U32                     MsgContext;                 /* 08h */
588    U16                     Reserved3;                  /* 0Ch */
589    U16                     IOCStatus;                  /* 0Eh */
590    U32                     IOCLogInfo;                 /* 10h */
591    U32                     AbortCount;                 /* 14h */
592} MSG_TARGET_MODE_ABORT_REPLY, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT_REPLY,
593  TargetModeAbortReply_t, MPI_POINTER pTargetModeAbortReply_t;
594
595
596/****************************************************************************/
597/* Target Mode Context Reply                                                */
598/****************************************************************************/
599
600#define TARGET_MODE_REPLY_IO_INDEX_MASK         (0x00003FFF)
601#define TARGET_MODE_REPLY_IO_INDEX_SHIFT        (0)
602#define TARGET_MODE_REPLY_INITIATOR_INDEX_MASK  (0x03FFC000)
603#define TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT (14)
604#define TARGET_MODE_REPLY_ALIAS_MASK            (0x04000000)
605#define TARGET_MODE_REPLY_ALIAS_SHIFT           (26)
606#define TARGET_MODE_REPLY_PORT_MASK             (0x10000000)
607#define TARGET_MODE_REPLY_PORT_SHIFT            (28)
608
609
610#define GET_IO_INDEX(x)     (((x) & TARGET_MODE_REPLY_IO_INDEX_MASK)           \
611                                    >> TARGET_MODE_REPLY_IO_INDEX_SHIFT)
612
613#define SET_IO_INDEX(t, i)                                                     \
614            ((t) = ((t) & ~TARGET_MODE_REPLY_IO_INDEX_MASK) |                  \
615                              (((i) << TARGET_MODE_REPLY_IO_INDEX_SHIFT) &     \
616                                             TARGET_MODE_REPLY_IO_INDEX_MASK))
617
618#define GET_INITIATOR_INDEX(x) (((x) & TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) \
619                                   >> TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT)
620
621#define SET_INITIATOR_INDEX(t, ii)                                             \
622        ((t) = ((t) & ~TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) |               \
623                        (((ii) << TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT) &   \
624                                      TARGET_MODE_REPLY_INITIATOR_INDEX_MASK))
625
626#define GET_ALIAS(x) (((x) & TARGET_MODE_REPLY_ALIAS_MASK)                     \
627                                               >> TARGET_MODE_REPLY_ALIAS_SHIFT)
628
629#define SET_ALIAS(t, a)  ((t) = ((t) & ~TARGET_MODE_REPLY_ALIAS_MASK) |        \
630                                    (((a) << TARGET_MODE_REPLY_ALIAS_SHIFT) &  \
631                                                 TARGET_MODE_REPLY_ALIAS_MASK))
632
633#define GET_PORT(x) (((x) & TARGET_MODE_REPLY_PORT_MASK)                       \
634                                               >> TARGET_MODE_REPLY_PORT_SHIFT)
635
636#define SET_PORT(t, p)  ((t) = ((t) & ~TARGET_MODE_REPLY_PORT_MASK) |          \
637                                    (((p) << TARGET_MODE_REPLY_PORT_SHIFT) &   \
638                                                  TARGET_MODE_REPLY_PORT_MASK))
639
640/* the following obsolete values are for MPI v1.0 support */
641#define TARGET_MODE_REPLY_0100_MASK_HOST_INDEX       (0x000003FF)
642#define TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX      (0)
643#define TARGET_MODE_REPLY_0100_MASK_IOC_INDEX        (0x001FF800)
644#define TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX       (11)
645#define TARGET_MODE_REPLY_0100_PORT_MASK             (0x00400000)
646#define TARGET_MODE_REPLY_0100_PORT_SHIFT            (22)
647#define TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX  (0x1F800000)
648#define TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX (23)
649
650#define GET_HOST_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) \
651                                  >> TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX)
652
653#define SET_HOST_INDEX_0100(t, hi)                                             \
654            ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) |           \
655                         (((hi) << TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX) &  \
656                                      TARGET_MODE_REPLY_0100_MASK_HOST_INDEX))
657
658#define GET_IOC_INDEX_0100(x)   (((x) & TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) \
659                                  >> TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX)
660
661#define SET_IOC_INDEX_0100(t, ii)                                              \
662            ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) |            \
663                        (((ii) << TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX) &    \
664                                     TARGET_MODE_REPLY_0100_MASK_IOC_INDEX))
665
666#define GET_INITIATOR_INDEX_0100(x)                                            \
667            (((x) & TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX)               \
668                              >> TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX)
669
670#define SET_INITIATOR_INDEX_0100(t, ii)                                        \
671        ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) |          \
672                   (((ii) << TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX) &   \
673                                TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX))
674
675
676#endif
677
678