isci: Intel(R) C600 Series Chipset Storage Control Unit Driver
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / scsi / isci / core / scu_constants.h
1 /*
2  * This file is provided under a dual BSD/GPLv2 license.  When using or
3  * redistributing this file, you may do so under either license.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of version 2 of the GNU General Public License as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21  * The full GNU General Public License is included in this distribution
22  * in the file called LICENSE.GPL.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
33  *   * Redistributions of source code must retain the above copyright
34  *     notice, this list of conditions and the following disclaimer.
35  *   * Redistributions in binary form must reproduce the above copyright
36  *     notice, this list of conditions and the following disclaimer in
37  *     the documentation and/or other materials provided with the
38  *     distribution.
39  *   * Neither the name of Intel Corporation nor the names of its
40  *     contributors may be used to endorse or promote products derived
41  *     from this software without specific prior written permission.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54  */
55
56 #ifndef _SCU_CONSTANTS_H_
57 #define _SCU_CONSTANTS_H_
58
59 /**
60  * This file contains the SCU hardware constants.
61  *
62  *
63  */
64
65 #include "sci_controller_constants.h"
66
67 /**
68  *
69  *
70  * 2 indicates the maximum number of UFs that can occur for a given IO request.
71  *  The hardware handles reception of additional unsolicited frames while all
72  * UFs are in use, by holding off the transmitting device.  This number could
73  * be theoretically reduced to 1, but 2 provides for more reliable operation.
74  * During SATA PIO operation, it is possible under some conditions for there to
75  * be 3 separate FISes received, back to back to back (PIO Setup, Data, D2H
76  * Register). It is unlikely to have all 3 pending all at once without some of
77  * them already being processed.
78  */
79 #define SCU_MIN_UNSOLICITED_FRAMES        (1)
80 #define SCU_MIN_CRITICAL_NOTIFICATIONS    (24)
81 #define SCU_MIN_EVENTS                    (4)
82 #define SCU_MIN_COMPLETION_QUEUE_SCRATCH  (2)
83 #define SCU_MIN_COMPLETION_QUEUE_ENTRIES  (SCU_MIN_CRITICAL_NOTIFICATIONS \
84                                            + SCU_MIN_EVENTS \
85                                            + SCU_MIN_UNSOLICITED_FRAMES \
86                                            + SCI_MIN_IO_REQUESTS \
87                                            + SCU_MIN_COMPLETION_QUEUE_SCRATCH)
88
89 #define SCU_MAX_CRITICAL_NOTIFICATIONS    (384)
90 #define SCU_MAX_EVENTS                    (128)
91 #define SCU_MAX_UNSOLICITED_FRAMES        (128)
92 #define SCU_MAX_COMPLETION_QUEUE_SCRATCH  (128)
93 #define SCU_MAX_COMPLETION_QUEUE_ENTRIES  (SCU_MAX_CRITICAL_NOTIFICATIONS \
94                                            + SCU_MAX_EVENTS \
95                                            + SCU_MAX_UNSOLICITED_FRAMES \
96                                            + SCI_MAX_IO_REQUESTS \
97                                            + SCU_MAX_COMPLETION_QUEUE_SCRATCH)
98
99 #if !defined(ENABLE_MINIMUM_MEMORY_MODE)
100 #define SCU_UNSOLICITED_FRAME_COUNT      SCU_MAX_UNSOLICITED_FRAMES
101 #define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MAX_CRITICAL_NOTIFICATIONS
102 #define SCU_EVENT_COUNT                  SCU_MAX_EVENTS
103 #define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MAX_COMPLETION_QUEUE_SCRATCH
104 #define SCU_IO_REQUEST_COUNT             SCI_MAX_IO_REQUESTS
105 #define SCU_IO_REQUEST_SGE_COUNT         SCI_MAX_SCATTER_GATHER_ELEMENTS
106 #define SCU_COMPLETION_QUEUE_COUNT       SCU_MAX_COMPLETION_QUEUE_ENTRIES
107 #else
108 #define SCU_UNSOLICITED_FRAME_COUNT      SCU_MIN_UNSOLICITED_FRAMES
109 #define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MIN_CRITICAL_NOTIFICATIONS
110 #define SCU_EVENT_COUNT                  SCU_MIN_EVENTS
111 #define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MIN_COMPLETION_QUEUE_SCRATCH
112 #define SCU_IO_REQUEST_COUNT             SCI_MIN_IO_REQUESTS
113 #define SCU_IO_REQUEST_SGE_COUNT         SCI_MIN_SCATTER_GATHER_ELEMENTS
114 #define SCU_COMPLETION_QUEUE_COUNT       SCU_MIN_COMPLETION_QUEUE_ENTRIES
115 #endif /* !defined(ENABLE_MINIMUM_MEMORY_OPERATION) */
116
117 /**
118  *
119  *
120  * The SCU_COMPLETION_QUEUE_COUNT constant indicates the size of the completion
121  * queue into which the hardware DMAs 32-bit quantas (completion entries).
122  */
123
124 /**
125  *
126  *
127  * This queue must be programmed to a power of 2 size (e.g. 32, 64, 1024, etc.).
128  */
129 #if (SCU_COMPLETION_QUEUE_COUNT != 16)  && \
130         (SCU_COMPLETION_QUEUE_COUNT != 32)  && \
131         (SCU_COMPLETION_QUEUE_COUNT != 64)  && \
132         (SCU_COMPLETION_QUEUE_COUNT != 128) && \
133         (SCU_COMPLETION_QUEUE_COUNT != 256) && \
134         (SCU_COMPLETION_QUEUE_COUNT != 512) && \
135         (SCU_COMPLETION_QUEUE_COUNT != 1024)
136 #error "SCU_COMPLETION_QUEUE_COUNT must be set to a power of 2."
137 #endif
138
139 #if SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
140 #error "Invalid configuration of unsolicited frame constants"
141 #endif /* SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES */
142
143 #define SCU_MIN_UF_TABLE_ENTRIES            (8)
144 #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
145 #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE   (1024)
146 #define SCU_INVALID_FRAME_INDEX             (0xFFFF)
147
148 #define SCU_IO_REQUEST_MAX_SGE_SIZE         (0x00FFFFFF)
149 #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH  (0x00FFFFFF)
150
151 #endif /* _SCU_CONSTANTS_H_ */