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