1 /* $FreeBSD$ */ 2 /* 3 * Copyright (c) 2000-2001 LSI Logic Corporation. 4 * 5 * 6 * Name: MPI_TARG.H 7 * Title: MPI Target mode messages and structures 8 * Creation Date: June 22, 2000 9 * 10 * MPI Version: 01.02.04 11 * 12 * Version History 13 * --------------- 14 * 15 * Date Version Description 16 * -------- -------- ------------------------------------------------------ 17 * 05-08-00 00.10.01 Original release for 0.10 spec dated 4/26/2000. 18 * 06-06-00 01.00.01 Update version number for 1.0 release. 19 * 06-22-00 01.00.02 Added _MSG_TARGET_CMD_BUFFER_POST_REPLY structure. 20 * Corrected DECSRIPTOR typo to DESCRIPTOR. 21 * 11-02-00 01.01.01 Original release for post 1.0 work 22 * Modified target mode to use IoIndex instead of 23 * HostIndex and IocIndex. Added Alias. 24 * 01-09-01 01.01.02 Added defines for TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER 25 * and TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER. 26 * 02-20-01 01.01.03 Started using MPI_POINTER. 27 * Added structures for MPI_TARGET_SCSI_SPI_CMD_BUFFER and 28 * MPI_TARGET_FCP_CMD_BUFFER. 29 * 03-27-01 01.01.04 Added structure offset comments. 30 * 08-08-01 01.02.01 Original release for v1.2 work. 31 * 09-28-01 01.02.02 Added structure for MPI_TARGET_SCSI_SPI_STATUS_IU. 32 * Added PriorityReason field to some replies and 33 * defined more PriorityReason codes. 34 * Added some defines for to support previous version 35 * of MPI. 36 * 10-04-01 01.02.03 Added PriorityReason to MSG_TARGET_ERROR_REPLY. 37 * 11-01-01 01.02.04 Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY. 38 * -------------------------------------------------------------------------- 39 */ 40 41 #ifndef MPI_TARG_H 42 #define MPI_TARG_H 43 44 45 /****************************************************************************** 46 * 47 * S C S I T a r g e t M e s s a g e s 48 * 49 *******************************************************************************/ 50 51 typedef struct _CMD_BUFFER_DESCRIPTOR 52 { 53 U16 IoIndex; /* 00h */ 54 U16 Reserved; /* 02h */ 55 union /* 04h */ 56 { 57 U32 PhysicalAddress32; 58 U64 PhysicalAddress64; 59 } _u; 60 } CMD_BUFFER_DESCRIPTOR, MPI_POINTER PTR_CMD_BUFFER_DESCRIPTOR, 61 CmdBufferDescriptor_t, MPI_POINTER pCmdBufferDescriptor_t; 62 63 64 /****************************************************************************/ 65 /* Target Command Buffer Post Request */ 66 /****************************************************************************/ 67 68 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REQUEST 69 { 70 U8 BufferPostFlags; /* 00h */ 71 U8 BufferCount; /* 01h */ 72 U8 ChainOffset; /* 02h */ 73 U8 Function; /* 03h */ 74 U8 BufferLength; /* 04h */ 75 U8 Reserved; /* 05h */ 76 U8 Reserved1; /* 06h */ 77 U8 MsgFlags; /* 07h */ 78 U32 MsgContext; /* 08h */ 79 CMD_BUFFER_DESCRIPTOR Buffer[1]; /* 0Ch */ 80 } MSG_TARGET_CMD_BUFFER_POST_REQUEST, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REQUEST, 81 TargetCmdBufferPostRequest_t, MPI_POINTER pTargetCmdBufferPostRequest_t; 82 83 #define CMD_BUFFER_POST_FLAGS_PORT_MASK (0x01) 84 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_MASK (0x80) 85 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_32 (0) 86 #define CMD_BUFFER_POST_FLAGS_ADDR_MODE_64 (1) 87 #define CMD_BUFFER_POST_FLAGS_64_BIT_ADDR (0x80) 88 89 #define CMD_BUFFER_POST_IO_INDEX_MASK (0x00003FFF) 90 #define CMD_BUFFER_POST_IO_INDEX_MASK_0100 (0x000003FF) /* obsolete */ 91 92 93 typedef struct _MSG_TARGET_CMD_BUFFER_POST_REPLY 94 { 95 U8 BufferPostFlags; /* 00h */ 96 U8 BufferCount; /* 01h */ 97 U8 MsgLength; /* 02h */ 98 U8 Function; /* 03h */ 99 U8 BufferLength; /* 04h */ 100 U8 Reserved; /* 05h */ 101 U8 Reserved1; /* 06h */ 102 U8 MsgFlags; /* 07h */ 103 U32 MsgContext; /* 08h */ 104 U16 Reserved2; /* 0Ch */ 105 U16 IOCStatus; /* 0Eh */ 106 U32 IOCLogInfo; /* 10h */ 107 } MSG_TARGET_CMD_BUFFER_POST_REPLY, MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_REPLY, 108 TargetCmdBufferPostReply_t, MPI_POINTER pTargetCmdBufferPostReply_t; 109 110 /* the following structure is obsolete as of MPI v1.2 */ 111 typedef struct _MSG_PRIORITY_CMD_RECEIVED_REPLY 112 { 113 U16 Reserved; /* 00h */ 114 U8 MsgLength; /* 02h */ 115 U8 Function; /* 03h */ 116 U16 Reserved1; /* 04h */ 117 U8 Reserved2; /* 06h */ 118 U8 MsgFlags; /* 07h */ 119 U32 MsgContext; /* 08h */ 120 U8 PriorityReason; /* 0Ch */ 121 U8 Reserved3; /* 0Dh */ 122 U16 IOCStatus; /* 0Eh */ 123 U32 IOCLogInfo; /* 10h */ 124 U32 ReplyWord; /* 14h */ 125 } MSG_PRIORITY_CMD_RECEIVED_REPLY, MPI_POINTER PTR_MSG_PRIORITY_CMD_RECEIVED_REPLY, 126 PriorityCommandReceivedReply_t, MPI_POINTER pPriorityCommandReceivedReply_t; 127 128 #define PRIORITY_REASON_NO_DISCONNECT (0x00) 129 #define PRIORITY_REASON_SCSI_TASK_MANAGEMENT (0x01) 130 #define PRIORITY_REASON_CMD_PARITY_ERR (0x02) 131 #define PRIORITY_REASON_MSG_OUT_PARITY_ERR (0x03) 132 #define PRIORITY_REASON_LQ_CRC_ERR (0x04) 133 #define PRIORITY_REASON_CMD_CRC_ERR (0x05) 134 #define PRIORITY_REASON_PROTOCOL_ERR (0x06) 135 #define PRIORITY_REASON_DATA_OUT_PARITY_ERR (0x07) 136 #define PRIORITY_REASON_DATA_OUT_CRC_ERR (0x08) 137 #define PRIORITY_REASON_UNKNOWN (0xFF) 138 139 140 typedef struct _MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY 141 { 142 U16 Reserved; /* 00h */ 143 U8 MsgLength; /* 02h */ 144 U8 Function; /* 03h */ 145 U16 Reserved1; /* 04h */ 146 U8 Reserved2; /* 06h */ 147 U8 MsgFlags; /* 07h */ 148 U32 MsgContext; /* 08h */ 149 U8 PriorityReason; /* 0Ch */ 150 U8 Reserved3; /* 0Dh */ 151 U16 IOCStatus; /* 0Eh */ 152 U32 IOCLogInfo; /* 10h */ 153 U32 ReplyWord; /* 14h */ 154 } MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY, 155 MPI_POINTER PTR_MSG_TARGET_CMD_BUFFER_POST_ERROR_REPLY, 156 TargetCmdBufferPostErrorReply_t, MPI_POINTER pTargetCmdBufferPostErrorReply_t; 157 158 159 typedef struct _MPI_TARGET_FCP_CMD_BUFFER 160 { 161 U8 FcpLun[8]; /* 00h */ 162 U8 FcpCntl[4]; /* 08h */ 163 U8 FcpCdb[16]; /* 0Ch */ 164 U32 FcpDl; /* 1Ch */ 165 } MPI_TARGET_FCP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_CMD_BUFFER, 166 MpiTargetFcpCmdBuffer, MPI_POINTER pMpiTargetFcpCmdBuffer; 167 168 169 typedef struct _MPI_TARGET_SCSI_SPI_CMD_BUFFER 170 { 171 /* SPI L_Q information unit */ 172 U8 L_QType; /* 00h */ 173 U8 Reserved; /* 01h */ 174 U16 Tag; /* 02h */ 175 U8 LogicalUnitNumber[8]; /* 04h */ 176 U32 DataLength; /* 0Ch */ 177 /* SPI command information unit */ 178 U8 ReservedFirstByteOfCommandIU; /* 10h */ 179 U8 TaskAttribute; /* 11h */ 180 U8 TaskManagementFlags; /* 12h */ 181 U8 AdditionalCDBLength; /* 13h */ 182 U8 CDB[16]; /* 14h */ 183 } MPI_TARGET_SCSI_SPI_CMD_BUFFER, 184 MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER, 185 MpiTargetScsiSpiCmdBuffer, MPI_POINTER pMpiTargetScsiSpiCmdBuffer; 186 187 188 /****************************************************************************/ 189 /* Target Assist Request */ 190 /****************************************************************************/ 191 192 typedef struct _MSG_TARGET_ASSIST_REQUEST 193 { 194 U8 StatusCode; /* 00h */ 195 U8 TargetAssistFlags; /* 01h */ 196 U8 ChainOffset; /* 02h */ 197 U8 Function; /* 03h */ 198 U16 QueueTag; /* 04h */ 199 U8 Reserved; /* 06h */ 200 U8 MsgFlags; /* 07h */ 201 U32 MsgContext; /* 08h */ 202 U32 ReplyWord; /* 0Ch */ 203 U8 LUN[8]; /* 10h */ 204 U32 RelativeOffset; /* 18h */ 205 U32 DataLength; /* 1Ch */ 206 SGE_IO_UNION SGL[1]; /* 20h */ 207 } MSG_TARGET_ASSIST_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_REQUEST, 208 TargetAssistRequest_t, MPI_POINTER pTargetAssistRequest_t; 209 210 #define TARGET_ASSIST_FLAGS_DATA_DIRECTION (0x01) 211 #define TARGET_ASSIST_FLAGS_AUTO_STATUS (0x02) 212 #define TARGET_ASSIST_FLAGS_HIGH_PRIORITY (0x04) 213 #define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER (0x80) 214 215 216 typedef struct _MSG_TARGET_ERROR_REPLY 217 { 218 U16 Reserved; /* 00h */ 219 U8 MsgLength; /* 02h */ 220 U8 Function; /* 03h */ 221 U16 Reserved1; /* 04h */ 222 U8 Reserved2; /* 06h */ 223 U8 MsgFlags; /* 07h */ 224 U32 MsgContext; /* 08h */ 225 U8 PriorityReason; /* 0Ch */ 226 U8 Reserved3; /* 0Dh */ 227 U16 IOCStatus; /* 0Eh */ 228 U32 IOCLogInfo; /* 10h */ 229 U32 ReplyWord; /* 14h */ 230 U32 TransferCount; /* 18h */ 231 } MSG_TARGET_ERROR_REPLY, MPI_POINTER PTR_MSG_TARGET_ERROR_REPLY, 232 TargetErrorReply_t, MPI_POINTER pTargetErrorReply_t; 233 234 235 /****************************************************************************/ 236 /* Target Status Send Request */ 237 /****************************************************************************/ 238 239 typedef struct _MSG_TARGET_STATUS_SEND_REQUEST 240 { 241 U8 StatusCode; /* 00h */ 242 U8 StatusFlags; /* 01h */ 243 U8 ChainOffset; /* 02h */ 244 U8 Function; /* 03h */ 245 U16 QueueTag; /* 04h */ 246 U8 Reserved; /* 06h */ 247 U8 MsgFlags; /* 07h */ 248 U32 MsgContext; /* 08h */ 249 U32 ReplyWord; /* 0Ch */ 250 U8 LUN[8]; /* 10h */ 251 SGE_SIMPLE_UNION StatusDataSGE; /* 18h */ 252 } MSG_TARGET_STATUS_SEND_REQUEST, MPI_POINTER PTR_MSG_TARGET_STATUS_SEND_REQUEST, 253 TargetStatusSendRequest_t, MPI_POINTER pTargetStatusSendRequest_t; 254 255 #define TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS (0x01) 256 #define TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY (0x04) 257 #define TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER (0x80) 258 259 typedef struct _MPI_TARGET_FCP_RSP_BUFFER 260 { 261 U8 Reserved0[8]; /* 00h */ 262 U8 FcpStatus; /* 08h */ 263 U8 FcpFlags; /* 09h */ 264 U8 Reserved1[2]; /* 0Ah */ 265 U32 FcpResid; /* 0Ch */ 266 U32 FcpSenseLength; /* 10h */ 267 U32 FcpResponseLength; /* 14h */ 268 U8 FcpResponseData[8]; /* 18h */ 269 U8 FcpSenseData[32]; /* Pad to 64 bytes */ /* 20h */ 270 } MPI_TARGET_FCP_RSP_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_RSP_BUFFER, 271 MpiTargetFcpRspBuffer, MPI_POINTER pMpiTargetFcpRspBuffer; 272 273 typedef struct _MPI_TARGET_SCSI_SPI_STATUS_IU 274 { 275 U8 Reserved0; /* 00h */ 276 U8 Reserved1; /* 01h */ 277 U8 Valid; /* 02h */ 278 U8 Status; /* 03h */ 279 U32 SenseDataListLength; /* 04h */ 280 U32 PktFailuresListLength; /* 08h */ 281 U8 SenseData[52]; /* Pad the IU to 64 bytes */ /* 0Ch */ 282 } MPI_TARGET_SCSI_SPI_STATUS_IU, MPI_POINTER PTR_MPI_TARGET_SCSI_SPI_STATUS_IU, 283 TargetScsiSpiStatusIU_t, MPI_POINTER pTargetScsiSpiStatusIU_t; 284 285 /****************************************************************************/ 286 /* Target Mode Abort Request */ 287 /****************************************************************************/ 288 289 typedef struct _MSG_TARGET_MODE_ABORT_REQUEST 290 { 291 U8 AbortType; /* 00h */ 292 U8 Reserved; /* 01h */ 293 U8 ChainOffset; /* 02h */ 294 U8 Function; /* 03h */ 295 U16 Reserved1; /* 04h */ 296 U8 Reserved2; /* 06h */ 297 U8 MsgFlags; /* 07h */ 298 U32 MsgContext; /* 08h */ 299 U32 ReplyWord; /* 0Ch */ 300 U32 MsgContextToAbort; /* 10h */ 301 } MSG_TARGET_MODE_ABORT, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT, 302 TargetModeAbort_t, MPI_POINTER pTargetModeAbort_t; 303 304 #define TARGET_MODE_ABORT_TYPE_ALL_CMD_BUFFERS (0x00) 305 #define TARGET_MODE_ABORT_TYPE_ALL_IO (0x01) 306 #define TARGET_MODE_ABORT_TYPE_EXACT_IO (0x02) 307 #define TARGET_MODE_ABORT_TYPE_EXACT_IO_REQUEST (0x03) 308 309 /* Target Mode Abort Reply */ 310 311 typedef struct _MSG_TARGET_MODE_ABORT_REPLY 312 { 313 U16 Reserved; /* 00h */ 314 U8 MsgLength; /* 02h */ 315 U8 Function; /* 03h */ 316 U16 Reserved1; /* 04h */ 317 U8 Reserved2; /* 06h */ 318 U8 MsgFlags; /* 07h */ 319 U32 MsgContext; /* 08h */ 320 U16 Reserved3; /* 0Ch */ 321 U16 IOCStatus; /* 0Eh */ 322 U32 IOCLogInfo; /* 10h */ 323 U32 AbortCount; /* 14h */ 324 } MSG_TARGET_MODE_ABORT_REPLY, MPI_POINTER PTR_MSG_TARGET_MODE_ABORT_REPLY, 325 TargetModeAbortReply_t, MPI_POINTER pTargetModeAbortReply_t; 326 327 328 /****************************************************************************/ 329 /* Target Mode Context Reply */ 330 /****************************************************************************/ 331 332 #define TARGET_MODE_REPLY_IO_INDEX_MASK (0x00003FFF) 333 #define TARGET_MODE_REPLY_IO_INDEX_SHIFT (0) 334 #define TARGET_MODE_REPLY_INITIATOR_INDEX_MASK (0x03FFC000) 335 #define TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT (14) 336 #define TARGET_MODE_REPLY_ALIAS_MASK (0x0C000000) 337 #define TARGET_MODE_REPLY_ALIAS_SHIFT (26) 338 #define TARGET_MODE_REPLY_PORT_MASK (0x10000000) 339 #define TARGET_MODE_REPLY_PORT_SHIFT (28) 340 341 342 #define GET_IO_INDEX(x) (((x) & TARGET_MODE_REPLY_IO_INDEX_MASK) \ 343 >> TARGET_MODE_REPLY_IO_INDEX_SHIFT) 344 345 #define SET_IO_INDEX(t, i) \ 346 ((t) = ((t) & ~TARGET_MODE_REPLY_IO_INDEX_MASK) | \ 347 (((i) << TARGET_MODE_REPLY_IO_INDEX_SHIFT) & \ 348 TARGET_MODE_REPLY_IO_INDEX_MASK)) 349 350 #define GET_INITIATOR_INDEX(x) (((x) & TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) \ 351 >> TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT) 352 353 #define SET_INITIATOR_INDEX(t, ii) \ 354 ((t) = ((t) & ~TARGET_MODE_REPLY_INITIATOR_INDEX_MASK) | \ 355 (((ii) << TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT) & \ 356 TARGET_MODE_REPLY_INITIATOR_INDEX_MASK)) 357 358 #define GET_ALIAS(x) (((x) & TARGET_MODE_REPLY_ALIAS_MASK) \ 359 >> TARGET_MODE_REPLY_ALIAS_SHIFT) 360 361 #define SET_ALIAS(t, a) ((t) = ((t) & ~TARGET_MODE_REPLY_ALIAS_MASK) | \ 362 (((a) << TARGET_MODE_REPLY_ALIAS_SHIFT) & \ 363 TARGET_MODE_REPLY_ALIAS_MASK)) 364 365 #define GET_PORT(x) (((x) & TARGET_MODE_REPLY_PORT_MASK) \ 366 >> TARGET_MODE_REPLY_PORT_SHIFT) 367 368 #define SET_PORT(t, p) ((t) = ((t) & ~TARGET_MODE_REPLY_PORT_MASK) | \ 369 (((p) << TARGET_MODE_REPLY_PORT_SHIFT) & \ 370 TARGET_MODE_REPLY_PORT_MASK)) 371 372 /* the following obsolete values are for MPI v1.0 support */ 373 #define TARGET_MODE_REPLY_0100_MASK_HOST_INDEX (0x000003FF) 374 #define TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX (0) 375 #define TARGET_MODE_REPLY_0100_MASK_IOC_INDEX (0x001FF800) 376 #define TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX (11) 377 #define TARGET_MODE_REPLY_0100_PORT_MASK (0x00400000) 378 #define TARGET_MODE_REPLY_0100_PORT_SHIFT (22) 379 #define TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX (0x1F800000) 380 #define TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX (23) 381 382 #define GET_HOST_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) \ 383 >> TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX) 384 385 #define SET_HOST_INDEX_0100(t, hi) \ 386 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_HOST_INDEX) | \ 387 (((hi) << TARGET_MODE_REPLY_0100_SHIFT_HOST_INDEX) & \ 388 TARGET_MODE_REPLY_0100_MASK_HOST_INDEX)) 389 390 #define GET_IOC_INDEX_0100(x) (((x) & TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) \ 391 >> TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX) 392 393 #define SET_IOC_INDEX_0100(t, ii) \ 394 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_IOC_INDEX) | \ 395 (((ii) << TARGET_MODE_REPLY_0100_SHIFT_IOC_INDEX) & \ 396 TARGET_MODE_REPLY_0100_MASK_IOC_INDEX)) 397 398 #define GET_INITIATOR_INDEX_0100(x) \ 399 (((x) & TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) \ 400 >> TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX) 401 402 #define SET_INITIATOR_INDEX_0100(t, ii) \ 403 ((t) = ((t) & ~TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX) | \ 404 (((ii) << TARGET_MODE_REPLY_0100_SHIFT_INITIATOR_INDEX) & \ 405 TARGET_MODE_REPLY_0100_MASK_INITIATOR_INDEX)) 406 407 408 #endif 409 410