xref: /freebsd/sys/dev/mpi3mr/mpi/mpi30_targ.h (revision 92f340d137ba5d6db7610ba1dae35842e2c9c8ea)
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_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_SHIFT             (2)
127 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_SYSTEM            (0x00)
128 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_IOCUDP            (0x04)
129 #define MPI3_CMD_BUF_POST_BASE_FLAGS_DLAS_IOCCTL            (0x08)
130 #define MPI3_CMD_BUF_POST_BASE_FLAGS_AUTO_POST_ALL          (0x01)
131 
132 /**** Defines for the CmdBufferLength field ****/
133 #define MPI3_CMD_BUF_POST_BASE_MIN_BUF_LENGTH               (0x34)
134 #define MPI3_CMD_BUF_POST_BASE_MAX_BUF_LENGTH               (0x3FC)
135 
136 /*****************************************************************************
137  *              Target Command Buffer Post List Request Message              *
138  ****************************************************************************/
139 typedef struct _MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST
140 {
141     U16                     HostTag;                    /* 0x00 */
142     U8                      IOCUseOnly02;               /* 0x02 */
143     U8                      Function;                   /* 0x03 */
144     U16                     IOCUseOnly04;               /* 0x04 */
145     U8                      IOCUseOnly06;               /* 0x06 */
146     U8                      MsgFlags;                   /* 0x07 */
147     U16                     ChangeCount;                /* 0x08 */
148     U16                     Reserved0A;                 /* 0x0A */
149     U8                      CmdBufferCount;             /* 0x0C */
150     U8                      Reserved0D[3];              /* 0x0D */
151     U16                     IoIndex[2];                 /* 0x10 */
152 } MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_CMD_BUF_POST_LIST_REQUEST,
153   Mpi3TargetCmdBufPostListRequest_t, MPI3_POINTER pMpi3TargetCmdBufPostListRequest_t;
154 
155 
156 /*****************************************************************************
157  *              Target Command Buffer Post Base List Reply Message           *
158  ****************************************************************************/
159 typedef struct _MPI3_TARGET_CMD_BUF_POST_REPLY
160 {
161     U16                     HostTag;                        /* 0x00 */
162     U8                      IOCUseOnly02;                   /* 0x02 */
163     U8                      Function;                       /* 0x03 */
164     U16                     IOCUseOnly04;                   /* 0x04 */
165     U8                      IOCUseOnly06;                   /* 0x06 */
166     U8                      MsgFlags;                       /* 0x07 */
167     U16                     IOCUseOnly08;                   /* 0x08 */
168     U16                     IOCStatus;                      /* 0x0A */
169     U32                     IOCLogInfo;                     /* 0x0C */
170     U8                      CmdBufferCount;                 /* 0x10 */
171     U8                      Reserved11[3];                  /* 0x11 */
172     U16                     IoIndex[2];                     /* 0x14 */
173 } MPI3_TARGET_CMD_BUF_POST_REPLY, MPI3_POINTER PTR_MPI3_TARGET_CMD_BUF_POST_REPLY,
174   Mpi3TargetCmdBufPostReply_t, MPI3_POINTER pMpi3TargetCmdBufPostReply_t;
175 
176 
177 /*****************************************************************************
178  *              Target Assist Request Message                                *
179  ****************************************************************************/
180 typedef struct _MPI3_TARGET_ASSIST_REQUEST
181 {
182     U16                     HostTag;                    /* 0x00 */
183     U8                      IOCUseOnly02;               /* 0x02 */
184     U8                      Function;                   /* 0x03 */
185     U16                     IOCUseOnly04;               /* 0x04 */
186     U8                      IOCUseOnly06;               /* 0x06 */
187     U8                      MsgFlags;                   /* 0x07 */
188     U16                     ChangeCount;                /* 0x08 */
189     U16                     DevHandle;                  /* 0x0A */
190     U32                     Flags;                      /* 0x0C */
191     U16                     Reserved10;                 /* 0x10 */
192     U16                     QueueTag;                   /* 0x12 */
193     U16                     IoIndex;                    /* 0x14 */
194     U16                     InitiatorConnectionTag;     /* 0x16 */
195     U32                     IOCUseOnly18;               /* 0x18 */
196     U32                     DataLength;                 /* 0x1C */
197     U32                     PortTransferLength;         /* 0x20 */
198     U32                     PrimaryReferenceTag;        /* 0x24 */
199     U16                     PrimaryApplicationTag;      /* 0x28 */
200     U16                     PrimaryApplicationTagMask;  /* 0x2A */
201     U32                     RelativeOffset;             /* 0x2C */
202     MPI3_SGE_UNION          SGL[5];                     /* 0x30 */
203 } MPI3_TARGET_ASSIST_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_ASSIST_REQUEST,
204   Mpi3TargetAssistRequest_t, MPI3_POINTER pMpi3TargetAssistRequest_t;
205 
206 /**** Defines for the MsgFlags field ****/
207 #define MPI3_TARGET_ASSIST_MSGFLAGS_METASGL_VALID           (0x80)
208 
209 /**** Defines for the Flags field ****/
210 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_23_MASK       (0x00800000)
211 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_23_SHIFT      (23)
212 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_22_MASK       (0x00400000)
213 #define MPI3_TARGET_ASSIST_FLAGS_IOC_USE_ONLY_22_SHIFT      (22)
214 #define MPI3_TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER          (0x00200000)
215 #define MPI3_TARGET_ASSIST_FLAGS_AUTO_STATUS                (0x00100000)
216 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_MASK         (0x000C0000)
217 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_SHIFT        (18)
218 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_WRITE        (0x00040000)
219 #define MPI3_TARGET_ASSIST_FLAGS_DATADIRECTION_READ         (0x00080000)
220 #define MPI3_TARGET_ASSIST_FLAGS_DMAOPERATION_MASK          (0x00030000)
221 #define MPI3_TARGET_ASSIST_FLAGS_DMAOPERATION_SHIFT         (16)
222 #define MPI3_TARGET_ASSIST_FLAGS_DMAOPERATION_HOST_PI       (0x00010000)
223 
224 /**** Defines for the SGL field ****/
225 #define MPI3_TARGET_ASSIST_METASGL_INDEX                    (4)
226 
227 /*****************************************************************************
228  *              Target Status Send Request Message                           *
229  ****************************************************************************/
230 typedef struct _MPI3_TARGET_STATUS_SEND_REQUEST
231 {
232     U16                     HostTag;                    /* 0x00 */
233     U8                      IOCUseOnly02;               /* 0x02 */
234     U8                      Function;                   /* 0x03 */
235     U16                     IOCUseOnly04;               /* 0x04 */
236     U8                      IOCUseOnly06;               /* 0x06 */
237     U8                      MsgFlags;                   /* 0x07 */
238     U16                     ChangeCount;                /* 0x08 */
239     U16                     DevHandle;                  /* 0x0A */
240     U16                     ResponseIULength;           /* 0x0C */
241     U16                     Flags;                      /* 0x0E */
242     U16                     Reserved10;                 /* 0x10 */
243     U16                     QueueTag;                   /* 0x12 */
244     U16                     IoIndex;                    /* 0x14 */
245     U16                     InitiatorConnectionTag;     /* 0x16 */
246     U32                     IOCUseOnly18[6];            /* 0x18 */
247     U32                     IOCUseOnly30[4];            /* 0x30 */
248     MPI3_SGE_UNION          SGL;                        /* 0x40 */
249 } MPI3_TARGET_STATUS_SEND_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_STATUS_SEND_REQUEST,
250   Mpi3TargetStatusSendRequest_t, MPI3_POINTER pMpi3TargetStatusSendRequest_t;
251 
252 /**** Defines for the Flags field ****/
253 #define MPI3_TSS_FLAGS_IOC_USE_ONLY_6_MASK              (0x0040)
254 #define MPI3_TSS_FLAGS_IOC_USE_ONLY_6_SHIFT             (6)
255 #define MPI3_TSS_FLAGS_REPOST_CMD_BUFFER                (0x0020)
256 #define MPI3_TSS_FLAGS_AUTO_SEND_GOOD_STATUS            (0x0010)
257 
258 
259 /*****************************************************************************
260  *              Standard Target Mode Reply Message                           *
261  ****************************************************************************/
262 typedef struct _MPI3_TARGET_STANDARD_REPLY
263 {
264     U16                     HostTag;                    /* 0x00 */
265     U8                      IOCUseOnly02;               /* 0x02 */
266     U8                      Function;                   /* 0x03 */
267     U16                     IOCUseOnly04;               /* 0x04 */
268     U8                      IOCUseOnly06;               /* 0x06 */
269     U8                      MsgFlags;                   /* 0x07 */
270     U16                     IOCUseOnly08;               /* 0x08 */
271     U16                     IOCStatus;                  /* 0x0A */
272     U32                     IOCLogInfo;                 /* 0x0C */
273     U32                     TransferCount;              /* 0x10 */
274 } MPI3_TARGET_STANDARD_REPLY, MPI3_POINTER PTR_MPI3_TARGET_STANDARD_REPLY,
275   Mpi3TargetStandardReply_t, MPI3_POINTER pMpi3TargetStandardReply_t;
276 
277 
278 /*****************************************************************************
279  *              Target Mode Abort Request Message                            *
280  ****************************************************************************/
281 typedef struct _MPI3_TARGET_MODE_ABORT_REQUEST
282 {
283     U16                     HostTag;                    /* 0x00 */
284     U8                      IOCUseOnly02;               /* 0x02 */
285     U8                      Function;                   /* 0x03 */
286     U16                     IOCUseOnly04;               /* 0x04 */
287     U8                      IOCUseOnly06;               /* 0x06 */
288     U8                      MsgFlags;                   /* 0x07 */
289     U16                     ChangeCount;                /* 0x08 */
290     U8                      AbortType;                  /* 0x0A */
291     U8                      Reserved0B;                 /* 0x0B */
292     U16                     RequestQueueIDToAbort;      /* 0x0C */
293     U16                     HostTagToAbort;             /* 0x0E */
294     U16                     DevHandle;                  /* 0x10 */
295     U8                      IOCUseOnly12;               /* 0x12 */
296     U8                      Reserved13;                 /* 0x13 */
297 } MPI3_TARGET_MODE_ABORT_REQUEST, MPI3_POINTER PTR_MPI3_TARGET_MODE_ABORT_REQUEST,
298   Mpi3TargetModeAbortRequest_t, MPI3_POINTER pMpi3TargetModeAbortRequest_t;
299 
300 /**** Defines for the AbortType field ****/
301 #define MPI3_TARGET_MODE_ABORT_ALL_CMD_BUFFERS              (0x00)
302 #define MPI3_TARGET_MODE_ABORT_EXACT_IO_REQUEST             (0x01)
303 #define MPI3_TARGET_MODE_ABORT_ALL_COMMANDS                 (0x02)
304 #define MPI3_TARGET_MODE_ABORT_ALL_COMMANDS_DEVHANDLE       (0x03)
305 
306 /*****************************************************************************
307  *              Target Mode Abort Reply Message                              *
308  ****************************************************************************/
309 typedef struct _MPI3_TARGET_MODE_ABORT_REPLY
310 {
311     U16                     HostTag;                    /* 0x00 */
312     U8                      IOCUseOnly02;               /* 0x02 */
313     U8                      Function;                   /* 0x03 */
314     U16                     IOCUseOnly04;               /* 0x04 */
315     U8                      IOCUseOnly06;               /* 0x06 */
316     U8                      MsgFlags;                   /* 0x07 */
317     U16                     IOCUseOnly08;               /* 0x08 */
318     U16                     IOCStatus;                  /* 0x0A */
319     U32                     IOCLogInfo;                 /* 0x0C */
320     U32                     AbortCount;                 /* 0x10 */
321 } MPI3_TARGET_MODE_ABORT_REPLY, MPI3_POINTER PTR_MPI3_TARGET_MODE_ABORT_REPLY,
322   Mpi3TargetModeAbortReply_t, MPI3_POINTER pMpi3TargetModeAbortReply_t;
323 
324 #endif  /* MPI30_TARG_H */
325 
326