isci: Intel(R) C600 Series Chipset Storage Control Unit Driver
[deliverable/linux.git] / drivers / scsi / isci / core / scic_sds_unsolicited_frame_control.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 /**
57 * This file contains all of the unsolicited frame related management for the
58 * address table, the headers, and actual payload buffers.
59 *
60 *
61 */
62
63 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
64 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
65
66 #include "scu_unsolicited_frame.h"
67 #include "sci_memory_descriptor_list.h"
68 #include "scu_constants.h"
69 #include "sci_status.h"
70
71 /**
72 * enum UNSOLICITED_FRAME_STATE -
73 *
74 * This enumeration represents the current unsolicited frame state. The
75 * controller object can not updtate the hardware unsolicited frame put pointer
76 * unless it has already processed the priror unsolicited frames.
77 */
78 enum UNSOLICITED_FRAME_STATE {
79 /**
80 * This state is when the frame is empty and not in use. It is
81 * different from the released state in that the hardware could DMA
82 * data to this frame buffer.
83 */
84 UNSOLICITED_FRAME_EMPTY,
85
86 /**
87 * This state is set when the frame buffer is in use by by some
88 * object in the system.
89 */
90 UNSOLICITED_FRAME_IN_USE,
91
92 /**
93 * This state is set when the frame is returned to the free pool
94 * but one or more frames prior to this one are still in use.
95 * Once all of the frame before this one are freed it will go to
96 * the empty state.
97 */
98 UNSOLICITED_FRAME_RELEASED,
99
100 UNSOLICITED_FRAME_MAX_STATES
101 };
102
103 /**
104 * struct scic_sds_unsolicited_frame -
105 *
106 * This is the unsolicited frame data structure it acts as the container for
107 * the current frame state, frame header and frame buffer.
108 */
109 struct scic_sds_unsolicited_frame {
110 /**
111 * This field contains the current frame state
112 */
113 enum UNSOLICITED_FRAME_STATE state;
114
115 /**
116 * This field points to the frame header data.
117 */
118 struct scu_unsolicited_frame_header *header;
119
120 /**
121 * This field points to the frame buffer data.
122 */
123 void *buffer;
124
125 };
126
127 /**
128 * struct scic_sds_uf_header_array -
129 *
130 * This structure contains all of the unsolicited frame header information.
131 */
132 struct scic_sds_uf_header_array {
133 /**
134 * This field is represents a virtual pointer to the start
135 * address of the UF address table. The table contains
136 * 64-bit pointers as required by the hardware.
137 */
138 struct scu_unsolicited_frame_header *array;
139
140 /**
141 * This field specifies the physical address location for the UF
142 * buffer array.
143 */
144 dma_addr_t physical_address;
145
146 };
147
148 /*
149 * Determine the size of the unsolicited frame array including
150 * unused buffers. */
151 #if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
152 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
153 #else
154 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
155 #endif /* SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES */
156
157 /**
158 * struct scic_sds_uf_buffer_array -
159 *
160 * This structure contains all of the unsolicited frame buffer (actual payload)
161 * information.
162 */
163 struct scic_sds_uf_buffer_array {
164 /**
165 * This field is the minimum number of unsolicited frames supported by the
166 * hardware and the number of unsolicited frames requested by the software.
167 */
168 u32 count;
169
170 /**
171 * This field is the SCIC_UNSOLICITED_FRAME data its used to manage
172 * the data for the unsolicited frame requests. It also represents
173 * the virtual address location that corresponds to the
174 * physical_address field.
175 */
176 struct scic_sds_unsolicited_frame array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE];
177
178 /**
179 * This field specifies the physical address location for the UF
180 * buffer array.
181 */
182 dma_addr_t physical_address;
183
184 };
185
186 /**
187 * struct scic_sds_uf_address_table_array -
188 *
189 * This object maintains all of the unsolicited frame address table specific
190 * data. The address table is a collection of 64-bit pointers that point to
191 * 1KB buffers into which the silicon will DMA unsolicited frames.
192 */
193 struct scic_sds_uf_address_table_array {
194 /**
195 * This field specifies the actual programmed size of the
196 * unsolicited frame buffer address table. The size of the table
197 * can be larger than the actual number of UF buffers, but it must
198 * be a power of 2 and the last entry in the table is not allowed
199 * to be NULL.
200 */
201 u32 count;
202
203 /**
204 * This field represents a virtual pointer that refers to the
205 * starting address of the UF address table.
206 * 64-bit pointers are required by the hardware.
207 */
208 dma_addr_t *array;
209
210 /**
211 * This field specifies the physical address location for the UF
212 * address table.
213 */
214 dma_addr_t physical_address;
215
216 };
217
218 /**
219 * struct scic_sds_unsolicited_frame_control -
220 *
221 * This object contains all of the data necessary to handle unsolicited frames.
222 */
223 struct scic_sds_unsolicited_frame_control {
224 /**
225 * This field is the software copy of the unsolicited frame queue
226 * get pointer. The controller object writes this value to the
227 * hardware to let the hardware put more unsolicited frame entries.
228 */
229 u32 get;
230
231 /**
232 * This field contains all of the unsolicited frame header
233 * specific fields.
234 */
235 struct scic_sds_uf_header_array headers;
236
237 /**
238 * This field contains all of the unsolicited frame buffer
239 * specific fields.
240 */
241 struct scic_sds_uf_buffer_array buffers;
242
243 /**
244 * This field contains all of the unsolicited frame address table
245 * specific fields.
246 */
247 struct scic_sds_uf_address_table_array address_table;
248
249 };
250
251 void scic_sds_unsolicited_frame_control_set_address_table_count(
252 struct scic_sds_unsolicited_frame_control *uf_control);
253
254 struct scic_sds_controller;
255 void scic_sds_unsolicited_frame_control_construct(
256 struct scic_sds_unsolicited_frame_control *uf_control,
257 struct sci_physical_memory_descriptor *mde,
258 struct scic_sds_controller *this_controller);
259
260 enum sci_status scic_sds_unsolicited_frame_control_get_header(
261 struct scic_sds_unsolicited_frame_control *uf_control,
262 u32 frame_index,
263 void **frame_header);
264
265 enum sci_status scic_sds_unsolicited_frame_control_get_buffer(
266 struct scic_sds_unsolicited_frame_control *uf_control,
267 u32 frame_index,
268 void **frame_buffer);
269
270 bool scic_sds_unsolicited_frame_control_release_frame(
271 struct scic_sds_unsolicited_frame_control *uf_control,
272 u32 frame_index);
273
274 /**
275 * scic_sds_unsolicited_frame_control_get_mde_size() -
276 *
277 * This macro simply calculates the size of the memory descriptor entry that
278 * relates to unsolicited frames and the surrounding silicon memory required to
279 * utilize it.
280 */
281 #define scic_sds_unsolicited_frame_control_get_mde_size(uf_control) \
282 (((uf_control).buffers.count * SCU_UNSOLICITED_FRAME_BUFFER_SIZE) \
283 + ((uf_control).address_table.count * sizeof(dma_addr_t)) \
284 + ((uf_control).buffers.count * sizeof(struct scu_unsolicited_frame_header)))
285
286 #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */
This page took 0.041619 seconds and 5 git commands to generate.