xref: /freebsd/sys/dev/mpi3mr/mpi/mpi30_init.h (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2016-2023, 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                     SkipCount;                      /* 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                           (0x60000000)
95 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS                      (0x00000000)
96 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16                 (0x20000000)
97 #define MPI3_SCSIIO_FLAGS_CDB_IN_SEPARATE_BUFFER              (0x40000000)
98 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_MASK                  (0x07000000)
99 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SIMPLEQ               (0x00000000)
100 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_HEADOFQ               (0x01000000)
101 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ORDEREDQ              (0x02000000)
102 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ACAQ                  (0x04000000)
103 #define MPI3_SCSIIO_FLAGS_CMDPRI_MASK                         (0x00F00000)
104 #define MPI3_SCSIIO_FLAGS_CMDPRI_SHIFT                        (20)
105 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_MASK                  (0x000C0000)
106 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_NO_DATA_TRANSFER      (0x00000000)
107 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_WRITE                 (0x00040000)
108 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_READ                  (0x00080000)
109 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_MASK                   (0x00030000)
110 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_HOST_PI                (0x00010000)
111 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_MASK                  (0x000000F0)
112 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_IO_THROTTLING         (0x00000010)
113 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_WRITE_SAME_TOO_LARGE  (0x00000020)
114 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_PROD_SPECIFIC         (0x00000080)
115 
116 /**** Defines for the SGL field ****/
117 #define MPI3_SCSIIO_METASGL_INDEX                             (3)
118 
119 /*****************************************************************************
120  *              SCSI IO Error Reply Message                                  *
121  ****************************************************************************/
122 typedef struct _MPI3_SCSI_IO_REPLY
123 {
124     U16                     HostTag;                        /* 0x00 */
125     U8                      IOCUseOnly02;                   /* 0x02 */
126     U8                      Function;                       /* 0x03 */
127     U16                     IOCUseOnly04;                   /* 0x04 */
128     U8                      IOCUseOnly06;                   /* 0x06 */
129     U8                      MsgFlags;                       /* 0x07 */
130     U16                     IOCUseOnly08;                   /* 0x08 */
131     U16                     IOCStatus;                      /* 0x0A */
132     U32                     IOCLogInfo;                     /* 0x0C */
133     U8                      SCSIStatus;                     /* 0x10 */
134     U8                      SCSIState;                      /* 0x11 */
135     U16                     DevHandle;                      /* 0x12 */
136     U32                     TransferCount;                  /* 0x14 */
137     U32                     SenseCount;                     /* 0x18 */
138     U32                     ResponseData;                   /* 0x1C */
139     U16                     TaskTag;                        /* 0x20 */
140     U16                     SCSIStatusQualifier;            /* 0x22 */
141     U32                     EEDPErrorOffset;                /* 0x24 */
142     U16                     EEDPObservedAppTag;             /* 0x28 */
143     U16                     EEDPObservedGuard;              /* 0x2A */
144     U32                     EEDPObservedRefTag;             /* 0x2C */
145     U64                     SenseDataBufferAddress;         /* 0x30 */
146 } MPI3_SCSI_IO_REPLY, MPI3_POINTER PTR_MPI3_SCSI_IO_REPLY,
147   Mpi3SCSIIOReply_t, MPI3_POINTER pMpi3SCSIIOReply_t;
148 
149 /**** Defines for the MsgFlags field ****/
150 #define MPI3_SCSIIO_REPLY_MSGFLAGS_REFTAG_OBSERVED_VALID        (0x01)
151 #define MPI3_SCSIIO_REPLY_MSGFLAGS_APPTAG_OBSERVED_VALID        (0x02)
152 #define MPI3_SCSIIO_REPLY_MSGFLAGS_GUARD_OBSERVED_VALID         (0x04)
153 
154 /**** Defines for the SCSIStatus field ****/
155 #define MPI3_SCSI_STATUS_GOOD                   (0x00)
156 #define MPI3_SCSI_STATUS_CHECK_CONDITION        (0x02)
157 #define MPI3_SCSI_STATUS_CONDITION_MET          (0x04)
158 #define MPI3_SCSI_STATUS_BUSY                   (0x08)
159 #define MPI3_SCSI_STATUS_INTERMEDIATE           (0x10)
160 #define MPI3_SCSI_STATUS_INTERMEDIATE_CONDMET   (0x14)
161 #define MPI3_SCSI_STATUS_RESERVATION_CONFLICT   (0x18)
162 #define MPI3_SCSI_STATUS_COMMAND_TERMINATED     (0x22)
163 #define MPI3_SCSI_STATUS_TASK_SET_FULL          (0x28)
164 #define MPI3_SCSI_STATUS_ACA_ACTIVE             (0x30)
165 #define MPI3_SCSI_STATUS_TASK_ABORTED           (0x40)
166 
167 /**** Defines for the SCSIState field ****/
168 #define MPI3_SCSI_STATE_SENSE_MASK              (0x03)
169 #define MPI3_SCSI_STATE_SENSE_VALID             (0x00)
170 #define MPI3_SCSI_STATE_SENSE_FAILED            (0x01)
171 #define MPI3_SCSI_STATE_SENSE_BUFF_Q_EMPTY      (0x02)
172 #define MPI3_SCSI_STATE_SENSE_NOT_AVAILABLE     (0x03)
173 #define MPI3_SCSI_STATE_NO_SCSI_STATUS          (0x04)
174 #define MPI3_SCSI_STATE_TERMINATED              (0x08)
175 #define MPI3_SCSI_STATE_RESPONSE_DATA_VALID     (0x10)
176 
177 /**** Defines for the ResponseData field ****/
178 #define MPI3_SCSI_RSP_RESPONSECODE_MASK         (0x000000FF)
179 #define MPI3_SCSI_RSP_RESPONSECODE_SHIFT        (0)
180 #define MPI3_SCSI_RSP_ARI2_MASK                 (0x0000FF00)
181 #define MPI3_SCSI_RSP_ARI2_SHIFT                (8)
182 #define MPI3_SCSI_RSP_ARI1_MASK                 (0x00FF0000)
183 #define MPI3_SCSI_RSP_ARI1_SHIFT                (16)
184 #define MPI3_SCSI_RSP_ARI0_MASK                 (0xFF000000)
185 #define MPI3_SCSI_RSP_ARI0_SHIFT                (24)
186 
187 /**** Defines for the TaskTag field ****/
188 #define MPI3_SCSI_TASKTAG_UNKNOWN               (0xFFFF)
189 
190 
191 /*****************************************************************************
192  *              SCSI Task Management Request Message                         *
193  ****************************************************************************/
194 typedef struct _MPI3_SCSI_TASK_MGMT_REQUEST
195 {
196     U16                     HostTag;                        /* 0x00 */
197     U8                      IOCUseOnly02;                   /* 0x02 */
198     U8                      Function;                       /* 0x03 */
199     U16                     IOCUseOnly04;                   /* 0x04 */
200     U8                      IOCUseOnly06;                   /* 0x06 */
201     U8                      MsgFlags;                       /* 0x07 */
202     U16                     ChangeCount;                    /* 0x08 */
203     U16                     DevHandle;                      /* 0x0A */
204     U16                     TaskHostTag;                    /* 0x0C */
205     U8                      TaskType;                       /* 0x0E */
206     U8                      Reserved0F;                     /* 0x0F */
207     U16                     TaskRequestQueueID;             /* 0x10 */
208     U8                      IOCUseOnly12;                   /* 0x12 */
209     U8                      Reserved13;                     /* 0x13 */
210     U32                     Reserved14;                     /* 0x14 */
211     U8                      LUN[8];                         /* 0x18 */
212 } MPI3_SCSI_TASK_MGMT_REQUEST, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REQUEST,
213   Mpi3SCSITaskMgmtRequest_t, MPI3_POINTER pMpi3SCSITaskMgmtRequest_t;
214 
215 /**** Defines for the MsgFlags field ****/
216 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU      (0x08)
217 
218 /**** Defines for the TaskType field ****/
219 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK               (0x01)
220 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET           (0x02)
221 #define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET             (0x03)
222 #define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET       (0x05)
223 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET           (0x06)
224 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK               (0x07)
225 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA                (0x08)
226 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET           (0x09)
227 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT        (0x0A)
228 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET          (0x0B)
229 
230 
231 /*****************************************************************************
232  *              SCSI Task Management Reply Message                           *
233  ****************************************************************************/
234 typedef struct _MPI3_SCSI_TASK_MGMT_REPLY
235 {
236     U16                     HostTag;                        /* 0x00 */
237     U8                      IOCUseOnly02;                   /* 0x02 */
238     U8                      Function;                       /* 0x03 */
239     U16                     IOCUseOnly04;                   /* 0x04 */
240     U8                      IOCUseOnly06;                   /* 0x06 */
241     U8                      MsgFlags;                       /* 0x07 */
242     U16                     IOCUseOnly08;                   /* 0x08 */
243     U16                     IOCStatus;                      /* 0x0A */
244     U32                     IOCLogInfo;                     /* 0x0C */
245     U32                     TerminationCount;               /* 0x10 */
246     U32                     ResponseData;                   /* 0x14 */
247     U32                     Reserved18;                     /* 0x18 */
248 } MPI3_SCSI_TASK_MGMT_REPLY, MPI3_POINTER PTR_MPI3_SCSI_TASK_MGMT_REPLY,
249   Mpi3SCSITaskMgmtReply_t, MPI3_POINTER pMpi3SCSITaskMgmtReply_t;
250 
251 /**** Defines for the ResponseData field - use MPI3_SCSI_RSP_ defines ****/
252 
253 /**** Defines for the ResponseCode field - Byte 0 of ResponseData  ****/
254 #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE                (0x00)
255 #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME              (0x02)
256 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED  (0x04)
257 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED                  (0x05)
258 #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED               (0x08)
259 #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN             (0x09)
260 #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG          (0x0A)
261 
262 #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC           (0x80)
263 #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED             (0x81)
264 
265 #endif  /* MPI30_INIT_H */
266