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