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