2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
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.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
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
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.
59 * @brief This file contains all of the unsolicited frame related
60 * management for the address table, the headers, and actual
64 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
65 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
71 #include <dev/isci/types.h>
72 #include <dev/isci/scil/scu_unsolicited_frame.h>
73 #include <dev/isci/scil/sci_memory_descriptor_list.h>
74 #include <dev/isci/scil/scu_constants.h>
75 #include <dev/isci/scil/sci_status.h>
78 * @enum UNSOLICITED_FRAME_STATE
80 * This enumeration represents the current unsolicited frame state. The
81 * controller object can not updtate the hardware unsolicited frame put
82 * pointer unless it has already processed the priror unsolicited frames.
84 enum UNSOLICITED_FRAME_STATE
87 * This state is when the frame is empty and not in use. It is
88 * different from the released state in that the hardware could DMA
89 * data to this frame buffer.
91 UNSOLICITED_FRAME_EMPTY,
94 * This state is set when the frame buffer is in use by by some
95 * object in the system.
97 UNSOLICITED_FRAME_IN_USE,
100 * This state is set when the frame is returned to the free pool
101 * but one or more frames prior to this one are still in use.
102 * Once all of the frame before this one are freed it will go to
105 UNSOLICITED_FRAME_RELEASED,
107 UNSOLICITED_FRAME_MAX_STATES
111 * @struct SCIC_SDS_UNSOLICITED_FRAME
113 * This is the unsolicited frame data structure it acts as the container for
114 * the current frame state, frame header and frame buffer.
116 typedef struct SCIC_SDS_UNSOLICITED_FRAME
119 * This field contains the current frame state
121 enum UNSOLICITED_FRAME_STATE state;
124 * This field points to the frame header data.
126 SCU_UNSOLICITED_FRAME_HEADER_T *header;
129 * This field points to the frame buffer data.
133 } SCIC_SDS_UNSOLICITED_FRAME_T;
136 * @struct SCIC_SDS_UF_HEADER_ARRAY
138 * This structure contains all of the unsolicited frame header
141 typedef struct SCIC_SDS_UF_HEADER_ARRAY
144 * This field is represents a virtual pointer to the start
145 * address of the UF address table. The table contains
146 * 64-bit pointers as required by the hardware.
148 SCU_UNSOLICITED_FRAME_HEADER_T *array;
151 * This field specifies the physical address location for the UF
154 SCI_PHYSICAL_ADDRESS physical_address;
156 } SCIC_SDS_UF_HEADER_ARRAY_T;
158 // Determine the size of the unsolicited frame array including
160 #if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
161 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
163 #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
164 #endif // SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
167 * @struct SCIC_SDS_UF_BUFFER_ARRAY
169 * This structure contains all of the unsolicited frame buffer (actual
170 * payload) information.
172 typedef struct SCIC_SDS_UF_BUFFER_ARRAY
175 * This field is the minimum number of unsolicited frames supported by the
176 * hardware and the number of unsolicited frames requested by the software.
181 * This field is the SCIC_UNSOLICITED_FRAME data its used to manage
182 * the data for the unsolicited frame requests. It also represents
183 * the virtual address location that corresponds to the
184 * physical_address field.
186 SCIC_SDS_UNSOLICITED_FRAME_T array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE];
189 * This field specifies the physical address location for the UF
192 SCI_PHYSICAL_ADDRESS physical_address;
194 } SCIC_SDS_UF_BUFFER_ARRAY_T;
197 * @struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY
199 * This object maintains all of the unsolicited frame address
200 * table specific data. The address table is a collection of
201 * 64-bit pointers that point to 1KB buffers into which
202 * the silicon will DMA unsolicited frames.
204 typedef struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY
207 * This field specifies the actual programmed size of the
208 * unsolicited frame buffer address table. The size of the table
209 * can be larger than the actual number of UF buffers, but it must
210 * be a power of 2 and the last entry in the table is not allowed
216 * This field represents a virtual pointer that refers to the
217 * starting address of the UF address table.
218 * 64-bit pointers are required by the hardware.
220 SCI_PHYSICAL_ADDRESS * array;
223 * This field specifies the physical address location for the UF
226 SCI_PHYSICAL_ADDRESS physical_address;
228 } SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T;
231 * @struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL
233 * This object contains all of the data necessary to handle
234 * unsolicited frames.
236 typedef struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL
239 * This field is the software copy of the unsolicited frame queue
240 * get pointer. The controller object writes this value to the
241 * hardware to let the hardware put more unsolicited frame entries.
246 * This field contains all of the unsolicited frame header
249 SCIC_SDS_UF_HEADER_ARRAY_T headers;
252 * This field contains all of the unsolicited frame buffer
255 SCIC_SDS_UF_BUFFER_ARRAY_T buffers;
258 * This field contains all of the unsolicited frame address table
261 SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T address_table;
263 } SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T;
265 void scic_sds_unsolicited_frame_control_set_address_table_count(
266 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control
269 struct SCIC_SDS_CONTROLLER;
270 void scic_sds_unsolicited_frame_control_construct(
271 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
272 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T *mde,
273 struct SCIC_SDS_CONTROLLER *this_controller
276 SCI_STATUS scic_sds_unsolicited_frame_control_get_header(
277 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
282 SCI_STATUS scic_sds_unsolicited_frame_control_get_buffer(
283 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
288 BOOL scic_sds_unsolicited_frame_control_release_frame(
289 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control,
294 * This macro simply calculates the size of the memory descriptor
295 * entry that relates to unsolicited frames and the surrounding
296 * silicon memory required to utilize it.
298 #define scic_sds_unsolicited_frame_control_get_mde_size(uf_control) \
299 ( ((uf_control).buffers.count * SCU_UNSOLICITED_FRAME_BUFFER_SIZE) \
300 + ((uf_control).address_table.count * sizeof(SCI_PHYSICAL_ADDRESS)) \
301 + ((uf_control).buffers.count * sizeof(SCU_UNSOLICITED_FRAME_HEADER_T)) )
305 #endif // __cplusplus
307 #endif // _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_