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