treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / scsi / isci / unsolicited_frame_control.h
blob1bc551ec611f5d9adc8472b3e3b263001a98f2b2
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.
5 * GPL LICENSE SUMMARY
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
24 * BSD LICENSE
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
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.
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.
56 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
57 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
59 #include "isci.h"
61 #define SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS 15
63 /**
64 * struct scu_unsolicited_frame_header -
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.
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.
75 u32 iit_exists:1;
77 /**
78 * This field simply indicates the protocol type (i.e. SSP, STP, SMP).
80 u32 protocol_type:3;
82 /**
83 * This field indicates if the frame is an address frame (IAF or OAF)
84 * or if it is a information unit frame.
86 u32 is_address_frame:1;
88 /**
89 * This field simply indicates the connection rate at which the frame
90 * was received.
92 u32 connection_rate:4;
94 u32 reserved:23;
96 /**
97 * This field represents the actual header data received on the link.
99 u32 data[SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS];
106 * enum unsolicited_frame_state -
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.
112 enum unsolicited_frame_state {
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.
118 UNSOLICITED_FRAME_EMPTY,
121 * This state is set when the frame buffer is in use by by some
122 * object in the system.
124 UNSOLICITED_FRAME_IN_USE,
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.
132 UNSOLICITED_FRAME_RELEASED,
134 UNSOLICITED_FRAME_MAX_STATES
138 * struct sci_unsolicited_frame -
140 * This is the unsolicited frame data structure it acts as the container for
141 * the current frame state, frame header and frame buffer.
143 struct sci_unsolicited_frame {
145 * This field contains the current frame state
147 enum unsolicited_frame_state state;
150 * This field points to the frame header data.
152 struct scu_unsolicited_frame_header *header;
155 * This field points to the frame buffer data.
157 void *buffer;
162 * struct sci_uf_header_array -
164 * This structure contains all of the unsolicited frame header information.
166 struct sci_uf_header_array {
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.
172 struct scu_unsolicited_frame_header *array;
175 * This field specifies the physical address location for the UF
176 * buffer array.
178 dma_addr_t physical_address;
183 * struct sci_uf_buffer_array -
185 * This structure contains all of the unsolicited frame buffer (actual payload)
186 * information.
188 struct sci_uf_buffer_array {
190 * This field is the unsolicited frame data its used to manage
191 * the data for the unsolicited frame requests. It also represents
192 * the virtual address location that corresponds to the
193 * physical_address field.
195 struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES];
198 * This field specifies the physical address location for the UF
199 * buffer array.
201 dma_addr_t physical_address;
205 * struct sci_uf_address_table_array -
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.
211 struct sci_uf_address_table_array {
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.
217 u64 *array;
220 * This field specifies the physical address location for the UF
221 * address table.
223 dma_addr_t physical_address;
228 * struct sci_unsolicited_frame_control -
230 * This object contains all of the data necessary to handle unsolicited frames.
232 struct sci_unsolicited_frame_control {
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.
238 u32 get;
241 * This field contains all of the unsolicited frame header
242 * specific fields.
244 struct sci_uf_header_array headers;
247 * This field contains all of the unsolicited frame buffer
248 * specific fields.
250 struct sci_uf_buffer_array buffers;
253 * This field contains all of the unsolicited frame address table
254 * specific fields.
256 struct sci_uf_address_table_array address_table;
260 #define SCI_UFI_BUF_SIZE (SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE)
261 #define SCI_UFI_HDR_SIZE (SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header))
262 #define SCI_UFI_TOTAL_SIZE (SCI_UFI_BUF_SIZE + SCI_UFI_HDR_SIZE + SCU_MAX_UNSOLICITED_FRAMES * sizeof(u64))
264 struct isci_host;
266 void sci_unsolicited_frame_control_construct(struct isci_host *ihost);
268 enum sci_status sci_unsolicited_frame_control_get_header(
269 struct sci_unsolicited_frame_control *uf_control,
270 u32 frame_index,
271 void **frame_header);
273 enum sci_status sci_unsolicited_frame_control_get_buffer(
274 struct sci_unsolicited_frame_control *uf_control,
275 u32 frame_index,
276 void **frame_buffer);
278 bool sci_unsolicited_frame_control_release_frame(
279 struct sci_unsolicited_frame_control *uf_control,
280 u32 frame_index);
282 #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */