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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 * @brief This file contains all of the unsolicited frame related
58 * management for the address table, the headers, and actual
62 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
63 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
69 #include <dev/isci/types.h>
70 #include <dev/isci/scil/scu_unsolicited_frame.h>
71 #include <dev/isci/scil/sci_memory_descriptor_list.h>
72 #include <dev/isci/scil/scu_constants.h>
73 #include <dev/isci/scil/sci_status.h>
76 * @enum UNSOLICITED_FRAME_STATE
78 * This enumeration represents the current unsolicited frame state. The
79 * controller object can not updtate the hardware unsolicited frame put
80 * pointer unless it has already processed the priror unsolicited frames.
82 enum UNSOLICITED_FRAME_STATE
85 * This state is when the frame is empty and not in use. It is
86 * different from the released state in that the hardware could DMA
87 * data to this frame buffer.
89 UNSOLICITED_FRAME_EMPTY,
92 * This state is set when the frame buffer is in use by by some
93 * object in the system.
95 UNSOLICITED_FRAME_IN_USE,
98 * This state is set when the frame is returned to the free pool
99 * but one or more frames prior to this one are still in use.
100 * Once all of the frame before this one are freed it will go to
103 UNSOLICITED_FRAME_RELEASED,
105 UNSOLICITED_FRAME_MAX_STATES
109 * @struct SCIC_SDS_UNSOLICITED_FRAME
111 * This is the unsolicited frame data structure it acts as the container for
112 * the current frame state, frame header and frame buffer.
114 typedef struct SCIC_SDS_UNSOLICITED_FRAME
117 * This field contains the current frame state
119 enum UNSOLICITED_FRAME_STATE state;
122 * This field points to the frame header data.
124 SCU_UNSOLICITED_FRAME_HEADER_T *header;
127 * This field points to the frame buffer data.
131 } SCIC_SDS_UNSOLICITED_FRAME_T;
134 * @struct SCIC_SDS_UF_HEADER_ARRAY
136 * This structure contains all of the unsolicited frame header
139 typedef struct SCIC_SDS_UF_HEADER_ARRAY
142 * This field is represents a virtual pointer to the start
143 * address of the UF address table. The table contains
144 * 64-bit pointers as required by the hardware.
146 SCU_UNSOLICITED_FRAME_HEADER_T *array;
149 * This field specifies the physical address location for the UF
152 SCI_PHYSICAL_ADDRESS physical_address;
154 } SCIC_SDS_UF_HEADER_ARRAY_T;
156 // Determine the size of the unsolicited frame array including
158 #if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
159 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
161 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
162 #endif // SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
165 * @struct SCIC_SDS_UF_BUFFER_ARRAY
167 * This structure contains all of the unsolicited frame buffer (actual
168 * payload) information.
170 typedef struct SCIC_SDS_UF_BUFFER_ARRAY
173 * This field is the minimum number of unsolicited frames supported by the
174 * hardware and the number of unsolicited frames requested by the software.
179 * This field is the SCIC_UNSOLICITED_FRAME data its used to manage
180 * the data for the unsolicited frame requests. It also represents
181 * the virtual address location that corresponds to the
182 * physical_address field.
184 SCIC_SDS_UNSOLICITED_FRAME_T array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE];
187 * This field specifies the physical address location for the UF
190 SCI_PHYSICAL_ADDRESS physical_address;
192 } SCIC_SDS_UF_BUFFER_ARRAY_T;
195 * @struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY
197 * This object maintains all of the unsolicited frame address
198 * table specific data. The address table is a collection of
199 * 64-bit pointers that point to 1KB buffers into which
200 * the silicon will DMA unsolicited frames.
202 typedef struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY
205 * This field specifies the actual programmed size of the
206 * unsolicited frame buffer address table. The size of the table
207 * can be larger than the actual number of UF buffers, but it must
208 * be a power of 2 and the last entry in the table is not allowed
214 * This field represents a virtual pointer that refers to the
215 * starting address of the UF address table.
216 * 64-bit pointers are required by the hardware.
218 SCI_PHYSICAL_ADDRESS * array;
221 * This field specifies the physical address location for the UF
224 SCI_PHYSICAL_ADDRESS physical_address;
226 } SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T;
229 * @struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL
231 * This object contains all of the data necessary to handle
232 * unsolicited frames.
234 typedef struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL
237 * This field is the software copy of the unsolicited frame queue
238 * get pointer. The controller object writes this value to the
239 * hardware to let the hardware put more unsolicited frame entries.
244 * This field contains all of the unsolicited frame header
247 SCIC_SDS_UF_HEADER_ARRAY_T headers;
250 * This field contains all of the unsolicited frame buffer
253 SCIC_SDS_UF_BUFFER_ARRAY_T buffers;
256 * This field contains all of the unsolicited frame address table
259 SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T address_table;
261 } SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T;
263 void scic_sds_unsolicited_frame_control_set_address_table_count(
264 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control
267 struct SCIC_SDS_CONTROLLER;
268 void scic_sds_unsolicited_frame_control_construct(
269 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
270 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T *mde,
271 struct SCIC_SDS_CONTROLLER *this_controller
274 SCI_STATUS scic_sds_unsolicited_frame_control_get_header(
275 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
280 SCI_STATUS scic_sds_unsolicited_frame_control_get_buffer(
281 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
286 BOOL scic_sds_unsolicited_frame_control_release_frame(
287 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
292 * This macro simply calculates the size of the memory descriptor
293 * entry that relates to unsolicited frames and the surrounding
294 * silicon memory required to utilize it.
296 #define scic_sds_unsolicited_frame_control_get_mde_size(uf_control) \
297 ( ((uf_control).buffers.count * SCU_UNSOLICITED_FRAME_BUFFER_SIZE) \
298 + ((uf_control).address_table.count * sizeof(SCI_PHYSICAL_ADDRESS)) \
299 + ((uf_control).buffers.count * sizeof(SCU_UNSOLICITED_FRAME_HEADER_T)) )
303 #endif // __cplusplus
305 #endif // _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_