Commit | Line | Data |
---|---|---|
6f231dda DW |
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 | ||
5409bc3a DW |
56 | #ifndef __ISCI_H__ |
57 | #define __ISCI_H__ | |
6f231dda | 58 | |
6f231dda | 59 | #include <linux/interrupt.h> |
12ef6544 | 60 | #include <linux/types.h> |
ce2b3261 DW |
61 | |
62 | #define DRV_NAME "isci" | |
63 | #define SCI_PCI_BAR_COUNT 2 | |
64 | #define SCI_NUM_MSI_X_INT 2 | |
65 | #define SCI_SMU_BAR 0 | |
66 | #define SCI_SMU_BAR_SIZE (16*1024) | |
67 | #define SCI_SCU_BAR 1 | |
68 | #define SCI_SCU_BAR_SIZE (4*1024*1024) | |
69 | #define SCI_IO_SPACE_BAR0 2 | |
70 | #define SCI_IO_SPACE_BAR1 3 | |
71 | #define ISCI_CAN_QUEUE_VAL 250 /* < SCI_MAX_IO_REQUESTS ? */ | |
72 | #define SCIC_CONTROLLER_STOP_TIMEOUT 5000 | |
73 | ||
74 | #define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF | |
75 | ||
76 | enum sci_controller_mode { | |
77 | SCI_MODE_SPEED, | |
78 | SCI_MODE_SIZE /* deprecated */ | |
79 | }; | |
80 | ||
7c78da31 | 81 | #define SCI_MAX_PHYS (4UL) |
ce2b3261 | 82 | #define SCI_MAX_PORTS SCI_MAX_PHYS |
ce2b3261 | 83 | #define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */ |
7c78da31 DW |
84 | #define SCI_MAX_REMOTE_DEVICES (256UL) |
85 | #define SCI_MAX_IO_REQUESTS (256UL) | |
dd047c8e | 86 | #define SCI_MAX_SEQ (16) |
ce2b3261 DW |
87 | #define SCI_MAX_MSIX_MESSAGES (2) |
88 | #define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */ | |
ce2b3261 DW |
89 | #define SCI_MAX_CONTROLLERS 2 |
90 | #define SCI_MAX_DOMAINS SCI_MAX_PORTS | |
91 | ||
ce2b3261 DW |
92 | #define SCU_MAX_CRITICAL_NOTIFICATIONS (384) |
93 | #define SCU_MAX_EVENTS (128) | |
94 | #define SCU_MAX_UNSOLICITED_FRAMES (128) | |
95 | #define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128) | |
96 | #define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \ | |
97 | + SCU_MAX_EVENTS \ | |
98 | + SCU_MAX_UNSOLICITED_FRAMES \ | |
99 | + SCI_MAX_IO_REQUESTS \ | |
100 | + SCU_MAX_COMPLETION_QUEUE_SCRATCH) | |
101 | ||
ce2b3261 DW |
102 | #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096) |
103 | #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024) | |
104 | #define SCU_INVALID_FRAME_INDEX (0xFFFF) | |
105 | ||
106 | #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF) | |
107 | #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF) | |
108 | ||
7c78da31 DW |
109 | static inline void check_sizes(void) |
110 | { | |
111 | BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_EVENTS); | |
112 | BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES <= 8); | |
113 | BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_UNSOLICITED_FRAMES); | |
114 | BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES); | |
115 | BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES); | |
ac668c69 | 116 | BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS); |
dd047c8e | 117 | BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_SEQ); |
7c78da31 | 118 | } |
ce2b3261 DW |
119 | |
120 | /** | |
121 | * enum sci_status - This is the general return status enumeration for non-IO, | |
122 | * non-task management related SCI interface methods. | |
123 | * | |
124 | * | |
125 | */ | |
126 | enum sci_status { | |
127 | /** | |
128 | * This member indicates successful completion. | |
129 | */ | |
130 | SCI_SUCCESS = 0, | |
131 | ||
132 | /** | |
133 | * This value indicates that the calling method completed successfully, | |
134 | * but that the IO may have completed before having it's start method | |
135 | * invoked. This occurs during SAT translation for requests that do | |
136 | * not require an IO to the target or for any other requests that may | |
137 | * be completed without having to submit IO. | |
138 | */ | |
139 | SCI_SUCCESS_IO_COMPLETE_BEFORE_START, | |
140 | ||
141 | /** | |
142 | * This Value indicates that the SCU hardware returned an early response | |
143 | * because the io request specified more data than is returned by the | |
144 | * target device (mode pages, inquiry data, etc.). The completion routine | |
145 | * will handle this case to get the actual number of bytes transferred. | |
146 | */ | |
147 | SCI_SUCCESS_IO_DONE_EARLY, | |
148 | ||
149 | /** | |
150 | * This member indicates that the object for which a state change is | |
151 | * being requested is already in said state. | |
152 | */ | |
153 | SCI_WARNING_ALREADY_IN_STATE, | |
154 | ||
155 | /** | |
156 | * This member indicates interrupt coalescence timer may cause SAS | |
157 | * specification compliance issues (i.e. SMP target mode response | |
158 | * frames must be returned within 1.9 milliseconds). | |
159 | */ | |
160 | SCI_WARNING_TIMER_CONFLICT, | |
161 | ||
162 | /** | |
163 | * This field indicates a sequence of action is not completed yet. Mostly, | |
164 | * this status is used when multiple ATA commands are needed in a SATI translation. | |
165 | */ | |
166 | SCI_WARNING_SEQUENCE_INCOMPLETE, | |
167 | ||
168 | /** | |
169 | * This member indicates that there was a general failure. | |
170 | */ | |
171 | SCI_FAILURE, | |
172 | ||
173 | /** | |
174 | * This member indicates that the SCI implementation is unable to complete | |
175 | * an operation due to a critical flaw the prevents any further operation | |
176 | * (i.e. an invalid pointer). | |
177 | */ | |
178 | SCI_FATAL_ERROR, | |
179 | ||
180 | /** | |
181 | * This member indicates the calling function failed, because the state | |
182 | * of the controller is in a state that prevents successful completion. | |
183 | */ | |
184 | SCI_FAILURE_INVALID_STATE, | |
185 | ||
186 | /** | |
187 | * This member indicates the calling function failed, because there is | |
188 | * insufficient resources/memory to complete the request. | |
189 | */ | |
190 | SCI_FAILURE_INSUFFICIENT_RESOURCES, | |
191 | ||
192 | /** | |
193 | * This member indicates the calling function failed, because the | |
194 | * controller object required for the operation can't be located. | |
195 | */ | |
196 | SCI_FAILURE_CONTROLLER_NOT_FOUND, | |
197 | ||
198 | /** | |
199 | * This member indicates the calling function failed, because the | |
200 | * discovered controller type is not supported by the library. | |
201 | */ | |
202 | SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE, | |
203 | ||
204 | /** | |
205 | * This member indicates the calling function failed, because the | |
206 | * requested initialization data version isn't supported. | |
207 | */ | |
208 | SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION, | |
209 | ||
210 | /** | |
211 | * This member indicates the calling function failed, because the | |
212 | * requested configuration of SAS Phys into SAS Ports is not supported. | |
213 | */ | |
214 | SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION, | |
215 | ||
216 | /** | |
217 | * This member indicates the calling function failed, because the | |
218 | * requested protocol is not supported by the remote device, port, | |
219 | * or controller. | |
220 | */ | |
221 | SCI_FAILURE_UNSUPPORTED_PROTOCOL, | |
222 | ||
223 | /** | |
224 | * This member indicates the calling function failed, because the | |
225 | * requested information type is not supported by the SCI implementation. | |
226 | */ | |
227 | SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE, | |
228 | ||
229 | /** | |
230 | * This member indicates the calling function failed, because the | |
231 | * device already exists. | |
232 | */ | |
233 | SCI_FAILURE_DEVICE_EXISTS, | |
234 | ||
235 | /** | |
236 | * This member indicates the calling function failed, because adding | |
237 | * a phy to the object is not possible. | |
238 | */ | |
239 | SCI_FAILURE_ADDING_PHY_UNSUPPORTED, | |
240 | ||
241 | /** | |
242 | * This member indicates the calling function failed, because the | |
243 | * requested information type is not supported by the SCI implementation. | |
244 | */ | |
245 | SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD, | |
246 | ||
247 | /** | |
248 | * This member indicates the calling function failed, because the SCI | |
249 | * implementation does not support the supplied time limit. | |
250 | */ | |
251 | SCI_FAILURE_UNSUPPORTED_TIME_LIMIT, | |
252 | ||
253 | /** | |
254 | * This member indicates the calling method failed, because the SCI | |
255 | * implementation does not contain the specified Phy. | |
256 | */ | |
257 | SCI_FAILURE_INVALID_PHY, | |
258 | ||
259 | /** | |
260 | * This member indicates the calling method failed, because the SCI | |
261 | * implementation does not contain the specified Port. | |
262 | */ | |
263 | SCI_FAILURE_INVALID_PORT, | |
264 | ||
265 | /** | |
266 | * This member indicates the calling method was partly successful | |
267 | * The port was reset but not all phys in port are operational | |
268 | */ | |
269 | SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS, | |
270 | ||
271 | /** | |
272 | * This member indicates that calling method failed | |
273 | * The port reset did not complete because none of the phys are operational | |
274 | */ | |
275 | SCI_FAILURE_RESET_PORT_FAILURE, | |
276 | ||
277 | /** | |
278 | * This member indicates the calling method failed, because the SCI | |
279 | * implementation does not contain the specified remote device. | |
280 | */ | |
281 | SCI_FAILURE_INVALID_REMOTE_DEVICE, | |
282 | ||
283 | /** | |
284 | * This member indicates the calling method failed, because the remote | |
285 | * device is in a bad state and requires a reset. | |
286 | */ | |
287 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, | |
288 | ||
289 | /** | |
290 | * This member indicates the calling method failed, because the SCI | |
291 | * implementation does not contain or support the specified IO tag. | |
292 | */ | |
293 | SCI_FAILURE_INVALID_IO_TAG, | |
294 | ||
295 | /** | |
296 | * This member indicates that the operation failed and the user should | |
297 | * check the response data associated with the IO. | |
298 | */ | |
299 | SCI_FAILURE_IO_RESPONSE_VALID, | |
300 | ||
301 | /** | |
302 | * This member indicates that the operation failed, the failure is | |
303 | * controller implementation specific, and the response data associated | |
304 | * with the request is not valid. You can query for the controller | |
305 | * specific error information via scic_controller_get_request_status() | |
306 | */ | |
307 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, | |
308 | ||
309 | /** | |
310 | * This member indicated that the operation failed because the | |
311 | * user requested this IO to be terminated. | |
312 | */ | |
313 | SCI_FAILURE_IO_TERMINATED, | |
314 | ||
315 | /** | |
316 | * This member indicates that the operation failed and the associated | |
317 | * request requires a SCSI abort task to be sent to the target. | |
318 | */ | |
319 | SCI_FAILURE_IO_REQUIRES_SCSI_ABORT, | |
320 | ||
321 | /** | |
322 | * This member indicates that the operation failed because the supplied | |
323 | * device could not be located. | |
324 | */ | |
325 | SCI_FAILURE_DEVICE_NOT_FOUND, | |
326 | ||
327 | /** | |
328 | * This member indicates that the operation failed because the | |
329 | * objects association is required and is not correctly set. | |
330 | */ | |
331 | SCI_FAILURE_INVALID_ASSOCIATION, | |
332 | ||
333 | /** | |
334 | * This member indicates that the operation failed, because a timeout | |
335 | * occurred. | |
336 | */ | |
337 | SCI_FAILURE_TIMEOUT, | |
338 | ||
339 | /** | |
340 | * This member indicates that the operation failed, because the user | |
341 | * specified a value that is either invalid or not supported. | |
342 | */ | |
343 | SCI_FAILURE_INVALID_PARAMETER_VALUE, | |
344 | ||
345 | /** | |
346 | * This value indicates that the operation failed, because the number | |
347 | * of messages (MSI-X) is not supported. | |
348 | */ | |
349 | SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT, | |
350 | ||
351 | /** | |
352 | * This value indicates that the method failed due to a lack of | |
353 | * available NCQ tags. | |
354 | */ | |
355 | SCI_FAILURE_NO_NCQ_TAG_AVAILABLE, | |
356 | ||
357 | /** | |
358 | * This value indicates that a protocol violation has occurred on the | |
359 | * link. | |
360 | */ | |
361 | SCI_FAILURE_PROTOCOL_VIOLATION, | |
362 | ||
363 | /** | |
364 | * This value indicates a failure condition that retry may help to clear. | |
365 | */ | |
366 | SCI_FAILURE_RETRY_REQUIRED, | |
367 | ||
368 | /** | |
369 | * This field indicates the retry limit was reached when a retry is attempted | |
370 | */ | |
371 | SCI_FAILURE_RETRY_LIMIT_REACHED, | |
372 | ||
373 | /** | |
374 | * This member indicates the calling method was partly successful. | |
375 | * Mostly, this status is used when a LUN_RESET issued to an expander attached | |
376 | * STP device in READY NCQ substate needs to have RNC suspended/resumed | |
377 | * before posting TC. | |
378 | */ | |
379 | SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS, | |
380 | ||
381 | /** | |
382 | * This field indicates an illegal phy connection based on the routing attribute | |
383 | * of both expander phy attached to each other. | |
384 | */ | |
385 | SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION, | |
386 | ||
387 | /** | |
388 | * This field indicates a CONFIG ROUTE INFO command has a response with function result | |
389 | * INDEX DOES NOT EXIST, usually means exceeding max route index. | |
390 | */ | |
391 | SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX, | |
392 | ||
393 | /** | |
394 | * This value indicates that an unsupported PCI device ID has been | |
395 | * specified. This indicates that attempts to invoke | |
396 | * scic_library_allocate_controller() will fail. | |
397 | */ | |
398 | SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID | |
399 | ||
400 | }; | |
401 | ||
402 | /** | |
403 | * enum sci_io_status - This enumeration depicts all of the possible IO | |
404 | * completion status values. Each value in this enumeration maps directly | |
405 | * to a value in the enum sci_status enumeration. Please refer to that | |
406 | * enumeration for detailed comments concerning what the status represents. | |
407 | * | |
408 | * Add the API to retrieve the SCU status from the core. Check to see that the | |
409 | * following status are properly handled: - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL | |
410 | * - SCI_IO_FAILURE_INVALID_IO_TAG | |
411 | */ | |
412 | enum sci_io_status { | |
413 | SCI_IO_SUCCESS = SCI_SUCCESS, | |
414 | SCI_IO_FAILURE = SCI_FAILURE, | |
415 | SCI_IO_SUCCESS_COMPLETE_BEFORE_START = SCI_SUCCESS_IO_COMPLETE_BEFORE_START, | |
416 | SCI_IO_SUCCESS_IO_DONE_EARLY = SCI_SUCCESS_IO_DONE_EARLY, | |
417 | SCI_IO_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE, | |
418 | SCI_IO_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES, | |
419 | SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL, | |
420 | SCI_IO_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID, | |
421 | SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, | |
422 | SCI_IO_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED, | |
423 | SCI_IO_FAILURE_REQUIRES_SCSI_ABORT = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT, | |
424 | SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE, | |
425 | SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE, | |
426 | SCI_IO_FAILURE_PROTOCOL_VIOLATION = SCI_FAILURE_PROTOCOL_VIOLATION, | |
427 | ||
428 | SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, | |
429 | ||
430 | SCI_IO_FAILURE_RETRY_REQUIRED = SCI_FAILURE_RETRY_REQUIRED, | |
431 | SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED, | |
432 | SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE | |
433 | }; | |
434 | ||
435 | /** | |
436 | * enum sci_task_status - This enumeration depicts all of the possible task | |
437 | * completion status values. Each value in this enumeration maps directly | |
438 | * to a value in the enum sci_status enumeration. Please refer to that | |
439 | * enumeration for detailed comments concerning what the status represents. | |
440 | * | |
441 | * Check to see that the following status are properly handled: | |
442 | */ | |
443 | enum sci_task_status { | |
444 | SCI_TASK_SUCCESS = SCI_SUCCESS, | |
445 | SCI_TASK_FAILURE = SCI_FAILURE, | |
446 | SCI_TASK_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE, | |
447 | SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES, | |
448 | SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL, | |
449 | SCI_TASK_FAILURE_INVALID_TAG = SCI_FAILURE_INVALID_IO_TAG, | |
450 | SCI_TASK_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID, | |
451 | SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, | |
452 | SCI_TASK_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED, | |
453 | SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE, | |
454 | ||
455 | SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, | |
456 | SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS | |
457 | ||
458 | }; | |
6f231dda | 459 | |
f1f52e75 DW |
460 | /** |
461 | * sci_swab32_cpy - convert between scsi and scu-hardware byte format | |
462 | * @dest: receive the 4-byte endian swapped version of src | |
463 | * @src: word aligned source buffer | |
464 | * | |
465 | * scu hardware handles SSP/SMP control, response, and unidentified | |
466 | * frames in "big endian dword" order. Regardless of host endian this | |
467 | * is always a swab32()-per-dword conversion of the standard definition, | |
468 | * i.e. single byte fields swapped and multi-byte fields in little- | |
469 | * endian | |
470 | */ | |
471 | static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt) | |
472 | { | |
473 | u32 *dest = _dest, *src = _src; | |
474 | ||
475 | while (--word_cnt >= 0) | |
476 | dest[word_cnt] = swab32(src[word_cnt]); | |
477 | } | |
478 | ||
b5f18a20 DJ |
479 | extern unsigned char no_outbound_task_to; |
480 | extern u16 ssp_max_occ_to; | |
481 | extern u16 stp_max_occ_to; | |
482 | extern u16 ssp_inactive_to; | |
483 | extern u16 stp_inactive_to; | |
484 | extern unsigned char phy_gen; | |
485 | extern unsigned char max_concurr_spinup; | |
486 | ||
c7ef4031 DW |
487 | irqreturn_t isci_msix_isr(int vec, void *data); |
488 | irqreturn_t isci_intx_isr(int vec, void *data); | |
92f4f0f5 | 489 | irqreturn_t isci_error_isr(int vec, void *data); |
5553ba2b EN |
490 | |
491 | /* | |
492 | * Each timer is associated with a cancellation flag that is set when | |
493 | * del_timer() is called and checked in the timer callback function. This | |
494 | * is needed since del_timer_sync() cannot be called with scic_lock held. | |
495 | * For deinit however, del_timer_sync() is used without holding the lock. | |
496 | */ | |
497 | struct sci_timer { | |
498 | struct timer_list timer; | |
499 | bool cancel; | |
500 | }; | |
501 | ||
502 | static inline | |
503 | void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long)) | |
504 | { | |
505 | tmr->timer.function = fn; | |
506 | tmr->timer.data = (unsigned long) tmr; | |
507 | tmr->cancel = 0; | |
508 | init_timer(&tmr->timer); | |
509 | } | |
510 | ||
511 | static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec) | |
512 | { | |
513 | tmr->cancel = 0; | |
514 | mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec)); | |
515 | } | |
516 | ||
517 | static inline void sci_del_timer(struct sci_timer *tmr) | |
518 | { | |
519 | tmr->cancel = 1; | |
520 | del_timer(&tmr->timer); | |
521 | } | |
522 | ||
12ef6544 EN |
523 | struct sci_base_state_machine { |
524 | const struct sci_base_state *state_table; | |
525 | u32 initial_state_id; | |
526 | u32 current_state_id; | |
527 | u32 previous_state_id; | |
528 | }; | |
529 | ||
530 | typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm); | |
531 | ||
532 | struct sci_base_state { | |
533 | sci_state_transition_t enter_state; /* Called on state entry */ | |
534 | sci_state_transition_t exit_state; /* Called on state exit */ | |
535 | }; | |
536 | ||
537 | extern void sci_init_sm(struct sci_base_state_machine *sm, | |
538 | const struct sci_base_state *state_table, | |
539 | u32 initial_state); | |
540 | extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state); | |
5409bc3a | 541 | #endif /* __ISCI_H__ */ |