blob: 75d896686f5aaa0750fe92c3886fe331566b67e7 [file] [log] [blame]
Dan Williams6f231dd2011-07-02 22:56:22 -07001/*
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 Williams6f231dd2011-07-02 22:56:22 -070056#ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
57#define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
58
Dan Williamsce2b3262011-05-08 15:49:15 -070059#include "isci.h"
Dan Williams4e4dca32011-07-01 11:15:12 -070060
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 */
70struct 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 Williams6f231dd2011-07-02 22:56:22 -0700104
105/**
Dave Jiangde728b72011-03-26 17:14:07 -0700106 * enum unsolicited_frame_state -
Dan Williams6f231dd2011-07-02 22:56:22 -0700107 *
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 Jiangde728b72011-03-26 17:14:07 -0700112enum unsolicited_frame_state {
Dan Williams6f231dd2011-07-02 22:56:22 -0700113 /**
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 Williams89a73012011-06-30 19:14:33 -0700138 * struct sci_unsolicited_frame -
Dan Williams6f231dd2011-07-02 22:56:22 -0700139 *
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 Williams89a73012011-06-30 19:14:33 -0700143struct sci_unsolicited_frame {
Dan Williams6f231dd2011-07-02 22:56:22 -0700144 /**
145 * This field contains the current frame state
146 */
Dave Jiangde728b72011-03-26 17:14:07 -0700147 enum unsolicited_frame_state state;
Dan Williams6f231dd2011-07-02 22:56:22 -0700148
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 Williams89a73012011-06-30 19:14:33 -0700162 * struct sci_uf_header_array -
Dan Williams6f231dd2011-07-02 22:56:22 -0700163 *
164 * This structure contains all of the unsolicited frame header information.
165 */
Dan Williams89a73012011-06-30 19:14:33 -0700166struct sci_uf_header_array {
Dan Williams6f231dd2011-07-02 22:56:22 -0700167 /**
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 Williams6f231dd2011-07-02 22:56:22 -0700182/**
Dan Williams89a73012011-06-30 19:14:33 -0700183 * struct sci_uf_buffer_array -
Dan Williams6f231dd2011-07-02 22:56:22 -0700184 *
185 * This structure contains all of the unsolicited frame buffer (actual payload)
186 * information.
187 */
Dan Williams89a73012011-06-30 19:14:33 -0700188struct sci_uf_buffer_array {
Dan Williams6f231dd2011-07-02 22:56:22 -0700189 /**
Dan Williams7c78da32011-06-01 16:00:01 -0700190 * This field is the unsolicited frame data its used to manage
Dan Williams6f231dd2011-07-02 22:56:22 -0700191 * 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 Williams89a73012011-06-30 19:14:33 -0700195 struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES];
Dan Williams6f231dd2011-07-02 22:56:22 -0700196
197 /**
198 * This field specifies the physical address location for the UF
199 * buffer array.
200 */
201 dma_addr_t physical_address;
Dan Williams6f231dd2011-07-02 22:56:22 -0700202};
203
204/**
Dan Williams89a73012011-06-30 19:14:33 -0700205 * struct sci_uf_address_table_array -
Dan Williams6f231dd2011-07-02 22:56:22 -0700206 *
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 Williams89a73012011-06-30 19:14:33 -0700211struct sci_uf_address_table_array {
Dan Williams6f231dd2011-07-02 22:56:22 -0700212 /**
Dan Williams6f231dd2011-07-02 22:56:22 -0700213 * 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 Williamsee33e2b2011-07-29 17:16:45 -0700217 u64 *array;
Dan Williams6f231dd2011-07-02 22:56:22 -0700218
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 Williams89a73012011-06-30 19:14:33 -0700228 * struct sci_unsolicited_frame_control -
Dan Williams6f231dd2011-07-02 22:56:22 -0700229 *
230 * This object contains all of the data necessary to handle unsolicited frames.
231 */
Dan Williams89a73012011-06-30 19:14:33 -0700232struct sci_unsolicited_frame_control {
Dan Williams6f231dd2011-07-02 22:56:22 -0700233 /**
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 Williams89a73012011-06-30 19:14:33 -0700244 struct sci_uf_header_array headers;
Dan Williams6f231dd2011-07-02 22:56:22 -0700245
246 /**
247 * This field contains all of the unsolicited frame buffer
248 * specific fields.
249 */
Dan Williams89a73012011-06-30 19:14:33 -0700250 struct sci_uf_buffer_array buffers;
Dan Williams6f231dd2011-07-02 22:56:22 -0700251
252 /**
253 * This field contains all of the unsolicited frame address table
254 * specific fields.
255 */
Dan Williams89a73012011-06-30 19:14:33 -0700256 struct sci_uf_address_table_array address_table;
Dan Williams6f231dd2011-07-02 22:56:22 -0700257
258};
259
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700260struct isci_host;
Christoph Hellwigbc5c9672011-04-02 08:15:04 -0400261
Dan Williams89a73012011-06-30 19:14:33 -0700262int sci_unsolicited_frame_control_construct(struct isci_host *ihost);
Dan Williams6f231dd2011-07-02 22:56:22 -0700263
Dan Williams89a73012011-06-30 19:14:33 -0700264enum sci_status sci_unsolicited_frame_control_get_header(
265 struct sci_unsolicited_frame_control *uf_control,
Dan Williams6f231dd2011-07-02 22:56:22 -0700266 u32 frame_index,
267 void **frame_header);
268
Dan Williams89a73012011-06-30 19:14:33 -0700269enum sci_status sci_unsolicited_frame_control_get_buffer(
270 struct sci_unsolicited_frame_control *uf_control,
Dan Williams6f231dd2011-07-02 22:56:22 -0700271 u32 frame_index,
272 void **frame_buffer);
273
Dan Williams89a73012011-06-30 19:14:33 -0700274bool sci_unsolicited_frame_control_release_frame(
275 struct sci_unsolicited_frame_control *uf_control,
Dan Williams6f231dd2011-07-02 22:56:22 -0700276 u32 frame_index);
277
Dan Williams6f231dd2011-07-02 22:56:22 -0700278#endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */