xref: /linux/drivers/scsi/isci/scu_completion_codes.h (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
163a3a15fSDan Williams /*
263a3a15fSDan Williams  * This file is provided under a dual BSD/GPLv2 license.  When using or
363a3a15fSDan Williams  * redistributing this file, you may do so under either license.
463a3a15fSDan Williams  *
563a3a15fSDan Williams  * GPL LICENSE SUMMARY
663a3a15fSDan Williams  *
763a3a15fSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
863a3a15fSDan Williams  *
963a3a15fSDan Williams  * This program is free software; you can redistribute it and/or modify
1063a3a15fSDan Williams  * it under the terms of version 2 of the GNU General Public License as
1163a3a15fSDan Williams  * published by the Free Software Foundation.
1263a3a15fSDan Williams  *
1363a3a15fSDan Williams  * This program is distributed in the hope that it will be useful, but
1463a3a15fSDan Williams  * WITHOUT ANY WARRANTY; without even the implied warranty of
1563a3a15fSDan Williams  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1663a3a15fSDan Williams  * General Public License for more details.
1763a3a15fSDan Williams  *
1863a3a15fSDan Williams  * You should have received a copy of the GNU General Public License
1963a3a15fSDan Williams  * along with this program; if not, write to the Free Software
2063a3a15fSDan Williams  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
2163a3a15fSDan Williams  * The full GNU General Public License is included in this distribution
2263a3a15fSDan Williams  * in the file called LICENSE.GPL.
2363a3a15fSDan Williams  *
2463a3a15fSDan Williams  * BSD LICENSE
2563a3a15fSDan Williams  *
2663a3a15fSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
2763a3a15fSDan Williams  * All rights reserved.
2863a3a15fSDan Williams  *
2963a3a15fSDan Williams  * Redistribution and use in source and binary forms, with or without
3063a3a15fSDan Williams  * modification, are permitted provided that the following conditions
3163a3a15fSDan Williams  * are met:
3263a3a15fSDan Williams  *
3363a3a15fSDan Williams  *   * Redistributions of source code must retain the above copyright
3463a3a15fSDan Williams  *     notice, this list of conditions and the following disclaimer.
3563a3a15fSDan Williams  *   * Redistributions in binary form must reproduce the above copyright
3663a3a15fSDan Williams  *     notice, this list of conditions and the following disclaimer in
3763a3a15fSDan Williams  *     the documentation and/or other materials provided with the
3863a3a15fSDan Williams  *     distribution.
3963a3a15fSDan Williams  *   * Neither the name of Intel Corporation nor the names of its
4063a3a15fSDan Williams  *     contributors may be used to endorse or promote products derived
4163a3a15fSDan Williams  *     from this software without specific prior written permission.
4263a3a15fSDan Williams  *
4363a3a15fSDan Williams  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4463a3a15fSDan Williams  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4563a3a15fSDan Williams  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4663a3a15fSDan Williams  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4763a3a15fSDan Williams  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4863a3a15fSDan Williams  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4963a3a15fSDan Williams  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5063a3a15fSDan Williams  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5163a3a15fSDan Williams  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5263a3a15fSDan Williams  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5363a3a15fSDan Williams  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5463a3a15fSDan Williams  */
5563a3a15fSDan Williams 
5663a3a15fSDan Williams #ifndef _SCU_COMPLETION_CODES_HEADER_
5763a3a15fSDan Williams #define _SCU_COMPLETION_CODES_HEADER_
5863a3a15fSDan Williams 
5963a3a15fSDan Williams /**
6063a3a15fSDan Williams  * This file contains the constants and macros for the SCU hardware completion
6163a3a15fSDan Williams  *    codes.
6263a3a15fSDan Williams  *
6363a3a15fSDan Williams  *
6463a3a15fSDan Williams  */
6563a3a15fSDan Williams 
6663a3a15fSDan Williams #define SCU_COMPLETION_TYPE_SHIFT      28
6763a3a15fSDan Williams #define SCU_COMPLETION_TYPE_MASK       0x70000000
6863a3a15fSDan Williams 
6963a3a15fSDan Williams /**
7063a3a15fSDan Williams  * SCU_COMPLETION_TYPE() -
7163a3a15fSDan Williams  *
7263a3a15fSDan Williams  * This macro constructs an SCU completion type
7363a3a15fSDan Williams  */
7463a3a15fSDan Williams #define SCU_COMPLETION_TYPE(type) \
7563a3a15fSDan Williams 	((u32)(type) << SCU_COMPLETION_TYPE_SHIFT)
7663a3a15fSDan Williams 
7763a3a15fSDan Williams /**
7863a3a15fSDan Williams  * SCU_COMPLETION_TYPE() -
7963a3a15fSDan Williams  *
8063a3a15fSDan Williams  * These macros contain the SCU completion types SCU_COMPLETION_TYPE
8163a3a15fSDan Williams  */
8263a3a15fSDan Williams #define SCU_COMPLETION_TYPE_TASK       SCU_COMPLETION_TYPE(0)
8363a3a15fSDan Williams #define SCU_COMPLETION_TYPE_SDMA       SCU_COMPLETION_TYPE(1)
8463a3a15fSDan Williams #define SCU_COMPLETION_TYPE_UFI        SCU_COMPLETION_TYPE(2)
8563a3a15fSDan Williams #define SCU_COMPLETION_TYPE_EVENT      SCU_COMPLETION_TYPE(3)
8663a3a15fSDan Williams #define SCU_COMPLETION_TYPE_NOTIFY     SCU_COMPLETION_TYPE(4)
8763a3a15fSDan Williams 
8863a3a15fSDan Williams /**
8963a3a15fSDan Williams  *
9063a3a15fSDan Williams  *
9163a3a15fSDan Williams  * These constants provide the shift and mask values for the various parts of
9263a3a15fSDan Williams  * an SCU completion code.
9363a3a15fSDan Williams  */
9463a3a15fSDan Williams #define SCU_COMPLETION_STATUS_MASK       0x0FFC0000
9563a3a15fSDan Williams #define SCU_COMPLETION_TL_STATUS_MASK    0x0FC00000
9663a3a15fSDan Williams #define SCU_COMPLETION_TL_STATUS_SHIFT   22
9763a3a15fSDan Williams #define SCU_COMPLETION_SDMA_STATUS_MASK  0x003C0000
9863a3a15fSDan Williams #define SCU_COMPLETION_PEG_MASK          0x00010000
9963a3a15fSDan Williams #define SCU_COMPLETION_PORT_MASK         0x00007000
10063a3a15fSDan Williams #define SCU_COMPLETION_PE_MASK           SCU_COMPLETION_PORT_MASK
10163a3a15fSDan Williams #define SCU_COMPLETION_PE_SHIFT          12
10263a3a15fSDan Williams #define SCU_COMPLETION_INDEX_MASK        0x00000FFF
10363a3a15fSDan Williams 
10463a3a15fSDan Williams /**
10563a3a15fSDan Williams  * SCU_GET_COMPLETION_TYPE() -
10663a3a15fSDan Williams  *
10763a3a15fSDan Williams  * This macro returns the SCU completion type.
10863a3a15fSDan Williams  */
10963a3a15fSDan Williams #define SCU_GET_COMPLETION_TYPE(completion_code) \
11063a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_TYPE_MASK)
11163a3a15fSDan Williams 
11263a3a15fSDan Williams /**
11363a3a15fSDan Williams  * SCU_GET_COMPLETION_STATUS() -
11463a3a15fSDan Williams  *
11563a3a15fSDan Williams  * This macro returns the SCU completion status.
11663a3a15fSDan Williams  */
11763a3a15fSDan Williams #define SCU_GET_COMPLETION_STATUS(completion_code) \
11863a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_STATUS_MASK)
11963a3a15fSDan Williams 
12063a3a15fSDan Williams /**
12163a3a15fSDan Williams  * SCU_GET_COMPLETION_TL_STATUS() -
12263a3a15fSDan Williams  *
12363a3a15fSDan Williams  * This macro returns the transport layer completion status.
12463a3a15fSDan Williams  */
12563a3a15fSDan Williams #define SCU_GET_COMPLETION_TL_STATUS(completion_code) \
12663a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_TL_STATUS_MASK)
12763a3a15fSDan Williams 
12863a3a15fSDan Williams /**
12963a3a15fSDan Williams  * SCU_MAKE_COMPLETION_STATUS() -
13063a3a15fSDan Williams  *
13163a3a15fSDan Williams  * This macro takes a completion code and performs the shift and mask
13263a3a15fSDan Williams  * operations to turn it into a completion code that can be compared to a
13363a3a15fSDan Williams  * SCU_GET_COMPLETION_TL_STATUS.
13463a3a15fSDan Williams  */
13563a3a15fSDan Williams #define SCU_MAKE_COMPLETION_STATUS(completion_code) \
13663a3a15fSDan Williams 	((u32)(completion_code) << SCU_COMPLETION_TL_STATUS_SHIFT)
13763a3a15fSDan Williams 
13863a3a15fSDan Williams /**
13963a3a15fSDan Williams  * SCU_NORMALIZE_COMPLETION_STATUS() -
14063a3a15fSDan Williams  *
14163a3a15fSDan Williams  * This macro takes a SCU_GET_COMPLETION_TL_STATUS and normalizes it for a
14263a3a15fSDan Williams  * return code.
14363a3a15fSDan Williams  */
14463a3a15fSDan Williams #define SCU_NORMALIZE_COMPLETION_STATUS(completion_code) \
14563a3a15fSDan Williams 	(\
14663a3a15fSDan Williams 		((completion_code) & SCU_COMPLETION_TL_STATUS_MASK) \
14763a3a15fSDan Williams 		>> SCU_COMPLETION_TL_STATUS_SHIFT \
14863a3a15fSDan Williams 	)
14963a3a15fSDan Williams 
15063a3a15fSDan Williams /**
15163a3a15fSDan Williams  * SCU_GET_COMPLETION_SDMA_STATUS() -
15263a3a15fSDan Williams  *
15363a3a15fSDan Williams  * This macro returns the SDMA completion status.
15463a3a15fSDan Williams  */
15563a3a15fSDan Williams #define SCU_GET_COMPLETION_SDMA_STATUS(completion_code)	\
15663a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_SDMA_STATUS_MASK)
15763a3a15fSDan Williams 
15863a3a15fSDan Williams /**
15963a3a15fSDan Williams  * SCU_GET_COMPLETION_PEG() -
16063a3a15fSDan Williams  *
16163a3a15fSDan Williams  * This macro returns the Protocol Engine Group from the completion code.
16263a3a15fSDan Williams  */
16363a3a15fSDan Williams #define SCU_GET_COMPLETION_PEG(completion_code)	\
16463a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_PEG_MASK)
16563a3a15fSDan Williams 
16663a3a15fSDan Williams /**
16763a3a15fSDan Williams  * SCU_GET_COMPLETION_PORT() -
16863a3a15fSDan Williams  *
16963a3a15fSDan Williams  * This macro reuturns the logical port index from the completion code.
17063a3a15fSDan Williams  */
17163a3a15fSDan Williams #define SCU_GET_COMPLETION_PORT(completion_code) \
17263a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_PORT_MASK)
17363a3a15fSDan Williams 
17463a3a15fSDan Williams /**
17563a3a15fSDan Williams  * SCU_GET_PROTOCOL_ENGINE_INDEX() -
17663a3a15fSDan Williams  *
17763a3a15fSDan Williams  * This macro returns the PE index from the completion code.
17863a3a15fSDan Williams  */
17963a3a15fSDan Williams #define SCU_GET_PROTOCOL_ENGINE_INDEX(completion_code) \
18063a3a15fSDan Williams 	(((completion_code) & SCU_COMPLETION_PE_MASK) >> SCU_COMPLETION_PE_SHIFT)
18163a3a15fSDan Williams 
18263a3a15fSDan Williams /**
18363a3a15fSDan Williams  * SCU_GET_COMPLETION_INDEX() -
18463a3a15fSDan Williams  *
18563a3a15fSDan Williams  * This macro returns the index of the completion which is either a TCi or an
18663a3a15fSDan Williams  * RNi depending on the completion type.
18763a3a15fSDan Williams  */
18863a3a15fSDan Williams #define SCU_GET_COMPLETION_INDEX(completion_code) \
18963a3a15fSDan Williams 	((completion_code) & SCU_COMPLETION_INDEX_MASK)
19063a3a15fSDan Williams 
19163a3a15fSDan Williams #define SCU_UNSOLICITED_FRAME_MASK     0x0FFF0000
19263a3a15fSDan Williams #define SCU_UNSOLICITED_FRAME_SHIFT    16
19363a3a15fSDan Williams 
19463a3a15fSDan Williams /**
19563a3a15fSDan Williams  * SCU_GET_FRAME_INDEX() -
19663a3a15fSDan Williams  *
19763a3a15fSDan Williams  * This macro returns a normalized frame index from an unsolicited frame
19863a3a15fSDan Williams  * completion.
19963a3a15fSDan Williams  */
20063a3a15fSDan Williams #define SCU_GET_FRAME_INDEX(completion_code) \
20163a3a15fSDan Williams 	(\
20263a3a15fSDan Williams 		((completion_code) & SCU_UNSOLICITED_FRAME_MASK) \
20363a3a15fSDan Williams 		>> SCU_UNSOLICITED_FRAME_SHIFT \
20463a3a15fSDan Williams 	)
20563a3a15fSDan Williams 
20663a3a15fSDan Williams #define SCU_UNSOLICITED_FRAME_ERROR_MASK  0x00008000
20763a3a15fSDan Williams 
20863a3a15fSDan Williams /**
20963a3a15fSDan Williams  * SCU_GET_FRAME_ERROR() -
21063a3a15fSDan Williams  *
21163a3a15fSDan Williams  * This macro returns a zero (0) value if there is no frame error otherwise it
21263a3a15fSDan Williams  * returns non-zero (!0).
21363a3a15fSDan Williams  */
21463a3a15fSDan Williams #define SCU_GET_FRAME_ERROR(completion_code) \
21563a3a15fSDan Williams 	((completion_code) & SCU_UNSOLICITED_FRAME_ERROR_MASK)
21663a3a15fSDan Williams 
21763a3a15fSDan Williams /**
21863a3a15fSDan Williams  *
21963a3a15fSDan Williams  *
22063a3a15fSDan Williams  * These constants represent normalized completion codes which must be shifted
22163a3a15fSDan Williams  * 18 bits to match it with the hardware completion code. In a 16-bit compiler,
22263a3a15fSDan Williams  * immediate constants are 16-bit values (the size of an int). If we shift
22363a3a15fSDan Williams  * those by 18 bits, we completely lose the value. To ensure the value is a
22463a3a15fSDan Williams  * 32-bit value like we want, each immediate value must be cast to a u32.
22563a3a15fSDan Williams  */
22663a3a15fSDan Williams #define SCU_TASK_DONE_GOOD                                  ((u32)0x00)
227*ac78ed0fSJeff Skirvin #define SCU_TASK_DONE_TX_RAW_CMD_ERR                        ((u32)0x08)
22863a3a15fSDan Williams #define SCU_TASK_DONE_CRC_ERR                               ((u32)0x14)
22963a3a15fSDan Williams #define SCU_TASK_DONE_CHECK_RESPONSE                        ((u32)0x14)
23063a3a15fSDan Williams #define SCU_TASK_DONE_GEN_RESPONSE                          ((u32)0x15)
23163a3a15fSDan Williams #define SCU_TASK_DONE_NAK_CMD_ERR                           ((u32)0x16)
23263a3a15fSDan Williams #define SCU_TASK_DONE_CMD_LL_R_ERR                          ((u32)0x16)
23363a3a15fSDan Williams #define SCU_TASK_DONE_LL_R_ERR                              ((u32)0x17)
23463a3a15fSDan Williams #define SCU_TASK_DONE_ACK_NAK_TO                            ((u32)0x17)
23563a3a15fSDan Williams #define SCU_TASK_DONE_LL_PERR                               ((u32)0x18)
23663a3a15fSDan Williams #define SCU_TASK_DONE_LL_SY_TERM                            ((u32)0x19)
23763a3a15fSDan Williams #define SCU_TASK_DONE_NAK_ERR                               ((u32)0x19)
23863a3a15fSDan Williams #define SCU_TASK_DONE_LL_LF_TERM                            ((u32)0x1A)
23963a3a15fSDan Williams #define SCU_TASK_DONE_DATA_LEN_ERR                          ((u32)0x1A)
24063a3a15fSDan Williams #define SCU_TASK_DONE_LL_CL_TERM                            ((u32)0x1B)
241*ac78ed0fSJeff Skirvin #define SCU_TASK_DONE_BREAK_RCVD                            ((u32)0x1B)
24263a3a15fSDan Williams #define SCU_TASK_DONE_LL_ABORT_ERR                          ((u32)0x1B)
24363a3a15fSDan Williams #define SCU_TASK_DONE_SEQ_INV_TYPE                          ((u32)0x1C)
24463a3a15fSDan Williams #define SCU_TASK_DONE_UNEXP_XR                              ((u32)0x1C)
24563a3a15fSDan Williams #define SCU_TASK_DONE_INV_FIS_TYPE                          ((u32)0x1D)
24663a3a15fSDan Williams #define SCU_TASK_DONE_XR_IU_LEN_ERR                         ((u32)0x1D)
24763a3a15fSDan Williams #define SCU_TASK_DONE_INV_FIS_LEN                           ((u32)0x1E)
24863a3a15fSDan Williams #define SCU_TASK_DONE_XR_WD_LEN                             ((u32)0x1E)
24963a3a15fSDan Williams #define SCU_TASK_DONE_SDMA_ERR                              ((u32)0x1F)
25063a3a15fSDan Williams #define SCU_TASK_DONE_OFFSET_ERR                            ((u32)0x20)
25163a3a15fSDan Williams #define SCU_TASK_DONE_MAX_PLD_ERR                           ((u32)0x21)
25263a3a15fSDan Williams #define SCU_TASK_DONE_EXCESS_DATA                           ((u32)0x22)
25363a3a15fSDan Williams #define SCU_TASK_DONE_LF_ERR                                ((u32)0x23)
25463a3a15fSDan Williams #define SCU_TASK_DONE_UNEXP_FIS                             ((u32)0x24)
25563a3a15fSDan Williams #define SCU_TASK_DONE_UNEXP_RESP                            ((u32)0x24)
25663a3a15fSDan Williams #define SCU_TASK_DONE_EARLY_RESP                            ((u32)0x25)
25763a3a15fSDan Williams #define SCU_TASK_DONE_SMP_RESP_TO_ERR                       ((u32)0x26)
25863a3a15fSDan Williams #define SCU_TASK_DONE_DMASETUP_DIRERR                       ((u32)0x27)
25963a3a15fSDan Williams #define SCU_TASK_DONE_SMP_UFI_ERR                           ((u32)0x27)
26063a3a15fSDan Williams #define SCU_TASK_DONE_XFERCNT_ERR                           ((u32)0x28)
26163a3a15fSDan Williams #define SCU_TASK_DONE_SMP_FRM_TYPE_ERR                      ((u32)0x28)
26263a3a15fSDan Williams #define SCU_TASK_DONE_SMP_LL_RX_ERR                         ((u32)0x29)
26363a3a15fSDan Williams #define SCU_TASK_DONE_RESP_LEN_ERR                          ((u32)0x2A)
26463a3a15fSDan Williams #define SCU_TASK_DONE_UNEXP_DATA                            ((u32)0x2B)
26563a3a15fSDan Williams #define SCU_TASK_DONE_OPEN_FAIL                             ((u32)0x2C)
26663a3a15fSDan Williams #define SCU_TASK_DONE_UNEXP_SDBFIS                          ((u32)0x2D)
26763a3a15fSDan Williams #define SCU_TASK_DONE_REG_ERR                               ((u32)0x2E)
26863a3a15fSDan Williams #define SCU_TASK_DONE_SDB_ERR                               ((u32)0x2F)
26963a3a15fSDan Williams #define SCU_TASK_DONE_TASK_ABORT                            ((u32)0x30)
27063a3a15fSDan Williams #define SCU_TASK_DONE_CMD_SDMA_ERR                          ((U32)0x32)
27163a3a15fSDan Williams #define SCU_TASK_DONE_CMD_LL_ABORT_ERR                      ((U32)0x33)
27263a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_WRONG_DESTINATION              ((u32)0x34)
27363a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1             ((u32)0x35)
27463a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2             ((u32)0x36)
27563a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3             ((u32)0x37)
27663a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_BAD_DESTINATION                ((u32)0x38)
27763a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_ZONE_VIOLATION                 ((u32)0x39)
27863a3a15fSDan Williams #define SCU_TASK_DONE_VIIT_ENTRY_NV                         ((u32)0x3A)
27963a3a15fSDan Williams #define SCU_TASK_DONE_IIT_ENTRY_NV                          ((u32)0x3B)
28063a3a15fSDan Williams #define SCU_TASK_DONE_RNCNV_OUTBOUND                        ((u32)0x3C)
28163a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY             ((u32)0x3D)
28263a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED         ((u32)0x3E)
28363a3a15fSDan Williams #define SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED  ((u32)0x3F)
28463a3a15fSDan Williams 
28563a3a15fSDan Williams #endif /* _SCU_COMPLETION_CODES_HEADER_ */
286