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