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
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.
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.
57 * This file contains all of the unsolicited frame related management for the
58 * address table, the headers, and actual payload buffers.
63 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
64 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
66 #include "scu_unsolicited_frame.h"
67 #include "sci_memory_descriptor_list.h"
68 #include "scu_constants.h"
69 #include "sci_status.h"
72 * enum UNSOLICITED_FRAME_STATE -
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.
78 enum UNSOLICITED_FRAME_STATE
{
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.
84 UNSOLICITED_FRAME_EMPTY
,
87 * This state is set when the frame buffer is in use by by some
88 * object in the system.
90 UNSOLICITED_FRAME_IN_USE
,
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
98 UNSOLICITED_FRAME_RELEASED
,
100 UNSOLICITED_FRAME_MAX_STATES
104 * struct scic_sds_unsolicited_frame -
106 * This is the unsolicited frame data structure it acts as the container for
107 * the current frame state, frame header and frame buffer.
109 struct scic_sds_unsolicited_frame
{
111 * This field contains the current frame state
113 enum UNSOLICITED_FRAME_STATE state
;
116 * This field points to the frame header data.
118 struct scu_unsolicited_frame_header
*header
;
121 * This field points to the frame buffer data.
128 * struct scic_sds_uf_header_array -
130 * This structure contains all of the unsolicited frame header information.
132 struct scic_sds_uf_header_array
{
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.
138 struct scu_unsolicited_frame_header
*array
;
141 * This field specifies the physical address location for the UF
144 dma_addr_t physical_address
;
149 * Determine the size of the unsolicited frame array including
151 #if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
152 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
154 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
155 #endif /* SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES */
158 * struct scic_sds_uf_buffer_array -
160 * This structure contains all of the unsolicited frame buffer (actual payload)
163 struct scic_sds_uf_buffer_array
{
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.
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.
176 struct scic_sds_unsolicited_frame array
[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE
];
179 * This field specifies the physical address location for the UF
182 dma_addr_t physical_address
;
187 * struct scic_sds_uf_address_table_array -
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.
193 struct scic_sds_uf_address_table_array
{
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
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.
211 * This field specifies the physical address location for the UF
214 dma_addr_t physical_address
;
219 * struct scic_sds_unsolicited_frame_control -
221 * This object contains all of the data necessary to handle unsolicited frames.
223 struct scic_sds_unsolicited_frame_control
{
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.
232 * This field contains all of the unsolicited frame header
235 struct scic_sds_uf_header_array headers
;
238 * This field contains all of the unsolicited frame buffer
241 struct scic_sds_uf_buffer_array buffers
;
244 * This field contains all of the unsolicited frame address table
247 struct scic_sds_uf_address_table_array address_table
;
251 void scic_sds_unsolicited_frame_control_set_address_table_count(
252 struct scic_sds_unsolicited_frame_control
*uf_control
);
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
);
260 enum sci_status
scic_sds_unsolicited_frame_control_get_header(
261 struct scic_sds_unsolicited_frame_control
*uf_control
,
263 void **frame_header
);
265 enum sci_status
scic_sds_unsolicited_frame_control_get_buffer(
266 struct scic_sds_unsolicited_frame_control
*uf_control
,
268 void **frame_buffer
);
270 bool scic_sds_unsolicited_frame_control_release_frame(
271 struct scic_sds_unsolicited_frame_control
*uf_control
,
275 * scic_sds_unsolicited_frame_control_get_mde_size() -
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
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)))
286 #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */