Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 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 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 56 | #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ |
| 57 | #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ |
| 58 | |
Dan Williams | ce2b326 | 2011-05-08 15:49:15 -0700 | [diff] [blame] | 59 | #include "isci.h" |
Dan Williams | 4e4dca3 | 2011-07-01 11:15:12 -0700 | [diff] [blame] | 60 | |
| 61 | #define SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS 15 |
| 62 | |
| 63 | /** |
| 64 | * struct scu_unsolicited_frame_header - |
| 65 | * |
| 66 | * This structure delineates the format of an unsolicited frame header. The |
| 67 | * first DWORD are UF attributes defined by the silicon architecture. The data |
| 68 | * depicts actual header information received on the link. |
| 69 | */ |
| 70 | struct scu_unsolicited_frame_header { |
| 71 | /** |
| 72 | * This field indicates if there is an Initiator Index Table entry with |
| 73 | * which this header is associated. |
| 74 | */ |
| 75 | u32 iit_exists:1; |
| 76 | |
| 77 | /** |
| 78 | * This field simply indicates the protocol type (i.e. SSP, STP, SMP). |
| 79 | */ |
| 80 | u32 protocol_type:3; |
| 81 | |
| 82 | /** |
| 83 | * This field indicates if the frame is an address frame (IAF or OAF) |
| 84 | * or if it is a information unit frame. |
| 85 | */ |
| 86 | u32 is_address_frame:1; |
| 87 | |
| 88 | /** |
| 89 | * This field simply indicates the connection rate at which the frame |
| 90 | * was received. |
| 91 | */ |
| 92 | u32 connection_rate:4; |
| 93 | |
| 94 | u32 reserved:23; |
| 95 | |
| 96 | /** |
| 97 | * This field represents the actual header data received on the link. |
| 98 | */ |
| 99 | u32 data[SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS]; |
| 100 | |
| 101 | }; |
| 102 | |
| 103 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 106 | * enum unsolicited_frame_state - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 107 | * |
| 108 | * This enumeration represents the current unsolicited frame state. The |
| 109 | * controller object can not updtate the hardware unsolicited frame put pointer |
| 110 | * unless it has already processed the priror unsolicited frames. |
| 111 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 112 | enum unsolicited_frame_state { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 113 | /** |
| 114 | * This state is when the frame is empty and not in use. It is |
| 115 | * different from the released state in that the hardware could DMA |
| 116 | * data to this frame buffer. |
| 117 | */ |
| 118 | UNSOLICITED_FRAME_EMPTY, |
| 119 | |
| 120 | /** |
| 121 | * This state is set when the frame buffer is in use by by some |
| 122 | * object in the system. |
| 123 | */ |
| 124 | UNSOLICITED_FRAME_IN_USE, |
| 125 | |
| 126 | /** |
| 127 | * This state is set when the frame is returned to the free pool |
| 128 | * but one or more frames prior to this one are still in use. |
| 129 | * Once all of the frame before this one are freed it will go to |
| 130 | * the empty state. |
| 131 | */ |
| 132 | UNSOLICITED_FRAME_RELEASED, |
| 133 | |
| 134 | UNSOLICITED_FRAME_MAX_STATES |
| 135 | }; |
| 136 | |
| 137 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 138 | * struct sci_unsolicited_frame - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 139 | * |
| 140 | * This is the unsolicited frame data structure it acts as the container for |
| 141 | * the current frame state, frame header and frame buffer. |
| 142 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 143 | struct sci_unsolicited_frame { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 144 | /** |
| 145 | * This field contains the current frame state |
| 146 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 147 | enum unsolicited_frame_state state; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * This field points to the frame header data. |
| 151 | */ |
| 152 | struct scu_unsolicited_frame_header *header; |
| 153 | |
| 154 | /** |
| 155 | * This field points to the frame buffer data. |
| 156 | */ |
| 157 | void *buffer; |
| 158 | |
| 159 | }; |
| 160 | |
| 161 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 162 | * struct sci_uf_header_array - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 163 | * |
| 164 | * This structure contains all of the unsolicited frame header information. |
| 165 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 166 | struct sci_uf_header_array { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 167 | /** |
| 168 | * This field is represents a virtual pointer to the start |
| 169 | * address of the UF address table. The table contains |
| 170 | * 64-bit pointers as required by the hardware. |
| 171 | */ |
| 172 | struct scu_unsolicited_frame_header *array; |
| 173 | |
| 174 | /** |
| 175 | * This field specifies the physical address location for the UF |
| 176 | * buffer array. |
| 177 | */ |
| 178 | dma_addr_t physical_address; |
| 179 | |
| 180 | }; |
| 181 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 182 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 183 | * struct sci_uf_buffer_array - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 184 | * |
| 185 | * This structure contains all of the unsolicited frame buffer (actual payload) |
| 186 | * information. |
| 187 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 188 | struct sci_uf_buffer_array { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 189 | /** |
Dan Williams | 7c78da3 | 2011-06-01 16:00:01 -0700 | [diff] [blame] | 190 | * This field is the unsolicited frame data its used to manage |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 191 | * the data for the unsolicited frame requests. It also represents |
| 192 | * the virtual address location that corresponds to the |
| 193 | * physical_address field. |
| 194 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 195 | struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES]; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 196 | |
| 197 | /** |
| 198 | * This field specifies the physical address location for the UF |
| 199 | * buffer array. |
| 200 | */ |
| 201 | dma_addr_t physical_address; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 202 | }; |
| 203 | |
| 204 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 205 | * struct sci_uf_address_table_array - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 206 | * |
| 207 | * This object maintains all of the unsolicited frame address table specific |
| 208 | * data. The address table is a collection of 64-bit pointers that point to |
| 209 | * 1KB buffers into which the silicon will DMA unsolicited frames. |
| 210 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 211 | struct sci_uf_address_table_array { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 212 | /** |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 213 | * This field represents a virtual pointer that refers to the |
| 214 | * starting address of the UF address table. |
| 215 | * 64-bit pointers are required by the hardware. |
| 216 | */ |
Dan Williams | ee33e2b | 2011-07-29 17:16:45 -0700 | [diff] [blame] | 217 | u64 *array; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 218 | |
| 219 | /** |
| 220 | * This field specifies the physical address location for the UF |
| 221 | * address table. |
| 222 | */ |
| 223 | dma_addr_t physical_address; |
| 224 | |
| 225 | }; |
| 226 | |
| 227 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 228 | * struct sci_unsolicited_frame_control - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 229 | * |
| 230 | * This object contains all of the data necessary to handle unsolicited frames. |
| 231 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 232 | struct sci_unsolicited_frame_control { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 233 | /** |
| 234 | * This field is the software copy of the unsolicited frame queue |
| 235 | * get pointer. The controller object writes this value to the |
| 236 | * hardware to let the hardware put more unsolicited frame entries. |
| 237 | */ |
| 238 | u32 get; |
| 239 | |
| 240 | /** |
| 241 | * This field contains all of the unsolicited frame header |
| 242 | * specific fields. |
| 243 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 244 | struct sci_uf_header_array headers; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * This field contains all of the unsolicited frame buffer |
| 248 | * specific fields. |
| 249 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 250 | struct sci_uf_buffer_array buffers; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * This field contains all of the unsolicited frame address table |
| 254 | * specific fields. |
| 255 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 256 | struct sci_uf_address_table_array address_table; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 257 | |
| 258 | }; |
| 259 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 260 | struct isci_host; |
Christoph Hellwig | bc5c967 | 2011-04-02 08:15:04 -0400 | [diff] [blame] | 261 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 262 | int sci_unsolicited_frame_control_construct(struct isci_host *ihost); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 263 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 264 | enum sci_status sci_unsolicited_frame_control_get_header( |
| 265 | struct sci_unsolicited_frame_control *uf_control, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 266 | u32 frame_index, |
| 267 | void **frame_header); |
| 268 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 269 | enum sci_status sci_unsolicited_frame_control_get_buffer( |
| 270 | struct sci_unsolicited_frame_control *uf_control, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 271 | u32 frame_index, |
| 272 | void **frame_buffer); |
| 273 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 274 | bool sci_unsolicited_frame_control_release_frame( |
| 275 | struct sci_unsolicited_frame_control *uf_control, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 276 | u32 frame_index); |
| 277 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 278 | #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */ |