1139749Simp/*- 212090Sgibbs * This file is provided under a dual BSD/GPLv2 license. When using or 38012Sjulian * redistributing this file, you may do so under either license. 415329Sgibbs * 512090Sgibbs * GPL LICENSE SUMMARY 615329Sgibbs * 712090Sgibbs * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 812090Sgibbs * 912090Sgibbs * This program is free software; you can redistribute it and/or modify 1012090Sgibbs * it under the terms of version 2 of the GNU General Public License as 1112090Sgibbs * published by the Free Software Foundation. 1212090Sgibbs * 1312090Sgibbs * This program is distributed in the hope that it will be useful, but 1412090Sgibbs * WITHOUT ANY WARRANTY; without even the implied warranty of 1512090Sgibbs * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1615329Sgibbs * General Public License for more details. 1715329Sgibbs * 188012Sjulian * You should have received a copy of the GNU General Public License 1915329Sgibbs * along with this program; if not, write to the Free Software 2015329Sgibbs * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 2115329Sgibbs * The full GNU General Public License is included in this distribution 2215329Sgibbs * in the file called LICENSE.GPL. 2315329Sgibbs * 2415329Sgibbs * BSD LICENSE 2515329Sgibbs * 2615329Sgibbs * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 2715329Sgibbs * All rights reserved. 2815329Sgibbs * 2915329Sgibbs * Redistribution and use in source and binary forms, with or without 3015329Sgibbs * modification, are permitted provided that the following conditions 3150477Speter * are met: 328012Sjulian * 338012Sjulian * * Redistributions of source code must retain the above copyright 34130274Simp * notice, this list of conditions and the following disclaimer. 35130274Simp * * Redistributions in binary form must reproduce the above copyright 368012Sjulian * notice, this list of conditions and the following disclaimer in 37130274Simp * the documentation and/or other materials provided with the 3813691Sgibbs * distribution. 3912090Sgibbs * 4012122Sgibbs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4112122Sgibbs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 4212122Sgibbs * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 4312122Sgibbs * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 4412122Sgibbs * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4512122Sgibbs * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 4612090Sgibbs * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 4723855Sjoerg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 4812090Sgibbs * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 4913691Sgibbs * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 5012090Sgibbs * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5145791Speter * 5245791Speter * $FreeBSD: releng/10.2/sys/dev/isci/scil/scic_sds_unsolicited_frame_control.h 231136 2012-02-07 17:43:58Z jimharris $ 5345791Speter */ 5445791Speter/** 5545791Speter * @file 5645791Speter * 5749360Smdodd * @brief This file contains all of the unsolicited frame related 5849360Smdodd * management for the address table, the headers, and actual 5949360Smdodd * payload buffers. 6045791Speter */ 6145791Speter 6245791Speter#ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ 63102177Smux#define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ 64102177Smux 6545791Speter#ifdef __cplusplus 6645791Speterextern "C" { 6745791Speter#endif // __cplusplus 6845791Speter 6945791Speter#include <dev/isci/types.h> 70102177Smux#include <dev/isci/scil/scu_unsolicited_frame.h> 71102177Smux#include <dev/isci/scil/sci_memory_descriptor_list.h> 7213691Sgibbs#include <dev/isci/scil/scu_constants.h> 7313691Sgibbs#include <dev/isci/scil/sci_status.h> 7413691Sgibbs 7513691Sgibbs/** 7613691Sgibbs * @enum UNSOLICITED_FRAME_STATE 7713691Sgibbs * 78130274Simp * This enumeration represents the current unsolicited frame state. The 79130274Simp * controller object can not updtate the hardware unsolicited frame put 80130274Simp * pointer unless it has already processed the priror unsolicited frames. 81130274Simp */ 82130274Simpenum UNSOLICITED_FRAME_STATE 83130274Simp{ 84130274Simp /** 85130274Simp * This state is when the frame is empty and not in use. It is 86130274Simp * different from the released state in that the hardware could DMA 87130274Simp * data to this frame buffer. 88130274Simp */ 89130274Simp UNSOLICITED_FRAME_EMPTY, 90130274Simp 91130274Simp /** 92130274Simp * This state is set when the frame buffer is in use by by some 93130274Simp * object in the system. 94130274Simp */ 95130274Simp UNSOLICITED_FRAME_IN_USE, 96130274Simp 97130274Simp /** 98130274Simp * 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 101 * the empty state. 102 */ 103 UNSOLICITED_FRAME_RELEASED, 104 105 UNSOLICITED_FRAME_MAX_STATES 106}; 107 108/** 109 * @struct SCIC_SDS_UNSOLICITED_FRAME 110 * 111 * This is the unsolicited frame data structure it acts as the container for 112 * the current frame state, frame header and frame buffer. 113 */ 114typedef struct SCIC_SDS_UNSOLICITED_FRAME 115{ 116 /** 117 * This field contains the current frame state 118 */ 119 enum UNSOLICITED_FRAME_STATE state; 120 121 /** 122 * This field points to the frame header data. 123 */ 124 SCU_UNSOLICITED_FRAME_HEADER_T *header; 125 126 /** 127 * This field points to the frame buffer data. 128 */ 129 void *buffer; 130 131} SCIC_SDS_UNSOLICITED_FRAME_T; 132 133/** 134 * @struct SCIC_SDS_UF_HEADER_ARRAY 135 * 136 * This structure contains all of the unsolicited frame header 137 * information. 138 */ 139typedef struct SCIC_SDS_UF_HEADER_ARRAY 140{ 141 /** 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. 145 */ 146 SCU_UNSOLICITED_FRAME_HEADER_T *array; 147 148 /** 149 * This field specifies the physical address location for the UF 150 * buffer array. 151 */ 152 SCI_PHYSICAL_ADDRESS physical_address; 153 154} SCIC_SDS_UF_HEADER_ARRAY_T; 155 156// Determine the size of the unsolicited frame array including 157// unused buffers. 158#if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES 159#define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES 160#else 161#define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES 162#endif // SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES 163 164/** 165 * @struct SCIC_SDS_UF_BUFFER_ARRAY 166 * 167 * This structure contains all of the unsolicited frame buffer (actual 168 * payload) information. 169 */ 170typedef struct SCIC_SDS_UF_BUFFER_ARRAY 171{ 172 /** 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. 175 */ 176 U32 count; 177 178 /** 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. 183 */ 184 SCIC_SDS_UNSOLICITED_FRAME_T array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE]; 185 186 /** 187 * This field specifies the physical address location for the UF 188 * buffer array. 189 */ 190 SCI_PHYSICAL_ADDRESS physical_address; 191 192} SCIC_SDS_UF_BUFFER_ARRAY_T; 193 194/** 195 * @struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY 196 * 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. 201 */ 202typedef struct SCIC_SDS_UF_ADDRESS_TABLE_ARRAY 203{ 204 /** 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 209 * to be NULL. 210 */ 211 U32 count; 212 213 /** 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. 217 */ 218 SCI_PHYSICAL_ADDRESS * array; 219 220 /** 221 * This field specifies the physical address location for the UF 222 * address table. 223 */ 224 SCI_PHYSICAL_ADDRESS physical_address; 225 226} SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T; 227 228/** 229 * @struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL 230 * 231 * This object contains all of the data necessary to handle 232 * unsolicited frames. 233 */ 234typedef struct SCIC_SDS_UNSOLICITED_FRAME_CONTROL 235{ 236 /** 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. 240 */ 241 U32 get; 242 243 /** 244 * This field contains all of the unsolicited frame header 245 * specific fields. 246 */ 247 SCIC_SDS_UF_HEADER_ARRAY_T headers; 248 249 /** 250 * This field contains all of the unsolicited frame buffer 251 * specific fields. 252 */ 253 SCIC_SDS_UF_BUFFER_ARRAY_T buffers; 254 255 /** 256 * This field contains all of the unsolicited frame address table 257 * specific fields. 258 */ 259 SCIC_SDS_UF_ADDRESS_TABLE_ARRAY_T address_table; 260 261} SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T; 262 263void scic_sds_unsolicited_frame_control_set_address_table_count( 264 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control 265); 266 267struct SCIC_SDS_CONTROLLER; 268void 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 272); 273 274SCI_STATUS scic_sds_unsolicited_frame_control_get_header( 275 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control, 276 U32 frame_index, 277 void **frame_header 278); 279 280SCI_STATUS scic_sds_unsolicited_frame_control_get_buffer( 281 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control, 282 U32 frame_index, 283 void **frame_buffer 284); 285 286BOOL scic_sds_unsolicited_frame_control_release_frame( 287 SCIC_SDS_UNSOLICITED_FRAME_CONTROL_T *uf_control, 288 U32 frame_index 289); 290 291/** 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. 295 */ 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)) ) 300 301#ifdef __cplusplus 302} 303#endif // __cplusplus 304 305#endif // _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ 306