1 /* 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2016-2025, 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 42 #ifndef MPI30_INIT_H 43 #define MPI30_INIT_H 1 44 45 /***************************************************************************** 46 * SCSI Initiator Messages * 47 ****************************************************************************/ 48 49 /***************************************************************************** 50 * SCSI IO Request Message * 51 ****************************************************************************/ 52 typedef struct _MPI3_SCSI_IO_CDB_EEDP32 53 { 54 U8 CDB[20]; /* 0x00 */ 55 U32 PrimaryReferenceTag; /* 0x14 */ 56 U16 PrimaryApplicationTag; /* 0x18 */ 57 U16 PrimaryApplicationTagMask; /* 0x1A */ 58 U32 TransferLength; /* 0x1C */ 59 } MPI3_SCSI_IO_CDB_EEDP32, MPI3_POINTER PTR_MPI3_SCSI_IO_CDB_EEDP32, 60 Mpi3ScsiIoCdbEedp32_t, MPI3_POINTER pMpi3ScsiIoCdbEedp32_t; 61 62 typedef union _MPI3_SCSI_IO_CDB_UNION 63 { 64 U8 CDB32[32]; 65 MPI3_SCSI_IO_CDB_EEDP32 EEDP32; 66 MPI3_SGE_SIMPLE SGE; 67 } MPI3_SCSI_IO_CDB_UNION, MPI3_POINTER PTR_MPI3_SCSI_IO_CDB_UNION, 68 Mpi3ScsiIoCdb_t, MPI3_POINTER pMpi3ScsiIoCdb_t; 69 70 typedef struct _MPI3_SCSI_IO_REQUEST 71 { 72 U16 HostTag; /* 0x00 */ 73 U8 IOCUseOnly02; /* 0x02 */ 74 U8 Function; /* 0x03 */ 75 U16 IOCUseOnly04; /* 0x04 */ 76 U8 IOCUseOnly06; /* 0x06 */ 77 U8 MsgFlags; /* 0x07 */ 78 U16 ChangeCount; /* 0x08 */ 79 U16 DevHandle; /* 0x0A */ 80 U32 Flags; /* 0x0C */ 81 U32 IOCUseOnly10; /* 0x10 */ 82 U32 DataLength; /* 0x14 */ 83 U8 LUN[8]; /* 0x18 */ 84 MPI3_SCSI_IO_CDB_UNION CDB; /* 0x20 */ 85 MPI3_SGE_UNION SGL[4]; /* 0x40 */ 86 } MPI3_SCSI_IO_REQUEST, MPI3_POINTER PTR_MPI3_SCSI_IO_REQUEST, 87 Mpi3SCSIIORequest_t, MPI3_POINTER pMpi3SCSIIORequest_t; 88 89 /**** Defines for the MsgFlags field ****/ 90 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID (0x80) 91 #define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE (0x40) 92 93 /**** Defines for the Flags field ****/ 94 #define MPI3_SCSIIO_FLAGS_LARGE_CDB_MASK (0x60000000) 95 #define MPI3_SCSIIO_FLAGS_LARGE_CDB_SHIFT (29) 96 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS (0x00000000) 97 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16 (0x20000000) 98 #define MPI3_SCSIIO_FLAGS_CDB_IN_SEPARATE_BUFFER (0x40000000) 99 #define MPI3_SCSIIO_FLAGS_CDB_PRODUCT_SPECIFIC (0x60000000) 100 #define MPI3_SCSIIO_FLAGS_IOC_USE_ONLY_27_MASK (0x18000000) 101 #define MPI3_SCSIIO_FLAGS_IOC_USE_ONLY_27_SHIFT (27) 102 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_MASK (0x07000000) 103 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SHIFT (24) 104 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SIMPLEQ (0x00000000) 105 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_HEADOFQ (0x01000000) 106 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ORDEREDQ (0x02000000) 107 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ACAQ (0x04000000) 108 #define MPI3_SCSIIO_FLAGS_CMDPRI_MASK (0x00F00000) 109 #define MPI3_SCSIIO_FLAGS_CMDPRI_SHIFT (20) 110 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_MASK (0x000C0000) 111 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_SHIFT (18) 112 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_NO_DATA_TRANSFER (0x00000000) 113 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_WRITE (0x00040000) 114 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_READ (0x00080000) 115 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_MASK (0x00030000) 116 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_SHIFT (16) 117 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_HOST_PI (0x00010000) 118 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_MASK (0x000000F0) 119 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_SHIFT (4) 120 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_IO_THROTTLING (0x00000010) 121 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_WRITE_SAME_TOO_LARGE (0x00000020) 122 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_PROD_SPECIFIC (0x00000080) 123 124 /**** Defines for the SGL field ****/ 125 #define MPI3_SCSIIO_METASGL_INDEX (3) 126 127 /***************************************************************************** 128 * SCSI IO Error Reply Message * 129 ****************************************************************************/ 130 typedef struct _MPI3_SCSI_IO_REPLY 131 { 132 U16 HostTag; /* 0x00 */ 133 U8 IOCUseOnly02; /* 0x02 */ 134 U8 Function; /* 0x03 */ 135 U16 IOCUseOnly04; /* 0x04 */ 136 U8 IOCUseOnly06; /* 0x06 */ 137 U8 MsgFlags; /* 0x07 */ 138 U16 IOCUseOnly08; /* 0x08 */ 139 U16 IOCStatus; /* 0x0A */ 140 U32 IOCLogInfo; /* 0x0C */ 141 U8 SCSIStatus; /* 0x10 */ 142 U8 SCSIState; /* 0x11 */ 143 U16 DevHandle; /* 0x12 */ 144 U32 TransferCount; /* 0x14 */ 145 U32 SenseCount; /* 0x18 */ 146 U32 ResponseData; /* 0x1C */ 147 U16 TaskTag; /* 0x20 */ 148 U16 SCSIStatusQualifier; /* 0x22 */ 149 U32 EEDPErrorOffset; /* 0x24 */ 150 U16 EEDPObservedAppTag; /* 0x28 */ 151 U16 EEDPObservedGuard; /* 0x2A */ 152 U32 EEDPObservedRefTag; /* 0x2C */ 153 U64 SenseDataBufferAddress; /* 0x30 */ 154 } MPI3_SCSI_IO_REPLY, MPI3_POINTER PTR_MPI3_SCSI_IO_REPLY, 155 Mpi3SCSIIOReply_t, MPI3_POINTER pMpi3SCSIIOReply_t; 156 157 /**** Defines for the MsgFlags field ****/ 158 #define MPI3_SCSIIO_REPLY_MSGFLAGS_REFTAG_OBSERVED_VALID (0x01) 159 #define MPI3_SCSIIO_REPLY_MSGFLAGS_APPTAG_OBSERVED_VALID (0x02) 160 #define MPI3_SCSIIO_REPLY_MSGFLAGS_GUARD_OBSERVED_VALID (0x04) 161 162 /**** Defines for the SCSIStatus field ****/ 163 #define MPI3_SCSI_STATUS_GOOD (0x00) 164 #define MPI3_SCSI_STATUS_CHECK_CONDITION (0x02) 165 #define MPI3_SCSI_STATUS_CONDITION_MET (0x04) 166 #define MPI3_SCSI_STATUS_BUSY (0x08) 167 #define MPI3_SCSI_STATUS_INTERMEDIATE (0x10) 168 #define MPI3_SCSI_STATUS_INTERMEDIATE_CONDMET (0x14) 169 #define MPI3_SCSI_STATUS_RESERVATION_CONFLICT (0x18) 170 #define MPI3_SCSI_STATUS_COMMAND_TERMINATED (0x22) 171 #define MPI3_SCSI_STATUS_TASK_SET_FULL (0x28) 172 #define MPI3_SCSI_STATUS_ACA_ACTIVE (0x30) 173 #define MPI3_SCSI_STATUS_TASK_ABORTED (0x40) 174 175 /**** Defines for the SCSIState field ****/ 176 #define MPI3_SCSI_STATE_SENSE_MASK (0x03) 177 #define MPI3_SCSI_STATE_SENSE_SHIFT (0) 178 #define MPI3_SCSI_STATE_SENSE_VALID (0x00) 179 #define MPI3_SCSI_STATE_SENSE_FAILED (0x01) 180 #define MPI3_SCSI_STATE_SENSE_BUFF_Q_EMPTY (0x02) 181 #define MPI3_SCSI_STATE_SENSE_NOT_AVAILABLE (0x03) 182 #define MPI3_SCSI_STATE_NO_SCSI_STATUS (0x04) 183 #define MPI3_SCSI_STATE_TERMINATED (0x08) 184 #define MPI3_SCSI_STATE_RESPONSE_DATA_VALID (0x10) 185 186 /**** Defines for the ResponseData field ****/ 187 #define MPI3_SCSI_RSP_RESPONSECODE_MASK (0x000000FF) 188 #define MPI3_SCSI_RSP_RESPONSECODE_SHIFT (0) 189 #define MPI3_SCSI_RSP_ARI2_MASK (0x0000FF00) 190 #define MPI3_SCSI_RSP_ARI2_SHIFT (8) 191 #define MPI3_SCSI_RSP_ARI1_MASK (0x00FF0000) 192 #define MPI3_SCSI_RSP_ARI1_SHIFT (16) 193 #define MPI3_SCSI_RSP_ARI0_MASK (0xFF000000) 194 #define MPI3_SCSI_RSP_ARI0_SHIFT (24) 195 196 /**** Defines for the TaskTag field ****/ 197 #define MPI3_SCSI_TASKTAG_UNKNOWN (0xFFFF) 198 199 200 /***************************************************************************** 201 * SCSI Task Management Request Message * 202 ****************************************************************************/ 203 typedef struct _MPI3_SCSI_TASK_MGMT_REQUEST 204 { 205 U16 HostTag; /* 0x00 */ 206 U8 IOCUseOnly02; /* 0x02 */ 207 U8 Function; /* 0x03 */ 208 U16 IOCUseOnly04; /* 0x04 */ 209 U8 IOCUseOnly06; /* 0x06 */ 210 U8 MsgFlags; /* 0x07 */ 211 U16 ChangeCount; /* 0x08 */ 212 U16 DevHandle; /* 0x0A */ 213 U16 TaskHostTag; /* 0x0C */ 214 U8 TaskType; /* 0x0E */ 215 U8 Reserved0F; /* 0x0F */ 216 U16 TaskRequestQueueID; /* 0x10 */ 217 U8 IOCUseOnly12; /* 0x12 */ 218 U8 Reserved13; /* 0x13 */ 219 U32 Reserved14; /* 0x14 */ 220 U8 LUN[8]; /* 0x18 */ 221 } MPI3_SCSI_TASK_MGMT_REQUEST, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REQUEST, 222 Mpi3SCSITaskMgmtRequest_t, MPI3_POINTER pMpi3SCSITaskMgmtRequest_t; 223 224 /**** Defines for the MsgFlags field ****/ 225 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08) 226 227 /**** Defines for the TaskType field ****/ 228 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01) 229 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02) 230 #define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03) 231 #define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) 232 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) 233 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) 234 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) 235 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09) 236 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0A) 237 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0B) 238 239 240 /***************************************************************************** 241 * SCSI Task Management Reply Message * 242 ****************************************************************************/ 243 typedef struct _MPI3_SCSI_TASK_MGMT_REPLY 244 { 245 U16 HostTag; /* 0x00 */ 246 U8 IOCUseOnly02; /* 0x02 */ 247 U8 Function; /* 0x03 */ 248 U16 IOCUseOnly04; /* 0x04 */ 249 U8 IOCUseOnly06; /* 0x06 */ 250 U8 MsgFlags; /* 0x07 */ 251 U16 IOCUseOnly08; /* 0x08 */ 252 U16 IOCStatus; /* 0x0A */ 253 U32 IOCLogInfo; /* 0x0C */ 254 U32 TerminationCount; /* 0x10 */ 255 U32 ResponseData; /* 0x14 */ 256 U32 Reserved18; /* 0x18 */ 257 } MPI3_SCSI_TASK_MGMT_REPLY, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REPLY, 258 Mpi3SCSITaskMgmtReply_t, MPI3_POINTER pMpi3SCSITaskMgmtReply_t; 259 260 /**** Defines for the ResponseData field - use MPI3_SCSI_RSP_ defines ****/ 261 262 /**** Defines for the ResponseCode field - Byte 0 of ResponseData ****/ 263 #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) 264 #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) 265 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) 266 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) 267 #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) 268 #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) 269 #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0A) 270 271 #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) 272 #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81) 273 274 #endif /* MPI30_INIT_H */ 275