1230557Sjimharris/*-
2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license.  When using or
3230557Sjimharris * redistributing this file, you may do so under either license.
4230557Sjimharris *
5230557Sjimharris * GPL LICENSE SUMMARY
6230557Sjimharris *
7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8230557Sjimharris *
9230557Sjimharris * This program is free software; you can redistribute it and/or modify
10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as
11230557Sjimharris * published by the Free Software Foundation.
12230557Sjimharris *
13230557Sjimharris * This program is distributed in the hope that it will be useful, but
14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of
15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16230557Sjimharris * General Public License for more details.
17230557Sjimharris *
18230557Sjimharris * You should have received a copy of the GNU General Public License
19230557Sjimharris * along with this program; if not, write to the Free Software
20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21230557Sjimharris * The full GNU General Public License is included in this distribution
22230557Sjimharris * in the file called LICENSE.GPL.
23230557Sjimharris *
24230557Sjimharris * BSD LICENSE
25230557Sjimharris *
26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27230557Sjimharris * All rights reserved.
28230557Sjimharris *
29230557Sjimharris * Redistribution and use in source and binary forms, with or without
30230557Sjimharris * modification, are permitted provided that the following conditions
31230557Sjimharris * are met:
32230557Sjimharris *
33230557Sjimharris *   * Redistributions of source code must retain the above copyright
34230557Sjimharris *     notice, this list of conditions and the following disclaimer.
35230557Sjimharris *   * Redistributions in binary form must reproduce the above copyright
36230557Sjimharris *     notice, this list of conditions and the following disclaimer in
37230557Sjimharris *     the documentation and/or other materials provided with the
38230557Sjimharris *     distribution.
39230557Sjimharris *
40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51230557Sjimharris *
52230557Sjimharris * $FreeBSD$
53230557Sjimharris */
54230557Sjimharris#ifndef _SCU_CONSTANTS_H_
55230557Sjimharris#define _SCU_CONSTANTS_H_
56230557Sjimharris
57230557Sjimharris/**
58230557Sjimharris * @file
59230557Sjimharris *
60230557Sjimharris * @brief This file contains the SCU hardware constants.
61230557Sjimharris */
62230557Sjimharris
63230557Sjimharris#ifdef __cplusplus
64230557Sjimharrisextern "C" {
65230557Sjimharris#endif // __cplusplus
66230557Sjimharris
67230557Sjimharris#include <dev/isci/scil/sci_controller_constants.h>
68230557Sjimharris
69230557Sjimharris/**
70230557Sjimharris * 2 indicates the maximum number of UFs that can occur for a given IO
71230557Sjimharris * request.  The hardware handles reception of additional unsolicited
72230557Sjimharris * frames while all UFs are in use, by holding off the transmitting
73230557Sjimharris * device.  This number could be theoretically reduced to 1, but 2
74230557Sjimharris * provides for more reliable operation.  During SATA PIO operation,
75230557Sjimharris * it is possible under some conditions for there to be 3 separate
76230557Sjimharris * FISes received, back to back to back (PIO Setup, Data, D2H Register).
77230557Sjimharris * It is unlikely to have all 3 pending all at once without some of
78230557Sjimharris * them already being processed.
79230557Sjimharris */
80230557Sjimharris#define SCU_MIN_UNSOLICITED_FRAMES        (8)
81230557Sjimharris#define SCU_MIN_CRITICAL_NOTIFICATIONS    (19)
82230557Sjimharris#define SCU_MIN_EVENTS                    (4)
83230557Sjimharris#define SCU_MIN_COMPLETION_QUEUE_SCRATCH  (0)
84230557Sjimharris#define SCU_MIN_COMPLETION_QUEUE_ENTRIES  ( SCU_MIN_CRITICAL_NOTIFICATIONS \
85230557Sjimharris                                          + SCU_MIN_EVENTS \
86230557Sjimharris                                          + SCU_MIN_UNSOLICITED_FRAMES \
87230557Sjimharris                                          + SCI_MIN_IO_REQUESTS \
88230557Sjimharris                                          + SCU_MIN_COMPLETION_QUEUE_SCRATCH )
89230557Sjimharris
90230557Sjimharris#define SCU_MAX_CRITICAL_NOTIFICATIONS    (384)
91230557Sjimharris#define SCU_MAX_EVENTS                    (128)
92230557Sjimharris#define SCU_MAX_UNSOLICITED_FRAMES        (128)
93230557Sjimharris#define SCU_MAX_COMPLETION_QUEUE_SCRATCH  (128)
94230557Sjimharris#define SCU_MAX_COMPLETION_QUEUE_ENTRIES  ( SCU_MAX_CRITICAL_NOTIFICATIONS \
95230557Sjimharris                                          + SCU_MAX_EVENTS \
96230557Sjimharris                                          + SCU_MAX_UNSOLICITED_FRAMES \
97230557Sjimharris                                          + SCI_MAX_IO_REQUESTS \
98230557Sjimharris                                          + SCU_MAX_COMPLETION_QUEUE_SCRATCH )
99230557Sjimharris
100230557Sjimharris#if !defined(ENABLE_MINIMUM_MEMORY_MODE)
101230557Sjimharris#define SCU_UNSOLICITED_FRAME_COUNT      SCU_MAX_UNSOLICITED_FRAMES
102230557Sjimharris#define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MAX_CRITICAL_NOTIFICATIONS
103230557Sjimharris#define SCU_EVENT_COUNT                  SCU_MAX_EVENTS
104230557Sjimharris#define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MAX_COMPLETION_QUEUE_SCRATCH
105230557Sjimharris#define SCU_IO_REQUEST_COUNT             SCI_MAX_IO_REQUESTS
106230557Sjimharris#define SCU_IO_REQUEST_SGE_COUNT         SCI_MAX_SCATTER_GATHER_ELEMENTS
107230557Sjimharris#define SCU_COMPLETION_QUEUE_COUNT       SCU_MAX_COMPLETION_QUEUE_ENTRIES
108230557Sjimharris#else
109230557Sjimharris#define SCU_UNSOLICITED_FRAME_COUNT      SCU_MIN_UNSOLICITED_FRAMES
110230557Sjimharris#define SCU_CRITICAL_NOTIFICATION_COUNT  SCU_MIN_CRITICAL_NOTIFICATIONS
111230557Sjimharris#define SCU_EVENT_COUNT                  SCU_MIN_EVENTS
112230557Sjimharris#define SCU_COMPLETION_QUEUE_SCRATCH     SCU_MIN_COMPLETION_QUEUE_SCRATCH
113230557Sjimharris#define SCU_IO_REQUEST_COUNT             SCI_MIN_IO_REQUESTS
114230557Sjimharris#define SCU_IO_REQUEST_SGE_COUNT         SCI_MIN_SCATTER_GATHER_ELEMENTS
115230557Sjimharris#define SCU_COMPLETION_QUEUE_COUNT       SCU_MIN_COMPLETION_QUEUE_ENTRIES
116230557Sjimharris#endif // !defined(ENABLE_MINIMUM_MEMORY_OPERATION)
117230557Sjimharris
118230557Sjimharris/**
119230557Sjimharris * The SCU_COMPLETION_QUEUE_COUNT constant indicates the size
120230557Sjimharris * of the completion queue into which the hardware DMAs 32-bit
121230557Sjimharris * quantas (completion entries).
122230557Sjimharris */
123230557Sjimharris
124230557Sjimharris/**
125230557Sjimharris * This queue must be programmed to a power of 2 size (e.g. 32, 64,
126230557Sjimharris * 1024, etc.).
127230557Sjimharris */
128230557Sjimharris#if (SCU_COMPLETION_QUEUE_COUNT != 16)  && \
129230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 32)  && \
130230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 64)  && \
131230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 128) && \
132230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 256) && \
133230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 512) && \
134230557Sjimharris    (SCU_COMPLETION_QUEUE_COUNT != 1024)
135230557Sjimharris#error "SCU_COMPLETION_QUEUE_COUNT must be set to a power of 2."
136230557Sjimharris#endif
137230557Sjimharris
138230557Sjimharris#if SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
139230557Sjimharris#error "Invalid configuration of unsolicited frame constants"
140230557Sjimharris#endif // SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
141230557Sjimharris
142230557Sjimharris#define SCU_MIN_UF_TABLE_ENTRIES            (8)
143230557Sjimharris#define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
144230557Sjimharris#define SCU_UNSOLICITED_FRAME_BUFFER_SIZE   (1024)
145230557Sjimharris#define SCU_INVALID_FRAME_INDEX             (0xFFFF)
146230557Sjimharris
147230557Sjimharris#define SCU_IO_REQUEST_MAX_SGE_SIZE         (0x00FFFFFF)
148230557Sjimharris#define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH  (0x00FFFFFF)
149230557Sjimharris
150230557Sjimharris#ifdef __cplusplus
151230557Sjimharris}
152230557Sjimharris#endif // __cplusplus
153230557Sjimharris
154230557Sjimharris#endif // _SCU_CONSTANTS_H_
155