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 | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 60 | #include "scu_unsolicited_frame.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 63 | * enum unsolicited_frame_state - |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 64 | * |
| 65 | * This enumeration represents the current unsolicited frame state. The |
| 66 | * controller object can not updtate the hardware unsolicited frame put pointer |
| 67 | * unless it has already processed the priror unsolicited frames. |
| 68 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 69 | enum unsolicited_frame_state { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 70 | /** |
| 71 | * This state is when the frame is empty and not in use. It is |
| 72 | * different from the released state in that the hardware could DMA |
| 73 | * data to this frame buffer. |
| 74 | */ |
| 75 | UNSOLICITED_FRAME_EMPTY, |
| 76 | |
| 77 | /** |
| 78 | * This state is set when the frame buffer is in use by by some |
| 79 | * object in the system. |
| 80 | */ |
| 81 | UNSOLICITED_FRAME_IN_USE, |
| 82 | |
| 83 | /** |
| 84 | * This state is set when the frame is returned to the free pool |
| 85 | * but one or more frames prior to this one are still in use. |
| 86 | * Once all of the frame before this one are freed it will go to |
| 87 | * the empty state. |
| 88 | */ |
| 89 | UNSOLICITED_FRAME_RELEASED, |
| 90 | |
| 91 | UNSOLICITED_FRAME_MAX_STATES |
| 92 | }; |
| 93 | |
| 94 | /** |
| 95 | * struct scic_sds_unsolicited_frame - |
| 96 | * |
| 97 | * This is the unsolicited frame data structure it acts as the container for |
| 98 | * the current frame state, frame header and frame buffer. |
| 99 | */ |
| 100 | struct scic_sds_unsolicited_frame { |
| 101 | /** |
| 102 | * This field contains the current frame state |
| 103 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 104 | enum unsolicited_frame_state state; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * This field points to the frame header data. |
| 108 | */ |
| 109 | struct scu_unsolicited_frame_header *header; |
| 110 | |
| 111 | /** |
| 112 | * This field points to the frame buffer data. |
| 113 | */ |
| 114 | void *buffer; |
| 115 | |
| 116 | }; |
| 117 | |
| 118 | /** |
| 119 | * struct scic_sds_uf_header_array - |
| 120 | * |
| 121 | * This structure contains all of the unsolicited frame header information. |
| 122 | */ |
| 123 | struct scic_sds_uf_header_array { |
| 124 | /** |
| 125 | * This field is represents a virtual pointer to the start |
| 126 | * address of the UF address table. The table contains |
| 127 | * 64-bit pointers as required by the hardware. |
| 128 | */ |
| 129 | struct scu_unsolicited_frame_header *array; |
| 130 | |
| 131 | /** |
| 132 | * This field specifies the physical address location for the UF |
| 133 | * buffer array. |
| 134 | */ |
| 135 | dma_addr_t physical_address; |
| 136 | |
| 137 | }; |
| 138 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 139 | /** |
| 140 | * struct scic_sds_uf_buffer_array - |
| 141 | * |
| 142 | * This structure contains all of the unsolicited frame buffer (actual payload) |
| 143 | * information. |
| 144 | */ |
| 145 | struct scic_sds_uf_buffer_array { |
| 146 | /** |
Dan Williams | 7c78da3 | 2011-06-01 16:00:01 -0700 | [diff] [blame] | 147 | * This field is the unsolicited frame data its used to manage |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 148 | * the data for the unsolicited frame requests. It also represents |
| 149 | * the virtual address location that corresponds to the |
| 150 | * physical_address field. |
| 151 | */ |
Dan Williams | 7c78da3 | 2011-06-01 16:00:01 -0700 | [diff] [blame] | 152 | struct scic_sds_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES]; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * This field specifies the physical address location for the UF |
| 156 | * buffer array. |
| 157 | */ |
| 158 | dma_addr_t physical_address; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | /** |
| 162 | * struct scic_sds_uf_address_table_array - |
| 163 | * |
| 164 | * This object maintains all of the unsolicited frame address table specific |
| 165 | * data. The address table is a collection of 64-bit pointers that point to |
| 166 | * 1KB buffers into which the silicon will DMA unsolicited frames. |
| 167 | */ |
| 168 | struct scic_sds_uf_address_table_array { |
| 169 | /** |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 170 | * This field represents a virtual pointer that refers to the |
| 171 | * starting address of the UF address table. |
| 172 | * 64-bit pointers are required by the hardware. |
| 173 | */ |
| 174 | dma_addr_t *array; |
| 175 | |
| 176 | /** |
| 177 | * This field specifies the physical address location for the UF |
| 178 | * address table. |
| 179 | */ |
| 180 | dma_addr_t physical_address; |
| 181 | |
| 182 | }; |
| 183 | |
| 184 | /** |
| 185 | * struct scic_sds_unsolicited_frame_control - |
| 186 | * |
| 187 | * This object contains all of the data necessary to handle unsolicited frames. |
| 188 | */ |
| 189 | struct scic_sds_unsolicited_frame_control { |
| 190 | /** |
| 191 | * This field is the software copy of the unsolicited frame queue |
| 192 | * get pointer. The controller object writes this value to the |
| 193 | * hardware to let the hardware put more unsolicited frame entries. |
| 194 | */ |
| 195 | u32 get; |
| 196 | |
| 197 | /** |
| 198 | * This field contains all of the unsolicited frame header |
| 199 | * specific fields. |
| 200 | */ |
| 201 | struct scic_sds_uf_header_array headers; |
| 202 | |
| 203 | /** |
| 204 | * This field contains all of the unsolicited frame buffer |
| 205 | * specific fields. |
| 206 | */ |
| 207 | struct scic_sds_uf_buffer_array buffers; |
| 208 | |
| 209 | /** |
| 210 | * This field contains all of the unsolicited frame address table |
| 211 | * specific fields. |
| 212 | */ |
| 213 | struct scic_sds_uf_address_table_array address_table; |
| 214 | |
| 215 | }; |
| 216 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame^] | 217 | struct isci_host; |
Christoph Hellwig | bc5c967 | 2011-04-02 08:15:04 -0400 | [diff] [blame] | 218 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame^] | 219 | int scic_sds_unsolicited_frame_control_construct(struct isci_host *ihost); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 220 | |
| 221 | enum sci_status scic_sds_unsolicited_frame_control_get_header( |
| 222 | struct scic_sds_unsolicited_frame_control *uf_control, |
| 223 | u32 frame_index, |
| 224 | void **frame_header); |
| 225 | |
| 226 | enum sci_status scic_sds_unsolicited_frame_control_get_buffer( |
| 227 | struct scic_sds_unsolicited_frame_control *uf_control, |
| 228 | u32 frame_index, |
| 229 | void **frame_buffer); |
| 230 | |
| 231 | bool scic_sds_unsolicited_frame_control_release_frame( |
| 232 | struct scic_sds_unsolicited_frame_control *uf_control, |
| 233 | u32 frame_index); |
| 234 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 235 | #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */ |