xref: /freebsd/sys/dev/isci/scil/scu_completion_codes.h (revision 718cf2ccb9956613756ab15d7a0e28f2c8e91cab)
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  * $FreeBSD$
55f11c7f63SJim Harris  */
56f11c7f63SJim Harris #ifndef _SCU_COMPLETION_CODES_HEADER_
57f11c7f63SJim Harris #define _SCU_COMPLETION_CODES_HEADER_
58f11c7f63SJim Harris 
59f11c7f63SJim Harris /**
60f11c7f63SJim Harris  * @file
61f11c7f63SJim Harris  *
62f11c7f63SJim Harris  * @brief This file contains the constants and macros for the SCU hardware
63f11c7f63SJim Harris  *        completion codes.
64f11c7f63SJim Harris  */
65f11c7f63SJim Harris 
66f11c7f63SJim Harris #ifdef __cplusplus
67f11c7f63SJim Harris extern "C" {
68f11c7f63SJim Harris #endif // __cplusplus
69f11c7f63SJim Harris 
70f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_SHIFT      28
71f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_MASK       0x70000000
72f11c7f63SJim Harris 
73f11c7f63SJim Harris /**
74f11c7f63SJim Harris  * This macro constructs an SCU completion type
75f11c7f63SJim Harris  */
76f11c7f63SJim Harris #define SCU_COMPLETION_TYPE(type) \
77f11c7f63SJim Harris    ((U32)(type) << SCU_COMPLETION_TYPE_SHIFT)
78f11c7f63SJim Harris 
79f11c7f63SJim Harris /**
80f11c7f63SJim Harris  * These macros contain the SCU completion types
81f11c7f63SJim Harris  *
82f11c7f63SJim Harris  * @name SCU_COMPLETION_TYPE
83f11c7f63SJim Harris  */
84f11c7f63SJim Harris /*@}*/
85f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_TASK       SCU_COMPLETION_TYPE(0)
86f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_SDMA       SCU_COMPLETION_TYPE(1)
87f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_UFI        SCU_COMPLETION_TYPE(2)
88f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_EVENT      SCU_COMPLETION_TYPE(3)
89f11c7f63SJim Harris #define SCU_COMPLETION_TYPE_NOTIFY     SCU_COMPLETION_TYPE(4)
90f11c7f63SJim Harris /*@}*/
91f11c7f63SJim Harris 
92f11c7f63SJim Harris /**
93f11c7f63SJim Harris  * These constants provide the shift and mask values for the various parts of
94f11c7f63SJim Harris  * an SCU completion code.
95f11c7f63SJim Harris  */
96f11c7f63SJim Harris #define SCU_COMPLETION_STATUS_MASK       0x0FFC0000
97f11c7f63SJim Harris #define SCU_COMPLETION_TL_STATUS_MASK    0x0FC00000
98f11c7f63SJim Harris #define SCU_COMPLETION_TL_STATUS_SHIFT   22
99f11c7f63SJim Harris #define SCU_COMPLETION_SDMA_STATUS_MASK  0x003C0000
100f11c7f63SJim Harris #define SCU_COMPLETION_PEG_MASK          0x00010000
101f11c7f63SJim Harris #define SCU_COMPLETION_PORT_MASK         0x00007000
102f11c7f63SJim Harris #define SCU_COMPLETION_PE_MASK           SCU_COMPLETION_PORT_MASK
103f11c7f63SJim Harris #define SCU_COMPLETION_PE_SHIFT          12
104f11c7f63SJim Harris #define SCU_COMPLETION_INDEX_MASK        0x00000FFF
105f11c7f63SJim Harris 
106f11c7f63SJim Harris /**
107f11c7f63SJim Harris  * This macro returns the SCU completion type.
108f11c7f63SJim Harris  */
109f11c7f63SJim Harris #define SCU_GET_COMPLETION_TYPE(completion_code) \
110f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_TYPE_MASK)
111f11c7f63SJim Harris 
112f11c7f63SJim Harris /**
113f11c7f63SJim Harris  * This macro returns the SCU completion status.
114f11c7f63SJim Harris  */
115f11c7f63SJim Harris #define SCU_GET_COMPLETION_STATUS(completion_code) \
116f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_STATUS_MASK)
117f11c7f63SJim Harris 
118f11c7f63SJim Harris /**
119f11c7f63SJim Harris  * This macro returns the transport layer completion status.
120f11c7f63SJim Harris  */
121f11c7f63SJim Harris #define SCU_GET_COMPLETION_TL_STATUS(completion_code) \
122f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)
123f11c7f63SJim Harris 
124f11c7f63SJim Harris /**
125f11c7f63SJim Harris  * This macro takes a completion code and performs the shift and mask
126f11c7f63SJim Harris  * operations to turn it into a completion code that can be compared to a
127f11c7f63SJim Harris  * SCU_GET_COMPLETION_TL_STATUS.
128f11c7f63SJim Harris  */
129f11c7f63SJim Harris #define SCU_MAKE_COMPLETION_STATUS(completion_code) \
130f11c7f63SJim Harris    ((U32)(completion_code) << SCU_COMPLETION_TL_STATUS_SHIFT)
131f11c7f63SJim Harris 
132f11c7f63SJim Harris /**
133f11c7f63SJim Harris  * This macro takes a SCU_GET_COMPLETION_TL_STATUS and normalizes it for a
134f11c7f63SJim Harris  * return code.
135f11c7f63SJim Harris  */
136f11c7f63SJim Harris #define SCU_NORMALIZE_COMPLETION_STATUS(completion_code) \
137f11c7f63SJim Harris    ( \
138f11c7f63SJim Harris       ((U32)((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)) \
139f11c7f63SJim Harris    >> SCU_COMPLETION_TL_STATUS_SHIFT \
140f11c7f63SJim Harris    )
141f11c7f63SJim Harris 
142f11c7f63SJim Harris /**
143f11c7f63SJim Harris  * This macro returns the SDMA completion status.
144f11c7f63SJim Harris  */
145f11c7f63SJim Harris #define SCU_GET_COMPLETION_SDMA_STATUS(completion_code) \
146f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_SDMA_STATUS_MASK)
147f11c7f63SJim Harris 
148f11c7f63SJim Harris /**
149f11c7f63SJim Harris  * This macro returns the Protocol Engine Group from the completion code.
150f11c7f63SJim Harris  */
151f11c7f63SJim Harris #define SCU_GET_COMPLETION_PEG(completion_code) \
152f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_PEG_MASK)
153f11c7f63SJim Harris 
154f11c7f63SJim Harris /**
155f11c7f63SJim Harris  * This macro reuturns the logical port index from the completion code.
156f11c7f63SJim Harris  */
157f11c7f63SJim Harris #define SCU_GET_COMPLETION_PORT(completion_code) \
158f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_PORT_MASK)
159f11c7f63SJim Harris 
160f11c7f63SJim Harris /**
161f11c7f63SJim Harris  * This macro returns the PE index from the completion code.
162f11c7f63SJim Harris  */
163f11c7f63SJim Harris #define SCU_GET_PROTOCOL_ENGINE_INDEX(completion_code) \
164f11c7f63SJim Harris    (((U32)((completion_code) & SCU_COMPLETION_PE_MASK)) >> SCU_COMPLETION_PE_SHIFT)
165f11c7f63SJim Harris 
166f11c7f63SJim Harris /**
167f11c7f63SJim Harris  * This macro returns the index of the completion which is either a TCi or an
168f11c7f63SJim Harris  * RNi depending on the completion type.
169f11c7f63SJim Harris  */
170f11c7f63SJim Harris #define SCU_GET_COMPLETION_INDEX(completion_code) \
171f11c7f63SJim Harris    ((completion_code) & SCU_COMPLETION_INDEX_MASK)
172f11c7f63SJim Harris 
173f11c7f63SJim Harris #define SCU_UNSOLICITED_FRAME_MASK     0x0FFF0000
174f11c7f63SJim Harris #define SCU_UNSOLICITED_FRAME_SHIFT    16
175f11c7f63SJim Harris 
176f11c7f63SJim Harris /**
177f11c7f63SJim Harris  * This macro returns a normalized frame index from an unsolicited frame
178f11c7f63SJim Harris  * completion.
179f11c7f63SJim Harris  */
180f11c7f63SJim Harris #define SCU_GET_FRAME_INDEX(completion_code) \
181f11c7f63SJim Harris    ( \
182f11c7f63SJim Harris         ((U32)((completion_code) & SCU_UNSOLICITED_FRAME_MASK)) \
183f11c7f63SJim Harris      >> SCU_UNSOLICITED_FRAME_SHIFT \
184f11c7f63SJim Harris    )
185f11c7f63SJim Harris 
186f11c7f63SJim Harris #define SCU_UNSOLICITED_FRAME_ERROR_MASK  0x00008000
187f11c7f63SJim Harris 
188f11c7f63SJim Harris /**
189f11c7f63SJim Harris  * This macro returns a zero (0) value if there is no frame error otherwise
190f11c7f63SJim Harris  * it returns non-zero (!0).
191f11c7f63SJim Harris  */
192f11c7f63SJim Harris #define SCU_GET_FRAME_ERROR(completion_code) \
193f11c7f63SJim Harris    ((completion_code) & SCU_UNSOLICITED_FRAME_ERROR_MASK)
194f11c7f63SJim Harris 
195f11c7f63SJim Harris /**
196f11c7f63SJim Harris  * These constants represent normalized completion codes which must be shifted
197f11c7f63SJim Harris  * 18 bits to match it with the hardware completion code. In a 16-bit compiler,
198f11c7f63SJim Harris  * immediate constants are 16-bit values (the size of an int). If we shift those
199f11c7f63SJim Harris  * by 18 bits, we completely lose the value. To ensure the value is a 32-bit
200f11c7f63SJim Harris  * value like we want, each immediate value must be cast to a U32.
201f11c7f63SJim Harris  */
202f11c7f63SJim Harris #define SCU_TASK_DONE_GOOD                                  ((U32)0x00)
203f11c7f63SJim Harris #define SCU_TASK_DONE_CRC_ERR                               ((U32)0x14)
204f11c7f63SJim Harris #define SCU_TASK_DONE_CHECK_RESPONSE                        ((U32)0x14)
205f11c7f63SJim Harris #define SCU_TASK_DONE_GEN_RESPONSE                          ((U32)0x15)
206f11c7f63SJim Harris #define SCU_TASK_DONE_NAK_CMD_ERR                           ((U32)0x16)
207f11c7f63SJim Harris #define SCU_TASK_DONE_CMD_LL_R_ERR                          ((U32)0x16)
208f11c7f63SJim Harris #define SCU_TASK_DONE_LL_R_ERR                              ((U32)0x17)
209f11c7f63SJim Harris #define SCU_TASK_DONE_ACK_NAK_TO                            ((U32)0x17)
210f11c7f63SJim Harris #define SCU_TASK_DONE_LL_PERR                               ((U32)0x18)
211f11c7f63SJim Harris #define SCU_TASK_DONE_LL_SY_TERM                            ((U32)0x19)
212f11c7f63SJim Harris #define SCU_TASK_DONE_NAK_ERR                               ((U32)0x19)
213f11c7f63SJim Harris #define SCU_TASK_DONE_LL_LF_TERM                            ((U32)0x1A)
214f11c7f63SJim Harris #define SCU_TASK_DONE_DATA_LEN_ERR                          ((U32)0x1A)
215f11c7f63SJim Harris #define SCU_TASK_DONE_LL_CL_TERM                            ((U32)0x1B)
216f11c7f63SJim Harris #define SCU_TASK_DONE_LL_ABORT_ERR                          ((U32)0x1B)
217f11c7f63SJim Harris #define SCU_TASK_DONE_SEQ_INV_TYPE                          ((U32)0x1C)
218f11c7f63SJim Harris #define SCU_TASK_DONE_UNEXP_XR                              ((U32)0x1C)
219f11c7f63SJim Harris #define SCU_TASK_DONE_INV_FIS_TYPE                          ((U32)0x1D)
220f11c7f63SJim Harris #define SCU_TASK_DONE_XR_IU_LEN_ERR                         ((U32)0x1D)
221f11c7f63SJim Harris #define SCU_TASK_DONE_INV_FIS_LEN                           ((U32)0x1E)
222f11c7f63SJim Harris #define SCU_TASK_DONE_XR_WD_LEN                             ((U32)0x1E)
223f11c7f63SJim Harris #define SCU_TASK_DONE_SDMA_ERR                              ((U32)0x1F)
224f11c7f63SJim Harris #define SCU_TASK_DONE_OFFSET_ERR                            ((U32)0x20)
225f11c7f63SJim Harris #define SCU_TASK_DONE_MAX_PLD_ERR                           ((U32)0x21)
226f11c7f63SJim Harris #define SCU_TASK_DONE_EXCESS_DATA                           ((U32)0x22)
227f11c7f63SJim Harris #define SCU_TASK_DONE_LF_ERR                                ((U32)0x23)
228f11c7f63SJim Harris #define SCU_TASK_DONE_UNEXP_FIS                             ((U32)0x24)
229f11c7f63SJim Harris #define SCU_TASK_DONE_UNEXP_RESP                            ((U32)0x24)
230f11c7f63SJim Harris #define SCU_TASK_DONE_EARLY_RESP                            ((U32)0x25)
231f11c7f63SJim Harris #define SCU_TASK_DONE_SMP_RESP_TO_ERR                       ((U32)0x26)
232f11c7f63SJim Harris #define SCU_TASK_DONE_DMASETUP_DIRERR                       ((U32)0x27)
233f11c7f63SJim Harris #define SCU_TASK_DONE_SMP_UFI_ERR                           ((U32)0x27)
234f11c7f63SJim Harris #define SCU_TASK_DONE_XFERCNT_ERR                           ((U32)0x28)
235f11c7f63SJim Harris #define SCU_TASK_DONE_SMP_FRM_TYPE_ERR                      ((U32)0x28)
236f11c7f63SJim Harris #define SCU_TASK_DONE_SMP_LL_RX_ERR                         ((U32)0x29)
237f11c7f63SJim Harris #define SCU_TASK_DONE_RESP_LEN_ERR                          ((U32)0x2A)
238f11c7f63SJim Harris #define SCU_TASK_DONE_UNEXP_DATA                            ((U32)0x2B)
239f11c7f63SJim Harris #define SCU_TASK_DONE_OPEN_FAIL                             ((U32)0x2C)
240f11c7f63SJim Harris #define SCU_TASK_DONE_UNEXP_SDBFIS                          ((U32)0x2D)
241f11c7f63SJim Harris #define SCU_TASK_DONE_REG_ERR                               ((U32)0x2E)
242f11c7f63SJim Harris #define SCU_TASK_DONE_SDB_ERR                               ((U32)0x2F)
243f11c7f63SJim Harris #define SCU_TASK_DONE_TASK_ABORT                            ((U32)0x30)
244f11c7f63SJim Harris #if defined(PBG_HBA_BETA_BUILD)
245f11c7f63SJim Harris #define SCU_TASK_DONE_CMD_SDMA_ERR                          ((U32)0x32)
246f11c7f63SJim Harris #define SCU_TASK_DONE_CMD_LL_ABORT_ERR                      ((U32)0x33)
247f11c7f63SJim Harris #endif
248f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_WRONG_DESTINATION              ((U32)0x34)
249f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1             ((U32)0x35)
250f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2             ((U32)0x36)
251f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3             ((U32)0x37)
252f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_BAD_DESTINATION                ((U32)0x38)
253f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_ZONE_VIOLATION                 ((U32)0x39)
254f11c7f63SJim Harris #define SCU_TASK_DONE_VIIT_ENTRY_NV                         ((U32)0x3A)
255f11c7f63SJim Harris #define SCU_TASK_DONE_IIT_ENTRY_NV                          ((U32)0x3B)
256f11c7f63SJim Harris #define SCU_TASK_DONE_RNCNV_OUTBOUND                        ((U32)0x3C)
257f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY             ((U32)0x3D)
258f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED         ((U32)0x3E)
259f11c7f63SJim Harris #define SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED  ((U32)0x3F)
260f11c7f63SJim Harris 
261f11c7f63SJim Harris #ifdef __cplusplus
262f11c7f63SJim Harris }
263f11c7f63SJim Harris #endif // __cplusplus
264f11c7f63SJim Harris 
265f11c7f63SJim Harris #endif // _SCU_COMPLETION_CODES_HEADER_
266