xref: /freebsd/sys/dev/mpi3mr/mpi/mpi30_targ.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
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_TARG_H
42 #define MPI30_TARG_H     1
43 
44 /*****************************************************************************
45  *              Command Buffer Formats                                       *
46  ****************************************************************************/
47 typedef struct _MPI3_TARGET_SSP_CMD_BUFFER
48 {
49     U8                      FrameType;                  /* 0x00 */
50     U8                      Reserved01;                 /* 0x01 */
51     U16                     InitiatorConnectionTag;     /* 0x02 */
52     U32                     HashedSourceSASAddress;     /* 0x04 */
53     U16                     Reserved08;                 /* 0x08 */
54     U16                     Flags;                      /* 0x0A */
55     U32                     Reserved0C;                 /* 0x0C */
56     U16                     Tag;                        /* 0x10 */
57     U16                     TargetPortTransferTag;      /* 0x12 */
58     U32                     DataOffset;                 /* 0x14 */
59     U8                      LogicalUnitNumber[8];       /* 0x18 */
60     U8                      Reserved20;                 /* 0x20 */
61     U8                      TaskAttribute;              /* 0x21 */
62     U8                      Reserved22;                 /* 0x22 */
63     U8                      AdditionalCDBLength;        /* 0x23 */
64     U8                      CDB[16];                    /* 0x24 */
65     /* AdditionalCDBBytes field starts here */          /* 0x34 */
66 } MPI3_TARGET_SSP_CMD_BUFFER, MPI3_POINTER PTR_MPI3_TARGET_SSP_CMD_BUFFER,
67   Mpi3TargetSspCmdBuffer_t, MPI3_POINTER pMpi3TargetSspCmdBuffer_t;
68 
69 typedef struct _MPI3_TARGET_SSP_TASK_BUFFER
70 {
71     U8                      FrameType;                  /* 0x00 */
72     U8                      Reserved01;                 /* 0x01 */
73     U16                     InitiatorConnectionTag;     /* 0x02 */
74     U32                     HashedSourceSASAddress;     /* 0x04 */
75     U16                     Reserved08;                 /* 0x08 */
76     U16                     Flags;                      /* 0x0A */
77     U32                     Reserved0C;                 /* 0x0C */
78     U16                     Tag;                        /* 0x10 */
79     U16                     TargetPortTransferTag;      /* 0x12 */
80     U32                     DataOffset;                 /* 0x14 */
81     U8                      LogicalUnitNumber[8];       /* 0x18 */
82     U16                     Reserved20;                 /* 0x20 */
83     U8                      TaskManagementFunction;     /* 0x22 */
84     U8                      Reserved23;                 /* 0x23 */
85     U16                     ManagedTaskTag;             /* 0x24 */
86     U16                     Reserved26;                 /* 0x26 */
87     U32                     Reserved28[3];              /* 0x28 */
88 } MPI3_TARGET_SSP_TASK_BUFFER, MPI3_POINTER PTR_MPI3_TARGET_SSP_TASK_BUFFER,
89   Mpi3TargetSspTaskBuffer_t, MPI3_POINTER pMpi3TargetSspTaskBuffer_t;
90 
91 /**** Defines for the FrameType field ****/
92 #define MPI3_TARGET_FRAME_TYPE_COMMAND                      (0x06)
93 #define MPI3_TARGET_FRAME_TYPE_TASK                         (0x16)
94 
95 /**** Defines for the HashedSourceSASAddress field ****/
96 #define MPI3_TARGET_HASHED_SAS_ADDRESS_MASK                 (0xFFFFFF00)
97 #define MPI3_TARGET_HASHED_SAS_ADDRESS_SHIFT                (8)
98 
99 
100 /*****************************************************************************
101  *              Target Command Buffer Post Base Request Message              *
102  ****************************************************************************/
103 typedef struct _MPI3_TARGET_CMD_BUF_POST_BASE_REQUEST
104 {
105     U16                     HostTag;                    /* 0x00 */
106     U8                      IOCUseOnly02;               /* 0x02 */
107     U8                      Function;                   /* 0x03 */
108     U16                     IOCUseOnly04;               /* 0x04 */
109     U8                      IOCUseOnly06;               /* 0x06 */
110     U8                      MsgFlags;                   /* 0x07 */
111     U16                     ChangeCount;                /* 0x08 */
112     U8                      BufferPostFlags;            /* 0x0A */
113     U8                      Reserved0B;                 /* 0x0B */
114     U16                     MinReplyQueueID;            /* 0x0C */
115     U16                     MaxReplyQueueID;            /* 0x0E */
116     U64                     BaseAddress;                /* 0x10 */
117     U16                     CmdBufferLength;            /* 0x18 */
118     U16                     TotalCmdBuffers;            /* 0x1A */
119     U32                     Reserved1C;                 /* 0x1C */
120 } MPI3_TARGET_CMD_BUF_POST_BASE_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_CMD_BUF_POST_BASE_REQUEST,
121   Mpi3TargetCmdBufPostBaseRequest_t, MPI3_POINTER pMpi3TargetCmdBufPostBaseRequest_t;
122 
123 /**** Defines for the BufferPostFlags field ****/
124 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_MASK              (0x0C)
125 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_SYSTEM            (0x00)
126 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_IOCUDP            (0x04)
127 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_IOCCTL            (0x08)
128 #define MPI3_CMD_BUF_POST_BASE_FLAGS_AUTO_POST_ALL          (0x01)
129 
130 /**** Defines for the CmdBufferLength field ****/
131 #define MPI3_CMD_BUF_POST_BASE_MIN_BUF_LENGTH               (0x34)
132 #define MPI3_CMD_BUF_POST_BASE_MAX_BUF_LENGTH               (0x3FC)
133 
134 /*****************************************************************************
135  *              Target Command Buffer Post List Request Message              *
136  ****************************************************************************/
137 typedef struct _MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST
138 {
139     U16                     HostTag;                    /* 0x00 */
140     U8                      IOCUseOnly02;               /* 0x02 */
141     U8                      Function;                   /* 0x03 */
142     U16                     IOCUseOnly04;               /* 0x04 */
143     U8                      IOCUseOnly06;               /* 0x06 */
144     U8                      MsgFlags;                   /* 0x07 */
145     U16                     ChangeCount;                /* 0x08 */
146     U16                     Reserved0A;                 /* 0x0A */
147     U8                      CmdBufferCount;             /* 0x0C */
148     U8                      Reserved0D[3];              /* 0x0D */
149     U16                     IoIndex[2];                 /* 0x10 */
150 } MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST,
151   Mpi3TargetCmdBufPostListRequest_t, MPI3_POINTER pMpi3TargetCmdBufPostListRequest_t;
152 
153 
154 /*****************************************************************************
155  *              Target Command Buffer Post Base List Reply Message           *
156  ****************************************************************************/
157 typedef struct _MPI3_TARGET_CMD_BUF_POST_REPLY
158 {
159     U16                     HostTag;                        /* 0x00 */
160     U8                      IOCUseOnly02;                   /* 0x02 */
161     U8                      Function;                       /* 0x03 */
162     U16                     IOCUseOnly04;                   /* 0x04 */
163     U8                      IOCUseOnly06;                   /* 0x06 */
164     U8                      MsgFlags;                       /* 0x07 */
165     U16                     IOCUseOnly08;                   /* 0x08 */
166     U16                     IOCStatus;                      /* 0x0A */
167     U32                     IOCLogInfo;                     /* 0x0C */
168     U8                      CmdBufferCount;                 /* 0x10 */
169     U8                      Reserved11[3];                  /* 0x11 */
170     U16                     IoIndex[2];                     /* 0x14 */
171 } MPI3_TARGET_CMD_BUF_POST_REPLY, MPI3_POINTER PTR_MPI3_TARGET_CMD_BUF_POST_REPLY,
172   Mpi3TargetCmdBufPostReply_t, MPI3_POINTER pMpi3TargetCmdBufPostReply_t;
173 
174 
175 /*****************************************************************************
176  *              Target Assist Request Message                                *
177  ****************************************************************************/
178 typedef struct _MPI3_TARGET_ASSIST_REQUEST
179 {
180     U16                     HostTag;                    /* 0x00 */
181     U8                      IOCUseOnly02;               /* 0x02 */
182     U8                      Function;                   /* 0x03 */
183     U16                     IOCUseOnly04;               /* 0x04 */
184     U8                      IOCUseOnly06;               /* 0x06 */
185     U8                      MsgFlags;                   /* 0x07 */
186     U16                     ChangeCount;                /* 0x08 */
187     U16                     DevHandle;                  /* 0x0A */
188     U32                     Flags;                      /* 0x0C */
189     U16                     Reserved10;                 /* 0x10 */
190     U16                     QueueTag;                   /* 0x12 */
191     U16                     IoIndex;                    /* 0x14 */
192     U16                     InitiatorConnectionTag;     /* 0x16 */
193     U32                     IOCUseOnly18;               /* 0x18 */
194     U32                     DataLength;                 /* 0x1C */
195     U32                     PortTransferLength;         /* 0x20 */
196     U32                     PrimaryReferenceTag;        /* 0x24 */
197     U16                     PrimaryApplicationTag;      /* 0x28 */
198     U16                     PrimaryApplicationTagMask;  /* 0x2A */
199     U32                     RelativeOffset;             /* 0x2C */
200     MPI3_SGE_UNION          SGL[5];                     /* 0x30 */
201 } MPI3_TARGET_ASSIST_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_ASSIST_REQUEST,
202   Mpi3TargetAssistRequest_t, MPI3_POINTER pMpi3TargetAssistRequest_t;
203 
204 /**** Defines for the MsgFlags field ****/
205 #define MPI3_TARGET_ASSIST_MSGFLAGS_METASGL_VALID           (0x80)
206 
207 /**** Defines for the Flags field ****/
208 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_23_MASK       (0x00800000)
209 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_22_MASK       (0x00400000)
210 #define MPI3_TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER          (0x00200000)
211 #define MPI3_TARGET_ASSIST_FLAGS_AUTO_STATUS                (0x00100000)
212 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_MASK         (0x000C0000)
213 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_WRITE        (0x00040000)
214 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_READ         (0x00080000)
215 #define MPI3_TARGET_ASSIST_FLAGS_DMAOPERATION_MASK          (0x00030000)
216 #define MPI3_TARGET_ASSIST_FLAGS_DMAOPERATION_HOST_PI       (0x00010000)
217 
218 /**** Defines for the SGL field ****/
219 #define MPI3_TARGET_ASSIST_METASGL_INDEX                    (4)
220 
221 /*****************************************************************************
222  *              Target Status Send Request Message                           *
223  ****************************************************************************/
224 typedef struct _MPI3_TARGET_STATUS_SEND_REQUEST
225 {
226     U16                     HostTag;                    /* 0x00 */
227     U8                      IOCUseOnly02;               /* 0x02 */
228     U8                      Function;                   /* 0x03 */
229     U16                     IOCUseOnly04;               /* 0x04 */
230     U8                      IOCUseOnly06;               /* 0x06 */
231     U8                      MsgFlags;                   /* 0x07 */
232     U16                     ChangeCount;                /* 0x08 */
233     U16                     DevHandle;                  /* 0x0A */
234     U16                     ResponseIULength;           /* 0x0C */
235     U16                     Flags;                      /* 0x0E */
236     U16                     Reserved10;                 /* 0x10 */
237     U16                     QueueTag;                   /* 0x12 */
238     U16                     IoIndex;                    /* 0x14 */
239     U16                     InitiatorConnectionTag;     /* 0x16 */
240     U32                     IOCUseOnly18[6];            /* 0x18 */
241     U32                     IOCUseOnly30[4];            /* 0x30 */
242     MPI3_SGE_UNION          SGL;                        /* 0x40 */
243 } MPI3_TARGET_STATUS_SEND_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_STATUS_SEND_REQUEST,
244   Mpi3TargetStatusSendRequest_t, MPI3_POINTER pMpi3TargetStatusSendRequest_t;
245 
246 /**** Defines for the Flags field ****/
247 #define MPI3_TSS_FLAGS_IOC_USE_ONLY_6_MASK              (0x0040)
248 #define MPI3_TSS_FLAGS_REPOST_CMD_BUFFER                (0x0020)
249 #define MPI3_TSS_FLAGS_AUTO_SEND_GOOD_STATUS            (0x0010)
250 
251 
252 /*****************************************************************************
253  *              Standard Target Mode Reply Message                           *
254  ****************************************************************************/
255 typedef struct _MPI3_TARGET_STANDARD_REPLY
256 {
257     U16                     HostTag;                    /* 0x00 */
258     U8                      IOCUseOnly02;               /* 0x02 */
259     U8                      Function;                   /* 0x03 */
260     U16                     IOCUseOnly04;               /* 0x04 */
261     U8                      IOCUseOnly06;               /* 0x06 */
262     U8                      MsgFlags;                   /* 0x07 */
263     U16                     IOCUseOnly08;               /* 0x08 */
264     U16                     IOCStatus;                  /* 0x0A */
265     U32                     IOCLogInfo;                 /* 0x0C */
266     U32                     TransferCount;              /* 0x10 */
267 } MPI3_TARGET_STANDARD_REPLY, MPI3_POINTER PTR_MPI3_TARGET_STANDARD_REPLY,
268   Mpi3TargetStandardReply_t, MPI3_POINTER pMpi3TargetStandardReply_t;
269 
270 
271 /*****************************************************************************
272  *              Target Mode Abort Request Message                            *
273  ****************************************************************************/
274 typedef struct _MPI3_TARGET_MODE_ABORT_REQUEST
275 {
276     U16                     HostTag;                    /* 0x00 */
277     U8                      IOCUseOnly02;               /* 0x02 */
278     U8                      Function;                   /* 0x03 */
279     U16                     IOCUseOnly04;               /* 0x04 */
280     U8                      IOCUseOnly06;               /* 0x06 */
281     U8                      MsgFlags;                   /* 0x07 */
282     U16                     ChangeCount;                /* 0x08 */
283     U8                      AbortType;                  /* 0x0A */
284     U8                      Reserved0B;                 /* 0x0B */
285     U16                     RequestQueueIDToAbort;      /* 0x0C */
286     U16                     HostTagToAbort;             /* 0x0E */
287     U16                     DevHandle;                  /* 0x10 */
288     U8                      IOCUseOnly12;               /* 0x12 */
289     U8                      Reserved13;                 /* 0x13 */
290 } MPI3_TARGET_MODE_ABORT_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_MODE_ABORT_REQUEST,
291   Mpi3TargetModeAbortRequest_t, MPI3_POINTER pMpi3TargetModeAbortRequest_t;
292 
293 /**** Defines for the AbortType field ****/
294 #define MPI3_TARGET_MODE_ABORT_ALL_CMD_BUFFERS              (0x00)
295 #define MPI3_TARGET_MODE_ABORT_EXACT_IO_REQUEST             (0x01)
296 #define MPI3_TARGET_MODE_ABORT_ALL_COMMANDS                 (0x02)
297 
298 
299 /*****************************************************************************
300  *              Target Mode Abort Reply Message                              *
301  ****************************************************************************/
302 typedef struct _MPI3_TARGET_MODE_ABORT_REPLY
303 {
304     U16                     HostTag;                    /* 0x00 */
305     U8                      IOCUseOnly02;               /* 0x02 */
306     U8                      Function;                   /* 0x03 */
307     U16                     IOCUseOnly04;               /* 0x04 */
308     U8                      IOCUseOnly06;               /* 0x06 */
309     U8                      MsgFlags;                   /* 0x07 */
310     U16                     IOCUseOnly08;               /* 0x08 */
311     U16                     IOCStatus;                  /* 0x0A */
312     U32                     IOCLogInfo;                 /* 0x0C */
313     U32                     AbortCount;                 /* 0x10 */
314 } MPI3_TARGET_MODE_ABORT_REPLY, MPI3_POINTER PTR_MPI3_TARGET_MODE_ABORT_REPLY,
315   Mpi3TargetModeAbortReply_t, MPI3_POINTER pMpi3TargetModeAbortReply_t;
316 
317 #endif  /* MPI30_TARG_H */
318 
319