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