1230557Sjimharris/*-
2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license.  When using or
3230557Sjimharris * redistributing this file, you may do so under either license.
4230557Sjimharris *
5230557Sjimharris * GPL LICENSE SUMMARY
6230557Sjimharris *
7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8230557Sjimharris *
9230557Sjimharris * This program is free software; you can redistribute it and/or modify
10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as
11230557Sjimharris * published by the Free Software Foundation.
12230557Sjimharris *
13230557Sjimharris * This program is distributed in the hope that it will be useful, but
14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of
15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16230557Sjimharris * General Public License for more details.
17230557Sjimharris *
18230557Sjimharris * You should have received a copy of the GNU General Public License
19230557Sjimharris * along with this program; if not, write to the Free Software
20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21230557Sjimharris * The full GNU General Public License is included in this distribution
22230557Sjimharris * in the file called LICENSE.GPL.
23230557Sjimharris *
24230557Sjimharris * BSD LICENSE
25230557Sjimharris *
26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27230557Sjimharris * All rights reserved.
28230557Sjimharris *
29230557Sjimharris * Redistribution and use in source and binary forms, with or without
30230557Sjimharris * modification, are permitted provided that the following conditions
31230557Sjimharris * are met:
32230557Sjimharris *
33230557Sjimharris *   * Redistributions of source code must retain the above copyright
34230557Sjimharris *     notice, this list of conditions and the following disclaimer.
35230557Sjimharris *   * Redistributions in binary form must reproduce the above copyright
36230557Sjimharris *     notice, this list of conditions and the following disclaimer in
37230557Sjimharris *     the documentation and/or other materials provided with the
38230557Sjimharris *     distribution.
39230557Sjimharris *
40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51230557Sjimharris *
52230557Sjimharris * $FreeBSD$
53230557Sjimharris */
54230557Sjimharris#ifndef _SCU_COMPLETION_CODES_HEADER_
55230557Sjimharris#define _SCU_COMPLETION_CODES_HEADER_
56230557Sjimharris
57230557Sjimharris/**
58230557Sjimharris * @file
59230557Sjimharris *
60230557Sjimharris * @brief This file contains the constants and macros for the SCU hardware
61230557Sjimharris *        completion codes.
62230557Sjimharris */
63230557Sjimharris
64230557Sjimharris#ifdef __cplusplus
65230557Sjimharrisextern "C" {
66230557Sjimharris#endif // __cplusplus
67230557Sjimharris
68230557Sjimharris#define SCU_COMPLETION_TYPE_SHIFT      28
69230557Sjimharris#define SCU_COMPLETION_TYPE_MASK       0x70000000
70230557Sjimharris
71230557Sjimharris/**
72230557Sjimharris * This macro constructs an SCU completion type
73230557Sjimharris */
74230557Sjimharris#define SCU_COMPLETION_TYPE(type) \
75230557Sjimharris   ((U32)(type) << SCU_COMPLETION_TYPE_SHIFT)
76230557Sjimharris
77230557Sjimharris/**
78230557Sjimharris * These macros contain the SCU completion types
79230557Sjimharris *
80230557Sjimharris * @name SCU_COMPLETION_TYPE
81230557Sjimharris */
82230557Sjimharris/*@}*/
83230557Sjimharris#define SCU_COMPLETION_TYPE_TASK       SCU_COMPLETION_TYPE(0)
84230557Sjimharris#define SCU_COMPLETION_TYPE_SDMA       SCU_COMPLETION_TYPE(1)
85230557Sjimharris#define SCU_COMPLETION_TYPE_UFI        SCU_COMPLETION_TYPE(2)
86230557Sjimharris#define SCU_COMPLETION_TYPE_EVENT      SCU_COMPLETION_TYPE(3)
87230557Sjimharris#define SCU_COMPLETION_TYPE_NOTIFY     SCU_COMPLETION_TYPE(4)
88230557Sjimharris/*@}*/
89230557Sjimharris
90230557Sjimharris/**
91230557Sjimharris * These constants provide the shift and mask values for the various parts of
92230557Sjimharris * an SCU completion code.
93230557Sjimharris */
94230557Sjimharris#define SCU_COMPLETION_STATUS_MASK       0x0FFC0000
95230557Sjimharris#define SCU_COMPLETION_TL_STATUS_MASK    0x0FC00000
96230557Sjimharris#define SCU_COMPLETION_TL_STATUS_SHIFT   22
97230557Sjimharris#define SCU_COMPLETION_SDMA_STATUS_MASK  0x003C0000
98230557Sjimharris#define SCU_COMPLETION_PEG_MASK          0x00010000
99230557Sjimharris#define SCU_COMPLETION_PORT_MASK         0x00007000
100230557Sjimharris#define SCU_COMPLETION_PE_MASK           SCU_COMPLETION_PORT_MASK
101230557Sjimharris#define SCU_COMPLETION_PE_SHIFT          12
102230557Sjimharris#define SCU_COMPLETION_INDEX_MASK        0x00000FFF
103230557Sjimharris
104230557Sjimharris/**
105230557Sjimharris * This macro returns the SCU completion type.
106230557Sjimharris */
107230557Sjimharris#define SCU_GET_COMPLETION_TYPE(completion_code) \
108230557Sjimharris   ((completion_code) & SCU_COMPLETION_TYPE_MASK)
109230557Sjimharris
110230557Sjimharris/**
111230557Sjimharris * This macro returns the SCU completion status.
112230557Sjimharris */
113230557Sjimharris#define SCU_GET_COMPLETION_STATUS(completion_code) \
114230557Sjimharris   ((completion_code) & SCU_COMPLETION_STATUS_MASK)
115230557Sjimharris
116230557Sjimharris/**
117230557Sjimharris * This macro returns the transport layer completion status.
118230557Sjimharris */
119230557Sjimharris#define SCU_GET_COMPLETION_TL_STATUS(completion_code) \
120230557Sjimharris   ((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)
121230557Sjimharris
122230557Sjimharris/**
123230557Sjimharris * This macro takes a completion code and performs the shift and mask
124230557Sjimharris * operations to turn it into a completion code that can be compared to a
125230557Sjimharris * SCU_GET_COMPLETION_TL_STATUS.
126230557Sjimharris */
127230557Sjimharris#define SCU_MAKE_COMPLETION_STATUS(completion_code) \
128230557Sjimharris   ((U32)(completion_code) << SCU_COMPLETION_TL_STATUS_SHIFT)
129230557Sjimharris
130230557Sjimharris/**
131230557Sjimharris * This macro takes a SCU_GET_COMPLETION_TL_STATUS and normalizes it for a
132230557Sjimharris * return code.
133230557Sjimharris */
134230557Sjimharris#define SCU_NORMALIZE_COMPLETION_STATUS(completion_code) \
135230557Sjimharris   ( \
136230557Sjimharris      ((U32)((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)) \
137230557Sjimharris   >> SCU_COMPLETION_TL_STATUS_SHIFT \
138230557Sjimharris   )
139230557Sjimharris
140230557Sjimharris/**
141230557Sjimharris * This macro returns the SDMA completion status.
142230557Sjimharris */
143230557Sjimharris#define SCU_GET_COMPLETION_SDMA_STATUS(completion_code) \
144230557Sjimharris   ((completion_code) & SCU_COMPLETION_SDMA_STATUS_MASK)
145230557Sjimharris
146230557Sjimharris/**
147230557Sjimharris * This macro returns the Protocol Engine Group from the completion code.
148230557Sjimharris */
149230557Sjimharris#define SCU_GET_COMPLETION_PEG(completion_code) \
150230557Sjimharris   ((completion_code) & SCU_COMPLETION_PEG_MASK)
151230557Sjimharris
152230557Sjimharris/**
153230557Sjimharris * This macro reuturns the logical port index from the completion code.
154230557Sjimharris */
155230557Sjimharris#define SCU_GET_COMPLETION_PORT(completion_code) \
156230557Sjimharris   ((completion_code) & SCU_COMPLETION_PORT_MASK)
157230557Sjimharris
158230557Sjimharris/**
159230557Sjimharris * This macro returns the PE index from the completion code.
160230557Sjimharris */
161230557Sjimharris#define SCU_GET_PROTOCOL_ENGINE_INDEX(completion_code) \
162230557Sjimharris   (((U32)((completion_code) & SCU_COMPLETION_PE_MASK)) >> SCU_COMPLETION_PE_SHIFT)
163230557Sjimharris
164230557Sjimharris/**
165230557Sjimharris * This macro returns the index of the completion which is either a TCi or an
166230557Sjimharris * RNi depending on the completion type.
167230557Sjimharris */
168230557Sjimharris#define SCU_GET_COMPLETION_INDEX(completion_code) \
169230557Sjimharris   ((completion_code) & SCU_COMPLETION_INDEX_MASK)
170230557Sjimharris
171230557Sjimharris#define SCU_UNSOLICITED_FRAME_MASK     0x0FFF0000
172230557Sjimharris#define SCU_UNSOLICITED_FRAME_SHIFT    16
173230557Sjimharris
174230557Sjimharris/**
175230557Sjimharris * This macro returns a normalized frame index from an unsolicited frame
176230557Sjimharris * completion.
177230557Sjimharris */
178230557Sjimharris#define SCU_GET_FRAME_INDEX(completion_code) \
179230557Sjimharris   ( \
180230557Sjimharris        ((U32)((completion_code) & SCU_UNSOLICITED_FRAME_MASK)) \
181230557Sjimharris     >> SCU_UNSOLICITED_FRAME_SHIFT \
182230557Sjimharris   )
183230557Sjimharris
184230557Sjimharris#define SCU_UNSOLICITED_FRAME_ERROR_MASK  0x00008000
185230557Sjimharris
186230557Sjimharris/**
187230557Sjimharris * This macro returns a zero (0) value if there is no frame error otherwise
188230557Sjimharris * it returns non-zero (!0).
189230557Sjimharris */
190230557Sjimharris#define SCU_GET_FRAME_ERROR(completion_code) \
191230557Sjimharris   ((completion_code) & SCU_UNSOLICITED_FRAME_ERROR_MASK)
192230557Sjimharris
193230557Sjimharris/**
194230557Sjimharris * These constants represent normalized completion codes which must be shifted
195230557Sjimharris * 18 bits to match it with the hardware completion code. In a 16-bit compiler,
196230557Sjimharris * immediate constants are 16-bit values (the size of an int). If we shift those
197230557Sjimharris * by 18 bits, we completely lose the value. To ensure the value is a 32-bit
198230557Sjimharris * value like we want, each immediate value must be cast to a U32.
199230557Sjimharris */
200230557Sjimharris#define SCU_TASK_DONE_GOOD                                  ((U32)0x00)
201230557Sjimharris#define SCU_TASK_DONE_CRC_ERR                               ((U32)0x14)
202230557Sjimharris#define SCU_TASK_DONE_CHECK_RESPONSE                        ((U32)0x14)
203230557Sjimharris#define SCU_TASK_DONE_GEN_RESPONSE                          ((U32)0x15)
204230557Sjimharris#define SCU_TASK_DONE_NAK_CMD_ERR                           ((U32)0x16)
205230557Sjimharris#define SCU_TASK_DONE_CMD_LL_R_ERR                          ((U32)0x16)
206230557Sjimharris#define SCU_TASK_DONE_LL_R_ERR                              ((U32)0x17)
207230557Sjimharris#define SCU_TASK_DONE_ACK_NAK_TO                            ((U32)0x17)
208230557Sjimharris#define SCU_TASK_DONE_LL_PERR                               ((U32)0x18)
209230557Sjimharris#define SCU_TASK_DONE_LL_SY_TERM                            ((U32)0x19)
210230557Sjimharris#define SCU_TASK_DONE_NAK_ERR                               ((U32)0x19)
211230557Sjimharris#define SCU_TASK_DONE_LL_LF_TERM                            ((U32)0x1A)
212230557Sjimharris#define SCU_TASK_DONE_DATA_LEN_ERR                          ((U32)0x1A)
213230557Sjimharris#define SCU_TASK_DONE_LL_CL_TERM                            ((U32)0x1B)
214230557Sjimharris#define SCU_TASK_DONE_LL_ABORT_ERR                          ((U32)0x1B)
215230557Sjimharris#define SCU_TASK_DONE_SEQ_INV_TYPE                          ((U32)0x1C)
216230557Sjimharris#define SCU_TASK_DONE_UNEXP_XR                              ((U32)0x1C)
217230557Sjimharris#define SCU_TASK_DONE_INV_FIS_TYPE                          ((U32)0x1D)
218230557Sjimharris#define SCU_TASK_DONE_XR_IU_LEN_ERR                         ((U32)0x1D)
219230557Sjimharris#define SCU_TASK_DONE_INV_FIS_LEN                           ((U32)0x1E)
220230557Sjimharris#define SCU_TASK_DONE_XR_WD_LEN                             ((U32)0x1E)
221230557Sjimharris#define SCU_TASK_DONE_SDMA_ERR                              ((U32)0x1F)
222230557Sjimharris#define SCU_TASK_DONE_OFFSET_ERR                            ((U32)0x20)
223230557Sjimharris#define SCU_TASK_DONE_MAX_PLD_ERR                           ((U32)0x21)
224230557Sjimharris#define SCU_TASK_DONE_EXCESS_DATA                           ((U32)0x22)
225230557Sjimharris#define SCU_TASK_DONE_LF_ERR                                ((U32)0x23)
226230557Sjimharris#define SCU_TASK_DONE_UNEXP_FIS                             ((U32)0x24)
227230557Sjimharris#define SCU_TASK_DONE_UNEXP_RESP                            ((U32)0x24)
228230557Sjimharris#define SCU_TASK_DONE_EARLY_RESP                            ((U32)0x25)
229230557Sjimharris#define SCU_TASK_DONE_SMP_RESP_TO_ERR                       ((U32)0x26)
230230557Sjimharris#define SCU_TASK_DONE_DMASETUP_DIRERR                       ((U32)0x27)
231230557Sjimharris#define SCU_TASK_DONE_SMP_UFI_ERR                           ((U32)0x27)
232230557Sjimharris#define SCU_TASK_DONE_XFERCNT_ERR                           ((U32)0x28)
233230557Sjimharris#define SCU_TASK_DONE_SMP_FRM_TYPE_ERR                      ((U32)0x28)
234230557Sjimharris#define SCU_TASK_DONE_SMP_LL_RX_ERR                         ((U32)0x29)
235230557Sjimharris#define SCU_TASK_DONE_RESP_LEN_ERR                          ((U32)0x2A)
236230557Sjimharris#define SCU_TASK_DONE_UNEXP_DATA                            ((U32)0x2B)
237230557Sjimharris#define SCU_TASK_DONE_OPEN_FAIL                             ((U32)0x2C)
238230557Sjimharris#define SCU_TASK_DONE_UNEXP_SDBFIS                          ((U32)0x2D)
239230557Sjimharris#define SCU_TASK_DONE_REG_ERR                               ((U32)0x2E)
240230557Sjimharris#define SCU_TASK_DONE_SDB_ERR                               ((U32)0x2F)
241230557Sjimharris#define SCU_TASK_DONE_TASK_ABORT                            ((U32)0x30)
242230557Sjimharris#if defined(PBG_HBA_BETA_BUILD)
243230557Sjimharris#define SCU_TASK_DONE_CMD_SDMA_ERR                          ((U32)0x32)
244230557Sjimharris#define SCU_TASK_DONE_CMD_LL_ABORT_ERR                      ((U32)0x33)
245230557Sjimharris#endif
246230557Sjimharris#define SCU_TASK_OPEN_REJECT_WRONG_DESTINATION              ((U32)0x34)
247230557Sjimharris#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1             ((U32)0x35)
248230557Sjimharris#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2             ((U32)0x36)
249230557Sjimharris#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3             ((U32)0x37)
250230557Sjimharris#define SCU_TASK_OPEN_REJECT_BAD_DESTINATION                ((U32)0x38)
251230557Sjimharris#define SCU_TASK_OPEN_REJECT_ZONE_VIOLATION                 ((U32)0x39)
252230557Sjimharris#define SCU_TASK_DONE_VIIT_ENTRY_NV                         ((U32)0x3A)
253230557Sjimharris#define SCU_TASK_DONE_IIT_ENTRY_NV                          ((U32)0x3B)
254230557Sjimharris#define SCU_TASK_DONE_RNCNV_OUTBOUND                        ((U32)0x3C)
255230557Sjimharris#define SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY             ((U32)0x3D)
256230557Sjimharris#define SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED         ((U32)0x3E)
257230557Sjimharris#define SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED  ((U32)0x3F)
258230557Sjimharris
259230557Sjimharris#ifdef __cplusplus
260230557Sjimharris}
261230557Sjimharris#endif // __cplusplus
262230557Sjimharris
263230557Sjimharris#endif // _SCU_COMPLETION_CODES_HEADER_
264