1 /* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_targ.h,v 1.1.2.2 2002/09/01 23:08:06 mjacob Exp $ */
3 * Copyright (c) 2000, 2001 by LSI Logic Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * Title: MPI Target mode messages and structures
29 * Creation Date: June 22, 2000
31 * MPI Version: 01.02.04
36 * Date Version Description
37 * -------- -------- ------------------------------------------------------
38 * 05-08-00 00.10.01 Original release for 0.10 spec dated 4/26/2000.
39 * 06-06-00 01.00.01 Update version number for 1.0 release.
40 * 06-22-00 01.00.02 Added _MSG_TARGET_CMD_BUFFER_POST_REPLY structure.
41 * Corrected DECSRIPTOR typo to DESCRIPTOR.
42 * 11-02-00 01.01.01 Original release for post 1.0 work
43 * Modified target mode to use IoIndex instead of
44 * HostIndex and IocIndex. Added Alias.
45 * 01-09-01 01.01.02 Added defines for TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER
46 * and TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER.
47 * 02-20-01 01.01.03 Started using MPI_POINTER.
48 * Added structures for MPI_TARGET_SCSI_SPI_CMD_BUFFER and
49 * MPI_TARGET_FCP_CMD_BUFFER.
50 * 03-27-01 01.01.04 Added structure offset comments.
51 * 08-08-01 01.02.01 Original release for v1.2 work.
52 * 09-28-01 01.02.02 Added structure for MPI_TARGET_SCSI_SPI_STATUS_IU.
53 * Added PriorityReason field to some replies and
54 * defined more PriorityReason codes.
55 * Added some defines for to support previous version
57 * 10-04-01 01.02.03 Added PriorityReason to MSG_TARGET_ERROR_REPLY.
58 * 11-01-01 01.02.04 Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY.
59 * --------------------------------------------------------------------------
66 /******************************************************************************
68 * S C S I T a r g e t M e s s a g e s
70 *******************************************************************************/
72 typedef struct _CMD_BUFFER_DESCRIPTOR
74 U16 IoIndex; /* 00h */
75 U16 Reserved; /* 02h */
78 U32 PhysicalAddress32;
79 U64 PhysicalAddress64;
81 } CMD_BUFFER_DESCRIPTOR, MPI_POINTER PTR_CMD_BUFFER_DESCRIPTOR,
82 CmdBufferDescriptor_t, MPI_POINTER pCmdBufferDescriptor_t;
85 /****************************************************************************/
86 /* Target Command Buffer Post Request */
87 /****************************************************************************/
89 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REQUEST
91 U8 BufferPostFlags; /* 00h */
92 U8 BufferCount; /* 01h */
93 U8 ChainOffset; /* 02h */
94 U8 Function; /* 03h */
95 U8 BufferLength; /* 04h */
96 U8 Reserved; /* 05h */
97 U8 Reserved1; /* 06h */
98 U8 MsgFlags; /* 07h */
99 U32 MsgContext; /* 08h */
100 CMD_BUFFER_DESCRIPTOR Buffer[1]; /* 0Ch */
101 } MSG_TARGET_CMD_BUFFER_POST_REQUEST, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REQUEST,
102 TargetCmdBufferPostRequest_t, MPI_POINTER pTargetCmdBufferPostRequest_t;
104 #define CMD_BUFFER_POST_FLAGS_PORT_MASK (0x01)
105 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_MASK (0x80)
106 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_32 (0)
107 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_64 (1)
108 #define CMD_BUFFER_POST_FLAGS_64_BIT_ADDR (0x80)
110 #define CMD_BUFFER_POST_IO_INDEX_MASK (0x00003FFF)
111 #define CMD_BUFFER_POST_IO_INDEX_MASK_0100 (0x000003FF) /* obsolete */
114 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REPLY
116 U8 BufferPostFlags; /* 00h */
117 U8 BufferCount; /* 01h */
118 U8 MsgLength; /* 02h */
119 U8 Function; /* 03h */
120 U8 BufferLength; /* 04h */
121 U8 Reserved; /* 05h */
122 U8 Reserved1; /* 06h */
123 U8 MsgFlags; /* 07h */
124 U32 MsgContext; /* 08h */
125 U16 Reserved2; /* 0Ch */
126 U16 IOCStatus; /* 0Eh */
127 U32 IOCLogInfo; /* 10h */
128 } MSG_TARGET_CMD_BUFFER_POST_REPLY, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REPLY,
129 TargetCmdBufferPostReply_t, MPI_POINTER pTargetCmdBufferPostReply_t;
131 /* the following structure is obsolete as of MPI v1.2 */
132 typedef struct _MSG_PRIORITY_CMD_RECEIVED_REPLY
134 U16 Reserved; /* 00h */
135 U8 MsgLength; /* 02h */
136 U8 Function; /* 03h */
137 U16 Reserved1; /* 04h */
138 U8 Reserved2; /* 06h */
139 U8 MsgFlags; /* 07h */
140 U32 MsgContext; /* 08h */
141 U8 PriorityReason; /* 0Ch */
142 U8 Reserved3; /* 0Dh */
143 U16 IOCStatus; /* 0Eh */
144 U32 IOCLogInfo; /* 10h */
145 U32 ReplyWord; /* 14h */
146 } MSG_PRIORITY_CMD_RECEIVED_REPLY, MPI_POINTER PTR_MSG_PRIORITY_CMD_RECEIVED_REPLY,
147 PriorityCommandReceivedReply_t, MPI_POINTER pPriorityCommandReceivedReply_t;
149 #define PRIORITY_REASON_NO_DISCONNECT (0x00)
150 #define PRIORITY_REASON_SCSI_TASK_MANAGEMENT (0x01)
151 #define PRIORITY_REASON_CMD_PARITY_ERR (0x02)
152 #define PRIORITY_REASON_MSG_OUT_PARITY_ERR (0x03)
153 #define PRIORITY_REASON_LQ_CRC_ERR (0x04)
154 #define PRIORITY_REASON_CMD_CRC_ERR (0x05)
155 #define PRIORITY_REASON_PROTOCOL_ERR (0x06)
156 #define PRIORITY_REASON_DATA_OUT_PARITY_ERR (0x07)
157 #define PRIORITY_REASON_DATA_OUT_CRC_ERR (0x08)
158 #define PRIORITY_REASON_UNKNOWN (0xFF)
161 typedef struct _MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY
163 U16 Reserved; /* 00h */
164 U8 MsgLength; /* 02h */
165 U8 Function; /* 03h */
166 U16 Reserved1; /* 04h */
167 U8 Reserved2; /* 06h */
168 U8 MsgFlags; /* 07h */
169 U32 MsgContext; /* 08h */
170 U8 PriorityReason; /* 0Ch */
171 U8 Reserved3; /* 0Dh */
172 U16 IOCStatus; /* 0Eh */
173 U32 IOCLogInfo; /* 10h */
174 U32 ReplyWord; /* 14h */
175 } MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
176 MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY,
177 TargetCmdBufferPostErrorReply_t, MPI_POINTER pTargetCmdBufferPostErrorReply_t;
180 typedef struct _MPI_TARGET_FCP_CMD_BUFFER
182 U8 FcpLun[8]; /* 00h */
183 U8 FcpCntl[4]; /* 08h */
184 U8 FcpCdb[16]; /* 0Ch */
186 } MPI_TARGET_FCP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_CMD_BUFFER,
187 MpiTargetFcpCmdBuffer, MPI_POINTER pMpiTargetFcpCmdBuffer;
190 typedef struct _MPI_TARGET_SCSI_SPI_CMD_BUFFER
192 /* SPI L_Q information unit */
193 U8 L_QType; /* 00h */
194 U8 Reserved; /* 01h */
196 U8 LogicalUnitNumber[8]; /* 04h */
197 U32 DataLength; /* 0Ch */
198 /* SPI command information unit */
199 U8 ReservedFirstByteOfCommandIU; /* 10h */
200 U8 TaskAttribute; /* 11h */
201 U8 TaskManagementFlags; /* 12h */
202 U8 AdditionalCDBLength; /* 13h */
203 U8 CDB[16]; /* 14h */
204 } MPI_TARGET_SCSI_SPI_CMD_BUFFER,
205 MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER,
206 MpiTargetScsiSpiCmdBuffer, MPI_POINTER pMpiTargetScsiSpiCmdBuffer;
209 /****************************************************************************/
210 /* Target Assist Request */
211 /****************************************************************************/
213 typedef struct _MSG_TARGET_ASSIST_REQUEST
215 U8 StatusCode; /* 00h */
216 U8 TargetAssistFlags; /* 01h */
217 U8 ChainOffset; /* 02h */
218 U8 Function; /* 03h */
219 U16 QueueTag; /* 04h */
220 U8 Reserved; /* 06h */
221 U8 MsgFlags; /* 07h */
222 U32 MsgContext; /* 08h */
223 U32 ReplyWord; /* 0Ch */
225 U32 RelativeOffset; /* 18h */
226 U32 DataLength; /* 1Ch */
227 SGE_IO_UNION SGL[1]; /* 20h */
228 } MSG_TARGET_ASSIST_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_REQUEST,
229 TargetAssistRequest_t, MPI_POINTER pTargetAssistRequest_t;
231 #define TARGET_ASSIST_FLAGS_DATA_DIRECTION (0x01)
232 #define TARGET_ASSIST_FLAGS_AUTO_STATUS (0x02)
233 #define TARGET_ASSIST_FLAGS_HIGH_PRIORITY (0x04)
234 #define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER (0x80)
237 typedef struct _MSG_TARGET_ERROR_REPLY
239 U16 Reserved; /* 00h */
240 U8 MsgLength; /* 02h */
241 U8 Function; /* 03h */
242 U16 Reserved1; /* 04h */
243 U8 Reserved2; /* 06h */
244 U8 MsgFlags; /* 07h */
245 U32 MsgContext; /* 08h */
246 U8 PriorityReason; /* 0Ch */
247 U8 Reserved3; /* 0Dh */
248 U16 IOCStatus; /* 0Eh */
249 U32 IOCLogInfo; /* 10h */
250 U32 ReplyWord; /* 14h */
251 U32 TransferCount; /* 18h */
252 } MSG_TARGET_ERROR_REPLY, MPI_POINTER PTR_MSG_TARGET_ERROR_REPLY,
253 TargetErrorReply_t, MPI_POINTER pTargetErrorReply_t;
256 /****************************************************************************/
257 /* Target Status Send Request */
258 /****************************************************************************/
260 typedef struct _MSG_TARGET_STATUS_SEND_REQUEST
262 U8 StatusCode; /* 00h */
263 U8 StatusFlags; /* 01h */
264 U8 ChainOffset; /* 02h */
265 U8 Function; /* 03h */
266 U16 QueueTag; /* 04h */
267 U8 Reserved; /* 06h */
268 U8 MsgFlags; /* 07h */
269 U32 MsgContext; /* 08h */
270 U32 ReplyWord; /* 0Ch */
272 SGE_SIMPLE_UNION StatusDataSGE; /* 18h */
273 } MSG_TARGET_STATUS_SEND_REQUEST, MPI_POINTER PTR_MSG_TARGET_STATUS_SEND_REQUEST,
274 TargetStatusSendRequest_t, MPI_POINTER pTargetStatusSendRequest_t;
276 #define TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS (0x01)
277 #define TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY (0x04)
278 #define TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER (0x80)
280 typedef struct _MPI_TARGET_FCP_RSP_BUFFER
282 U8 Reserved0[8]; /* 00h */
283 U8 FcpStatus; /* 08h */
284 U8 FcpFlags; /* 09h */
285 U8 Reserved1[2]; /* 0Ah */
286 U32 FcpResid; /* 0Ch */
287 U32 FcpSenseLength; /* 10h */
288 U32 FcpResponseLength; /* 14h */
289 U8 FcpResponseData[8]; /* 18h */
290 U8 FcpSenseData[32]; /* Pad to 64 bytes */ /* 20h */
291 } MPI_TARGET_FCP_RSP_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_RSP_BUFFER,
292 MpiTargetFcpRspBuffer, MPI_POINTER pMpiTargetFcpRspBuffer;
294 typedef struct _MPI_TARGET_SCSI_SPI_STATUS_IU
296 U8 Reserved0; /* 00h */
297 U8 Reserved1; /* 01h */
300 U32 SenseDataListLength; /* 04h */
301 U32 PktFailuresListLength; /* 08h */
302 U8 SenseData[52]; /* Pad the IU to 64 bytes */ /* 0Ch */
303 } MPI_TARGET_SCSI_SPI_STATUS_IU, MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_STATUS_IU,
304 TargetScsiSpiStatusIU_t, MPI_POINTER pTargetScsiSpiStatusIU_t;
306 /****************************************************************************/
307 /* Target Mode Abort Request */
308 /****************************************************************************/
310 typedef struct _MSG_TARGET_MODE_ABORT_REQUEST
312 U8 AbortType; /* 00h */
313 U8 Reserved; /* 01h */
314 U8 ChainOffset; /* 02h */
315 U8 Function; /* 03h */
316 U16 Reserved1; /* 04h */
317 U8 Reserved2; /* 06h */
318 U8 MsgFlags; /* 07h */
319 U32 MsgContext; /* 08h */
320 U32 ReplyWord; /* 0Ch */
321 U32 MsgContextToAbort; /* 10h */
322 } MSG_TARGET_MODE_ABORT, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT,
323 TargetModeAbort_t, MPI_POINTER pTargetModeAbort_t;
325 #define TARGET_MODE_ABORT_TYPE_ALL_CMD_BUFFERS (0x00)
326 #define TARGET_MODE_ABORT_TYPE_ALL_IO (0x01)
327 #define TARGET_MODE_ABORT_TYPE_EXACT_IO (0x02)
328 #define TARGET_MODE_ABORT_TYPE_EXACT_IO_REQUEST (0x03)
330 /* Target Mode Abort Reply */
332 typedef struct _MSG_TARGET_MODE_ABORT_REPLY
334 U16 Reserved; /* 00h */
335 U8 MsgLength; /* 02h */
336 U8 Function; /* 03h */
337 U16 Reserved1; /* 04h */
338 U8 Reserved2; /* 06h */
339 U8 MsgFlags; /* 07h */
340 U32 MsgContext; /* 08h */
341 U16 Reserved3; /* 0Ch */
342 U16 IOCStatus; /* 0Eh */
343 U32 IOCLogInfo; /* 10h */
344 U32 AbortCount; /* 14h */
345 } MSG_TARGET_MODE_ABORT_REPLY, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT_REPLY,
346 TargetModeAbortReply_t, MPI_POINTER pTargetModeAbortReply_t;
349 /****************************************************************************/
350 /* Target Mode Context Reply */
351 /****************************************************************************/
353 #define TARGET_MODE_REPLY_IO_INDEX_MASK (0x00003FFF)
354 #define TARGET_MODE_REPLY_IO_INDEX_SHIFT (0)
355 #define TARGET_MODE_REPLY_INITIATOR_INDEX_MASK (0x03FFC000)
356 #define TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT (14)
357 #define TARGET_MODE_REPLY_ALIAS_MASK (0x0C000000)
358 #define TARGET_MODE_REPLY_ALIAS_SHIFT (26)
359 #define TARGET_MODE_REPLY_PORT_MASK (0x10000000)
360 #define TARGET_MODE_REPLY_PORT_SHIFT (28)
363 #define GET_IO_INDEX(x) (((x) & TARGET_MODE_REPLY_IO_INDEX_MASK) \
364 >> TARGET_MODE_REPLY_IO_INDEX_SHIFT)
366 #define SET_IO_INDEX(t, i) \
367 ((t) = ((t) & ~TARGET_MODE_REPLY_IO_INDEX_MASK) | \
368 (((i) << TARGET_MODE_REPLY_IO_INDEX_SHIFT) & \
369 TARGET_MODE_REPLY_IO_INDEX_MASK))
371 #define GET_INITIATOR_INDEX(x) (((x) & TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) \
372 >> TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT)
374 #define SET_INITIATOR_INDEX(t, ii) \
375 ((t) = ((t) & ~TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) | \
376 (((ii) << TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT) & \
377 TARGET_MODE_REPLY_INITIATOR_INDEX_MASK))
379 #define GET_ALIAS(x) (((x) & TARGET_MODE_REPLY_ALIAS_MASK) \
380 >> TARGET_MODE_REPLY_ALIAS_SHIFT)
382 #define SET_ALIAS(t, a) ((t) = ((t) & ~TARGET_MODE_REPLY_ALIAS_MASK) | \
383 (((a) << TARGET_MODE_REPLY_ALIAS_SHIFT) & \
384 TARGET_MODE_REPLY_ALIAS_MASK))
386 #define GET_PORT(x) (((x) & TARGET_MODE_REPLY_PORT_MASK) \
387 >> TARGET_MODE_REPLY_PORT_SHIFT)
389 #define SET_PORT(t, p) ((t) = ((t) & ~TARGET_MODE_REPLY_PORT_MASK) | \
390 (((p) << TARGET_MODE_REPLY_PORT_SHIFT) & \
391 TARGET_MODE_REPLY_PORT_MASK))
393 /* the following obsolete values are for MPI v1.0 support */
394 #define TARGET_MODE_REPLY_0100_MASK_HOST_INDEX (0x000003FF)
395 #define TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX (0)
396 #define TARGET_MODE_REPLY_0100_MASK_IOC_INDEX (0x001FF800)
397 #define TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX (11)
398 #define TARGET_MODE_REPLY_0100_PORT_MASK (0x00400000)
399 #define TARGET_MODE_REPLY_0100_PORT_SHIFT (22)
400 #define TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX (0x1F800000)
401 #define TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX (23)
403 #define GET_HOST_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) \
404 >> TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX)
406 #define SET_HOST_INDEX_0100(t, hi) \
407 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) | \
408 (((hi) << TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX) & \
409 TARGET_MODE_REPLY_0100_MASK_HOST_INDEX))
411 #define GET_IOC_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) \
412 >> TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX)
414 #define SET_IOC_INDEX_0100(t, ii) \
415 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) | \
416 (((ii) << TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX) & \
417 TARGET_MODE_REPLY_0100_MASK_IOC_INDEX))
419 #define GET_INITIATOR_INDEX_0100(x) \
420 (((x) & TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) \
421 >> TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX)
423 #define SET_INITIATOR_INDEX_0100(t, ii) \
424 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) | \
425 (((ii) << TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX) & \
426 TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX))