xref: /freebsd/sys/dev/isci/scil/scu_completion_codes.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * This file is provided under a dual BSD/GPLv2 license.  When using or
5  * redistributing this file, you may do so under either license.
6  *
7  * GPL LICENSE SUMMARY
8  *
9  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23  * The full GNU General Public License is included in this distribution
24  * in the file called LICENSE.GPL.
25  *
26  * BSD LICENSE
27  *
28  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  *
35  *   * Redistributions of source code must retain the above copyright
36  *     notice, this list of conditions and the following disclaimer.
37  *   * Redistributions in binary form must reproduce the above copyright
38  *     notice, this list of conditions and the following disclaimer in
39  *     the documentation and/or other materials provided with the
40  *     distribution.
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  *
54  * $FreeBSD$
55  */
56 #ifndef _SCU_COMPLETION_CODES_HEADER_
57 #define _SCU_COMPLETION_CODES_HEADER_
58 
59 /**
60  * @file
61  *
62  * @brief This file contains the constants and macros for the SCU hardware
63  *        completion codes.
64  */
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif // __cplusplus
69 
70 #define SCU_COMPLETION_TYPE_SHIFT      28
71 #define SCU_COMPLETION_TYPE_MASK       0x70000000
72 
73 /**
74  * This macro constructs an SCU completion type
75  */
76 #define SCU_COMPLETION_TYPE(type) \
77    ((U32)(type) << SCU_COMPLETION_TYPE_SHIFT)
78 
79 /**
80  * These macros contain the SCU completion types
81  *
82  * @name SCU_COMPLETION_TYPE
83  */
84 /*@}*/
85 #define SCU_COMPLETION_TYPE_TASK       SCU_COMPLETION_TYPE(0)
86 #define SCU_COMPLETION_TYPE_SDMA       SCU_COMPLETION_TYPE(1)
87 #define SCU_COMPLETION_TYPE_UFI        SCU_COMPLETION_TYPE(2)
88 #define SCU_COMPLETION_TYPE_EVENT      SCU_COMPLETION_TYPE(3)
89 #define SCU_COMPLETION_TYPE_NOTIFY     SCU_COMPLETION_TYPE(4)
90 /*@}*/
91 
92 /**
93  * These constants provide the shift and mask values for the various parts of
94  * an SCU completion code.
95  */
96 #define SCU_COMPLETION_STATUS_MASK       0x0FFC0000
97 #define SCU_COMPLETION_TL_STATUS_MASK    0x0FC00000
98 #define SCU_COMPLETION_TL_STATUS_SHIFT   22
99 #define SCU_COMPLETION_SDMA_STATUS_MASK  0x003C0000
100 #define SCU_COMPLETION_PEG_MASK          0x00010000
101 #define SCU_COMPLETION_PORT_MASK         0x00007000
102 #define SCU_COMPLETION_PE_MASK           SCU_COMPLETION_PORT_MASK
103 #define SCU_COMPLETION_PE_SHIFT          12
104 #define SCU_COMPLETION_INDEX_MASK        0x00000FFF
105 
106 /**
107  * This macro returns the SCU completion type.
108  */
109 #define SCU_GET_COMPLETION_TYPE(completion_code) \
110    ((completion_code) & SCU_COMPLETION_TYPE_MASK)
111 
112 /**
113  * This macro returns the SCU completion status.
114  */
115 #define SCU_GET_COMPLETION_STATUS(completion_code) \
116    ((completion_code) & SCU_COMPLETION_STATUS_MASK)
117 
118 /**
119  * This macro returns the transport layer completion status.
120  */
121 #define SCU_GET_COMPLETION_TL_STATUS(completion_code) \
122    ((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)
123 
124 /**
125  * This macro takes a completion code and performs the shift and mask
126  * operations to turn it into a completion code that can be compared to a
127  * SCU_GET_COMPLETION_TL_STATUS.
128  */
129 #define SCU_MAKE_COMPLETION_STATUS(completion_code) \
130    ((U32)(completion_code) << SCU_COMPLETION_TL_STATUS_SHIFT)
131 
132 /**
133  * This macro takes a SCU_GET_COMPLETION_TL_STATUS and normalizes it for a
134  * return code.
135  */
136 #define SCU_NORMALIZE_COMPLETION_STATUS(completion_code) \
137    ( \
138       ((U32)((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)) \
139    >> SCU_COMPLETION_TL_STATUS_SHIFT \
140    )
141 
142 /**
143  * This macro returns the SDMA completion status.
144  */
145 #define SCU_GET_COMPLETION_SDMA_STATUS(completion_code) \
146    ((completion_code) & SCU_COMPLETION_SDMA_STATUS_MASK)
147 
148 /**
149  * This macro returns the Protocol Engine Group from the completion code.
150  */
151 #define SCU_GET_COMPLETION_PEG(completion_code) \
152    ((completion_code) & SCU_COMPLETION_PEG_MASK)
153 
154 /**
155  * This macro reuturns the logical port index from the completion code.
156  */
157 #define SCU_GET_COMPLETION_PORT(completion_code) \
158    ((completion_code) & SCU_COMPLETION_PORT_MASK)
159 
160 /**
161  * This macro returns the PE index from the completion code.
162  */
163 #define SCU_GET_PROTOCOL_ENGINE_INDEX(completion_code) \
164    (((U32)((completion_code) & SCU_COMPLETION_PE_MASK)) >> SCU_COMPLETION_PE_SHIFT)
165 
166 /**
167  * This macro returns the index of the completion which is either a TCi or an
168  * RNi depending on the completion type.
169  */
170 #define SCU_GET_COMPLETION_INDEX(completion_code) \
171    ((completion_code) & SCU_COMPLETION_INDEX_MASK)
172 
173 #define SCU_UNSOLICITED_FRAME_MASK     0x0FFF0000
174 #define SCU_UNSOLICITED_FRAME_SHIFT    16
175 
176 /**
177  * This macro returns a normalized frame index from an unsolicited frame
178  * completion.
179  */
180 #define SCU_GET_FRAME_INDEX(completion_code) \
181    ( \
182         ((U32)((completion_code) & SCU_UNSOLICITED_FRAME_MASK)) \
183      >> SCU_UNSOLICITED_FRAME_SHIFT \
184    )
185 
186 #define SCU_UNSOLICITED_FRAME_ERROR_MASK  0x00008000
187 
188 /**
189  * This macro returns a zero (0) value if there is no frame error otherwise
190  * it returns non-zero (!0).
191  */
192 #define SCU_GET_FRAME_ERROR(completion_code) \
193    ((completion_code) & SCU_UNSOLICITED_FRAME_ERROR_MASK)
194 
195 /**
196  * These constants represent normalized completion codes which must be shifted
197  * 18 bits to match it with the hardware completion code. In a 16-bit compiler,
198  * immediate constants are 16-bit values (the size of an int). If we shift those
199  * by 18 bits, we completely lose the value. To ensure the value is a 32-bit
200  * value like we want, each immediate value must be cast to a U32.
201  */
202 #define SCU_TASK_DONE_GOOD                                  ((U32)0x00)
203 #define SCU_TASK_DONE_CRC_ERR                               ((U32)0x14)
204 #define SCU_TASK_DONE_CHECK_RESPONSE                        ((U32)0x14)
205 #define SCU_TASK_DONE_GEN_RESPONSE                          ((U32)0x15)
206 #define SCU_TASK_DONE_NAK_CMD_ERR                           ((U32)0x16)
207 #define SCU_TASK_DONE_CMD_LL_R_ERR                          ((U32)0x16)
208 #define SCU_TASK_DONE_LL_R_ERR                              ((U32)0x17)
209 #define SCU_TASK_DONE_ACK_NAK_TO                            ((U32)0x17)
210 #define SCU_TASK_DONE_LL_PERR                               ((U32)0x18)
211 #define SCU_TASK_DONE_LL_SY_TERM                            ((U32)0x19)
212 #define SCU_TASK_DONE_NAK_ERR                               ((U32)0x19)
213 #define SCU_TASK_DONE_LL_LF_TERM                            ((U32)0x1A)
214 #define SCU_TASK_DONE_DATA_LEN_ERR                          ((U32)0x1A)
215 #define SCU_TASK_DONE_LL_CL_TERM                            ((U32)0x1B)
216 #define SCU_TASK_DONE_LL_ABORT_ERR                          ((U32)0x1B)
217 #define SCU_TASK_DONE_SEQ_INV_TYPE                          ((U32)0x1C)
218 #define SCU_TASK_DONE_UNEXP_XR                              ((U32)0x1C)
219 #define SCU_TASK_DONE_INV_FIS_TYPE                          ((U32)0x1D)
220 #define SCU_TASK_DONE_XR_IU_LEN_ERR                         ((U32)0x1D)
221 #define SCU_TASK_DONE_INV_FIS_LEN                           ((U32)0x1E)
222 #define SCU_TASK_DONE_XR_WD_LEN                             ((U32)0x1E)
223 #define SCU_TASK_DONE_SDMA_ERR                              ((U32)0x1F)
224 #define SCU_TASK_DONE_OFFSET_ERR                            ((U32)0x20)
225 #define SCU_TASK_DONE_MAX_PLD_ERR                           ((U32)0x21)
226 #define SCU_TASK_DONE_EXCESS_DATA                           ((U32)0x22)
227 #define SCU_TASK_DONE_LF_ERR                                ((U32)0x23)
228 #define SCU_TASK_DONE_UNEXP_FIS                             ((U32)0x24)
229 #define SCU_TASK_DONE_UNEXP_RESP                            ((U32)0x24)
230 #define SCU_TASK_DONE_EARLY_RESP                            ((U32)0x25)
231 #define SCU_TASK_DONE_SMP_RESP_TO_ERR                       ((U32)0x26)
232 #define SCU_TASK_DONE_DMASETUP_DIRERR                       ((U32)0x27)
233 #define SCU_TASK_DONE_SMP_UFI_ERR                           ((U32)0x27)
234 #define SCU_TASK_DONE_XFERCNT_ERR                           ((U32)0x28)
235 #define SCU_TASK_DONE_SMP_FRM_TYPE_ERR                      ((U32)0x28)
236 #define SCU_TASK_DONE_SMP_LL_RX_ERR                         ((U32)0x29)
237 #define SCU_TASK_DONE_RESP_LEN_ERR                          ((U32)0x2A)
238 #define SCU_TASK_DONE_UNEXP_DATA                            ((U32)0x2B)
239 #define SCU_TASK_DONE_OPEN_FAIL                             ((U32)0x2C)
240 #define SCU_TASK_DONE_UNEXP_SDBFIS                          ((U32)0x2D)
241 #define SCU_TASK_DONE_REG_ERR                               ((U32)0x2E)
242 #define SCU_TASK_DONE_SDB_ERR                               ((U32)0x2F)
243 #define SCU_TASK_DONE_TASK_ABORT                            ((U32)0x30)
244 #if defined(PBG_HBA_BETA_BUILD)
245 #define SCU_TASK_DONE_CMD_SDMA_ERR                          ((U32)0x32)
246 #define SCU_TASK_DONE_CMD_LL_ABORT_ERR                      ((U32)0x33)
247 #endif
248 #define SCU_TASK_OPEN_REJECT_WRONG_DESTINATION              ((U32)0x34)
249 #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1             ((U32)0x35)
250 #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2             ((U32)0x36)
251 #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3             ((U32)0x37)
252 #define SCU_TASK_OPEN_REJECT_BAD_DESTINATION                ((U32)0x38)
253 #define SCU_TASK_OPEN_REJECT_ZONE_VIOLATION                 ((U32)0x39)
254 #define SCU_TASK_DONE_VIIT_ENTRY_NV                         ((U32)0x3A)
255 #define SCU_TASK_DONE_IIT_ENTRY_NV                          ((U32)0x3B)
256 #define SCU_TASK_DONE_RNCNV_OUTBOUND                        ((U32)0x3C)
257 #define SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY             ((U32)0x3D)
258 #define SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED         ((U32)0x3E)
259 #define SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED  ((U32)0x3F)
260 
261 #ifdef __cplusplus
262 }
263 #endif // __cplusplus
264 
265 #endif // _SCU_COMPLETION_CODES_HEADER_
266