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 | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame^] | 56 | #ifndef _ISCI_REMOTE_DEVICE_H_ |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 57 | #define _ISCI_REMOTE_DEVICE_H_ |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame^] | 58 | #include <scsi/libsas.h> |
| 59 | #include "sci_status.h" |
| 60 | #include "intel_sas.h" |
| 61 | #include "scu_remote_node_context.h" |
| 62 | #include "remote_node_context.h" |
| 63 | #include "port.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 64 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame^] | 65 | enum scic_remote_device_not_ready_reason_code { |
| 66 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, |
| 67 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, |
| 68 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, |
| 69 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, |
| 70 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, |
| 71 | |
| 72 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | struct scic_sds_remote_device { |
| 77 | /** |
| 78 | * The field specifies that the parent object for the base remote |
| 79 | * device is the base object itself. |
| 80 | */ |
| 81 | struct sci_base_object parent; |
| 82 | |
| 83 | /** |
| 84 | * This field contains the information for the base remote device state |
| 85 | * machine. |
| 86 | */ |
| 87 | struct sci_base_state_machine state_machine; |
| 88 | |
| 89 | /** |
| 90 | * This field is the programmed device port width. This value is |
| 91 | * written to the RCN data structure to tell the SCU how many open |
| 92 | * connections this device can have. |
| 93 | */ |
| 94 | u32 device_port_width; |
| 95 | |
| 96 | /** |
| 97 | * This field is the programmed connection rate for this remote device. It is |
| 98 | * used to program the TC with the maximum allowed connection rate. |
| 99 | */ |
| 100 | enum sas_linkrate connection_rate; |
| 101 | |
| 102 | /** |
| 103 | * This field contains the allowed target protocols for this remote device. |
| 104 | */ |
| 105 | struct smp_discover_response_protocols target_protocols; |
| 106 | |
| 107 | /** |
| 108 | * This field contains the device SAS address. |
| 109 | */ |
| 110 | struct sci_sas_address device_address; |
| 111 | |
| 112 | /** |
| 113 | * This filed is assinged the value of true if the device is directly |
| 114 | * attached to the port. |
| 115 | */ |
| 116 | bool is_direct_attached; |
| 117 | |
| 118 | #if !defined(DISABLE_ATAPI) |
| 119 | /** |
| 120 | * This filed is assinged the value of true if the device is an ATAPI |
| 121 | * device. |
| 122 | */ |
| 123 | bool is_atapi; |
| 124 | #endif |
| 125 | |
| 126 | /** |
| 127 | * This filed contains a pointer back to the port to which this device |
| 128 | * is assigned. |
| 129 | */ |
| 130 | struct scic_sds_port *owning_port; |
| 131 | |
| 132 | /** |
| 133 | * This field contains the SCU silicon remote node context specific |
| 134 | * information. |
| 135 | */ |
| 136 | struct scic_sds_remote_node_context rnc; |
| 137 | |
| 138 | /** |
| 139 | * This field contains the stated request count for the remote device. The |
| 140 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all |
| 141 | * requests are complete and the rnc_posted value is false. |
| 142 | */ |
| 143 | u32 started_request_count; |
| 144 | |
| 145 | /** |
| 146 | * This field contains a pointer to the working request object. It is only |
| 147 | * used only for SATA requests since the unsolicited frames we get from the |
| 148 | * hardware have no Tag value to look up the io request object. |
| 149 | */ |
| 150 | struct scic_sds_request *working_request; |
| 151 | |
| 152 | /** |
| 153 | * This field contains the reason for the remote device going not_ready. It is |
| 154 | * assigned in the state handlers and used in the state transition. |
| 155 | */ |
| 156 | u32 not_ready_reason; |
| 157 | |
| 158 | /** |
| 159 | * This field is true if this remote device has an initialzied ready substate |
| 160 | * machine. SSP devices do not have a ready substate machine and STP devices |
| 161 | * have a ready substate machine. |
| 162 | */ |
| 163 | bool has_ready_substate_machine; |
| 164 | |
| 165 | /** |
| 166 | * This field contains the state machine for the ready substate machine for |
| 167 | * this struct scic_sds_remote_device object. |
| 168 | */ |
| 169 | struct sci_base_state_machine ready_substate_machine; |
| 170 | |
| 171 | /** |
| 172 | * This field maintains the set of state handlers for the remote device |
| 173 | * object. These are changed each time the remote device enters a new state. |
| 174 | */ |
| 175 | const struct scic_sds_remote_device_state_handler *state_handlers; |
| 176 | }; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 177 | |
| 178 | struct isci_remote_device { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 179 | enum isci_status status; |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 180 | #define IDEV_START_PENDING 0 |
| 181 | #define IDEV_STOP_PENDING 1 |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 182 | #define IDEV_ALLOCATED 2 |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 183 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 184 | struct isci_port *isci_port; |
| 185 | struct domain_device *domain_dev; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 186 | struct list_head node; |
| 187 | struct list_head reqs_in_process; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 188 | spinlock_t state_lock; |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 189 | struct scic_sds_remote_device sci; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 192 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
| 193 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 194 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
| 195 | struct isci_remote_device *idev); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 196 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
| 197 | struct isci_remote_device *idev); |
Dan Williams | 037afc7 | 2011-03-31 13:10:42 -0700 | [diff] [blame] | 198 | void isci_remote_device_ready(struct isci_host *ihost, |
| 199 | struct isci_remote_device *idev); |
Dan Williams | 037afc7 | 2011-03-31 13:10:42 -0700 | [diff] [blame] | 200 | void isci_remote_device_not_ready(struct isci_host *ihost, |
| 201 | struct isci_remote_device *idev, u32 reason); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 202 | void isci_remote_device_gone(struct domain_device *domain_dev); |
| 203 | int isci_remote_device_found(struct domain_device *domain_dev); |
| 204 | bool isci_device_is_reset_pending(struct isci_host *ihost, |
| 205 | struct isci_remote_device *idev); |
| 206 | void isci_device_clear_reset_pending(struct isci_host *ihost, |
| 207 | struct isci_remote_device *idev); |
| 208 | void isci_remote_device_change_state(struct isci_remote_device *idev, |
| 209 | enum isci_status status); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame^] | 210 | /** |
| 211 | * scic_remote_device_stop() - This method will stop both transmission and |
| 212 | * reception of link activity for the supplied remote device. This method |
| 213 | * disables normal IO requests from flowing through to the remote device. |
| 214 | * @remote_device: This parameter specifies the device to be stopped. |
| 215 | * @timeout: This parameter specifies the number of milliseconds in which the |
| 216 | * stop operation should complete. |
| 217 | * |
| 218 | * An indication of whether the device was successfully stopped. SCI_SUCCESS |
| 219 | * This value is returned if the transmission and reception for the device was |
| 220 | * successfully stopped. |
| 221 | */ |
| 222 | enum sci_status scic_remote_device_stop( |
| 223 | struct scic_sds_remote_device *remote_device, |
| 224 | u32 timeout); |
| 225 | |
| 226 | /** |
| 227 | * scic_remote_device_reset() - This method will reset the device making it |
| 228 | * ready for operation. This method must be called anytime the device is |
| 229 | * reset either through a SMP phy control or a port hard reset request. |
| 230 | * @remote_device: This parameter specifies the device to be reset. |
| 231 | * |
| 232 | * This method does not actually cause the device hardware to be reset. This |
| 233 | * method resets the software object so that it will be operational after a |
| 234 | * device hardware reset completes. An indication of whether the device reset |
| 235 | * was accepted. SCI_SUCCESS This value is returned if the device reset is |
| 236 | * started. |
| 237 | */ |
| 238 | enum sci_status scic_remote_device_reset( |
| 239 | struct scic_sds_remote_device *remote_device); |
| 240 | |
| 241 | /** |
| 242 | * scic_remote_device_reset_complete() - This method informs the device object |
| 243 | * that the reset operation is complete and the device can resume operation |
| 244 | * again. |
| 245 | * @remote_device: This parameter specifies the device which is to be informed |
| 246 | * of the reset complete operation. |
| 247 | * |
| 248 | * An indication that the device is resuming operation. SCI_SUCCESS the device |
| 249 | * is resuming operation. |
| 250 | */ |
| 251 | enum sci_status scic_remote_device_reset_complete( |
| 252 | struct scic_sds_remote_device *remote_device); |
| 253 | |
| 254 | |
| 255 | |
| 256 | /** |
| 257 | * scic_remote_device_get_connection_rate() - This method simply returns the |
| 258 | * link rate at which communications to the remote device occur. |
| 259 | * @remote_device: This parameter specifies the device for which to get the |
| 260 | * connection rate. |
| 261 | * |
| 262 | * Return the link rate at which we transfer for the supplied remote device. |
| 263 | */ |
| 264 | enum sas_linkrate scic_remote_device_get_connection_rate( |
| 265 | struct scic_sds_remote_device *remote_device); |
| 266 | |
| 267 | /** |
| 268 | * scic_remote_device_get_protocols() - This method will indicate which |
| 269 | * protocols are supported by this remote device. |
| 270 | * @remote_device: This parameter specifies the device for which to return the |
| 271 | * protocol. |
| 272 | * @protocols: This parameter specifies the output values, from the remote |
| 273 | * device object, which indicate the protocols supported by the supplied |
| 274 | * remote_device. |
| 275 | * |
| 276 | * The type of protocols supported by this device. The values are returned as |
| 277 | * part of a bit mask in order to allow for multi-protocol support. |
| 278 | */ |
| 279 | void scic_remote_device_get_protocols( |
| 280 | struct scic_sds_remote_device *remote_device, |
| 281 | struct smp_discover_response_protocols *protocols); |
| 282 | |
| 283 | |
| 284 | #if !defined(DISABLE_ATAPI) |
| 285 | /** |
| 286 | * scic_remote_device_is_atapi() - |
| 287 | * @this_device: The device whose type is to be decided. |
| 288 | * |
| 289 | * This method first decide whether a device is a stp target, then decode the |
| 290 | * signature fis of a DA STP device to tell whether it is a standard end disk |
| 291 | * or an ATAPI device. bool Indicate a device is ATAPI device or not. |
| 292 | */ |
| 293 | bool scic_remote_device_is_atapi( |
| 294 | struct scic_sds_remote_device *device_handle); |
| 295 | #else /* !defined(DISABLE_ATAPI) */ |
| 296 | #define scic_remote_device_is_atapi(device_handle) false |
| 297 | #endif /* !defined(DISABLE_ATAPI) */ |
| 298 | |
| 299 | |
| 300 | |
| 301 | /** |
| 302 | * enum scic_sds_remote_device_states - This enumeration depicts all the states |
| 303 | * for the common remote device state machine. |
| 304 | * |
| 305 | * |
| 306 | */ |
| 307 | enum scic_sds_remote_device_states { |
| 308 | /** |
| 309 | * Simply the initial state for the base remote device state machine. |
| 310 | */ |
| 311 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, |
| 312 | |
| 313 | /** |
| 314 | * This state indicates that the remote device has successfully been |
| 315 | * stopped. In this state no new IO operations are permitted. |
| 316 | * This state is entered from the INITIAL state. |
| 317 | * This state is entered from the STOPPING state. |
| 318 | */ |
| 319 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, |
| 320 | |
| 321 | /** |
| 322 | * This state indicates the the remote device is in the process of |
| 323 | * becoming ready (i.e. starting). In this state no new IO operations |
| 324 | * are permitted. |
| 325 | * This state is entered from the STOPPED state. |
| 326 | */ |
| 327 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, |
| 328 | |
| 329 | /** |
| 330 | * This state indicates the remote device is now ready. Thus, the user |
| 331 | * is able to perform IO operations on the remote device. |
| 332 | * This state is entered from the STARTING state. |
| 333 | */ |
| 334 | SCI_BASE_REMOTE_DEVICE_STATE_READY, |
| 335 | |
| 336 | /** |
| 337 | * This state indicates that the remote device is in the process of |
| 338 | * stopping. In this state no new IO operations are permitted, but |
| 339 | * existing IO operations are allowed to complete. |
| 340 | * This state is entered from the READY state. |
| 341 | * This state is entered from the FAILED state. |
| 342 | */ |
| 343 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, |
| 344 | |
| 345 | /** |
| 346 | * This state indicates that the remote device has failed. |
| 347 | * In this state no new IO operations are permitted. |
| 348 | * This state is entered from the INITIALIZING state. |
| 349 | * This state is entered from the READY state. |
| 350 | */ |
| 351 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, |
| 352 | |
| 353 | /** |
| 354 | * This state indicates the device is being reset. |
| 355 | * In this state no new IO operations are permitted. |
| 356 | * This state is entered from the READY state. |
| 357 | */ |
| 358 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, |
| 359 | |
| 360 | /** |
| 361 | * Simply the final state for the base remote device state machine. |
| 362 | */ |
| 363 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, |
| 364 | }; |
| 365 | |
| 366 | /** |
| 367 | * enum scic_sds_ssp_remote_device_ready_substates - |
| 368 | * |
| 369 | * This is the enumeration of the ready substates for the |
| 370 | * struct scic_sds_remote_device. |
| 371 | */ |
| 372 | enum scic_sds_ssp_remote_device_ready_substates { |
| 373 | /** |
| 374 | * This is the initial state for the remote device ready substate. |
| 375 | */ |
| 376 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, |
| 377 | |
| 378 | /** |
| 379 | * This is the ready operational substate for the remote device. |
| 380 | * This is the normal operational state for a remote device. |
| 381 | */ |
| 382 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, |
| 383 | |
| 384 | /** |
| 385 | * This is the suspended state for the remote device. This is the state |
| 386 | * that the device is placed in when a RNC suspend is received by |
| 387 | * the SCU hardware. |
| 388 | */ |
| 389 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, |
| 390 | |
| 391 | /** |
| 392 | * This is the final state that the device is placed in before a change |
| 393 | * to the base state machine. |
| 394 | */ |
| 395 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, |
| 396 | |
| 397 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES |
| 398 | }; |
| 399 | |
| 400 | /** |
| 401 | * enum scic_sds_stp_remote_device_ready_substates - |
| 402 | * |
| 403 | * This is the enumeration for the struct scic_sds_remote_device ready substates |
| 404 | * for the STP remote device. |
| 405 | */ |
| 406 | enum scic_sds_stp_remote_device_ready_substates { |
| 407 | /** |
| 408 | * This is the idle substate for the stp remote device. When there are no |
| 409 | * active IO for the device it is is in this state. |
| 410 | */ |
| 411 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, |
| 412 | |
| 413 | /** |
| 414 | * This is the command state for for the STP remote device. This state is |
| 415 | * entered when the device is processing a non-NCQ command. The device object |
| 416 | * will fail any new start IO requests until this command is complete. |
| 417 | */ |
| 418 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, |
| 419 | |
| 420 | /** |
| 421 | * This is the NCQ state for the STP remote device. This state is entered |
| 422 | * when the device is processing an NCQ reuqest. It will remain in this state |
| 423 | * so long as there is one or more NCQ requests being processed. |
| 424 | */ |
| 425 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, |
| 426 | |
| 427 | /** |
| 428 | * This is the NCQ error state for the STP remote device. This state is |
| 429 | * entered when an SDB error FIS is received by the device object while in the |
| 430 | * NCQ state. The device object will only accept a READ LOG command while in |
| 431 | * this state. |
| 432 | */ |
| 433 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, |
| 434 | |
| 435 | #if !defined(DISABLE_ATAPI) |
| 436 | /** |
| 437 | * This is the ATAPI error state for the STP ATAPI remote device. This state is |
| 438 | * entered when ATAPI device sends error status FIS without data while the device |
| 439 | * object is in CMD state. A suspension event is expected in this state. The device |
| 440 | * object will resume right away. |
| 441 | */ |
| 442 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR, |
| 443 | #endif |
| 444 | |
| 445 | /** |
| 446 | * This is the READY substate indicates the device is waiting for the RESET task |
| 447 | * coming to be recovered from certain hardware specific error. |
| 448 | */ |
| 449 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, |
| 450 | }; |
| 451 | |
| 452 | /** |
| 453 | * enum scic_sds_smp_remote_device_ready_substates - |
| 454 | * |
| 455 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. |
| 456 | */ |
| 457 | enum scic_sds_smp_remote_device_ready_substates { |
| 458 | /** |
| 459 | * This is the ready operational substate for the remote device. This is the |
| 460 | * normal operational state for a remote device. |
| 461 | */ |
| 462 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, |
| 463 | |
| 464 | /** |
| 465 | * This is the suspended state for the remote device. This is the state that |
| 466 | * the device is placed in when a RNC suspend is received by the SCU hardware. |
| 467 | */ |
| 468 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, |
| 469 | }; |
| 470 | |
| 471 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) |
| 472 | { |
| 473 | struct scic_sds_remote_device *sci_dev; |
| 474 | |
| 475 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); |
| 476 | |
| 477 | return sci_dev; |
| 478 | } |
| 479 | |
| 480 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( |
| 481 | struct scic_sds_remote_device *device, |
| 482 | struct scic_sds_request *request); |
| 483 | |
| 484 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( |
| 485 | struct scic_sds_remote_device *device, |
| 486 | struct scic_sds_request *request, |
| 487 | void *, |
| 488 | enum sci_io_status); |
| 489 | |
| 490 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( |
| 491 | struct scic_sds_remote_device *sci_dev); |
| 492 | |
| 493 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( |
| 494 | struct scic_sds_remote_device *sci_dev, |
| 495 | u32 suspend_type); |
| 496 | |
| 497 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( |
| 498 | struct scic_sds_remote_device *sci_dev); |
| 499 | |
| 500 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( |
| 501 | struct scic_sds_remote_device *sci_dev, |
| 502 | u32 frame_index); |
| 503 | |
| 504 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( |
| 505 | struct scic_sds_remote_device *sci_dev, |
| 506 | u32 event_code); |
| 507 | |
| 508 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( |
| 509 | struct scic_sds_remote_device *sci_dev); |
| 510 | |
| 511 | /** |
| 512 | * struct scic_sds_remote_device_state_handler - This structure conains the |
| 513 | * state handlers that are needed to process requests for the SCU remote |
| 514 | * device objects. |
| 515 | * |
| 516 | * |
| 517 | */ |
| 518 | struct scic_sds_remote_device_state_handler { |
| 519 | /** |
| 520 | * The start_handler specifies the method invoked when a user |
| 521 | * attempts to start a remote device. |
| 522 | */ |
| 523 | scic_sds_remote_device_handler_t start_handler; |
| 524 | |
| 525 | /** |
| 526 | * The stop_handler specifies the method invoked when a user attempts to |
| 527 | * stop a remote device. |
| 528 | */ |
| 529 | scic_sds_remote_device_handler_t stop_handler; |
| 530 | |
| 531 | /** |
| 532 | * The fail_handler specifies the method invoked when a remote device |
| 533 | * failure has occurred. A failure may be due to an inability to |
| 534 | * initialize/configure the device. |
| 535 | */ |
| 536 | scic_sds_remote_device_handler_t fail_handler; |
| 537 | |
| 538 | /** |
| 539 | * The destruct_handler specifies the method invoked when attempting to |
| 540 | * destruct a remote device. |
| 541 | */ |
| 542 | scic_sds_remote_device_handler_t destruct_handler; |
| 543 | |
| 544 | /** |
| 545 | * The reset handler specifies the method invloked when requesting to |
| 546 | * reset a remote device. |
| 547 | */ |
| 548 | scic_sds_remote_device_handler_t reset_handler; |
| 549 | |
| 550 | /** |
| 551 | * The reset complete handler specifies the method invloked when |
| 552 | * reporting that a reset has completed to the remote device. |
| 553 | */ |
| 554 | scic_sds_remote_device_handler_t reset_complete_handler; |
| 555 | |
| 556 | /** |
| 557 | * The start_io_handler specifies the method invoked when a user |
| 558 | * attempts to start an IO request for a remote device. |
| 559 | */ |
| 560 | scic_sds_remote_device_request_handler_t start_io_handler; |
| 561 | |
| 562 | /** |
| 563 | * The complete_io_handler specifies the method invoked when a user |
| 564 | * attempts to complete an IO request for a remote device. |
| 565 | */ |
| 566 | scic_sds_remote_device_request_handler_t complete_io_handler; |
| 567 | |
| 568 | /** |
| 569 | * The continue_io_handler specifies the method invoked when a user |
| 570 | * attempts to continue an IO request for a remote device. |
| 571 | */ |
| 572 | scic_sds_remote_device_request_handler_t continue_io_handler; |
| 573 | |
| 574 | /** |
| 575 | * The start_task_handler specifies the method invoked when a user |
| 576 | * attempts to start a task management request for a remote device. |
| 577 | */ |
| 578 | scic_sds_remote_device_request_handler_t start_task_handler; |
| 579 | |
| 580 | /** |
| 581 | * The complete_task_handler specifies the method invoked when a user |
| 582 | * attempts to complete a task management request for a remote device. |
| 583 | */ |
| 584 | scic_sds_remote_device_request_handler_t complete_task_handler; |
| 585 | |
| 586 | |
| 587 | scic_sds_remote_device_suspend_handler_t suspend_handler; |
| 588 | scic_sds_remote_device_resume_handler_t resume_handler; |
| 589 | scic_sds_remote_device_event_handler_t event_handler; |
| 590 | scic_sds_remote_device_frame_handler_t frame_handler; |
| 591 | }; |
| 592 | |
| 593 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; |
| 594 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; |
| 595 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; |
| 596 | |
| 597 | /** |
| 598 | * scic_sds_remote_device_increment_request_count() - |
| 599 | * |
| 600 | * This macro incrments the request count for this device |
| 601 | */ |
| 602 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ |
| 603 | ((sci_dev)->started_request_count++) |
| 604 | |
| 605 | /** |
| 606 | * scic_sds_remote_device_decrement_request_count() - |
| 607 | * |
| 608 | * This macro decrements the request count for this device. This count will |
| 609 | * never decrment past 0. |
| 610 | */ |
| 611 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ |
| 612 | ((sci_dev)->started_request_count > 0 ? \ |
| 613 | (sci_dev)->started_request_count-- : 0) |
| 614 | |
| 615 | /** |
| 616 | * scic_sds_remote_device_get_request_count() - |
| 617 | * |
| 618 | * This is a helper macro to return the current device request count. |
| 619 | */ |
| 620 | #define scic_sds_remote_device_get_request_count(sci_dev) \ |
| 621 | ((sci_dev)->started_request_count) |
| 622 | |
| 623 | /** |
| 624 | * scic_sds_remote_device_get_port() - |
| 625 | * |
| 626 | * This macro returns the owning port of this remote device obejct. |
| 627 | */ |
| 628 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 629 | ((sci_dev)->owning_port) |
| 630 | |
| 631 | /** |
| 632 | * scic_sds_remote_device_get_controller() - |
| 633 | * |
| 634 | * This macro returns the controller object that contains this device object |
| 635 | */ |
| 636 | #define scic_sds_remote_device_get_controller(sci_dev) \ |
| 637 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) |
| 638 | |
| 639 | /** |
| 640 | * scic_sds_remote_device_set_state_handlers() - |
| 641 | * |
| 642 | * This macro sets the remote device state handlers pointer and is set on entry |
| 643 | * to each device state. |
| 644 | */ |
| 645 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ |
| 646 | ((sci_dev)->state_handlers = (handlers)) |
| 647 | |
| 648 | /** |
| 649 | * scic_sds_remote_device_get_port() - |
| 650 | * |
| 651 | * This macro returns the owning port of this device |
| 652 | */ |
| 653 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 654 | ((sci_dev)->owning_port) |
| 655 | |
| 656 | /** |
| 657 | * scic_sds_remote_device_get_sequence() - |
| 658 | * |
| 659 | * This macro returns the remote device sequence value |
| 660 | */ |
| 661 | #define scic_sds_remote_device_get_sequence(sci_dev) \ |
| 662 | (\ |
| 663 | scic_sds_remote_device_get_controller(sci_dev)-> \ |
| 664 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ |
| 665 | ) |
| 666 | |
| 667 | /** |
| 668 | * scic_sds_remote_device_get_controller_peg() - |
| 669 | * |
| 670 | * This macro returns the controllers protocol engine group |
| 671 | */ |
| 672 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ |
| 673 | (\ |
| 674 | scic_sds_controller_get_protocol_engine_group(\ |
| 675 | scic_sds_port_get_controller(\ |
| 676 | scic_sds_remote_device_get_port(sci_dev) \ |
| 677 | ) \ |
| 678 | ) \ |
| 679 | ) |
| 680 | |
| 681 | /** |
| 682 | * scic_sds_remote_device_get_port_index() - |
| 683 | * |
| 684 | * This macro returns the port index for the devices owning port |
| 685 | */ |
| 686 | #define scic_sds_remote_device_get_port_index(sci_dev) \ |
| 687 | (scic_sds_port_get_index(scic_sds_remote_device_get_port(sci_dev))) |
| 688 | |
| 689 | /** |
| 690 | * scic_sds_remote_device_get_index() - |
| 691 | * |
| 692 | * This macro returns the remote node index for this device object |
| 693 | */ |
| 694 | #define scic_sds_remote_device_get_index(sci_dev) \ |
| 695 | ((sci_dev)->rnc.remote_node_index) |
| 696 | |
| 697 | /** |
| 698 | * scic_sds_remote_device_build_command_context() - |
| 699 | * |
| 700 | * This macro builds a remote device context for the SCU post request operation |
| 701 | */ |
| 702 | #define scic_sds_remote_device_build_command_context(device, command) \ |
| 703 | ((command) \ |
| 704 | | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \ |
| 705 | | (scic_sds_remote_device_get_port_index((device)) << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ |
| 706 | | (scic_sds_remote_device_get_index((device))) \ |
| 707 | ) |
| 708 | |
| 709 | /** |
| 710 | * scic_sds_remote_device_set_working_request() - |
| 711 | * |
| 712 | * This macro makes the working request assingment for the remote device |
| 713 | * object. To clear the working request use this macro with a NULL request |
| 714 | * object. |
| 715 | */ |
| 716 | #define scic_sds_remote_device_set_working_request(device, request) \ |
| 717 | ((device)->working_request = (request)) |
| 718 | |
| 719 | enum sci_status scic_sds_remote_device_frame_handler( |
| 720 | struct scic_sds_remote_device *sci_dev, |
| 721 | u32 frame_index); |
| 722 | |
| 723 | enum sci_status scic_sds_remote_device_event_handler( |
| 724 | struct scic_sds_remote_device *sci_dev, |
| 725 | u32 event_code); |
| 726 | |
| 727 | enum sci_status scic_sds_remote_device_start_io( |
| 728 | struct scic_sds_controller *controller, |
| 729 | struct scic_sds_remote_device *sci_dev, |
| 730 | struct scic_sds_request *io_request); |
| 731 | |
| 732 | enum sci_status scic_sds_remote_device_complete_io( |
| 733 | struct scic_sds_controller *controller, |
| 734 | struct scic_sds_remote_device *sci_dev, |
| 735 | struct scic_sds_request *io_request); |
| 736 | |
| 737 | enum sci_status scic_sds_remote_device_resume( |
| 738 | struct scic_sds_remote_device *sci_dev); |
| 739 | |
| 740 | enum sci_status scic_sds_remote_device_suspend( |
| 741 | struct scic_sds_remote_device *sci_dev, |
| 742 | u32 suspend_type); |
| 743 | |
| 744 | enum sci_status scic_sds_remote_device_start_task( |
| 745 | struct scic_sds_controller *controller, |
| 746 | struct scic_sds_remote_device *sci_dev, |
| 747 | struct scic_sds_request *io_request); |
| 748 | |
| 749 | void scic_sds_remote_device_post_request( |
| 750 | struct scic_sds_remote_device *sci_dev, |
| 751 | u32 request); |
| 752 | |
| 753 | #if !defined(DISABLE_ATAPI) |
| 754 | bool scic_sds_remote_device_is_atapi( |
| 755 | struct scic_sds_remote_device *sci_dev); |
| 756 | #else /* !defined(DISABLE_ATAPI) */ |
| 757 | #define scic_sds_remote_device_is_atapi(sci_dev) false |
| 758 | #endif /* !defined(DISABLE_ATAPI) */ |
| 759 | |
| 760 | void scic_sds_remote_device_start_request( |
| 761 | struct scic_sds_remote_device *sci_dev, |
| 762 | struct scic_sds_request *sci_req, |
| 763 | enum sci_status status); |
| 764 | |
| 765 | void scic_sds_remote_device_continue_request(void *sci_dev); |
| 766 | |
| 767 | enum sci_status scic_sds_remote_device_default_start_handler( |
| 768 | struct scic_sds_remote_device *sci_dev); |
| 769 | |
| 770 | enum sci_status scic_sds_remote_device_default_fail_handler( |
| 771 | struct scic_sds_remote_device *sci_dev); |
| 772 | |
| 773 | enum sci_status scic_sds_remote_device_default_destruct_handler( |
| 774 | struct scic_sds_remote_device *sci_dev); |
| 775 | |
| 776 | enum sci_status scic_sds_remote_device_default_reset_handler( |
| 777 | struct scic_sds_remote_device *device); |
| 778 | |
| 779 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( |
| 780 | struct scic_sds_remote_device *device); |
| 781 | |
| 782 | enum sci_status scic_sds_remote_device_default_start_request_handler( |
| 783 | struct scic_sds_remote_device *device, |
| 784 | struct scic_sds_request *request); |
| 785 | |
| 786 | enum sci_status scic_sds_remote_device_default_complete_request_handler( |
| 787 | struct scic_sds_remote_device *device, |
| 788 | struct scic_sds_request *request); |
| 789 | |
| 790 | enum sci_status scic_sds_remote_device_default_continue_request_handler( |
| 791 | struct scic_sds_remote_device *device, |
| 792 | struct scic_sds_request *request); |
| 793 | |
| 794 | enum sci_status scic_sds_remote_device_default_suspend_handler( |
| 795 | struct scic_sds_remote_device *sci_dev, |
| 796 | u32 suspend_type); |
| 797 | |
| 798 | enum sci_status scic_sds_remote_device_default_resume_handler( |
| 799 | struct scic_sds_remote_device *sci_dev); |
| 800 | |
| 801 | |
| 802 | enum sci_status scic_sds_remote_device_default_frame_handler( |
| 803 | struct scic_sds_remote_device *sci_dev, |
| 804 | u32 frame_index); |
| 805 | |
| 806 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( |
| 807 | struct scic_sds_remote_device *device); |
| 808 | |
| 809 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( |
| 810 | struct scic_sds_remote_device *device); |
| 811 | |
| 812 | enum sci_status scic_sds_remote_device_general_frame_handler( |
| 813 | struct scic_sds_remote_device *sci_dev, |
| 814 | u32 frame_index); |
| 815 | |
| 816 | enum sci_status scic_sds_remote_device_general_event_handler( |
| 817 | struct scic_sds_remote_device *sci_dev, |
| 818 | u32 event_code); |
| 819 | |
| 820 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( |
| 821 | struct scic_sds_remote_device *sci_dev); |
| 822 | |
| 823 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 824 | |
| 825 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |