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> |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 59 | #include "scu_remote_node_context.h" |
| 60 | #include "remote_node_context.h" |
| 61 | #include "port.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 62 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 63 | enum scic_remote_device_not_ready_reason_code { |
| 64 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, |
| 65 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, |
| 66 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, |
| 67 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, |
| 68 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 69 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | struct scic_sds_remote_device { |
| 73 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 74 | * This field contains the information for the base remote device state |
| 75 | * machine. |
| 76 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 77 | struct sci_base_state_machine sm; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * This field is the programmed device port width. This value is |
| 81 | * written to the RCN data structure to tell the SCU how many open |
| 82 | * connections this device can have. |
| 83 | */ |
| 84 | u32 device_port_width; |
| 85 | |
| 86 | /** |
| 87 | * This field is the programmed connection rate for this remote device. It is |
| 88 | * used to program the TC with the maximum allowed connection rate. |
| 89 | */ |
| 90 | enum sas_linkrate connection_rate; |
| 91 | |
| 92 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 93 | * This filed is assinged the value of true if the device is directly |
| 94 | * attached to the port. |
| 95 | */ |
| 96 | bool is_direct_attached; |
| 97 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 98 | /** |
| 99 | * This filed contains a pointer back to the port to which this device |
| 100 | * is assigned. |
| 101 | */ |
| 102 | struct scic_sds_port *owning_port; |
| 103 | |
| 104 | /** |
| 105 | * This field contains the SCU silicon remote node context specific |
| 106 | * information. |
| 107 | */ |
| 108 | struct scic_sds_remote_node_context rnc; |
| 109 | |
| 110 | /** |
| 111 | * This field contains the stated request count for the remote device. The |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 112 | * device can not reach the SCI_DEV_STOPPED until all |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 113 | * requests are complete and the rnc_posted value is false. |
| 114 | */ |
| 115 | u32 started_request_count; |
| 116 | |
| 117 | /** |
| 118 | * This field contains a pointer to the working request object. It is only |
| 119 | * used only for SATA requests since the unsolicited frames we get from the |
| 120 | * hardware have no Tag value to look up the io request object. |
| 121 | */ |
| 122 | struct scic_sds_request *working_request; |
| 123 | |
| 124 | /** |
| 125 | * This field contains the reason for the remote device going not_ready. It is |
| 126 | * assigned in the state handlers and used in the state transition. |
| 127 | */ |
| 128 | u32 not_ready_reason; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 129 | }; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 130 | |
| 131 | struct isci_remote_device { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 132 | enum isci_status status; |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 133 | #define IDEV_START_PENDING 0 |
| 134 | #define IDEV_STOP_PENDING 1 |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 135 | #define IDEV_ALLOCATED 2 |
Dan Williams | d06b487 | 2011-05-02 13:59:25 -0700 | [diff] [blame] | 136 | #define IDEV_EH 3 |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 137 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 138 | struct isci_port *isci_port; |
| 139 | struct domain_device *domain_dev; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 140 | struct list_head node; |
| 141 | struct list_head reqs_in_process; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 142 | spinlock_t state_lock; |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 143 | struct scic_sds_remote_device sci; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 146 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
| 147 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 148 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
| 149 | struct isci_remote_device *idev); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 150 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
| 151 | struct isci_remote_device *idev); |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 152 | void isci_remote_device_gone(struct domain_device *domain_dev); |
| 153 | int isci_remote_device_found(struct domain_device *domain_dev); |
| 154 | bool isci_device_is_reset_pending(struct isci_host *ihost, |
| 155 | struct isci_remote_device *idev); |
| 156 | void isci_device_clear_reset_pending(struct isci_host *ihost, |
| 157 | struct isci_remote_device *idev); |
| 158 | void isci_remote_device_change_state(struct isci_remote_device *idev, |
| 159 | enum isci_status status); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 160 | /** |
| 161 | * scic_remote_device_stop() - This method will stop both transmission and |
| 162 | * reception of link activity for the supplied remote device. This method |
| 163 | * disables normal IO requests from flowing through to the remote device. |
| 164 | * @remote_device: This parameter specifies the device to be stopped. |
| 165 | * @timeout: This parameter specifies the number of milliseconds in which the |
| 166 | * stop operation should complete. |
| 167 | * |
| 168 | * An indication of whether the device was successfully stopped. SCI_SUCCESS |
| 169 | * This value is returned if the transmission and reception for the device was |
| 170 | * successfully stopped. |
| 171 | */ |
| 172 | enum sci_status scic_remote_device_stop( |
| 173 | struct scic_sds_remote_device *remote_device, |
| 174 | u32 timeout); |
| 175 | |
| 176 | /** |
| 177 | * scic_remote_device_reset() - This method will reset the device making it |
| 178 | * ready for operation. This method must be called anytime the device is |
| 179 | * reset either through a SMP phy control or a port hard reset request. |
| 180 | * @remote_device: This parameter specifies the device to be reset. |
| 181 | * |
| 182 | * This method does not actually cause the device hardware to be reset. This |
| 183 | * method resets the software object so that it will be operational after a |
| 184 | * device hardware reset completes. An indication of whether the device reset |
| 185 | * was accepted. SCI_SUCCESS This value is returned if the device reset is |
| 186 | * started. |
| 187 | */ |
| 188 | enum sci_status scic_remote_device_reset( |
| 189 | struct scic_sds_remote_device *remote_device); |
| 190 | |
| 191 | /** |
| 192 | * scic_remote_device_reset_complete() - This method informs the device object |
| 193 | * that the reset operation is complete and the device can resume operation |
| 194 | * again. |
| 195 | * @remote_device: This parameter specifies the device which is to be informed |
| 196 | * of the reset complete operation. |
| 197 | * |
| 198 | * An indication that the device is resuming operation. SCI_SUCCESS the device |
| 199 | * is resuming operation. |
| 200 | */ |
| 201 | enum sci_status scic_remote_device_reset_complete( |
| 202 | struct scic_sds_remote_device *remote_device); |
| 203 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 204 | #define scic_remote_device_is_atapi(device_handle) false |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 205 | |
| 206 | /** |
| 207 | * enum scic_sds_remote_device_states - This enumeration depicts all the states |
| 208 | * for the common remote device state machine. |
| 209 | * |
| 210 | * |
| 211 | */ |
| 212 | enum scic_sds_remote_device_states { |
| 213 | /** |
| 214 | * Simply the initial state for the base remote device state machine. |
| 215 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 216 | SCI_DEV_INITIAL, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * This state indicates that the remote device has successfully been |
| 220 | * stopped. In this state no new IO operations are permitted. |
| 221 | * This state is entered from the INITIAL state. |
| 222 | * This state is entered from the STOPPING state. |
| 223 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 224 | SCI_DEV_STOPPED, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 225 | |
| 226 | /** |
| 227 | * This state indicates the the remote device is in the process of |
| 228 | * becoming ready (i.e. starting). In this state no new IO operations |
| 229 | * are permitted. |
| 230 | * This state is entered from the STOPPED state. |
| 231 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 232 | SCI_DEV_STARTING, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 233 | |
| 234 | /** |
| 235 | * This state indicates the remote device is now ready. Thus, the user |
| 236 | * is able to perform IO operations on the remote device. |
| 237 | * This state is entered from the STARTING state. |
| 238 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 239 | SCI_DEV_READY, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 240 | |
| 241 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 242 | * This is the idle substate for the stp remote device. When there are no |
| 243 | * active IO for the device it is is in this state. |
| 244 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 245 | SCI_STP_DEV_IDLE, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 246 | |
| 247 | /** |
| 248 | * This is the command state for for the STP remote device. This state is |
| 249 | * entered when the device is processing a non-NCQ command. The device object |
| 250 | * will fail any new start IO requests until this command is complete. |
| 251 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 252 | SCI_STP_DEV_CMD, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * This is the NCQ state for the STP remote device. This state is entered |
| 256 | * when the device is processing an NCQ reuqest. It will remain in this state |
| 257 | * so long as there is one or more NCQ requests being processed. |
| 258 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 259 | SCI_STP_DEV_NCQ, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 260 | |
| 261 | /** |
| 262 | * This is the NCQ error state for the STP remote device. This state is |
| 263 | * entered when an SDB error FIS is received by the device object while in the |
| 264 | * NCQ state. The device object will only accept a READ LOG command while in |
| 265 | * this state. |
| 266 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 267 | SCI_STP_DEV_NCQ_ERROR, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 268 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 269 | /** |
| 270 | * This is the READY substate indicates the device is waiting for the RESET task |
| 271 | * coming to be recovered from certain hardware specific error. |
| 272 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 273 | SCI_STP_DEV_AWAIT_RESET, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 274 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 275 | /** |
| 276 | * This is the ready operational substate for the remote device. This is the |
| 277 | * normal operational state for a remote device. |
| 278 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 279 | SCI_SMP_DEV_IDLE, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 280 | |
| 281 | /** |
| 282 | * This is the suspended state for the remote device. This is the state that |
| 283 | * the device is placed in when a RNC suspend is received by the SCU hardware. |
| 284 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 285 | SCI_SMP_DEV_CMD, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 286 | |
| 287 | /** |
| 288 | * This state indicates that the remote device is in the process of |
| 289 | * stopping. In this state no new IO operations are permitted, but |
| 290 | * existing IO operations are allowed to complete. |
| 291 | * This state is entered from the READY state. |
| 292 | * This state is entered from the FAILED state. |
| 293 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 294 | SCI_DEV_STOPPING, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * This state indicates that the remote device has failed. |
| 298 | * In this state no new IO operations are permitted. |
| 299 | * This state is entered from the INITIALIZING state. |
| 300 | * This state is entered from the READY state. |
| 301 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 302 | SCI_DEV_FAILED, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 303 | |
| 304 | /** |
| 305 | * This state indicates the device is being reset. |
| 306 | * In this state no new IO operations are permitted. |
| 307 | * This state is entered from the READY state. |
| 308 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 309 | SCI_DEV_RESETTING, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 310 | |
| 311 | /** |
| 312 | * Simply the final state for the base remote device state machine. |
| 313 | */ |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame^] | 314 | SCI_DEV_FINAL, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) |
| 318 | { |
| 319 | struct scic_sds_remote_device *sci_dev; |
| 320 | |
| 321 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); |
| 322 | |
| 323 | return sci_dev; |
| 324 | } |
| 325 | |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 326 | 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] | 327 | { |
| 328 | struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci); |
| 329 | |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 330 | return idev; |
| 331 | } |
| 332 | |
| 333 | static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev) |
| 334 | { |
| 335 | return sci_dev_to_idev(sci_dev)->domain_dev; |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | static inline bool dev_is_expander(struct domain_device *dev) |
| 339 | { |
| 340 | return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; |
| 341 | } |
| 342 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 343 | /** |
| 344 | * scic_sds_remote_device_increment_request_count() - |
| 345 | * |
| 346 | * This macro incrments the request count for this device |
| 347 | */ |
| 348 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ |
| 349 | ((sci_dev)->started_request_count++) |
| 350 | |
| 351 | /** |
| 352 | * scic_sds_remote_device_decrement_request_count() - |
| 353 | * |
| 354 | * This macro decrements the request count for this device. This count will |
| 355 | * never decrment past 0. |
| 356 | */ |
| 357 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ |
| 358 | ((sci_dev)->started_request_count > 0 ? \ |
| 359 | (sci_dev)->started_request_count-- : 0) |
| 360 | |
| 361 | /** |
| 362 | * scic_sds_remote_device_get_request_count() - |
| 363 | * |
| 364 | * This is a helper macro to return the current device request count. |
| 365 | */ |
| 366 | #define scic_sds_remote_device_get_request_count(sci_dev) \ |
| 367 | ((sci_dev)->started_request_count) |
| 368 | |
| 369 | /** |
| 370 | * scic_sds_remote_device_get_port() - |
| 371 | * |
| 372 | * This macro returns the owning port of this remote device obejct. |
| 373 | */ |
| 374 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 375 | ((sci_dev)->owning_port) |
| 376 | |
| 377 | /** |
| 378 | * scic_sds_remote_device_get_controller() - |
| 379 | * |
| 380 | * This macro returns the controller object that contains this device object |
| 381 | */ |
| 382 | #define scic_sds_remote_device_get_controller(sci_dev) \ |
| 383 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) |
| 384 | |
| 385 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 386 | * scic_sds_remote_device_get_port() - |
| 387 | * |
| 388 | * This macro returns the owning port of this device |
| 389 | */ |
| 390 | #define scic_sds_remote_device_get_port(sci_dev) \ |
| 391 | ((sci_dev)->owning_port) |
| 392 | |
| 393 | /** |
| 394 | * scic_sds_remote_device_get_sequence() - |
| 395 | * |
| 396 | * This macro returns the remote device sequence value |
| 397 | */ |
| 398 | #define scic_sds_remote_device_get_sequence(sci_dev) \ |
| 399 | (\ |
| 400 | scic_sds_remote_device_get_controller(sci_dev)-> \ |
| 401 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ |
| 402 | ) |
| 403 | |
| 404 | /** |
| 405 | * scic_sds_remote_device_get_controller_peg() - |
| 406 | * |
| 407 | * This macro returns the controllers protocol engine group |
| 408 | */ |
| 409 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ |
| 410 | (\ |
| 411 | scic_sds_controller_get_protocol_engine_group(\ |
| 412 | scic_sds_port_get_controller(\ |
| 413 | scic_sds_remote_device_get_port(sci_dev) \ |
| 414 | ) \ |
| 415 | ) \ |
| 416 | ) |
| 417 | |
| 418 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 419 | * scic_sds_remote_device_get_index() - |
| 420 | * |
| 421 | * This macro returns the remote node index for this device object |
| 422 | */ |
| 423 | #define scic_sds_remote_device_get_index(sci_dev) \ |
| 424 | ((sci_dev)->rnc.remote_node_index) |
| 425 | |
| 426 | /** |
| 427 | * scic_sds_remote_device_build_command_context() - |
| 428 | * |
| 429 | * This macro builds a remote device context for the SCU post request operation |
| 430 | */ |
| 431 | #define scic_sds_remote_device_build_command_context(device, command) \ |
| 432 | ((command) \ |
| 433 | | (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] | 434 | | ((device)->owning_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 435 | | (scic_sds_remote_device_get_index((device))) \ |
| 436 | ) |
| 437 | |
| 438 | /** |
| 439 | * scic_sds_remote_device_set_working_request() - |
| 440 | * |
| 441 | * This macro makes the working request assingment for the remote device |
| 442 | * object. To clear the working request use this macro with a NULL request |
| 443 | * object. |
| 444 | */ |
| 445 | #define scic_sds_remote_device_set_working_request(device, request) \ |
| 446 | ((device)->working_request = (request)) |
| 447 | |
| 448 | enum sci_status scic_sds_remote_device_frame_handler( |
| 449 | struct scic_sds_remote_device *sci_dev, |
| 450 | u32 frame_index); |
| 451 | |
| 452 | enum sci_status scic_sds_remote_device_event_handler( |
| 453 | struct scic_sds_remote_device *sci_dev, |
| 454 | u32 event_code); |
| 455 | |
| 456 | enum sci_status scic_sds_remote_device_start_io( |
| 457 | struct scic_sds_controller *controller, |
| 458 | struct scic_sds_remote_device *sci_dev, |
| 459 | struct scic_sds_request *io_request); |
| 460 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 461 | enum sci_status scic_sds_remote_device_start_task( |
| 462 | struct scic_sds_controller *controller, |
| 463 | struct scic_sds_remote_device *sci_dev, |
| 464 | struct scic_sds_request *io_request); |
| 465 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 466 | enum sci_status scic_sds_remote_device_complete_io( |
| 467 | struct scic_sds_controller *controller, |
| 468 | struct scic_sds_remote_device *sci_dev, |
| 469 | struct scic_sds_request *io_request); |
| 470 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 471 | enum sci_status scic_sds_remote_device_suspend( |
| 472 | struct scic_sds_remote_device *sci_dev, |
| 473 | u32 suspend_type); |
| 474 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 475 | void scic_sds_remote_device_post_request( |
| 476 | struct scic_sds_remote_device *sci_dev, |
| 477 | u32 request); |
| 478 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 479 | #define scic_sds_remote_device_is_atapi(sci_dev) false |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 480 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 481 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |