xref: /freebsd/sys/dev/isci/scil/scu_constants.h (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
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  * $FreeBSD$
55  */
56 #ifndef _SCU_CONSTANTS_H_
57 #define _SCU_CONSTANTS_H_
58 
59 /**
60  * @file
61  *
62  * @brief This file contains the SCU hardware constants.
63  */
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif // __cplusplus
68 
69 #include <dev/isci/scil/sci_controller_constants.h>
70 
71 /**
72  * 2 indicates the maximum number of UFs that can occur for a given IO
73  * request.  The hardware handles reception of additional unsolicited
74  * frames while all UFs are in use, by holding off the transmitting
75  * device.  This number could be theoretically reduced to 1, but 2
76  * provides for more reliable operation.  During SATA PIO operation,
77  * it is possible under some conditions for there to be 3 separate
78  * FISes received, back to back to back (PIO Setup, Data, D2H Register).
79  * It is unlikely to have all 3 pending all at once without some of
80  * them already being processed.
81  */
82 #define SCU_MIN_UNSOLICITED_FRAMES        (8)
83 #define SCU_MIN_CRITICAL_NOTIFICATIONS    (19)
84 #define SCU_MIN_EVENTS                    (4)
85 #define SCU_MIN_COMPLETION_QUEUE_SCRATCH  (0)
86 #define SCU_MIN_COMPLETION_QUEUE_ENTRIES  ( SCU_MIN_CRITICAL_NOTIFICATIONS \
87                                           + SCU_MIN_EVENTS \
88                                           + SCU_MIN_UNSOLICITED_FRAMES \
89                                           + SCI_MIN_IO_REQUESTS \
90                                           + SCU_MIN_COMPLETION_QUEUE_SCRATCH )
91 
92 #define SCU_MAX_CRITICAL_NOTIFICATIONS    (384)
93 #define SCU_MAX_EVENTS                    (128)
94 #define SCU_MAX_UNSOLICITED_FRAMES        (128)
95 #define SCU_MAX_COMPLETION_QUEUE_SCRATCH  (128)
96 #define SCU_MAX_COMPLETION_QUEUE_ENTRIES  ( SCU_MAX_CRITICAL_NOTIFICATIONS \
97                                           + SCU_MAX_EVENTS \
98                                           + SCU_MAX_UNSOLICITED_FRAMES \
99                                           + SCI_MAX_IO_REQUESTS \
100                                           + SCU_MAX_COMPLETION_QUEUE_SCRATCH )
101 
102 #if !defined(ENABLE_MINIMUM_MEMORY_MODE)
103 #define SCU_UNSOLICITED_FRAME_COUNT      SCU_MAX_UNSOLICITED_FRAMES
104 #define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MAX_CRITICAL_NOTIFICATIONS
105 #define SCU_EVENT_COUNT                  SCU_MAX_EVENTS
106 #define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MAX_COMPLETION_QUEUE_SCRATCH
107 #define SCU_IO_REQUEST_COUNT             SCI_MAX_IO_REQUESTS
108 #define SCU_IO_REQUEST_SGE_COUNT         SCI_MAX_SCATTER_GATHER_ELEMENTS
109 #define SCU_COMPLETION_QUEUE_COUNT       SCU_MAX_COMPLETION_QUEUE_ENTRIES
110 #else
111 #define SCU_UNSOLICITED_FRAME_COUNT      SCU_MIN_UNSOLICITED_FRAMES
112 #define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MIN_CRITICAL_NOTIFICATIONS
113 #define SCU_EVENT_COUNT                  SCU_MIN_EVENTS
114 #define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MIN_COMPLETION_QUEUE_SCRATCH
115 #define SCU_IO_REQUEST_COUNT             SCI_MIN_IO_REQUESTS
116 #define SCU_IO_REQUEST_SGE_COUNT         SCI_MIN_SCATTER_GATHER_ELEMENTS
117 #define SCU_COMPLETION_QUEUE_COUNT       SCU_MIN_COMPLETION_QUEUE_ENTRIES
118 #endif // !defined(ENABLE_MINIMUM_MEMORY_OPERATION)
119 
120 /**
121  * The SCU_COMPLETION_QUEUE_COUNT constant indicates the size
122  * of the completion queue into which the hardware DMAs 32-bit
123  * quantas (completion entries).
124  */
125 
126 /**
127  * This queue must be programmed to a power of 2 size (e.g. 32, 64,
128  * 1024, etc.).
129  */
130 #if (SCU_COMPLETION_QUEUE_COUNT != 16)  && \
131     (SCU_COMPLETION_QUEUE_COUNT != 32)  && \
132     (SCU_COMPLETION_QUEUE_COUNT != 64)  && \
133     (SCU_COMPLETION_QUEUE_COUNT != 128) && \
134     (SCU_COMPLETION_QUEUE_COUNT != 256) && \
135     (SCU_COMPLETION_QUEUE_COUNT != 512) && \
136     (SCU_COMPLETION_QUEUE_COUNT != 1024)
137 #error "SCU_COMPLETION_QUEUE_COUNT must be set to a power of 2."
138 #endif
139 
140 #if SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
141 #error "Invalid configuration of unsolicited frame constants"
142 #endif // SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
143 
144 #define SCU_MIN_UF_TABLE_ENTRIES            (8)
145 #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
146 #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE   (1024)
147 #define SCU_INVALID_FRAME_INDEX             (0xFFFF)
148 
149 #define SCU_IO_REQUEST_MAX_SGE_SIZE         (0x00FFFFFF)
150 #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH  (0x00FFFFFF)
151 
152 #ifdef __cplusplus
153 }
154 #endif // __cplusplus
155 
156 #endif // _SCU_CONSTANTS_H_
157