1 /* 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2016-2024, Broadcom Inc. All rights reserved. 5 * Support: <fbsd-storage-driver.pdl@broadcom.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * 1. Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation and/or other 15 * materials provided with the distribution. 16 * 3. Neither the name of the Broadcom Inc. nor the names of its contributors 17 * may be used to endorse or promote products derived from this software without 18 * specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * The views and conclusions contained in the software and documentation are 33 * those of the authors and should not be interpreted as representing 34 * official policies,either expressed or implied, of the FreeBSD Project. 35 * 36 * Mail to: Broadcom Inc 1320 Ridder Park Dr, San Jose, CA 95131 37 * 38 * Broadcom Inc. (Broadcom) MPI3MR Adapter FreeBSD 39 * 40 */ 41 #ifndef MPI30_INIT_H 42 #define MPI30_INIT_H 1 43 44 /***************************************************************************** 45 * SCSI Initiator Messages * 46 ****************************************************************************/ 47 48 /***************************************************************************** 49 * SCSI IO Request Message * 50 ****************************************************************************/ 51 typedef struct _MPI3_SCSI_IO_CDB_EEDP32 52 { 53 U8 CDB[20]; /* 0x00 */ 54 U32 PrimaryReferenceTag; /* 0x14 */ 55 U16 PrimaryApplicationTag; /* 0x18 */ 56 U16 PrimaryApplicationTagMask; /* 0x1A */ 57 U32 TransferLength; /* 0x1C */ 58 } MPI3_SCSI_IO_CDB_EEDP32, MPI3_POINTER PTR_MPI3_SCSI_IO_CDB_EEDP32, 59 Mpi3ScsiIoCdbEedp32_t, MPI3_POINTER pMpi3ScsiIoCdbEedp32_t; 60 61 typedef union _MPI3_SCSI_IO_CDB_UNION 62 { 63 U8 CDB32[32]; 64 MPI3_SCSI_IO_CDB_EEDP32 EEDP32; 65 MPI3_SGE_SIMPLE SGE; 66 } MPI3_SCSI_IO_CDB_UNION, MPI3_POINTER PTR_MPI3_SCSI_IO_CDB_UNION, 67 Mpi3ScsiIoCdb_t, MPI3_POINTER pMpi3ScsiIoCdb_t; 68 69 typedef struct _MPI3_SCSI_IO_REQUEST 70 { 71 U16 HostTag; /* 0x00 */ 72 U8 IOCUseOnly02; /* 0x02 */ 73 U8 Function; /* 0x03 */ 74 U16 IOCUseOnly04; /* 0x04 */ 75 U8 IOCUseOnly06; /* 0x06 */ 76 U8 MsgFlags; /* 0x07 */ 77 U16 ChangeCount; /* 0x08 */ 78 U16 DevHandle; /* 0x0A */ 79 U32 Flags; /* 0x0C */ 80 U32 IOCUseOnly10; /* 0x10 */ 81 U32 DataLength; /* 0x14 */ 82 U8 LUN[8]; /* 0x18 */ 83 MPI3_SCSI_IO_CDB_UNION CDB; /* 0x20 */ 84 MPI3_SGE_UNION SGL[4]; /* 0x40 */ 85 } MPI3_SCSI_IO_REQUEST, MPI3_POINTER PTR_MPI3_SCSI_IO_REQUEST, 86 Mpi3SCSIIORequest_t, MPI3_POINTER pMpi3SCSIIORequest_t; 87 88 /**** Defines for the MsgFlags field ****/ 89 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID (0x80) 90 #define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE (0x40) 91 92 /**** Defines for the Flags field ****/ 93 #define MPI3_SCSIIO_FLAGS_LARGE_CDB_MASK (0x60000000) 94 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS (0x00000000) 95 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16 (0x20000000) 96 #define MPI3_SCSIIO_FLAGS_CDB_IN_SEPARATE_BUFFER (0x40000000) 97 #define MPI3_SCSIIO_FLAGS_CDB_PRODUCT_SPECIFIC (0x60000000) 98 #define MPI3_SCSIIO_FLAGS_IOC_USE_ONLY_27_MASK (0x18000000) 99 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_MASK (0x07000000) 100 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SIMPLEQ (0x00000000) 101 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_HEADOFQ (0x01000000) 102 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ORDEREDQ (0x02000000) 103 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ACAQ (0x04000000) 104 #define MPI3_SCSIIO_FLAGS_CMDPRI_MASK (0x00F00000) 105 #define MPI3_SCSIIO_FLAGS_CMDPRI_SHIFT (20) 106 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_MASK (0x000C0000) 107 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_NO_DATA_TRANSFER (0x00000000) 108 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_WRITE (0x00040000) 109 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_READ (0x00080000) 110 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_MASK (0x00030000) 111 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_HOST_PI (0x00010000) 112 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_MASK (0x000000F0) 113 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_IO_THROTTLING (0x00000010) 114 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_WRITE_SAME_TOO_LARGE (0x00000020) 115 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_PROD_SPECIFIC (0x00000080) 116 117 /**** Defines for the SGL field ****/ 118 #define MPI3_SCSIIO_METASGL_INDEX (3) 119 120 /***************************************************************************** 121 * SCSI IO Error Reply Message * 122 ****************************************************************************/ 123 typedef struct _MPI3_SCSI_IO_REPLY 124 { 125 U16 HostTag; /* 0x00 */ 126 U8 IOCUseOnly02; /* 0x02 */ 127 U8 Function; /* 0x03 */ 128 U16 IOCUseOnly04; /* 0x04 */ 129 U8 IOCUseOnly06; /* 0x06 */ 130 U8 MsgFlags; /* 0x07 */ 131 U16 IOCUseOnly08; /* 0x08 */ 132 U16 IOCStatus; /* 0x0A */ 133 U32 IOCLogInfo; /* 0x0C */ 134 U8 SCSIStatus; /* 0x10 */ 135 U8 SCSIState; /* 0x11 */ 136 U16 DevHandle; /* 0x12 */ 137 U32 TransferCount; /* 0x14 */ 138 U32 SenseCount; /* 0x18 */ 139 U32 ResponseData; /* 0x1C */ 140 U16 TaskTag; /* 0x20 */ 141 U16 SCSIStatusQualifier; /* 0x22 */ 142 U32 EEDPErrorOffset; /* 0x24 */ 143 U16 EEDPObservedAppTag; /* 0x28 */ 144 U16 EEDPObservedGuard; /* 0x2A */ 145 U32 EEDPObservedRefTag; /* 0x2C */ 146 U64 SenseDataBufferAddress; /* 0x30 */ 147 } MPI3_SCSI_IO_REPLY, MPI3_POINTER PTR_MPI3_SCSI_IO_REPLY, 148 Mpi3SCSIIOReply_t, MPI3_POINTER pMpi3SCSIIOReply_t; 149 150 /**** Defines for the MsgFlags field ****/ 151 #define MPI3_SCSIIO_REPLY_MSGFLAGS_REFTAG_OBSERVED_VALID (0x01) 152 #define MPI3_SCSIIO_REPLY_MSGFLAGS_APPTAG_OBSERVED_VALID (0x02) 153 #define MPI3_SCSIIO_REPLY_MSGFLAGS_GUARD_OBSERVED_VALID (0x04) 154 155 /**** Defines for the SCSIStatus field ****/ 156 #define MPI3_SCSI_STATUS_GOOD (0x00) 157 #define MPI3_SCSI_STATUS_CHECK_CONDITION (0x02) 158 #define MPI3_SCSI_STATUS_CONDITION_MET (0x04) 159 #define MPI3_SCSI_STATUS_BUSY (0x08) 160 #define MPI3_SCSI_STATUS_INTERMEDIATE (0x10) 161 #define MPI3_SCSI_STATUS_INTERMEDIATE_CONDMET (0x14) 162 #define MPI3_SCSI_STATUS_RESERVATION_CONFLICT (0x18) 163 #define MPI3_SCSI_STATUS_COMMAND_TERMINATED (0x22) 164 #define MPI3_SCSI_STATUS_TASK_SET_FULL (0x28) 165 #define MPI3_SCSI_STATUS_ACA_ACTIVE (0x30) 166 #define MPI3_SCSI_STATUS_TASK_ABORTED (0x40) 167 168 /**** Defines for the SCSIState field ****/ 169 #define MPI3_SCSI_STATE_SENSE_MASK (0x03) 170 #define MPI3_SCSI_STATE_SENSE_VALID (0x00) 171 #define MPI3_SCSI_STATE_SENSE_FAILED (0x01) 172 #define MPI3_SCSI_STATE_SENSE_BUFF_Q_EMPTY (0x02) 173 #define MPI3_SCSI_STATE_SENSE_NOT_AVAILABLE (0x03) 174 #define MPI3_SCSI_STATE_NO_SCSI_STATUS (0x04) 175 #define MPI3_SCSI_STATE_TERMINATED (0x08) 176 #define MPI3_SCSI_STATE_RESPONSE_DATA_VALID (0x10) 177 178 /**** Defines for the ResponseData field ****/ 179 #define MPI3_SCSI_RSP_RESPONSECODE_MASK (0x000000FF) 180 #define MPI3_SCSI_RSP_RESPONSECODE_SHIFT (0) 181 #define MPI3_SCSI_RSP_ARI2_MASK (0x0000FF00) 182 #define MPI3_SCSI_RSP_ARI2_SHIFT (8) 183 #define MPI3_SCSI_RSP_ARI1_MASK (0x00FF0000) 184 #define MPI3_SCSI_RSP_ARI1_SHIFT (16) 185 #define MPI3_SCSI_RSP_ARI0_MASK (0xFF000000) 186 #define MPI3_SCSI_RSP_ARI0_SHIFT (24) 187 188 /**** Defines for the TaskTag field ****/ 189 #define MPI3_SCSI_TASKTAG_UNKNOWN (0xFFFF) 190 191 192 /***************************************************************************** 193 * SCSI Task Management Request Message * 194 ****************************************************************************/ 195 typedef struct _MPI3_SCSI_TASK_MGMT_REQUEST 196 { 197 U16 HostTag; /* 0x00 */ 198 U8 IOCUseOnly02; /* 0x02 */ 199 U8 Function; /* 0x03 */ 200 U16 IOCUseOnly04; /* 0x04 */ 201 U8 IOCUseOnly06; /* 0x06 */ 202 U8 MsgFlags; /* 0x07 */ 203 U16 ChangeCount; /* 0x08 */ 204 U16 DevHandle; /* 0x0A */ 205 U16 TaskHostTag; /* 0x0C */ 206 U8 TaskType; /* 0x0E */ 207 U8 Reserved0F; /* 0x0F */ 208 U16 TaskRequestQueueID; /* 0x10 */ 209 U8 IOCUseOnly12; /* 0x12 */ 210 U8 Reserved13; /* 0x13 */ 211 U32 Reserved14; /* 0x14 */ 212 U8 LUN[8]; /* 0x18 */ 213 } MPI3_SCSI_TASK_MGMT_REQUEST, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REQUEST, 214 Mpi3SCSITaskMgmtRequest_t, MPI3_POINTER pMpi3SCSITaskMgmtRequest_t; 215 216 /**** Defines for the MsgFlags field ****/ 217 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08) 218 219 /**** Defines for the TaskType field ****/ 220 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01) 221 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02) 222 #define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03) 223 #define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) 224 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) 225 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) 226 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) 227 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09) 228 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0A) 229 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0B) 230 231 232 /***************************************************************************** 233 * SCSI Task Management Reply Message * 234 ****************************************************************************/ 235 typedef struct _MPI3_SCSI_TASK_MGMT_REPLY 236 { 237 U16 HostTag; /* 0x00 */ 238 U8 IOCUseOnly02; /* 0x02 */ 239 U8 Function; /* 0x03 */ 240 U16 IOCUseOnly04; /* 0x04 */ 241 U8 IOCUseOnly06; /* 0x06 */ 242 U8 MsgFlags; /* 0x07 */ 243 U16 IOCUseOnly08; /* 0x08 */ 244 U16 IOCStatus; /* 0x0A */ 245 U32 IOCLogInfo; /* 0x0C */ 246 U32 TerminationCount; /* 0x10 */ 247 U32 ResponseData; /* 0x14 */ 248 U32 Reserved18; /* 0x18 */ 249 } MPI3_SCSI_TASK_MGMT_REPLY, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REPLY, 250 Mpi3SCSITaskMgmtReply_t, MPI3_POINTER pMpi3SCSITaskMgmtReply_t; 251 252 /**** Defines for the ResponseData field - use MPI3_SCSI_RSP_ defines ****/ 253 254 /**** Defines for the ResponseCode field - Byte 0 of ResponseData ****/ 255 #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) 256 #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) 257 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) 258 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) 259 #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) 260 #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) 261 #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0A) 262 263 #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) 264 #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81) 265 266 #endif /* MPI30_INIT_H */ 267