![]() |
|
|||
0001 /* 0002 * This file is provided under a dual BSD/GPLv2 license. When using or 0003 * redistributing this file, you may do so under either license. 0004 * 0005 * GPL LICENSE SUMMARY 0006 * 0007 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 0008 * 0009 * This program is free software; you can redistribute it and/or modify 0010 * it under the terms of version 2 of the GNU General Public License as 0011 * published by the Free Software Foundation. 0012 * 0013 * This program is distributed in the hope that it will be useful, but 0014 * WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 * General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU General Public License 0019 * along with this program; if not, write to the Free Software 0020 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 0021 * The full GNU General Public License is included in this distribution 0022 * in the file called LICENSE.GPL. 0023 * 0024 * BSD LICENSE 0025 * 0026 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 0027 * All rights reserved. 0028 * 0029 * Redistribution and use in source and binary forms, with or without 0030 * modification, are permitted provided that the following conditions 0031 * are met: 0032 * 0033 * * Redistributions of source code must retain the above copyright 0034 * notice, this list of conditions and the following disclaimer. 0035 * * Redistributions in binary form must reproduce the above copyright 0036 * notice, this list of conditions and the following disclaimer in 0037 * the documentation and/or other materials provided with the 0038 * distribution. 0039 * * Neither the name of Intel Corporation nor the names of its 0040 * contributors may be used to endorse or promote products derived 0041 * from this software without specific prior written permission. 0042 * 0043 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0044 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0045 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0046 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0047 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0048 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0049 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0050 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0051 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0052 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0053 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0054 */ 0055 0056 #ifndef _ISCI_REMOTE_DEVICE_H_ 0057 #define _ISCI_REMOTE_DEVICE_H_ 0058 #include <scsi/libsas.h> 0059 #include <linux/kref.h> 0060 #include "scu_remote_node_context.h" 0061 #include "remote_node_context.h" 0062 #include "port.h" 0063 0064 enum sci_remote_device_not_ready_reason_code { 0065 SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, 0066 SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, 0067 SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, 0068 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, 0069 SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, 0070 SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX 0071 }; 0072 0073 /** 0074 * isci_remote_device - isci representation of a sas expander / end point 0075 * @device_port_width: hw setting for number of simultaneous connections 0076 * @connection_rate: per-taskcontext connection rate for this device 0077 * @working_request: SATA requests have no tag we for unaccelerated 0078 * protocols we need a method to associate unsolicited 0079 * frames with a pending request 0080 */ 0081 struct isci_remote_device { 0082 #define IDEV_START_PENDING 0 0083 #define IDEV_STOP_PENDING 1 0084 #define IDEV_ALLOCATED 2 0085 #define IDEV_GONE 3 0086 #define IDEV_IO_READY 4 0087 #define IDEV_IO_NCQERROR 5 0088 #define IDEV_RNC_LLHANG_ENABLED 6 0089 #define IDEV_ABORT_PATH_ACTIVE 7 0090 #define IDEV_ABORT_PATH_RESUME_PENDING 8 0091 unsigned long flags; 0092 struct kref kref; 0093 struct isci_port *isci_port; 0094 struct domain_device *domain_dev; 0095 struct list_head node; 0096 struct sci_base_state_machine sm; 0097 u32 device_port_width; 0098 enum sas_linkrate connection_rate; 0099 struct isci_port *owning_port; 0100 struct sci_remote_node_context rnc; 0101 /* XXX unify with device reference counting and delete */ 0102 u32 started_request_count; 0103 struct isci_request *working_request; 0104 u32 not_ready_reason; 0105 scics_sds_remote_node_context_callback abort_resume_cb; 0106 void *abort_resume_cbparam; 0107 }; 0108 0109 #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 0110 0111 /* device reference routines must be called under sci_lock */ 0112 static inline struct isci_remote_device *isci_get_device( 0113 struct isci_remote_device *idev) 0114 { 0115 if (idev) 0116 kref_get(&idev->kref); 0117 return idev; 0118 } 0119 0120 static inline struct isci_remote_device *isci_lookup_device(struct domain_device *dev) 0121 { 0122 struct isci_remote_device *idev = dev->lldd_dev; 0123 0124 if (idev && !test_bit(IDEV_GONE, &idev->flags)) { 0125 kref_get(&idev->kref); 0126 return idev; 0127 } 0128 0129 return NULL; 0130 } 0131 0132 void isci_remote_device_release(struct kref *kref); 0133 static inline void isci_put_device(struct isci_remote_device *idev) 0134 { 0135 if (idev) 0136 kref_put(&idev->kref, isci_remote_device_release); 0137 } 0138 0139 enum sci_status isci_remote_device_stop(struct isci_host *ihost, 0140 struct isci_remote_device *idev); 0141 void isci_remote_device_nuke_requests(struct isci_host *ihost, 0142 struct isci_remote_device *idev); 0143 void isci_remote_device_gone(struct domain_device *domain_dev); 0144 int isci_remote_device_found(struct domain_device *domain_dev); 0145 0146 /** 0147 * sci_remote_device_stop() - This method will stop both transmission and 0148 * reception of link activity for the supplied remote device. This method 0149 * disables normal IO requests from flowing through to the remote device. 0150 * @remote_device: This parameter specifies the device to be stopped. 0151 * @timeout: This parameter specifies the number of milliseconds in which the 0152 * stop operation should complete. 0153 * 0154 * An indication of whether the device was successfully stopped. SCI_SUCCESS 0155 * This value is returned if the transmission and reception for the device was 0156 * successfully stopped. 0157 */ 0158 enum sci_status sci_remote_device_stop( 0159 struct isci_remote_device *idev, 0160 u32 timeout); 0161 0162 /** 0163 * sci_remote_device_reset() - This method will reset the device making it 0164 * ready for operation. This method must be called anytime the device is 0165 * reset either through a SMP phy control or a port hard reset request. 0166 * @remote_device: This parameter specifies the device to be reset. 0167 * 0168 * This method does not actually cause the device hardware to be reset. This 0169 * method resets the software object so that it will be operational after a 0170 * device hardware reset completes. An indication of whether the device reset 0171 * was accepted. SCI_SUCCESS This value is returned if the device reset is 0172 * started. 0173 */ 0174 enum sci_status sci_remote_device_reset( 0175 struct isci_remote_device *idev); 0176 0177 /** 0178 * sci_remote_device_reset_complete() - This method informs the device object 0179 * that the reset operation is complete and the device can resume operation 0180 * again. 0181 * @remote_device: This parameter specifies the device which is to be informed 0182 * of the reset complete operation. 0183 * 0184 * An indication that the device is resuming operation. SCI_SUCCESS the device 0185 * is resuming operation. 0186 */ 0187 enum sci_status sci_remote_device_reset_complete( 0188 struct isci_remote_device *idev); 0189 0190 /** 0191 * enum sci_remote_device_states - This enumeration depicts all the states 0192 * for the common remote device state machine. 0193 * @SCI_DEV_INITIAL: Simply the initial state for the base remote device 0194 * state machine. 0195 * 0196 * @SCI_DEV_STOPPED: This state indicates that the remote device has 0197 * successfully been stopped. In this state no new IO operations are 0198 * permitted. This state is entered from the INITIAL state. This state 0199 * is entered from the STOPPING state. 0200 * 0201 * @SCI_DEV_STARTING: This state indicates the the remote device is in 0202 * the process of becoming ready (i.e. starting). In this state no new 0203 * IO operations are permitted. This state is entered from the STOPPED 0204 * state. 0205 * 0206 * @SCI_DEV_READY: This state indicates the remote device is now ready. 0207 * Thus, the user is able to perform IO operations on the remote device. 0208 * This state is entered from the STARTING state. 0209 * 0210 * @SCI_STP_DEV_IDLE: This is the idle substate for the stp remote 0211 * device. When there are no active IO for the device it is is in this 0212 * state. 0213 * 0214 * @SCI_STP_DEV_CMD: This is the command state for for the STP remote 0215 * device. This state is entered when the device is processing a 0216 * non-NCQ command. The device object will fail any new start IO 0217 * requests until this command is complete. 0218 * 0219 * @SCI_STP_DEV_NCQ: This is the NCQ state for the STP remote device. 0220 * This state is entered when the device is processing an NCQ reuqest. 0221 * It will remain in this state so long as there is one or more NCQ 0222 * requests being processed. 0223 * 0224 * @SCI_STP_DEV_NCQ_ERROR: This is the NCQ error state for the STP 0225 * remote device. This state is entered when an SDB error FIS is 0226 * received by the device object while in the NCQ state. The device 0227 * object will only accept a READ LOG command while in this state. 0228 * 0229 * @SCI_STP_DEV_ATAPI_ERROR: This is the ATAPI error state for the STP 0230 * ATAPI remote device. This state is entered when ATAPI device sends 0231 * error status FIS without data while the device object is in CMD 0232 * state. A suspension event is expected in this state. The device 0233 * object will resume right away. 0234 * 0235 * @SCI_STP_DEV_AWAIT_RESET: This is the READY substate indicates the 0236 * device is waiting for the RESET task coming to be recovered from 0237 * certain hardware specific error. 0238 * 0239 * @SCI_SMP_DEV_IDLE: This is the ready operational substate for the 0240 * remote device. This is the normal operational state for a remote 0241 * device. 0242 * 0243 * @SCI_SMP_DEV_CMD: This is the suspended state for the remote device. 0244 * This is the state that the device is placed in when a RNC suspend is 0245 * received by the SCU hardware. 0246 * 0247 * @SCI_DEV_STOPPING: This state indicates that the remote device is in 0248 * the process of stopping. In this state no new IO operations are 0249 * permitted, but existing IO operations are allowed to complete. This 0250 * state is entered from the READY state. This state is entered from 0251 * the FAILED state. 0252 * 0253 * @SCI_DEV_FAILED: This state indicates that the remote device has 0254 * failed. In this state no new IO operations are permitted. This 0255 * state is entered from the INITIALIZING state. This state is entered 0256 * from the READY state. 0257 * 0258 * @SCI_DEV_RESETTING: This state indicates the device is being reset. 0259 * In this state no new IO operations are permitted. This state is 0260 * entered from the READY state. 0261 * 0262 * @SCI_DEV_FINAL: Simply the final state for the base remote device 0263 * state machine. 0264 */ 0265 #define REMOTE_DEV_STATES {\ 0266 C(DEV_INITIAL),\ 0267 C(DEV_STOPPED),\ 0268 C(DEV_STARTING),\ 0269 C(DEV_READY),\ 0270 C(STP_DEV_IDLE),\ 0271 C(STP_DEV_CMD),\ 0272 C(STP_DEV_NCQ),\ 0273 C(STP_DEV_NCQ_ERROR),\ 0274 C(STP_DEV_ATAPI_ERROR),\ 0275 C(STP_DEV_AWAIT_RESET),\ 0276 C(SMP_DEV_IDLE),\ 0277 C(SMP_DEV_CMD),\ 0278 C(DEV_STOPPING),\ 0279 C(DEV_FAILED),\ 0280 C(DEV_RESETTING),\ 0281 C(DEV_FINAL),\ 0282 } 0283 #undef C 0284 #define C(a) SCI_##a 0285 enum sci_remote_device_states REMOTE_DEV_STATES; 0286 #undef C 0287 const char *dev_state_name(enum sci_remote_device_states state); 0288 0289 static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc) 0290 { 0291 struct isci_remote_device *idev; 0292 0293 idev = container_of(rnc, typeof(*idev), rnc); 0294 0295 return idev; 0296 } 0297 0298 static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev) 0299 { 0300 /* XXX delete this voodoo when converting to the top-level device 0301 * reference count 0302 */ 0303 if (WARN_ONCE(idev->started_request_count == 0, 0304 "%s: tried to decrement started_request_count past 0!?", 0305 __func__)) 0306 /* pass */; 0307 else 0308 idev->started_request_count--; 0309 } 0310 0311 void isci_dev_set_hang_detection_timeout(struct isci_remote_device *idev, u32 timeout); 0312 0313 enum sci_status sci_remote_device_frame_handler( 0314 struct isci_remote_device *idev, 0315 u32 frame_index); 0316 0317 enum sci_status sci_remote_device_event_handler( 0318 struct isci_remote_device *idev, 0319 u32 event_code); 0320 0321 enum sci_status sci_remote_device_start_io( 0322 struct isci_host *ihost, 0323 struct isci_remote_device *idev, 0324 struct isci_request *ireq); 0325 0326 enum sci_status sci_remote_device_start_task( 0327 struct isci_host *ihost, 0328 struct isci_remote_device *idev, 0329 struct isci_request *ireq); 0330 0331 enum sci_status sci_remote_device_complete_io( 0332 struct isci_host *ihost, 0333 struct isci_remote_device *idev, 0334 struct isci_request *ireq); 0335 0336 void sci_remote_device_post_request( 0337 struct isci_remote_device *idev, 0338 u32 request); 0339 0340 enum sci_status sci_remote_device_terminate_requests( 0341 struct isci_remote_device *idev); 0342 0343 int isci_remote_device_is_safe_to_abort( 0344 struct isci_remote_device *idev); 0345 0346 enum sci_status 0347 sci_remote_device_abort_requests_pending_abort( 0348 struct isci_remote_device *idev); 0349 0350 enum sci_status isci_remote_device_suspend( 0351 struct isci_host *ihost, 0352 struct isci_remote_device *idev); 0353 0354 enum sci_status sci_remote_device_resume( 0355 struct isci_remote_device *idev, 0356 scics_sds_remote_node_context_callback cb_fn, 0357 void *cb_p); 0358 0359 enum sci_status isci_remote_device_resume_from_abort( 0360 struct isci_host *ihost, 0361 struct isci_remote_device *idev); 0362 0363 enum sci_status isci_remote_device_reset( 0364 struct isci_host *ihost, 0365 struct isci_remote_device *idev); 0366 0367 enum sci_status isci_remote_device_reset_complete( 0368 struct isci_host *ihost, 0369 struct isci_remote_device *idev); 0370 0371 enum sci_status isci_remote_device_suspend_terminate( 0372 struct isci_host *ihost, 0373 struct isci_remote_device *idev, 0374 struct isci_request *ireq); 0375 0376 enum sci_status isci_remote_device_terminate_requests( 0377 struct isci_host *ihost, 0378 struct isci_remote_device *idev, 0379 struct isci_request *ireq); 0380 enum sci_status sci_remote_device_suspend(struct isci_remote_device *idev, 0381 enum sci_remote_node_suspension_reasons reason); 0382 #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |