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, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 71 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | struct scic_sds_remote_device { |
| 75 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 76 | * This field contains the information for the base remote device state |
| 77 | * machine. |
| 78 | */ |
| 79 | struct sci_base_state_machine state_machine; |
| 80 | |
| 81 | /** |
| 82 | * This field is the programmed device port width. This value is |
| 83 | * written to the RCN data structure to tell the SCU how many open |
| 84 | * connections this device can have. |
| 85 | */ |
| 86 | u32 device_port_width; |
| 87 | |
| 88 | /** |
| 89 | * This field is the programmed connection rate for this remote device. It is |
| 90 | * used to program the TC with the maximum allowed connection rate. |
| 91 | */ |
| 92 | enum sas_linkrate connection_rate; |
| 93 | |
| 94 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 95 | * This filed is assinged the value of true if the device is directly |
| 96 | * attached to the port. |
| 97 | */ |
| 98 | bool is_direct_attached; |
| 99 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 100 | /** |
| 101 | * This filed contains a pointer back to the port to which this device |
| 102 | * is assigned. |
| 103 | */ |
| 104 | struct scic_sds_port *owning_port; |
| 105 | |
| 106 | /** |
| 107 | * This field contains the SCU silicon remote node context specific |
| 108 | * information. |
| 109 | */ |
| 110 | struct scic_sds_remote_node_context rnc; |
| 111 | |
| 112 | /** |
| 113 | * This field contains the stated request count for the remote device. The |
| 114 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all |
| 115 | * requests are complete and the rnc_posted value is false. |
| 116 | */ |
| 117 | u32 started_request_count; |
| 118 | |
| 119 | /** |
| 120 | * This field contains a pointer to the working request object. It is only |
| 121 | * used only for SATA requests since the unsolicited frames we get from the |
| 122 | * hardware have no Tag value to look up the io request object. |
| 123 | */ |
| 124 | struct scic_sds_request *working_request; |
| 125 | |
| 126 | /** |
| 127 | * This field contains the reason for the remote device going not_ready. It is |
| 128 | * assigned in the state handlers and used in the state transition. |
| 129 | */ |
| 130 | u32 not_ready_reason; |
| 131 | |
| 132 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 133 | * This field maintains the set of state handlers for the remote device |
| 134 | * object. These are changed each time the remote device enters a new state. |
| 135 | */ |
| 136 | const struct scic_sds_remote_device_state_handler *state_handlers; |
| 137 | }; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 138 | |
| 139 | struct isci_remote_device { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 140 | enum isci_status status; |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 141 | #define IDEV_START_PENDING 0 |
| 142 | #define IDEV_STOP_PENDING 1 |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 143 | #define IDEV_ALLOCATED 2 |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 144 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 145 | struct isci_port *isci_port; |
| 146 | struct domain_device *domain_dev; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 147 | struct list_head node; |
| 148 | struct list_head reqs_in_process; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 149 | spinlock_t state_lock; |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 150 | struct scic_sds_remote_device sci; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 153 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
| 154 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 155 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
| 156 | struct isci_remote_device *idev); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 157 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
| 158 | struct isci_remote_device *idev); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 159 | void isci_remote_device_gone(struct domain_device *domain_dev); |
| 160 | int isci_remote_device_found(struct domain_device *domain_dev); |
| 161 | bool isci_device_is_reset_pending(struct isci_host *ihost, |
| 162 | struct isci_remote_device *idev); |
| 163 | void isci_device_clear_reset_pending(struct isci_host *ihost, |
| 164 | struct isci_remote_device *idev); |
| 165 | void isci_remote_device_change_state(struct isci_remote_device *idev, |
| 166 | enum isci_status status); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 167 | /** |
| 168 | * scic_remote_device_stop() - This method will stop both transmission and |
| 169 | * reception of link activity for the supplied remote device. This method |
| 170 | * disables normal IO requests from flowing through to the remote device. |
| 171 | * @remote_device: This parameter specifies the device to be stopped. |
| 172 | * @timeout: This parameter specifies the number of milliseconds in which the |
| 173 | * stop operation should complete. |
| 174 | * |
| 175 | * An indication of whether the device was successfully stopped. SCI_SUCCESS |
| 176 | * This value is returned if the transmission and reception for the device was |
| 177 | * successfully stopped. |
| 178 | */ |
| 179 | enum sci_status scic_remote_device_stop( |
| 180 | struct scic_sds_remote_device *remote_device, |
| 181 | u32 timeout); |
| 182 | |
| 183 | /** |
| 184 | * scic_remote_device_reset() - This method will reset the device making it |
| 185 | * ready for operation. This method must be called anytime the device is |
| 186 | * reset either through a SMP phy control or a port hard reset request. |
| 187 | * @remote_device: This parameter specifies the device to be reset. |
| 188 | * |
| 189 | * This method does not actually cause the device hardware to be reset. This |
| 190 | * method resets the software object so that it will be operational after a |
| 191 | * device hardware reset completes. An indication of whether the device reset |
| 192 | * was accepted. SCI_SUCCESS This value is returned if the device reset is |
| 193 | * started. |
| 194 | */ |
| 195 | enum sci_status scic_remote_device_reset( |
| 196 | struct scic_sds_remote_device *remote_device); |
| 197 | |
| 198 | /** |
| 199 | * scic_remote_device_reset_complete() - This method informs the device object |
| 200 | * that the reset operation is complete and the device can resume operation |
| 201 | * again. |
| 202 | * @remote_device: This parameter specifies the device which is to be informed |
| 203 | * of the reset complete operation. |
| 204 | * |
| 205 | * An indication that the device is resuming operation. SCI_SUCCESS the device |
| 206 | * is resuming operation. |
| 207 | */ |
| 208 | enum sci_status scic_remote_device_reset_complete( |
| 209 | struct scic_sds_remote_device *remote_device); |
| 210 | |
| 211 | |
| 212 | |
| 213 | /** |
| 214 | * scic_remote_device_get_connection_rate() - This method simply returns the |
| 215 | * link rate at which communications to the remote device occur. |
| 216 | * @remote_device: This parameter specifies the device for which to get the |
| 217 | * connection rate. |
| 218 | * |
| 219 | * Return the link rate at which we transfer for the supplied remote device. |
| 220 | */ |
| 221 | enum sas_linkrate scic_remote_device_get_connection_rate( |
| 222 | struct scic_sds_remote_device *remote_device); |
| 223 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 224 | #define scic_remote_device_is_atapi(device_handle) false |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 225 | |
| 226 | /** |
| 227 | * enum scic_sds_remote_device_states - This enumeration depicts all the states |
| 228 | * for the common remote device state machine. |
| 229 | * |
| 230 | * |
| 231 | */ |
| 232 | enum scic_sds_remote_device_states { |
| 233 | /** |
| 234 | * Simply the initial state for the base remote device state machine. |
| 235 | */ |
| 236 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, |
| 237 | |
| 238 | /** |
| 239 | * This state indicates that the remote device has successfully been |
| 240 | * stopped. In this state no new IO operations are permitted. |
| 241 | * This state is entered from the INITIAL state. |
| 242 | * This state is entered from the STOPPING state. |
| 243 | */ |
| 244 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, |
| 245 | |
| 246 | /** |
| 247 | * This state indicates the the remote device is in the process of |
| 248 | * becoming ready (i.e. starting). In this state no new IO operations |
| 249 | * are permitted. |
| 250 | * This state is entered from the STOPPED state. |
| 251 | */ |
| 252 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, |
| 253 | |
| 254 | /** |
| 255 | * This state indicates the remote device is now ready. Thus, the user |
| 256 | * is able to perform IO operations on the remote device. |
| 257 | * This state is entered from the STARTING state. |
| 258 | */ |
| 259 | SCI_BASE_REMOTE_DEVICE_STATE_READY, |
| 260 | |
| 261 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 262 | * This is the idle substate for the stp remote device. When there are no |
| 263 | * active IO for the device it is is in this state. |
| 264 | */ |
| 265 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, |
| 266 | |
| 267 | /** |
| 268 | * This is the command state for for the STP remote device. This state is |
| 269 | * entered when the device is processing a non-NCQ command. The device object |
| 270 | * will fail any new start IO requests until this command is complete. |
| 271 | */ |
| 272 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, |
| 273 | |
| 274 | /** |
| 275 | * This is the NCQ state for the STP remote device. This state is entered |
| 276 | * when the device is processing an NCQ reuqest. It will remain in this state |
| 277 | * so long as there is one or more NCQ requests being processed. |
| 278 | */ |
| 279 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, |
| 280 | |
| 281 | /** |
| 282 | * This is the NCQ error state for the STP remote device. This state is |
| 283 | * entered when an SDB error FIS is received by the device object while in the |
| 284 | * NCQ state. The device object will only accept a READ LOG command while in |
| 285 | * this state. |
| 286 | */ |
| 287 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, |
| 288 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 289 | /** |
| 290 | * This is the READY substate indicates the device is waiting for the RESET task |
| 291 | * coming to be recovered from certain hardware specific error. |
| 292 | */ |
| 293 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 294 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 295 | /** |
| 296 | * This is the ready operational substate for the remote device. This is the |
| 297 | * normal operational state for a remote device. |
| 298 | */ |
| 299 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, |
| 300 | |
| 301 | /** |
| 302 | * This is the suspended state for the remote device. This is the state that |
| 303 | * the device is placed in when a RNC suspend is received by the SCU hardware. |
| 304 | */ |
| 305 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame^] | 306 | |
| 307 | /** |
| 308 | * This state indicates that the remote device is in the process of |
| 309 | * stopping. In this state no new IO operations are permitted, but |
| 310 | * existing IO operations are allowed to complete. |
| 311 | * This state is entered from the READY state. |
| 312 | * This state is entered from the FAILED state. |
| 313 | */ |
| 314 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, |
| 315 | |
| 316 | /** |
| 317 | * This state indicates that the remote device has failed. |
| 318 | * In this state no new IO operations are permitted. |
| 319 | * This state is entered from the INITIALIZING state. |
| 320 | * This state is entered from the READY state. |
| 321 | */ |
| 322 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, |
| 323 | |
| 324 | /** |
| 325 | * This state indicates the device is being reset. |
| 326 | * In this state no new IO operations are permitted. |
| 327 | * This state is entered from the READY state. |
| 328 | */ |
| 329 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, |
| 330 | |
| 331 | /** |
| 332 | * Simply the final state for the base remote device state machine. |
| 333 | */ |
| 334 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) |
| 338 | { |
| 339 | struct scic_sds_remote_device *sci_dev; |
| 340 | |
| 341 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); |
| 342 | |
| 343 | return sci_dev; |
| 344 | } |
| 345 | |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 346 | static inline struct isci_remote_device *sci_dev_to_idev(struct scic_sds_remote_device *sci_dev) |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 347 | { |
| 348 | struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci); |
| 349 | |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 350 | return idev; |
| 351 | } |
| 352 | |
| 353 | static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev) |
| 354 | { |
| 355 | return sci_dev_to_idev(sci_dev)->domain_dev; |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | static inline bool dev_is_expander(struct domain_device *dev) |
| 359 | { |
| 360 | return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; |
| 361 | } |
| 362 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 363 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( |
| 364 | struct scic_sds_remote_device *device, |
| 365 | struct scic_sds_request *request); |
| 366 | |
| 367 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( |
| 368 | struct scic_sds_remote_device *device, |
| 369 | struct scic_sds_request *request, |
| 370 | void *, |
| 371 | enum sci_io_status); |
| 372 | |
| 373 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( |
| 374 | struct scic_sds_remote_device *sci_dev); |
| 375 | |
| 376 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( |
| 377 | struct scic_sds_remote_device *sci_dev, |
| 378 | u32 suspend_type); |
| 379 | |
| 380 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( |
| 381 | struct scic_sds_remote_device *sci_dev); |
| 382 | |
| 383 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( |
| 384 | struct scic_sds_remote_device *sci_dev, |
| 385 | u32 frame_index); |
| 386 | |
| 387 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( |
| 388 | struct scic_sds_remote_device *sci_dev, |
| 389 | u32 event_code); |
| 390 | |
| 391 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( |
| 392 | struct scic_sds_remote_device *sci_dev); |
| 393 | |
| 394 | /** |
| 395 | * struct scic_sds_remote_device_state_handler - This structure conains the |
| 396 | * state handlers that are needed to process requests for the SCU remote |
| 397 | * device objects. |
| 398 | * |
| 399 | * |
| 400 | */ |
| 401 | struct scic_sds_remote_device_state_handler { |
| 402 | /** |
| 403 | * The start_handler specifies the method invoked when a user |
| 404 | * attempts to start a remote device. |
| 405 | */ |
| 406 | scic_sds_remote_device_handler_t start_handler; |
| 407 | |
| 408 | /** |
| 409 | * The stop_handler specifies the method invoked when a user attempts to |
| 410 | * stop a remote device. |
| 411 | */ |
| 412 | scic_sds_remote_device_handler_t stop_handler; |
| 413 | |
| 414 | /** |
| 415 | * The fail_handler specifies the method invoked when a remote device |
| 416 | * failure has occurred. A failure may be due to an inability to |
| 417 | * initialize/configure the device. |
| 418 | */ |
| 419 | scic_sds_remote_device_handler_t fail_handler; |
| 420 | |
| 421 | /** |
| 422 | * The destruct_handler specifies the method invoked when attempting to |
| 423 | * destruct a remote device. |
| 424 | */ |
| 425 | scic_sds_remote_device_handler_t destruct_handler; |
| 426 | |
| 427 | /** |
| 428 | * The reset handler specifies the method invloked when requesting to |
| 429 | * reset a remote device. |
| 430 | */ |
| 431 | scic_sds_remote_device_handler_t reset_handler; |
| 432 | |
| 433 | /** |
| 434 | * The reset complete handler specifies the method invloked when |
| 435 | * reporting that a reset has completed to the remote device. |
| 436 | */ |
| 437 | scic_sds_remote_device_handler_t reset_complete_handler; |
| 438 | |
| 439 | /** |
| 440 | * The start_io_handler specifies the method invoked when a user |
| 441 | * attempts to start an IO request for a remote device. |
| 442 | */ |
| 443 | scic_sds_remote_device_request_handler_t start_io_handler; |
| 444 | |
| 445 | /** |
| 446 | * The complete_io_handler specifies the method invoked when a user |
| 447 | * attempts to complete an IO request for a remote device. |
| 448 | */ |
| 449 | scic_sds_remote_device_request_handler_t complete_io_handler; |
| 450 | |
| 451 | /** |
| 452 | * The continue_io_handler specifies the method invoked when a user |
| 453 | * attempts to continue an IO request for a remote device. |
| 454 | */ |
| 455 | scic_sds_remote_device_request_handler_t continue_io_handler; |
| 456 | |
| 457 | /** |
| 458 | * The start_task_handler specifies the method invoked when a user |
| 459 | * attempts to start a task management request for a remote device. |
| 460 | */ |
| 461 | scic_sds_remote_device_request_handler_t start_task_handler; |
| 462 | |
| 463 | /** |
| 464 | * The complete_task_handler specifies the method invoked when a user |
| 465 | * attempts to complete a task management request for a remote device. |
| 466 | */ |
| 467 | scic_sds_remote_device_request_handler_t complete_task_handler; |
| 468 | |
| 469 | |
| 470 | scic_sds_remote_device_suspend_handler_t suspend_handler; |
| 471 | scic_sds_remote_device_resume_handler_t resume_handler; |
| 472 | scic_sds_remote_device_event_handler_t event_handler; |
| 473 | scic_sds_remote_device_frame_handler_t frame_handler; |
| 474 | }; |
| 475 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 476 | /** |
| 477 | * scic_sds_remote_device_increment_request_count() - |
| 478 | * |
| 479 | * This macro incrments the request count for this device |
| 480 | */ |
| 481 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ |
| 482 | ((sci_dev)->started_request_count++) |
| 483 | |
| 484 | /** |
| 485 | * scic_sds_remote_device_decrement_request_count() - |
| 486 | * |
| 487 | * This macro decrements the request count for this device. This count will |
| 488 | * never decrment past 0. |
| 489 | */ |
| 490 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ |
| 491 | ((sci_dev)->started_request_count > 0 ? \ |
| 492 | (sci_dev)->started_request_count-- : 0) |
| 493 | |
| 494 | /** |
| 495 | * scic_sds_remote_device_get_request_count() - |
| 496 | * |
| 497 | * This is a helper macro to return the current device request count. |
| 498 | */ |
| 499 | #define scic_sds_remote_device_get_request_count(sci_dev) \ |
| 500 | ((sci_dev)->started_request_count) |
| 501 | |
| 502 | /** |
| 503 | * scic_sds_remote_device_get_port() - |
| 504 | * |
| 505 | * This macro returns the owning port of this remote device obejct. |
| 506 | */ |
| 507 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 508 | ((sci_dev)->owning_port) |
| 509 | |
| 510 | /** |
| 511 | * scic_sds_remote_device_get_controller() - |
| 512 | * |
| 513 | * This macro returns the controller object that contains this device object |
| 514 | */ |
| 515 | #define scic_sds_remote_device_get_controller(sci_dev) \ |
| 516 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) |
| 517 | |
| 518 | /** |
| 519 | * scic_sds_remote_device_set_state_handlers() - |
| 520 | * |
| 521 | * This macro sets the remote device state handlers pointer and is set on entry |
| 522 | * to each device state. |
| 523 | */ |
| 524 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ |
| 525 | ((sci_dev)->state_handlers = (handlers)) |
| 526 | |
| 527 | /** |
| 528 | * scic_sds_remote_device_get_port() - |
| 529 | * |
| 530 | * This macro returns the owning port of this device |
| 531 | */ |
| 532 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 533 | ((sci_dev)->owning_port) |
| 534 | |
| 535 | /** |
| 536 | * scic_sds_remote_device_get_sequence() - |
| 537 | * |
| 538 | * This macro returns the remote device sequence value |
| 539 | */ |
| 540 | #define scic_sds_remote_device_get_sequence(sci_dev) \ |
| 541 | (\ |
| 542 | scic_sds_remote_device_get_controller(sci_dev)-> \ |
| 543 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ |
| 544 | ) |
| 545 | |
| 546 | /** |
| 547 | * scic_sds_remote_device_get_controller_peg() - |
| 548 | * |
| 549 | * This macro returns the controllers protocol engine group |
| 550 | */ |
| 551 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ |
| 552 | (\ |
| 553 | scic_sds_controller_get_protocol_engine_group(\ |
| 554 | scic_sds_port_get_controller(\ |
| 555 | scic_sds_remote_device_get_port(sci_dev) \ |
| 556 | ) \ |
| 557 | ) \ |
| 558 | ) |
| 559 | |
| 560 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 561 | * scic_sds_remote_device_get_index() - |
| 562 | * |
| 563 | * This macro returns the remote node index for this device object |
| 564 | */ |
| 565 | #define scic_sds_remote_device_get_index(sci_dev) \ |
| 566 | ((sci_dev)->rnc.remote_node_index) |
| 567 | |
| 568 | /** |
| 569 | * scic_sds_remote_device_build_command_context() - |
| 570 | * |
| 571 | * This macro builds a remote device context for the SCU post request operation |
| 572 | */ |
| 573 | #define scic_sds_remote_device_build_command_context(device, command) \ |
| 574 | ((command) \ |
| 575 | | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \ |
Dan Williams | 1f4fa1f | 2011-04-26 11:44:06 -0700 | [diff] [blame] | 576 | | ((device)->owning_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 577 | | (scic_sds_remote_device_get_index((device))) \ |
| 578 | ) |
| 579 | |
| 580 | /** |
| 581 | * scic_sds_remote_device_set_working_request() - |
| 582 | * |
| 583 | * This macro makes the working request assingment for the remote device |
| 584 | * object. To clear the working request use this macro with a NULL request |
| 585 | * object. |
| 586 | */ |
| 587 | #define scic_sds_remote_device_set_working_request(device, request) \ |
| 588 | ((device)->working_request = (request)) |
| 589 | |
| 590 | enum sci_status scic_sds_remote_device_frame_handler( |
| 591 | struct scic_sds_remote_device *sci_dev, |
| 592 | u32 frame_index); |
| 593 | |
| 594 | enum sci_status scic_sds_remote_device_event_handler( |
| 595 | struct scic_sds_remote_device *sci_dev, |
| 596 | u32 event_code); |
| 597 | |
| 598 | enum sci_status scic_sds_remote_device_start_io( |
| 599 | struct scic_sds_controller *controller, |
| 600 | struct scic_sds_remote_device *sci_dev, |
| 601 | struct scic_sds_request *io_request); |
| 602 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame^] | 603 | enum sci_status scic_sds_remote_device_start_task( |
| 604 | struct scic_sds_controller *controller, |
| 605 | struct scic_sds_remote_device *sci_dev, |
| 606 | struct scic_sds_request *io_request); |
| 607 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 608 | enum sci_status scic_sds_remote_device_complete_io( |
| 609 | struct scic_sds_controller *controller, |
| 610 | struct scic_sds_remote_device *sci_dev, |
| 611 | struct scic_sds_request *io_request); |
| 612 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 613 | enum sci_status scic_sds_remote_device_suspend( |
| 614 | struct scic_sds_remote_device *sci_dev, |
| 615 | u32 suspend_type); |
| 616 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 617 | void scic_sds_remote_device_post_request( |
| 618 | struct scic_sds_remote_device *sci_dev, |
| 619 | u32 request); |
| 620 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 621 | #define scic_sds_remote_device_is_atapi(sci_dev) false |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 622 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 623 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |