diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-04-22 22:18:03 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:00:38 -0400 |
commit | 88f3b62ac131e2549b6c262cacbd47e8cca42d6e (patch) | |
tree | 331870b812b2cb7c4c8ce89779df8473f9570b9c /drivers | |
parent | 57f20f4ed6fb702339be2ef4dea9d15e6a7d0d07 (diff) |
isci: move remote_device handling out of the core
Now that the core/lldd remote_device data structures are nominally unified
merge the corresponding sources into the top-level directory. Also move the
remote_node_context infrastructure which has no analog at the lldd level.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
30 files changed, 2325 insertions, 2758 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile index 522e7a7c062e..ccc8c53f501d 100644 --- a/drivers/scsi/isci/Makefile +++ b/drivers/scsi/isci/Makefile | |||
@@ -10,20 +10,19 @@ obj-$(CONFIG_SCSI_ISCI) += isci.o | |||
10 | isci-objs := init.o phy.o request.o sata.o \ | 10 | isci-objs := init.o phy.o request.o sata.o \ |
11 | remote_device.o port.o timers.o \ | 11 | remote_device.o port.o timers.o \ |
12 | host.o task.o probe_roms.o \ | 12 | host.o task.o probe_roms.o \ |
13 | stp_remote_device.o \ | ||
14 | smp_remote_device.o \ | ||
15 | remote_node_context.o \ | ||
16 | remote_node_table.o \ | ||
13 | core/scic_sds_controller.o \ | 17 | core/scic_sds_controller.o \ |
14 | core/scic_sds_remote_device.o \ | ||
15 | core/scic_sds_request.o \ | 18 | core/scic_sds_request.o \ |
16 | core/scic_sds_stp_request.o \ | 19 | core/scic_sds_stp_request.o \ |
17 | core/scic_sds_stp_packet_request.o \ | 20 | core/scic_sds_stp_packet_request.o \ |
18 | core/scic_sds_stp_remote_device.o \ | ||
19 | core/scic_sds_port.o \ | 21 | core/scic_sds_port.o \ |
20 | core/scic_sds_port_configuration_agent.o \ | 22 | core/scic_sds_port_configuration_agent.o \ |
21 | core/scic_sds_phy.o \ | 23 | core/scic_sds_phy.o \ |
22 | core/scic_sds_ssp_request.o \ | 24 | core/scic_sds_ssp_request.o \ |
23 | core/scic_sds_remote_node_context.o \ | ||
24 | core/scic_sds_smp_request.o \ | 25 | core/scic_sds_smp_request.o \ |
25 | core/scic_sds_smp_remote_device.o \ | ||
26 | core/scic_sds_remote_node_table.o \ | ||
27 | core/scic_sds_unsolicited_frame_control.o \ | 26 | core/scic_sds_unsolicited_frame_control.o \ |
28 | core/sci_base_state_machine.o \ | 27 | core/sci_base_state_machine.o \ |
29 | core/sci_util.o | 28 | core/sci_util.o |
diff --git a/drivers/scsi/isci/core/scic_remote_device.h b/drivers/scsi/isci/core/scic_remote_device.h deleted file mode 100644 index 23e90af5a01b..000000000000 --- a/drivers/scsi/isci/core/scic_remote_device.h +++ /dev/null | |||
@@ -1,282 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_REMOTE_DEVICE_H_ | ||
57 | #define _SCIC_REMOTE_DEVICE_H_ | ||
58 | |||
59 | /** | ||
60 | * This file contains all of the interface methods that can be called by an | ||
61 | * SCIC user on the device object. | ||
62 | * | ||
63 | * | ||
64 | */ | ||
65 | |||
66 | |||
67 | #include "sci_status.h" | ||
68 | #include "intel_sas.h" | ||
69 | |||
70 | struct scic_sds_port; | ||
71 | struct scic_sds_remote_device; | ||
72 | |||
73 | /** | ||
74 | * | ||
75 | * | ||
76 | * | ||
77 | */ | ||
78 | enum scic_remote_device_not_ready_reason_code { | ||
79 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, | ||
80 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, | ||
81 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, | ||
82 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, | ||
83 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, | ||
84 | |||
85 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX | ||
86 | |||
87 | }; | ||
88 | |||
89 | /** | ||
90 | * scic_remote_device_construct() - This method will perform the construction | ||
91 | * common to all remote device objects. | ||
92 | * @sci_port: SAS/SATA port through which this device is accessed. | ||
93 | * @sci_dev: remote device to construct | ||
94 | * | ||
95 | * It isn't necessary to call scic_remote_device_destruct() for device objects | ||
96 | * that have only called this method for construction. Once subsequent | ||
97 | * construction methods have been invoked (e.g. | ||
98 | * scic_remote_device_da_construct()), then destruction should occur. none | ||
99 | */ | ||
100 | void scic_remote_device_construct(struct scic_sds_port *sci_port, | ||
101 | struct scic_sds_remote_device *sci_dev); | ||
102 | |||
103 | /** | ||
104 | * scic_remote_device_da_construct() - This method will construct a | ||
105 | * SCIC_REMOTE_DEVICE object for a direct attached (da) device. The | ||
106 | * information (e.g. IAF, Signature FIS, etc.) necessary to build the device | ||
107 | * is known to the SCI Core since it is contained in the scic_phy object. | ||
108 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
109 | * | ||
110 | * The user must have previously called scic_remote_device_construct() Remote | ||
111 | * device objects are a limited resource. As such, they must be protected. | ||
112 | * Thus calls to construct and destruct are mutually exclusive and | ||
113 | * non-reentrant. Indicate if the remote device was successfully constructed. | ||
114 | * SCI_SUCCESS Returned if the device was successfully constructed. | ||
115 | * SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been | ||
116 | * constructed. If it's an additional phy for the target, then call | ||
117 | * scic_remote_device_da_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned | ||
118 | * if the supplied parameters necessitate creation of a remote device for which | ||
119 | * the protocol is not supported by the underlying controller hardware. | ||
120 | * SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core | ||
121 | * controller associated with the supplied parameters is unable to support | ||
122 | * additional remote devices. | ||
123 | */ | ||
124 | enum sci_status scic_remote_device_da_construct( | ||
125 | struct scic_sds_remote_device *remote_device); | ||
126 | |||
127 | /** | ||
128 | * scic_remote_device_ea_construct() - This method will construct an | ||
129 | * SCIC_REMOTE_DEVICE object for an expander attached (ea) device from an | ||
130 | * SMP Discover Response. | ||
131 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
132 | * @discover_response: This parameter specifies the SMP Discovery Response to | ||
133 | * be used in device creation. | ||
134 | * | ||
135 | * The user must have previously called scic_remote_device_construct() Remote | ||
136 | * device objects are a limited resource. As such, they must be protected. | ||
137 | * Thus calls to construct and destruct are mutually exclusive and | ||
138 | * non-reentrant. Indicate if the remote device was successfully constructed. | ||
139 | * SCI_SUCCESS Returned if the device was successfully constructed. | ||
140 | * SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been | ||
141 | * constructed. If it's an additional phy for the target, then call | ||
142 | * scic_ea_remote_device_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned | ||
143 | * if the supplied parameters necessitate creation of a remote device for which | ||
144 | * the protocol is not supported by the underlying controller hardware. | ||
145 | * SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core | ||
146 | * controller associated with the supplied parameters is unable to support | ||
147 | * additional remote devices. | ||
148 | */ | ||
149 | enum sci_status scic_remote_device_ea_construct( | ||
150 | struct scic_sds_remote_device *remote_device, | ||
151 | struct smp_response_discover *discover_response); | ||
152 | |||
153 | /** | ||
154 | * scic_remote_device_destruct() - This method is utilized to free up a core's | ||
155 | * remote device object. | ||
156 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
157 | * | ||
158 | * Remote device objects are a limited resource. As such, they must be | ||
159 | * protected. Thus calls to construct and destruct are mutually exclusive and | ||
160 | * non-reentrant. The return value shall indicate if the device was | ||
161 | * successfully destructed or if some failure occurred. enum sci_status This value | ||
162 | * is returned if the device is successfully destructed. | ||
163 | * SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the supplied | ||
164 | * device isn't valid (e.g. it's already been destoryed, the handle isn't | ||
165 | * valid, etc.). | ||
166 | */ | ||
167 | enum sci_status scic_remote_device_destruct( | ||
168 | struct scic_sds_remote_device *remote_device); | ||
169 | |||
170 | |||
171 | |||
172 | |||
173 | |||
174 | /** | ||
175 | * scic_remote_device_start() - This method will start the supplied remote | ||
176 | * device. This method enables normal IO requests to flow through to the | ||
177 | * remote device. | ||
178 | * @remote_device: This parameter specifies the device to be started. | ||
179 | * @timeout: This parameter specifies the number of milliseconds in which the | ||
180 | * start operation should complete. | ||
181 | * | ||
182 | * An indication of whether the device was successfully started. SCI_SUCCESS | ||
183 | * This value is returned if the device was successfully started. | ||
184 | * SCI_FAILURE_INVALID_PHY This value is returned if the user attempts to start | ||
185 | * the device when there have been no phys added to it. | ||
186 | */ | ||
187 | enum sci_status scic_remote_device_start( | ||
188 | struct scic_sds_remote_device *remote_device, | ||
189 | u32 timeout); | ||
190 | |||
191 | /** | ||
192 | * scic_remote_device_stop() - This method will stop both transmission and | ||
193 | * reception of link activity for the supplied remote device. This method | ||
194 | * disables normal IO requests from flowing through to the remote device. | ||
195 | * @remote_device: This parameter specifies the device to be stopped. | ||
196 | * @timeout: This parameter specifies the number of milliseconds in which the | ||
197 | * stop operation should complete. | ||
198 | * | ||
199 | * An indication of whether the device was successfully stopped. SCI_SUCCESS | ||
200 | * This value is returned if the transmission and reception for the device was | ||
201 | * successfully stopped. | ||
202 | */ | ||
203 | enum sci_status scic_remote_device_stop( | ||
204 | struct scic_sds_remote_device *remote_device, | ||
205 | u32 timeout); | ||
206 | |||
207 | /** | ||
208 | * scic_remote_device_reset() - This method will reset the device making it | ||
209 | * ready for operation. This method must be called anytime the device is | ||
210 | * reset either through a SMP phy control or a port hard reset request. | ||
211 | * @remote_device: This parameter specifies the device to be reset. | ||
212 | * | ||
213 | * This method does not actually cause the device hardware to be reset. This | ||
214 | * method resets the software object so that it will be operational after a | ||
215 | * device hardware reset completes. An indication of whether the device reset | ||
216 | * was accepted. SCI_SUCCESS This value is returned if the device reset is | ||
217 | * started. | ||
218 | */ | ||
219 | enum sci_status scic_remote_device_reset( | ||
220 | struct scic_sds_remote_device *remote_device); | ||
221 | |||
222 | /** | ||
223 | * scic_remote_device_reset_complete() - This method informs the device object | ||
224 | * that the reset operation is complete and the device can resume operation | ||
225 | * again. | ||
226 | * @remote_device: This parameter specifies the device which is to be informed | ||
227 | * of the reset complete operation. | ||
228 | * | ||
229 | * An indication that the device is resuming operation. SCI_SUCCESS the device | ||
230 | * is resuming operation. | ||
231 | */ | ||
232 | enum sci_status scic_remote_device_reset_complete( | ||
233 | struct scic_sds_remote_device *remote_device); | ||
234 | |||
235 | |||
236 | |||
237 | /** | ||
238 | * scic_remote_device_get_connection_rate() - This method simply returns the | ||
239 | * link rate at which communications to the remote device occur. | ||
240 | * @remote_device: This parameter specifies the device for which to get the | ||
241 | * connection rate. | ||
242 | * | ||
243 | * Return the link rate at which we transfer for the supplied remote device. | ||
244 | */ | ||
245 | enum sas_linkrate scic_remote_device_get_connection_rate( | ||
246 | struct scic_sds_remote_device *remote_device); | ||
247 | |||
248 | /** | ||
249 | * scic_remote_device_get_protocols() - This method will indicate which | ||
250 | * protocols are supported by this remote device. | ||
251 | * @remote_device: This parameter specifies the device for which to return the | ||
252 | * protocol. | ||
253 | * @protocols: This parameter specifies the output values, from the remote | ||
254 | * device object, which indicate the protocols supported by the supplied | ||
255 | * remote_device. | ||
256 | * | ||
257 | * The type of protocols supported by this device. The values are returned as | ||
258 | * part of a bit mask in order to allow for multi-protocol support. | ||
259 | */ | ||
260 | void scic_remote_device_get_protocols( | ||
261 | struct scic_sds_remote_device *remote_device, | ||
262 | struct smp_discover_response_protocols *protocols); | ||
263 | |||
264 | |||
265 | #if !defined(DISABLE_ATAPI) | ||
266 | /** | ||
267 | * scic_remote_device_is_atapi() - | ||
268 | * @this_device: The device whose type is to be decided. | ||
269 | * | ||
270 | * This method first decide whether a device is a stp target, then decode the | ||
271 | * signature fis of a DA STP device to tell whether it is a standard end disk | ||
272 | * or an ATAPI device. bool Indicate a device is ATAPI device or not. | ||
273 | */ | ||
274 | bool scic_remote_device_is_atapi( | ||
275 | struct scic_sds_remote_device *device_handle); | ||
276 | #else /* !defined(DISABLE_ATAPI) */ | ||
277 | #define scic_remote_device_is_atapi(device_handle) false | ||
278 | #endif /* !defined(DISABLE_ATAPI) */ | ||
279 | |||
280 | |||
281 | #endif /* _SCIC_REMOTE_DEVICE_H_ */ | ||
282 | |||
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index 63f4cd130d1d..c684d9ec8c97 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c | |||
@@ -57,13 +57,12 @@ | |||
57 | #include "scic_controller.h" | 57 | #include "scic_controller.h" |
58 | #include "scic_phy.h" | 58 | #include "scic_phy.h" |
59 | #include "scic_port.h" | 59 | #include "scic_port.h" |
60 | #include "scic_remote_device.h" | ||
61 | #include "scic_sds_controller.h" | 60 | #include "scic_sds_controller.h" |
62 | #include "scu_registers.h" | 61 | #include "scu_registers.h" |
63 | #include "scic_sds_phy.h" | 62 | #include "scic_sds_phy.h" |
64 | #include "scic_sds_port_configuration_agent.h" | 63 | #include "scic_sds_port_configuration_agent.h" |
65 | #include "scic_sds_port.h" | 64 | #include "scic_sds_port.h" |
66 | #include "scic_sds_remote_device.h" | 65 | #include "remote_device.h" |
67 | #include "scic_sds_request.h" | 66 | #include "scic_sds_request.h" |
68 | #include "sci_environment.h" | 67 | #include "sci_environment.h" |
69 | #include "sci_util.h" | 68 | #include "sci_util.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h index 4bb9a43fbe4d..e15c4e2fd76d 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.h +++ b/drivers/scsi/isci/core/scic_sds_controller.h | |||
@@ -73,7 +73,7 @@ | |||
73 | #include "scic_config_parameters.h" | 73 | #include "scic_config_parameters.h" |
74 | #include "scic_sds_port.h" | 74 | #include "scic_sds_port.h" |
75 | #include "scic_sds_phy.h" | 75 | #include "scic_sds_phy.h" |
76 | #include "scic_sds_remote_node_table.h" | 76 | #include "remote_node_table.h" |
77 | #include "scu_registers.h" | 77 | #include "scu_registers.h" |
78 | #include "scu_constants.h" | 78 | #include "scu_constants.h" |
79 | #include "scu_remote_node_context.h" | 79 | #include "scu_remote_node_context.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c index 34bd3b25ccf6..09018466f993 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ b/drivers/scsi/isci/core/scic_sds_phy.c | |||
@@ -61,7 +61,7 @@ | |||
61 | #include "scic_sds_controller.h" | 61 | #include "scic_sds_controller.h" |
62 | #include "scic_sds_phy.h" | 62 | #include "scic_sds_phy.h" |
63 | #include "scic_sds_port.h" | 63 | #include "scic_sds_port.h" |
64 | #include "scic_sds_remote_node_context.h" | 64 | #include "remote_node_context.h" |
65 | #include "sci_environment.h" | 65 | #include "sci_environment.h" |
66 | #include "sci_util.h" | 66 | #include "sci_util.h" |
67 | #include "scu_event_codes.h" | 67 | #include "scu_event_codes.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c index a8d7e51bdf7b..b07e48e2f188 100644 --- a/drivers/scsi/isci/core/scic_sds_port.c +++ b/drivers/scsi/isci/core/scic_sds_port.c | |||
@@ -60,8 +60,8 @@ | |||
60 | #include "scic_sds_controller.h" | 60 | #include "scic_sds_controller.h" |
61 | #include "scic_sds_phy.h" | 61 | #include "scic_sds_phy.h" |
62 | #include "scic_sds_port.h" | 62 | #include "scic_sds_port.h" |
63 | #include "scic_sds_remote_device.h" | 63 | #include "remote_device.h" |
64 | #include "scic_sds_remote_node_context.h" | 64 | #include "remote_node_context.h" |
65 | #include "scic_sds_request.h" | 65 | #include "scic_sds_request.h" |
66 | #include "sci_environment.h" | 66 | #include "sci_environment.h" |
67 | #include "scu_registers.h" | 67 | #include "scu_registers.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c deleted file mode 100644 index d314e2b2088b..000000000000 --- a/drivers/scsi/isci/core/scic_sds_remote_device.c +++ /dev/null | |||
@@ -1,1664 +0,0 @@ | |||
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 | |||
56 | #include "intel_sas.h" | ||
57 | #include "scic_controller.h" | ||
58 | #include "scic_phy.h" | ||
59 | #include "scic_port.h" | ||
60 | #include "scic_remote_device.h" | ||
61 | #include "scic_sds_controller.h" | ||
62 | #include "scic_sds_phy.h" | ||
63 | #include "scic_sds_port.h" | ||
64 | #include "scic_sds_remote_device.h" | ||
65 | #include "scic_sds_remote_node_context.h" | ||
66 | #include "scic_sds_request.h" | ||
67 | #include "sci_environment.h" | ||
68 | #include "sci_util.h" | ||
69 | #include "scu_event_codes.h" | ||
70 | |||
71 | |||
72 | #define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000) | ||
73 | |||
74 | enum sci_status scic_remote_device_da_construct( | ||
75 | struct scic_sds_remote_device *sci_dev) | ||
76 | { | ||
77 | enum sci_status status; | ||
78 | u16 remote_node_index; | ||
79 | struct sci_sas_identify_address_frame_protocols protocols; | ||
80 | |||
81 | /* | ||
82 | * This information is request to determine how many remote node context | ||
83 | * entries will be needed to store the remote node. | ||
84 | */ | ||
85 | scic_sds_port_get_attached_protocols(sci_dev->owning_port, &protocols); | ||
86 | sci_dev->target_protocols.u.all = protocols.u.all; | ||
87 | sci_dev->is_direct_attached = true; | ||
88 | #if !defined(DISABLE_ATAPI) | ||
89 | sci_dev->is_atapi = scic_sds_remote_device_is_atapi(sci_dev); | ||
90 | #endif | ||
91 | |||
92 | status = scic_sds_controller_allocate_remote_node_context( | ||
93 | sci_dev->owning_port->owning_controller, | ||
94 | sci_dev, | ||
95 | &remote_node_index); | ||
96 | |||
97 | if (status == SCI_SUCCESS) { | ||
98 | sci_dev->rnc.remote_node_index = remote_node_index; | ||
99 | |||
100 | scic_sds_port_get_attached_sas_address( | ||
101 | sci_dev->owning_port, &sci_dev->device_address); | ||
102 | |||
103 | if (sci_dev->target_protocols.u.bits.attached_ssp_target) { | ||
104 | sci_dev->has_ready_substate_machine = false; | ||
105 | } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { | ||
106 | sci_dev->has_ready_substate_machine = true; | ||
107 | |||
108 | sci_base_state_machine_construct( | ||
109 | &sci_dev->ready_substate_machine, | ||
110 | &sci_dev->parent, | ||
111 | scic_sds_stp_remote_device_ready_substate_table, | ||
112 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
113 | } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { | ||
114 | sci_dev->has_ready_substate_machine = true; | ||
115 | |||
116 | /* add the SMP ready substate machine construction here */ | ||
117 | sci_base_state_machine_construct( | ||
118 | &sci_dev->ready_substate_machine, | ||
119 | &sci_dev->parent, | ||
120 | scic_sds_smp_remote_device_ready_substate_table, | ||
121 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
122 | } | ||
123 | |||
124 | sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed( | ||
125 | sci_dev->owning_port); | ||
126 | |||
127 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ | ||
128 | sci_dev->device_port_width = 1; | ||
129 | } | ||
130 | |||
131 | return status; | ||
132 | } | ||
133 | |||
134 | |||
135 | static void scic_sds_remote_device_get_info_from_smp_discover_response( | ||
136 | struct scic_sds_remote_device *sci_dev, | ||
137 | struct smp_response_discover *discover_response) | ||
138 | { | ||
139 | /* decode discover_response to set sas_address to sci_dev. */ | ||
140 | sci_dev->device_address.high = | ||
141 | discover_response->attached_sas_address.high; | ||
142 | |||
143 | sci_dev->device_address.low = | ||
144 | discover_response->attached_sas_address.low; | ||
145 | |||
146 | sci_dev->target_protocols.u.all = discover_response->protocols.u.all; | ||
147 | } | ||
148 | |||
149 | |||
150 | enum sci_status scic_remote_device_ea_construct( | ||
151 | struct scic_sds_remote_device *sci_dev, | ||
152 | struct smp_response_discover *discover_response) | ||
153 | { | ||
154 | enum sci_status status; | ||
155 | struct scic_sds_controller *scic; | ||
156 | |||
157 | scic = scic_sds_port_get_controller(sci_dev->owning_port); | ||
158 | |||
159 | scic_sds_remote_device_get_info_from_smp_discover_response( | ||
160 | sci_dev, discover_response); | ||
161 | |||
162 | status = scic_sds_controller_allocate_remote_node_context( | ||
163 | scic, sci_dev, &sci_dev->rnc.remote_node_index); | ||
164 | |||
165 | if (status == SCI_SUCCESS) { | ||
166 | if (sci_dev->target_protocols.u.bits.attached_ssp_target) { | ||
167 | sci_dev->has_ready_substate_machine = false; | ||
168 | } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { | ||
169 | sci_dev->has_ready_substate_machine = true; | ||
170 | |||
171 | /* add the SMP ready substate machine construction here */ | ||
172 | sci_base_state_machine_construct( | ||
173 | &sci_dev->ready_substate_machine, | ||
174 | &sci_dev->parent, | ||
175 | scic_sds_smp_remote_device_ready_substate_table, | ||
176 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
177 | } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { | ||
178 | sci_dev->has_ready_substate_machine = true; | ||
179 | |||
180 | sci_base_state_machine_construct( | ||
181 | &sci_dev->ready_substate_machine, | ||
182 | &sci_dev->parent, | ||
183 | scic_sds_stp_remote_device_ready_substate_table, | ||
184 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
185 | } | ||
186 | |||
187 | /* | ||
188 | * For SAS-2 the physical link rate is actually a logical link | ||
189 | * rate that incorporates multiplexing. The SCU doesn't | ||
190 | * incorporate multiplexing and for the purposes of the | ||
191 | * connection the logical link rate is that same as the | ||
192 | * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay | ||
193 | * one another, so this code works for both situations. */ | ||
194 | sci_dev->connection_rate = min_t(u16, | ||
195 | scic_sds_port_get_max_allowed_speed(sci_dev->owning_port), | ||
196 | discover_response->u2.sas1_1.negotiated_physical_link_rate | ||
197 | ); | ||
198 | |||
199 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ | ||
200 | sci_dev->device_port_width = 1; | ||
201 | } | ||
202 | |||
203 | return status; | ||
204 | } | ||
205 | |||
206 | enum sci_status scic_remote_device_destruct( | ||
207 | struct scic_sds_remote_device *sci_dev) | ||
208 | { | ||
209 | return sci_dev->state_handlers->destruct_handler(sci_dev); | ||
210 | } | ||
211 | |||
212 | |||
213 | enum sci_status scic_remote_device_start( | ||
214 | struct scic_sds_remote_device *sci_dev, | ||
215 | u32 timeout) | ||
216 | { | ||
217 | return sci_dev->state_handlers->start_handler(sci_dev); | ||
218 | } | ||
219 | |||
220 | |||
221 | enum sci_status scic_remote_device_stop( | ||
222 | struct scic_sds_remote_device *sci_dev, | ||
223 | u32 timeout) | ||
224 | { | ||
225 | return sci_dev->state_handlers->stop_handler(sci_dev); | ||
226 | } | ||
227 | |||
228 | |||
229 | enum sci_status scic_remote_device_reset( | ||
230 | struct scic_sds_remote_device *sci_dev) | ||
231 | { | ||
232 | return sci_dev->state_handlers->reset_handler(sci_dev); | ||
233 | } | ||
234 | |||
235 | |||
236 | enum sci_status scic_remote_device_reset_complete( | ||
237 | struct scic_sds_remote_device *sci_dev) | ||
238 | { | ||
239 | return sci_dev->state_handlers->reset_complete_handler(sci_dev); | ||
240 | } | ||
241 | |||
242 | |||
243 | enum sas_linkrate scic_remote_device_get_connection_rate( | ||
244 | struct scic_sds_remote_device *sci_dev) | ||
245 | { | ||
246 | return sci_dev->connection_rate; | ||
247 | } | ||
248 | |||
249 | |||
250 | void scic_remote_device_get_protocols( | ||
251 | struct scic_sds_remote_device *sci_dev, | ||
252 | struct smp_discover_response_protocols *pr) | ||
253 | { | ||
254 | pr->u.all = sci_dev->target_protocols.u.all; | ||
255 | } | ||
256 | |||
257 | #if !defined(DISABLE_ATAPI) | ||
258 | bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev) | ||
259 | { | ||
260 | return sci_dev->is_atapi; | ||
261 | } | ||
262 | #endif | ||
263 | |||
264 | |||
265 | /* | ||
266 | * ***************************************************************************** | ||
267 | * * SCU DRIVER STANDARD (SDS) REMOTE DEVICE IMPLEMENTATIONS | ||
268 | * ***************************************************************************** */ | ||
269 | |||
270 | /** | ||
271 | * | ||
272 | * | ||
273 | * Remote device timer requirements | ||
274 | */ | ||
275 | #define SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT (0) | ||
276 | #define SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT (SCI_MAX_REMOTE_DEVICES) | ||
277 | |||
278 | |||
279 | /** | ||
280 | * | ||
281 | * @sci_dev: The remote device for which the suspend is being requested. | ||
282 | * | ||
283 | * This method invokes the remote device suspend state handler. enum sci_status | ||
284 | */ | ||
285 | enum sci_status scic_sds_remote_device_suspend( | ||
286 | struct scic_sds_remote_device *sci_dev, | ||
287 | u32 suspend_type) | ||
288 | { | ||
289 | return sci_dev->state_handlers->suspend_handler(sci_dev, suspend_type); | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * | ||
294 | * @sci_dev: The remote device for which the resume is being requested. | ||
295 | * | ||
296 | * This method invokes the remote device resume state handler. enum sci_status | ||
297 | */ | ||
298 | enum sci_status scic_sds_remote_device_resume( | ||
299 | struct scic_sds_remote_device *sci_dev) | ||
300 | { | ||
301 | return sci_dev->state_handlers->resume_handler(sci_dev); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * | ||
306 | * @sci_dev: The remote device for which the event handling is being | ||
307 | * requested. | ||
308 | * @frame_index: This is the frame index that is being processed. | ||
309 | * | ||
310 | * This method invokes the frame handler for the remote device state machine | ||
311 | * enum sci_status | ||
312 | */ | ||
313 | enum sci_status scic_sds_remote_device_frame_handler( | ||
314 | struct scic_sds_remote_device *sci_dev, | ||
315 | u32 frame_index) | ||
316 | { | ||
317 | return sci_dev->state_handlers->frame_handler(sci_dev, frame_index); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * | ||
322 | * @sci_dev: The remote device for which the event handling is being | ||
323 | * requested. | ||
324 | * @event_code: This is the event code that is to be processed. | ||
325 | * | ||
326 | * This method invokes the remote device event handler. enum sci_status | ||
327 | */ | ||
328 | enum sci_status scic_sds_remote_device_event_handler( | ||
329 | struct scic_sds_remote_device *sci_dev, | ||
330 | u32 event_code) | ||
331 | { | ||
332 | return sci_dev->state_handlers->event_handler(sci_dev, event_code); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * | ||
337 | * @controller: The controller that is starting the io request. | ||
338 | * @sci_dev: The remote device for which the start io handling is being | ||
339 | * requested. | ||
340 | * @io_request: The io request that is being started. | ||
341 | * | ||
342 | * This method invokes the remote device start io handler. enum sci_status | ||
343 | */ | ||
344 | enum sci_status scic_sds_remote_device_start_io( | ||
345 | struct scic_sds_controller *controller, | ||
346 | struct scic_sds_remote_device *sci_dev, | ||
347 | struct scic_sds_request *io_request) | ||
348 | { | ||
349 | return sci_dev->state_handlers->start_io_handler( | ||
350 | sci_dev, io_request); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * | ||
355 | * @controller: The controller that is completing the io request. | ||
356 | * @sci_dev: The remote device for which the complete io handling is being | ||
357 | * requested. | ||
358 | * @io_request: The io request that is being completed. | ||
359 | * | ||
360 | * This method invokes the remote device complete io handler. enum sci_status | ||
361 | */ | ||
362 | enum sci_status scic_sds_remote_device_complete_io( | ||
363 | struct scic_sds_controller *controller, | ||
364 | struct scic_sds_remote_device *sci_dev, | ||
365 | struct scic_sds_request *io_request) | ||
366 | { | ||
367 | return sci_dev->state_handlers->complete_io_handler( | ||
368 | sci_dev, io_request); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * | ||
373 | * @controller: The controller that is starting the task request. | ||
374 | * @sci_dev: The remote device for which the start task handling is being | ||
375 | * requested. | ||
376 | * @io_request: The task request that is being started. | ||
377 | * | ||
378 | * This method invokes the remote device start task handler. enum sci_status | ||
379 | */ | ||
380 | enum sci_status scic_sds_remote_device_start_task( | ||
381 | struct scic_sds_controller *controller, | ||
382 | struct scic_sds_remote_device *sci_dev, | ||
383 | struct scic_sds_request *io_request) | ||
384 | { | ||
385 | return sci_dev->state_handlers->start_task_handler( | ||
386 | sci_dev, io_request); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * | ||
391 | * @controller: The controller that is completing the task request. | ||
392 | * @sci_dev: The remote device for which the complete task handling is | ||
393 | * being requested. | ||
394 | * @io_request: The task request that is being completed. | ||
395 | * | ||
396 | * This method invokes the remote device complete task handler. enum sci_status | ||
397 | */ | ||
398 | |||
399 | /** | ||
400 | * | ||
401 | * @sci_dev: | ||
402 | * @request: | ||
403 | * | ||
404 | * This method takes the request and bulids an appropriate SCU context for the | ||
405 | * request and then requests the controller to post the request. none | ||
406 | */ | ||
407 | void scic_sds_remote_device_post_request( | ||
408 | struct scic_sds_remote_device *sci_dev, | ||
409 | u32 request) | ||
410 | { | ||
411 | u32 context; | ||
412 | |||
413 | context = scic_sds_remote_device_build_command_context(sci_dev, request); | ||
414 | |||
415 | scic_sds_controller_post_request( | ||
416 | scic_sds_remote_device_get_controller(sci_dev), | ||
417 | context | ||
418 | ); | ||
419 | } | ||
420 | |||
421 | #if !defined(DISABLE_ATAPI) | ||
422 | /** | ||
423 | * | ||
424 | * @sci_dev: The device to be checked. | ||
425 | * | ||
426 | * This method check the signature fis of a stp device to decide whether a | ||
427 | * device is atapi or not. true if a device is atapi device. False if a device | ||
428 | * is not atapi. | ||
429 | */ | ||
430 | bool scic_sds_remote_device_is_atapi( | ||
431 | struct scic_sds_remote_device *sci_dev) | ||
432 | { | ||
433 | if (!sci_dev->target_protocols.u.bits.attached_stp_target) | ||
434 | return false; | ||
435 | else if (sci_dev->is_direct_attached) { | ||
436 | struct scic_sds_phy *phy; | ||
437 | struct scic_sata_phy_properties properties; | ||
438 | struct sata_fis_reg_d2h *signature_fis; | ||
439 | phy = scic_sds_port_get_a_connected_phy(sci_dev->owning_port); | ||
440 | scic_sata_phy_get_properties(phy, &properties); | ||
441 | |||
442 | /* decode the signature fis. */ | ||
443 | signature_fis = &(properties.signature_fis); | ||
444 | |||
445 | if ((signature_fis->sector_count == 0x01) | ||
446 | && (signature_fis->lba_low == 0x01) | ||
447 | && (signature_fis->lba_mid == 0x14) | ||
448 | && (signature_fis->lba_high == 0xEB) | ||
449 | && ((signature_fis->device & 0x5F) == 0x00) | ||
450 | ) { | ||
451 | /* An ATA device supporting the PACKET command set. */ | ||
452 | return true; | ||
453 | } else | ||
454 | return false; | ||
455 | } else { | ||
456 | /* Expander supported ATAPI device is not currently supported. */ | ||
457 | return false; | ||
458 | } | ||
459 | } | ||
460 | #endif | ||
461 | |||
462 | /** | ||
463 | * | ||
464 | * @user_parameter: This is cast to a remote device object. | ||
465 | * | ||
466 | * This method is called once the remote node context is ready to be freed. | ||
467 | * The remote device can now report that its stop operation is complete. none | ||
468 | */ | ||
469 | static void scic_sds_cb_remote_device_rnc_destruct_complete( | ||
470 | void *user_parameter) | ||
471 | { | ||
472 | struct scic_sds_remote_device *sci_dev; | ||
473 | |||
474 | sci_dev = (struct scic_sds_remote_device *)user_parameter; | ||
475 | |||
476 | BUG_ON(sci_dev->started_request_count != 0); | ||
477 | |||
478 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
479 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * | ||
484 | * @user_parameter: This is cast to a remote device object. | ||
485 | * | ||
486 | * This method is called once the remote node context has transisitioned to a | ||
487 | * ready state. This is the indication that the remote device object can also | ||
488 | * transition to ready. none | ||
489 | */ | ||
490 | static void scic_sds_remote_device_resume_complete_handler( | ||
491 | void *user_parameter) | ||
492 | { | ||
493 | struct scic_sds_remote_device *sci_dev; | ||
494 | |||
495 | sci_dev = (struct scic_sds_remote_device *)user_parameter; | ||
496 | |||
497 | if ( | ||
498 | sci_base_state_machine_get_state(&sci_dev->state_machine) | ||
499 | != SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
500 | ) { | ||
501 | sci_base_state_machine_change_state( | ||
502 | &sci_dev->state_machine, | ||
503 | SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
504 | ); | ||
505 | } | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * | ||
510 | * @device: This parameter specifies the device for which the request is being | ||
511 | * started. | ||
512 | * @request: This parameter specifies the request being started. | ||
513 | * @status: This parameter specifies the current start operation status. | ||
514 | * | ||
515 | * This method will perform the STP request start processing common to IO | ||
516 | * requests and task requests of all types. none | ||
517 | */ | ||
518 | void scic_sds_remote_device_start_request( | ||
519 | struct scic_sds_remote_device *sci_dev, | ||
520 | struct scic_sds_request *sci_req, | ||
521 | enum sci_status status) | ||
522 | { | ||
523 | /* We still have a fault in starting the io complete it on the port */ | ||
524 | if (status == SCI_SUCCESS) | ||
525 | scic_sds_remote_device_increment_request_count(sci_dev); | ||
526 | else{ | ||
527 | sci_dev->owning_port->state_handlers->complete_io_handler( | ||
528 | sci_dev->owning_port, sci_dev, sci_req | ||
529 | ); | ||
530 | } | ||
531 | } | ||
532 | |||
533 | |||
534 | /** | ||
535 | * | ||
536 | * @request: This parameter specifies the request being continued. | ||
537 | * | ||
538 | * This method will continue to post tc for a STP request. This method usually | ||
539 | * serves as a callback when RNC gets resumed during a task management | ||
540 | * sequence. none | ||
541 | */ | ||
542 | void scic_sds_remote_device_continue_request(void *dev) | ||
543 | { | ||
544 | struct scic_sds_remote_device *sci_dev = dev; | ||
545 | |||
546 | /* we need to check if this request is still valid to continue. */ | ||
547 | if (sci_dev->working_request) | ||
548 | scic_controller_continue_io(sci_dev->working_request); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * | ||
553 | * @user_parameter: This is cast to a remote device object. | ||
554 | * | ||
555 | * This method is called once the remote node context has reached a suspended | ||
556 | * state. The remote device can now report that its suspend operation is | ||
557 | * complete. none | ||
558 | */ | ||
559 | |||
560 | /** | ||
561 | * This method will terminate all of the IO requests in the controllers IO | ||
562 | * request table that were targeted for this device. | ||
563 | * @sci_dev: This parameter specifies the remote device for which to | ||
564 | * attempt to terminate all requests. | ||
565 | * | ||
566 | * This method returns an indication as to whether all requests were | ||
567 | * successfully terminated. If a single request fails to be terminated, then | ||
568 | * this method will return the failure. | ||
569 | */ | ||
570 | static enum sci_status scic_sds_remote_device_terminate_requests( | ||
571 | struct scic_sds_remote_device *sci_dev) | ||
572 | { | ||
573 | enum sci_status status = SCI_SUCCESS; | ||
574 | enum sci_status terminate_status = SCI_SUCCESS; | ||
575 | struct scic_sds_request *sci_req; | ||
576 | u32 index; | ||
577 | u32 request_count = sci_dev->started_request_count; | ||
578 | |||
579 | for (index = 0; | ||
580 | (index < SCI_MAX_IO_REQUESTS) && (request_count > 0); | ||
581 | index++) { | ||
582 | sci_req = sci_dev->owning_port->owning_controller->io_request_table[index]; | ||
583 | |||
584 | if ((sci_req != NULL) && (sci_req->target_device == sci_dev)) { | ||
585 | terminate_status = scic_controller_terminate_request( | ||
586 | sci_dev->owning_port->owning_controller, | ||
587 | sci_dev, | ||
588 | sci_req | ||
589 | ); | ||
590 | |||
591 | if (terminate_status != SCI_SUCCESS) | ||
592 | status = terminate_status; | ||
593 | |||
594 | request_count--; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | return status; | ||
599 | } | ||
600 | |||
601 | static enum sci_status | ||
602 | default_device_handler(struct scic_sds_remote_device *sci_dev, | ||
603 | const char *func) | ||
604 | { | ||
605 | dev_warn(scirdev_to_dev(sci_dev), | ||
606 | "%s: in wrong state: %d\n", func, | ||
607 | sci_base_state_machine_get_state(&sci_dev->state_machine)); | ||
608 | return SCI_FAILURE_INVALID_STATE; | ||
609 | } | ||
610 | |||
611 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
612 | struct scic_sds_remote_device *sci_dev) | ||
613 | { | ||
614 | return default_device_handler(sci_dev, __func__); | ||
615 | } | ||
616 | |||
617 | static enum sci_status scic_sds_remote_device_default_stop_handler( | ||
618 | struct scic_sds_remote_device *sci_dev) | ||
619 | { | ||
620 | return default_device_handler(sci_dev, __func__); | ||
621 | } | ||
622 | |||
623 | enum sci_status scic_sds_remote_device_default_fail_handler( | ||
624 | struct scic_sds_remote_device *sci_dev) | ||
625 | { | ||
626 | return default_device_handler(sci_dev, __func__); | ||
627 | } | ||
628 | |||
629 | enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
630 | struct scic_sds_remote_device *sci_dev) | ||
631 | { | ||
632 | return default_device_handler(sci_dev, __func__); | ||
633 | } | ||
634 | |||
635 | enum sci_status scic_sds_remote_device_default_reset_handler( | ||
636 | struct scic_sds_remote_device *sci_dev) | ||
637 | { | ||
638 | return default_device_handler(sci_dev, __func__); | ||
639 | } | ||
640 | |||
641 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | ||
642 | struct scic_sds_remote_device *sci_dev) | ||
643 | { | ||
644 | return default_device_handler(sci_dev, __func__); | ||
645 | } | ||
646 | |||
647 | enum sci_status scic_sds_remote_device_default_suspend_handler( | ||
648 | struct scic_sds_remote_device *sci_dev, u32 suspend_type) | ||
649 | { | ||
650 | return default_device_handler(sci_dev, __func__); | ||
651 | } | ||
652 | |||
653 | enum sci_status scic_sds_remote_device_default_resume_handler( | ||
654 | struct scic_sds_remote_device *sci_dev) | ||
655 | { | ||
656 | return default_device_handler(sci_dev, __func__); | ||
657 | } | ||
658 | |||
659 | /** | ||
660 | * | ||
661 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
662 | * struct scic_sds_remote_device. | ||
663 | * @event_code: The event code that the struct scic_sds_controller wants the device | ||
664 | * object to process. | ||
665 | * | ||
666 | * This method is the default event handler. It will call the RNC state | ||
667 | * machine handler for any RNC events otherwise it will log a warning and | ||
668 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
669 | */ | ||
670 | static enum sci_status scic_sds_remote_device_core_event_handler( | ||
671 | struct scic_sds_remote_device *sci_dev, | ||
672 | u32 event_code, | ||
673 | bool is_ready_state) | ||
674 | { | ||
675 | enum sci_status status; | ||
676 | |||
677 | switch (scu_get_event_type(event_code)) { | ||
678 | case SCU_EVENT_TYPE_RNC_OPS_MISC: | ||
679 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX: | ||
680 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: | ||
681 | status = scic_sds_remote_node_context_event_handler(&sci_dev->rnc, event_code); | ||
682 | break; | ||
683 | case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: | ||
684 | |||
685 | if (scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT) { | ||
686 | status = SCI_SUCCESS; | ||
687 | |||
688 | /* Suspend the associated RNC */ | ||
689 | scic_sds_remote_node_context_suspend(&sci_dev->rnc, | ||
690 | SCI_SOFTWARE_SUSPENSION, | ||
691 | NULL, NULL); | ||
692 | |||
693 | dev_dbg(scirdev_to_dev(sci_dev), | ||
694 | "%s: device: %p event code: %x: %s\n", | ||
695 | __func__, sci_dev, event_code, | ||
696 | (is_ready_state) | ||
697 | ? "I_T_Nexus_Timeout event" | ||
698 | : "I_T_Nexus_Timeout event in wrong state"); | ||
699 | |||
700 | break; | ||
701 | } | ||
702 | /* Else, fall through and treat as unhandled... */ | ||
703 | |||
704 | default: | ||
705 | dev_dbg(scirdev_to_dev(sci_dev), | ||
706 | "%s: device: %p event code: %x: %s\n", | ||
707 | __func__, sci_dev, event_code, | ||
708 | (is_ready_state) | ||
709 | ? "unexpected event" | ||
710 | : "unexpected event in wrong state"); | ||
711 | status = SCI_FAILURE_INVALID_STATE; | ||
712 | break; | ||
713 | } | ||
714 | |||
715 | return status; | ||
716 | } | ||
717 | /** | ||
718 | * | ||
719 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
720 | * struct scic_sds_remote_device. | ||
721 | * @event_code: The event code that the struct scic_sds_controller wants the device | ||
722 | * object to process. | ||
723 | * | ||
724 | * This method is the default event handler. It will call the RNC state | ||
725 | * machine handler for any RNC events otherwise it will log a warning and | ||
726 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
727 | */ | ||
728 | static enum sci_status scic_sds_remote_device_default_event_handler( | ||
729 | struct scic_sds_remote_device *sci_dev, | ||
730 | u32 event_code) | ||
731 | { | ||
732 | return scic_sds_remote_device_core_event_handler(sci_dev, | ||
733 | event_code, | ||
734 | false); | ||
735 | } | ||
736 | |||
737 | /** | ||
738 | * | ||
739 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
740 | * struct scic_sds_remote_device. | ||
741 | * @frame_index: The frame index for which the struct scic_sds_controller wants this | ||
742 | * device object to process. | ||
743 | * | ||
744 | * This method is the default unsolicited frame handler. It logs a warning, | ||
745 | * releases the frame and returns a failure. enum sci_status | ||
746 | * SCI_FAILURE_INVALID_STATE | ||
747 | */ | ||
748 | enum sci_status scic_sds_remote_device_default_frame_handler( | ||
749 | struct scic_sds_remote_device *sci_dev, | ||
750 | u32 frame_index) | ||
751 | { | ||
752 | dev_warn(scirdev_to_dev(sci_dev), | ||
753 | "%s: SCIC Remote Device requested to handle frame %x " | ||
754 | "while in wrong state %d\n", | ||
755 | __func__, | ||
756 | frame_index, | ||
757 | sci_base_state_machine_get_state( | ||
758 | &sci_dev->state_machine)); | ||
759 | |||
760 | /* Return the frame back to the controller */ | ||
761 | scic_sds_controller_release_frame( | ||
762 | scic_sds_remote_device_get_controller(sci_dev), frame_index | ||
763 | ); | ||
764 | |||
765 | return SCI_FAILURE_INVALID_STATE; | ||
766 | } | ||
767 | |||
768 | enum sci_status scic_sds_remote_device_default_start_request_handler( | ||
769 | struct scic_sds_remote_device *sci_dev, | ||
770 | struct scic_sds_request *request) | ||
771 | { | ||
772 | return default_device_handler(sci_dev, __func__); | ||
773 | } | ||
774 | |||
775 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | ||
776 | struct scic_sds_remote_device *sci_dev, | ||
777 | struct scic_sds_request *request) | ||
778 | { | ||
779 | return default_device_handler(sci_dev, __func__); | ||
780 | } | ||
781 | |||
782 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | ||
783 | struct scic_sds_remote_device *sci_dev, | ||
784 | struct scic_sds_request *request) | ||
785 | { | ||
786 | return default_device_handler(sci_dev, __func__); | ||
787 | } | ||
788 | |||
789 | /** | ||
790 | * | ||
791 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
792 | * struct scic_sds_remote_device. | ||
793 | * @frame_index: The frame index for which the struct scic_sds_controller wants this | ||
794 | * device object to process. | ||
795 | * | ||
796 | * This method is a general ssp frame handler. In most cases the device object | ||
797 | * needs to route the unsolicited frame processing to the io request object. | ||
798 | * This method decodes the tag for the io request object and routes the | ||
799 | * unsolicited frame to that object. enum sci_status SCI_FAILURE_INVALID_STATE | ||
800 | */ | ||
801 | enum sci_status scic_sds_remote_device_general_frame_handler( | ||
802 | struct scic_sds_remote_device *sci_dev, | ||
803 | u32 frame_index) | ||
804 | { | ||
805 | enum sci_status result; | ||
806 | struct sci_ssp_frame_header *frame_header; | ||
807 | struct scic_sds_request *io_request; | ||
808 | |||
809 | result = scic_sds_unsolicited_frame_control_get_header( | ||
810 | &(scic_sds_remote_device_get_controller(sci_dev)->uf_control), | ||
811 | frame_index, | ||
812 | (void **)&frame_header | ||
813 | ); | ||
814 | |||
815 | if (SCI_SUCCESS == result) { | ||
816 | io_request = scic_sds_controller_get_io_request_from_tag( | ||
817 | scic_sds_remote_device_get_controller(sci_dev), frame_header->tag); | ||
818 | |||
819 | if ((io_request == NULL) | ||
820 | || (io_request->target_device != sci_dev)) { | ||
821 | /* | ||
822 | * We could not map this tag to a valid IO request | ||
823 | * Just toss the frame and continue */ | ||
824 | scic_sds_controller_release_frame( | ||
825 | scic_sds_remote_device_get_controller(sci_dev), frame_index | ||
826 | ); | ||
827 | } else { | ||
828 | /* The IO request is now in charge of releasing the frame */ | ||
829 | result = io_request->state_handlers->frame_handler( | ||
830 | io_request, frame_index); | ||
831 | } | ||
832 | } | ||
833 | |||
834 | return result; | ||
835 | } | ||
836 | |||
837 | /** | ||
838 | * | ||
839 | * @[in]: sci_dev This is the device object that is receiving the event. | ||
840 | * @[in]: event_code The event code to process. | ||
841 | * | ||
842 | * This is a common method for handling events reported to the remote device | ||
843 | * from the controller object. enum sci_status | ||
844 | */ | ||
845 | enum sci_status scic_sds_remote_device_general_event_handler( | ||
846 | struct scic_sds_remote_device *sci_dev, | ||
847 | u32 event_code) | ||
848 | { | ||
849 | return scic_sds_remote_device_core_event_handler(sci_dev, | ||
850 | event_code, | ||
851 | true); | ||
852 | } | ||
853 | |||
854 | /* | ||
855 | * ***************************************************************************** | ||
856 | * * STOPPED STATE HANDLERS | ||
857 | * ***************************************************************************** */ | ||
858 | |||
859 | /** | ||
860 | * | ||
861 | * @device: | ||
862 | * | ||
863 | * This method takes the struct scic_sds_remote_device from a stopped state and | ||
864 | * attempts to start it. The RNC buffer for the device is constructed and the | ||
865 | * device state machine is transitioned to the | ||
866 | * SCIC_BASE_REMOTE_DEVICE_STATE_STARTING. enum sci_status SCI_SUCCESS if there is | ||
867 | * an RNC buffer available to construct the remote device. | ||
868 | * SCI_FAILURE_INSUFFICIENT_RESOURCES if there is no RNC buffer available in | ||
869 | * which to construct the remote device. | ||
870 | */ | ||
871 | static enum sci_status scic_sds_remote_device_stopped_state_start_handler( | ||
872 | struct scic_sds_remote_device *sci_dev) | ||
873 | { | ||
874 | enum sci_status status; | ||
875 | |||
876 | status = scic_sds_remote_node_context_resume(&sci_dev->rnc, | ||
877 | scic_sds_remote_device_resume_complete_handler, sci_dev); | ||
878 | |||
879 | if (status == SCI_SUCCESS) | ||
880 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
881 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); | ||
882 | |||
883 | return status; | ||
884 | } | ||
885 | |||
886 | static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( | ||
887 | struct scic_sds_remote_device *sci_dev) | ||
888 | { | ||
889 | return SCI_SUCCESS; | ||
890 | } | ||
891 | |||
892 | /** | ||
893 | * | ||
894 | * @sci_dev: The struct scic_sds_remote_device which is cast into a | ||
895 | * struct scic_sds_remote_device. | ||
896 | * | ||
897 | * This method will destruct a struct scic_sds_remote_device that is in a stopped | ||
898 | * state. This is the only state from which a destruct request will succeed. | ||
899 | * The RNi for this struct scic_sds_remote_device is returned to the free pool and the | ||
900 | * device object transitions to the SCI_BASE_REMOTE_DEVICE_STATE_FINAL. | ||
901 | * enum sci_status SCI_SUCCESS | ||
902 | */ | ||
903 | static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( | ||
904 | struct scic_sds_remote_device *sci_dev) | ||
905 | { | ||
906 | struct scic_sds_controller *scic; | ||
907 | |||
908 | scic = scic_sds_remote_device_get_controller(sci_dev); | ||
909 | scic_sds_controller_free_remote_node_context(scic, sci_dev, | ||
910 | sci_dev->rnc.remote_node_index); | ||
911 | sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; | ||
912 | |||
913 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
914 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL); | ||
915 | |||
916 | return SCI_SUCCESS; | ||
917 | } | ||
918 | |||
919 | /* | ||
920 | * ***************************************************************************** | ||
921 | * * STARTING STATE HANDLERS | ||
922 | * ***************************************************************************** */ | ||
923 | |||
924 | static enum sci_status scic_sds_remote_device_starting_state_stop_handler( | ||
925 | struct scic_sds_remote_device *sci_dev) | ||
926 | { | ||
927 | /* | ||
928 | * This device has not yet started so there had better be no IO requests | ||
929 | */ | ||
930 | BUG_ON(sci_dev->started_request_count != 0); | ||
931 | |||
932 | /* | ||
933 | * Destroy the remote node context | ||
934 | */ | ||
935 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
936 | scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev); | ||
937 | |||
938 | /* | ||
939 | * Transition to the stopping state and wait for the remote node to | ||
940 | * complete being posted and invalidated. | ||
941 | */ | ||
942 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
943 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); | ||
944 | |||
945 | return SCI_SUCCESS; | ||
946 | } | ||
947 | |||
948 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | ||
949 | struct scic_sds_remote_device *sci_dev) | ||
950 | { | ||
951 | enum sci_status status = SCI_SUCCESS; | ||
952 | |||
953 | /* Request the parent state machine to transition to the stopping state */ | ||
954 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
955 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); | ||
956 | |||
957 | if (sci_dev->started_request_count == 0) { | ||
958 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
959 | scic_sds_cb_remote_device_rnc_destruct_complete, | ||
960 | sci_dev); | ||
961 | } else | ||
962 | status = scic_sds_remote_device_terminate_requests(sci_dev); | ||
963 | |||
964 | return status; | ||
965 | } | ||
966 | |||
967 | /** | ||
968 | * | ||
969 | * @device: The struct scic_sds_remote_device object which is cast to a | ||
970 | * struct scic_sds_remote_device object. | ||
971 | * | ||
972 | * This is the ready state device reset handler enum sci_status | ||
973 | */ | ||
974 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | ||
975 | struct scic_sds_remote_device *sci_dev) | ||
976 | { | ||
977 | /* Request the parent state machine to transition to the stopping state */ | ||
978 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
979 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); | ||
980 | |||
981 | return SCI_SUCCESS; | ||
982 | } | ||
983 | |||
984 | /* | ||
985 | * This method will attempt to start a task request for this device object. The | ||
986 | * remote device object will issue the start request for the task and if | ||
987 | * successful it will start the request for the port object then increment its | ||
988 | * own requet count. enum sci_status SCI_SUCCESS if the task request is started for | ||
989 | * this device object. SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request | ||
990 | * object could not get the resources to start. | ||
991 | */ | ||
992 | static enum sci_status scic_sds_remote_device_ready_state_start_task_handler( | ||
993 | struct scic_sds_remote_device *sci_dev, | ||
994 | struct scic_sds_request *request) | ||
995 | { | ||
996 | enum sci_status result; | ||
997 | |||
998 | /* See if the port is in a state where we can start the IO request */ | ||
999 | result = scic_sds_port_start_io( | ||
1000 | scic_sds_remote_device_get_port(sci_dev), sci_dev, request); | ||
1001 | |||
1002 | if (result == SCI_SUCCESS) { | ||
1003 | result = scic_sds_remote_node_context_start_task(&sci_dev->rnc, | ||
1004 | request); | ||
1005 | if (result == SCI_SUCCESS) | ||
1006 | result = scic_sds_request_start(request); | ||
1007 | |||
1008 | scic_sds_remote_device_start_request(sci_dev, request, result); | ||
1009 | } | ||
1010 | |||
1011 | return result; | ||
1012 | } | ||
1013 | |||
1014 | /* | ||
1015 | * This method will attempt to start an io request for this device object. The | ||
1016 | * remote device object will issue the start request for the io and if | ||
1017 | * successful it will start the request for the port object then increment its | ||
1018 | * own requet count. enum sci_status SCI_SUCCESS if the io request is started for | ||
1019 | * this device object. SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request | ||
1020 | * object could not get the resources to start. | ||
1021 | */ | ||
1022 | static enum sci_status scic_sds_remote_device_ready_state_start_io_handler( | ||
1023 | struct scic_sds_remote_device *sci_dev, | ||
1024 | struct scic_sds_request *request) | ||
1025 | { | ||
1026 | enum sci_status result; | ||
1027 | |||
1028 | /* See if the port is in a state where we can start the IO request */ | ||
1029 | result = scic_sds_port_start_io( | ||
1030 | scic_sds_remote_device_get_port(sci_dev), sci_dev, request); | ||
1031 | |||
1032 | if (result == SCI_SUCCESS) { | ||
1033 | result = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request); | ||
1034 | if (result == SCI_SUCCESS) | ||
1035 | result = scic_sds_request_start(request); | ||
1036 | |||
1037 | scic_sds_remote_device_start_request(sci_dev, request, result); | ||
1038 | } | ||
1039 | |||
1040 | return result; | ||
1041 | } | ||
1042 | |||
1043 | /* | ||
1044 | * This method will complete the request for the remote device object. The | ||
1045 | * method will call the completion handler for the request object and if | ||
1046 | * successful it will complete the request on the port object then decrement | ||
1047 | * its own started_request_count. enum sci_status | ||
1048 | */ | ||
1049 | static enum sci_status scic_sds_remote_device_ready_state_complete_request_handler( | ||
1050 | struct scic_sds_remote_device *sci_dev, | ||
1051 | struct scic_sds_request *request) | ||
1052 | { | ||
1053 | enum sci_status result; | ||
1054 | |||
1055 | result = scic_sds_request_complete(request); | ||
1056 | |||
1057 | if (result != SCI_SUCCESS) | ||
1058 | return result; | ||
1059 | |||
1060 | /* See if the port is in a state | ||
1061 | * where we can start the IO request */ | ||
1062 | result = scic_sds_port_complete_io( | ||
1063 | scic_sds_remote_device_get_port(sci_dev), | ||
1064 | sci_dev, request); | ||
1065 | |||
1066 | if (result == SCI_SUCCESS) | ||
1067 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
1068 | |||
1069 | return result; | ||
1070 | } | ||
1071 | |||
1072 | /* | ||
1073 | * ***************************************************************************** | ||
1074 | * * STOPPING STATE HANDLERS | ||
1075 | * ***************************************************************************** */ | ||
1076 | |||
1077 | /** | ||
1078 | * | ||
1079 | * @sci_dev: The struct scic_sds_remote_device which is cast into a | ||
1080 | * struct scic_sds_remote_device. | ||
1081 | * | ||
1082 | * This method will stop a struct scic_sds_remote_device that is already in the | ||
1083 | * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This is not considered an error | ||
1084 | * since we allow a stop request on a device that is alreay stopping or | ||
1085 | * stopped. enum sci_status SCI_SUCCESS | ||
1086 | */ | ||
1087 | static enum sci_status scic_sds_remote_device_stopping_state_stop_handler( | ||
1088 | struct scic_sds_remote_device *device) | ||
1089 | { | ||
1090 | /* | ||
1091 | * All requests should have been terminated, but if there is an | ||
1092 | * attempt to stop a device already in the stopping state, then | ||
1093 | * try again to terminate. */ | ||
1094 | return scic_sds_remote_device_terminate_requests(device); | ||
1095 | } | ||
1096 | |||
1097 | |||
1098 | /** | ||
1099 | * | ||
1100 | * @device: The device object for which the request is completing. | ||
1101 | * @request: The task request that is being completed. | ||
1102 | * | ||
1103 | * This method completes requests for this struct scic_sds_remote_device while it is | ||
1104 | * in the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This method calls the | ||
1105 | * complete method for the request object and if that is successful the port | ||
1106 | * object is called to complete the task request. Then the device object itself | ||
1107 | * completes the task request. If struct scic_sds_remote_device started_request_count | ||
1108 | * goes to 0 and the invalidate RNC request has completed the device object can | ||
1109 | * transition to the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED. enum sci_status | ||
1110 | */ | ||
1111 | static enum sci_status scic_sds_remote_device_stopping_state_complete_request_handler( | ||
1112 | struct scic_sds_remote_device *sci_dev, | ||
1113 | struct scic_sds_request *request) | ||
1114 | { | ||
1115 | enum sci_status status = SCI_SUCCESS; | ||
1116 | |||
1117 | status = scic_sds_request_complete(request); | ||
1118 | |||
1119 | if (status != SCI_SUCCESS) | ||
1120 | return status; | ||
1121 | |||
1122 | status = scic_sds_port_complete_io(scic_sds_remote_device_get_port(sci_dev), | ||
1123 | sci_dev, request); | ||
1124 | if (status != SCI_SUCCESS) | ||
1125 | return status; | ||
1126 | |||
1127 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
1128 | |||
1129 | if (scic_sds_remote_device_get_request_count(sci_dev) == 0) | ||
1130 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
1131 | scic_sds_cb_remote_device_rnc_destruct_complete, | ||
1132 | sci_dev); | ||
1133 | return SCI_SUCCESS; | ||
1134 | } | ||
1135 | |||
1136 | /** | ||
1137 | * | ||
1138 | * @device: The struct scic_sds_remote_device which is to be cast into a | ||
1139 | * struct scic_sds_remote_device object. | ||
1140 | * | ||
1141 | * This method will complete the reset operation when the device is in the | ||
1142 | * resetting state. enum sci_status | ||
1143 | */ | ||
1144 | static enum sci_status scic_sds_remote_device_resetting_state_reset_complete_handler( | ||
1145 | struct scic_sds_remote_device *sci_dev) | ||
1146 | { | ||
1147 | |||
1148 | sci_base_state_machine_change_state( | ||
1149 | &sci_dev->state_machine, | ||
1150 | SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
1151 | ); | ||
1152 | |||
1153 | return SCI_SUCCESS; | ||
1154 | } | ||
1155 | |||
1156 | /** | ||
1157 | * | ||
1158 | * @device: The struct scic_sds_remote_device which is to be cast into a | ||
1159 | * struct scic_sds_remote_device object. | ||
1160 | * | ||
1161 | * This method will stop the remote device while in the resetting state. | ||
1162 | * enum sci_status | ||
1163 | */ | ||
1164 | static enum sci_status scic_sds_remote_device_resetting_state_stop_handler( | ||
1165 | struct scic_sds_remote_device *sci_dev) | ||
1166 | { | ||
1167 | sci_base_state_machine_change_state( | ||
1168 | &sci_dev->state_machine, | ||
1169 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
1170 | ); | ||
1171 | |||
1172 | return SCI_SUCCESS; | ||
1173 | } | ||
1174 | |||
1175 | /* | ||
1176 | * This method completes requests for this struct scic_sds_remote_device while it is | ||
1177 | * in the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the | ||
1178 | * complete method for the request object and if that is successful the port | ||
1179 | * object is called to complete the task request. Then the device object itself | ||
1180 | * completes the task request. enum sci_status | ||
1181 | */ | ||
1182 | static enum sci_status scic_sds_remote_device_resetting_state_complete_request_handler( | ||
1183 | struct scic_sds_remote_device *sci_dev, | ||
1184 | struct scic_sds_request *request) | ||
1185 | { | ||
1186 | enum sci_status status = SCI_SUCCESS; | ||
1187 | |||
1188 | status = scic_sds_request_complete(request); | ||
1189 | |||
1190 | if (status == SCI_SUCCESS) { | ||
1191 | status = scic_sds_port_complete_io( | ||
1192 | scic_sds_remote_device_get_port(sci_dev), | ||
1193 | sci_dev, request); | ||
1194 | |||
1195 | if (status == SCI_SUCCESS) { | ||
1196 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
1197 | } | ||
1198 | } | ||
1199 | |||
1200 | return status; | ||
1201 | } | ||
1202 | |||
1203 | /* | ||
1204 | * ***************************************************************************** | ||
1205 | * * FAILED STATE HANDLERS | ||
1206 | * ***************************************************************************** */ | ||
1207 | |||
1208 | /** | ||
1209 | * | ||
1210 | * @device: The struct scic_sds_remote_device which is to be cast into a | ||
1211 | * struct scic_sds_remote_device object. | ||
1212 | * | ||
1213 | * This method handles the remove request for a failed struct scic_sds_remote_device | ||
1214 | * object. The method will transition the device object to the | ||
1215 | * SCIC_BASE_REMOTE_DEVICE_STATE_STOPPING. enum sci_status SCI_SUCCESS | ||
1216 | */ | ||
1217 | |||
1218 | /* --------------------------------------------------------------------------- */ | ||
1219 | |||
1220 | static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { | ||
1221 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { | ||
1222 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1223 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1224 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1225 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1226 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1227 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1228 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1229 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1230 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1231 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1232 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1233 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1234 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1235 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1236 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1237 | }, | ||
1238 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { | ||
1239 | .start_handler = scic_sds_remote_device_stopped_state_start_handler, | ||
1240 | .stop_handler = scic_sds_remote_device_stopped_state_stop_handler, | ||
1241 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1242 | .destruct_handler = scic_sds_remote_device_stopped_state_destruct_handler, | ||
1243 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1244 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1245 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1246 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1247 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1248 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1249 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1250 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1251 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1252 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1253 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1254 | }, | ||
1255 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { | ||
1256 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1257 | .stop_handler = scic_sds_remote_device_starting_state_stop_handler, | ||
1258 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1259 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1260 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1261 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1262 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1263 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1264 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1265 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1266 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1267 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1268 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1269 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1270 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1271 | }, | ||
1272 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { | ||
1273 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1274 | .stop_handler = scic_sds_remote_device_ready_state_stop_handler, | ||
1275 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1276 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1277 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | ||
1278 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1279 | .start_io_handler = scic_sds_remote_device_ready_state_start_io_handler, | ||
1280 | .complete_io_handler = scic_sds_remote_device_ready_state_complete_request_handler, | ||
1281 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1282 | .start_task_handler = scic_sds_remote_device_ready_state_start_task_handler, | ||
1283 | .complete_task_handler = scic_sds_remote_device_ready_state_complete_request_handler, | ||
1284 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1285 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1286 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1287 | .frame_handler = scic_sds_remote_device_general_frame_handler, | ||
1288 | }, | ||
1289 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { | ||
1290 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1291 | .stop_handler = scic_sds_remote_device_stopping_state_stop_handler, | ||
1292 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1293 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1294 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1295 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1296 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1297 | .complete_io_handler = scic_sds_remote_device_stopping_state_complete_request_handler, | ||
1298 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1299 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1300 | .complete_task_handler = scic_sds_remote_device_stopping_state_complete_request_handler, | ||
1301 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1302 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1303 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1304 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1305 | }, | ||
1306 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { | ||
1307 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1308 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1309 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1310 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1311 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1312 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1313 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1314 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1315 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1316 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1317 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1318 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1319 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1320 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1321 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1322 | }, | ||
1323 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { | ||
1324 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1325 | .stop_handler = scic_sds_remote_device_resetting_state_stop_handler, | ||
1326 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1327 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1328 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1329 | .reset_complete_handler = scic_sds_remote_device_resetting_state_reset_complete_handler, | ||
1330 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1331 | .complete_io_handler = scic_sds_remote_device_resetting_state_complete_request_handler, | ||
1332 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1333 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1334 | .complete_task_handler = scic_sds_remote_device_resetting_state_complete_request_handler, | ||
1335 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1336 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1337 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1338 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1339 | }, | ||
1340 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { | ||
1341 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1342 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1343 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1344 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1345 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1346 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1347 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1348 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1349 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1350 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1351 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1352 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1353 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1354 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1355 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1356 | } | ||
1357 | }; | ||
1358 | |||
1359 | /** | ||
1360 | * | ||
1361 | * @object: This is the struct sci_base_object that is cast into a | ||
1362 | * struct scic_sds_remote_device. | ||
1363 | * | ||
1364 | * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it | ||
1365 | * immediatly transitions the remote device object to the stopped state. none | ||
1366 | */ | ||
1367 | static void scic_sds_remote_device_initial_state_enter( | ||
1368 | struct sci_base_object *object) | ||
1369 | { | ||
1370 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1371 | |||
1372 | sci_dev = container_of(object, typeof(*sci_dev), parent); | ||
1373 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1374 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); | ||
1375 | |||
1376 | /* Initial state is a transitional state to the stopped state */ | ||
1377 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
1378 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
1379 | } | ||
1380 | |||
1381 | /** | ||
1382 | * | ||
1383 | * @object: This is the struct sci_base_object that is cast into a | ||
1384 | * struct scic_sds_remote_device. | ||
1385 | * | ||
1386 | * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it | ||
1387 | * sets the stopped state handlers and if this state is entered from the | ||
1388 | * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING then the SCI User is informed that the | ||
1389 | * device stop is complete. none | ||
1390 | */ | ||
1391 | static void scic_sds_remote_device_stopped_state_enter( | ||
1392 | struct sci_base_object *object) | ||
1393 | { | ||
1394 | struct scic_sds_remote_device *sci_dev; | ||
1395 | struct scic_sds_controller *scic; | ||
1396 | struct isci_remote_device *idev; | ||
1397 | struct isci_host *ihost; | ||
1398 | u32 prev_state; | ||
1399 | |||
1400 | sci_dev = container_of(object, typeof(*sci_dev), parent); | ||
1401 | scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1402 | ihost = sci_object_get_association(scic); | ||
1403 | idev = sci_object_get_association(sci_dev); | ||
1404 | |||
1405 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1406 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
1407 | |||
1408 | /* If we are entering from the stopping state let the SCI User know that | ||
1409 | * the stop operation has completed. | ||
1410 | */ | ||
1411 | prev_state = sci_dev->state_machine.previous_state_id; | ||
1412 | if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) | ||
1413 | isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS); | ||
1414 | |||
1415 | scic_sds_controller_remote_device_stopped(scic, sci_dev); | ||
1416 | } | ||
1417 | |||
1418 | /** | ||
1419 | * | ||
1420 | * @object: This is the struct sci_base_object that is cast into a | ||
1421 | * struct scic_sds_remote_device. | ||
1422 | * | ||
1423 | * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it | ||
1424 | * sets the starting state handlers, sets the device not ready, and posts the | ||
1425 | * remote node context to the hardware. none | ||
1426 | */ | ||
1427 | static void scic_sds_remote_device_starting_state_enter(struct sci_base_object *object) | ||
1428 | { | ||
1429 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1430 | parent); | ||
1431 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1432 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1433 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1434 | |||
1435 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1436 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); | ||
1437 | |||
1438 | isci_remote_device_not_ready(ihost, idev, | ||
1439 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); | ||
1440 | } | ||
1441 | |||
1442 | static void scic_sds_remote_device_starting_state_exit(struct sci_base_object *object) | ||
1443 | { | ||
1444 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1445 | parent); | ||
1446 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1447 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1448 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1449 | |||
1450 | /* | ||
1451 | * @todo Check the device object for the proper return code for this | ||
1452 | * callback | ||
1453 | */ | ||
1454 | isci_remote_device_start_complete(ihost, idev, SCI_SUCCESS); | ||
1455 | } | ||
1456 | |||
1457 | /** | ||
1458 | * | ||
1459 | * @object: This is the struct sci_base_object that is cast into a | ||
1460 | * struct scic_sds_remote_device. | ||
1461 | * | ||
1462 | * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets | ||
1463 | * the ready state handlers, and starts the ready substate machine. none | ||
1464 | */ | ||
1465 | static void scic_sds_remote_device_ready_state_enter(struct sci_base_object *object) | ||
1466 | { | ||
1467 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1468 | parent); | ||
1469 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1470 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1471 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1472 | |||
1473 | SET_STATE_HANDLER(sci_dev, | ||
1474 | scic_sds_remote_device_state_handler_table, | ||
1475 | SCI_BASE_REMOTE_DEVICE_STATE_READY); | ||
1476 | |||
1477 | scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++; | ||
1478 | |||
1479 | if (sci_dev->has_ready_substate_machine) | ||
1480 | sci_base_state_machine_start(&sci_dev->ready_substate_machine); | ||
1481 | else | ||
1482 | isci_remote_device_ready(ihost, idev); | ||
1483 | } | ||
1484 | |||
1485 | /** | ||
1486 | * | ||
1487 | * @object: This is the struct sci_base_object that is cast into a | ||
1488 | * struct scic_sds_remote_device. | ||
1489 | * | ||
1490 | * This is the exit function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it does | ||
1491 | * nothing. none | ||
1492 | */ | ||
1493 | static void scic_sds_remote_device_ready_state_exit( | ||
1494 | struct sci_base_object *object) | ||
1495 | { | ||
1496 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1497 | parent); | ||
1498 | if (sci_dev->has_ready_substate_machine) | ||
1499 | sci_base_state_machine_stop(&sci_dev->ready_substate_machine); | ||
1500 | else { | ||
1501 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1502 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1503 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1504 | |||
1505 | isci_remote_device_not_ready(ihost, idev, | ||
1506 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED); | ||
1507 | } | ||
1508 | } | ||
1509 | |||
1510 | /** | ||
1511 | * | ||
1512 | * @object: This is the struct sci_base_object that is cast into a | ||
1513 | * struct scic_sds_remote_device. | ||
1514 | * | ||
1515 | * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING it | ||
1516 | * sets the stopping state handlers and posts an RNC invalidate request to the | ||
1517 | * SCU hardware. none | ||
1518 | */ | ||
1519 | static void scic_sds_remote_device_stopping_state_enter( | ||
1520 | struct sci_base_object *object) | ||
1521 | { | ||
1522 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1523 | |||
1524 | SET_STATE_HANDLER( | ||
1525 | sci_dev, | ||
1526 | scic_sds_remote_device_state_handler_table, | ||
1527 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
1528 | ); | ||
1529 | } | ||
1530 | |||
1531 | /** | ||
1532 | * | ||
1533 | * @object: This is the struct sci_base_object that is cast into a | ||
1534 | * struct scic_sds_remote_device. | ||
1535 | * | ||
1536 | * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FAILED it sets | ||
1537 | * the stopping state handlers. none | ||
1538 | */ | ||
1539 | static void scic_sds_remote_device_failed_state_enter( | ||
1540 | struct sci_base_object *object) | ||
1541 | { | ||
1542 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1543 | |||
1544 | SET_STATE_HANDLER( | ||
1545 | sci_dev, | ||
1546 | scic_sds_remote_device_state_handler_table, | ||
1547 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED | ||
1548 | ); | ||
1549 | } | ||
1550 | |||
1551 | /** | ||
1552 | * | ||
1553 | * @object: This is the struct sci_base_object that is cast into a | ||
1554 | * struct scic_sds_remote_device. | ||
1555 | * | ||
1556 | * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it | ||
1557 | * sets the resetting state handlers. none | ||
1558 | */ | ||
1559 | static void scic_sds_remote_device_resetting_state_enter( | ||
1560 | struct sci_base_object *object) | ||
1561 | { | ||
1562 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1563 | |||
1564 | SET_STATE_HANDLER( | ||
1565 | sci_dev, | ||
1566 | scic_sds_remote_device_state_handler_table, | ||
1567 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING | ||
1568 | ); | ||
1569 | |||
1570 | scic_sds_remote_node_context_suspend( | ||
1571 | &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); | ||
1572 | } | ||
1573 | |||
1574 | /** | ||
1575 | * | ||
1576 | * @object: This is the struct sci_base_object that is cast into a | ||
1577 | * struct scic_sds_remote_device. | ||
1578 | * | ||
1579 | * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it | ||
1580 | * does nothing. none | ||
1581 | */ | ||
1582 | static void scic_sds_remote_device_resetting_state_exit( | ||
1583 | struct sci_base_object *object) | ||
1584 | { | ||
1585 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1586 | |||
1587 | scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); | ||
1588 | } | ||
1589 | |||
1590 | /** | ||
1591 | * | ||
1592 | * @object: This is the struct sci_base_object that is cast into a | ||
1593 | * struct scic_sds_remote_device. | ||
1594 | * | ||
1595 | * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FINAL it sets | ||
1596 | * the final state handlers. none | ||
1597 | */ | ||
1598 | static void scic_sds_remote_device_final_state_enter( | ||
1599 | struct sci_base_object *object) | ||
1600 | { | ||
1601 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1602 | |||
1603 | SET_STATE_HANDLER( | ||
1604 | sci_dev, | ||
1605 | scic_sds_remote_device_state_handler_table, | ||
1606 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL | ||
1607 | ); | ||
1608 | } | ||
1609 | |||
1610 | /* --------------------------------------------------------------------------- */ | ||
1611 | |||
1612 | static const struct sci_base_state scic_sds_remote_device_state_table[] = { | ||
1613 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { | ||
1614 | .enter_state = scic_sds_remote_device_initial_state_enter, | ||
1615 | }, | ||
1616 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { | ||
1617 | .enter_state = scic_sds_remote_device_stopped_state_enter, | ||
1618 | }, | ||
1619 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { | ||
1620 | .enter_state = scic_sds_remote_device_starting_state_enter, | ||
1621 | .exit_state = scic_sds_remote_device_starting_state_exit | ||
1622 | }, | ||
1623 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { | ||
1624 | .enter_state = scic_sds_remote_device_ready_state_enter, | ||
1625 | .exit_state = scic_sds_remote_device_ready_state_exit | ||
1626 | }, | ||
1627 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { | ||
1628 | .enter_state = scic_sds_remote_device_stopping_state_enter, | ||
1629 | }, | ||
1630 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { | ||
1631 | .enter_state = scic_sds_remote_device_failed_state_enter, | ||
1632 | }, | ||
1633 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { | ||
1634 | .enter_state = scic_sds_remote_device_resetting_state_enter, | ||
1635 | .exit_state = scic_sds_remote_device_resetting_state_exit | ||
1636 | }, | ||
1637 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { | ||
1638 | .enter_state = scic_sds_remote_device_final_state_enter, | ||
1639 | }, | ||
1640 | }; | ||
1641 | |||
1642 | void scic_remote_device_construct(struct scic_sds_port *sci_port, | ||
1643 | struct scic_sds_remote_device *sci_dev) | ||
1644 | { | ||
1645 | sci_dev->owning_port = sci_port; | ||
1646 | sci_dev->started_request_count = 0; | ||
1647 | sci_dev->parent.private = NULL; | ||
1648 | |||
1649 | sci_base_state_machine_construct( | ||
1650 | &sci_dev->state_machine, | ||
1651 | &sci_dev->parent, | ||
1652 | scic_sds_remote_device_state_table, | ||
1653 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL | ||
1654 | ); | ||
1655 | |||
1656 | sci_base_state_machine_start( | ||
1657 | &sci_dev->state_machine | ||
1658 | ); | ||
1659 | |||
1660 | scic_sds_remote_node_context_construct(&sci_dev->rnc, | ||
1661 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); | ||
1662 | |||
1663 | sci_object_set_association(&sci_dev->rnc, sci_dev); | ||
1664 | } | ||
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.h b/drivers/scsi/isci/core/scic_sds_remote_device.h deleted file mode 100644 index bff44b8b83ab..000000000000 --- a/drivers/scsi/isci/core/scic_sds_remote_device.h +++ /dev/null | |||
@@ -1,694 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_SDS_REMOTE_DEVICE_H_ | ||
57 | #define _SCIC_SDS_REMOTE_DEVICE_H_ | ||
58 | |||
59 | #include "intel_sas.h" | ||
60 | #include "scu_remote_node_context.h" | ||
61 | #include "scic_sds_remote_node_context.h" | ||
62 | #include <scsi/libsas.h> | ||
63 | |||
64 | /** | ||
65 | * enum scic_sds_remote_device_states - This enumeration depicts all the states | ||
66 | * for the common remote device state machine. | ||
67 | * | ||
68 | * | ||
69 | */ | ||
70 | enum scic_sds_remote_device_states { | ||
71 | /** | ||
72 | * Simply the initial state for the base remote device state machine. | ||
73 | */ | ||
74 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, | ||
75 | |||
76 | /** | ||
77 | * This state indicates that the remote device has successfully been | ||
78 | * stopped. In this state no new IO operations are permitted. | ||
79 | * This state is entered from the INITIAL state. | ||
80 | * This state is entered from the STOPPING state. | ||
81 | */ | ||
82 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, | ||
83 | |||
84 | /** | ||
85 | * This state indicates the the remote device is in the process of | ||
86 | * becoming ready (i.e. starting). In this state no new IO operations | ||
87 | * are permitted. | ||
88 | * This state is entered from the STOPPED state. | ||
89 | */ | ||
90 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, | ||
91 | |||
92 | /** | ||
93 | * This state indicates the remote device is now ready. Thus, the user | ||
94 | * is able to perform IO operations on the remote device. | ||
95 | * This state is entered from the STARTING state. | ||
96 | */ | ||
97 | SCI_BASE_REMOTE_DEVICE_STATE_READY, | ||
98 | |||
99 | /** | ||
100 | * This state indicates that the remote device is in the process of | ||
101 | * stopping. In this state no new IO operations are permitted, but | ||
102 | * existing IO operations are allowed to complete. | ||
103 | * This state is entered from the READY state. | ||
104 | * This state is entered from the FAILED state. | ||
105 | */ | ||
106 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | ||
107 | |||
108 | /** | ||
109 | * This state indicates that the remote device has failed. | ||
110 | * In this state no new IO operations are permitted. | ||
111 | * This state is entered from the INITIALIZING state. | ||
112 | * This state is entered from the READY state. | ||
113 | */ | ||
114 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | ||
115 | |||
116 | /** | ||
117 | * This state indicates the device is being reset. | ||
118 | * In this state no new IO operations are permitted. | ||
119 | * This state is entered from the READY state. | ||
120 | */ | ||
121 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | ||
122 | |||
123 | /** | ||
124 | * Simply the final state for the base remote device state machine. | ||
125 | */ | ||
126 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | ||
127 | }; | ||
128 | |||
129 | /** | ||
130 | * enum scic_sds_ssp_remote_device_ready_substates - | ||
131 | * | ||
132 | * This is the enumeration of the ready substates for the | ||
133 | * struct scic_sds_remote_device. | ||
134 | */ | ||
135 | enum scic_sds_ssp_remote_device_ready_substates { | ||
136 | /** | ||
137 | * This is the initial state for the remote device ready substate. | ||
138 | */ | ||
139 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, | ||
140 | |||
141 | /** | ||
142 | * This is the ready operational substate for the remote device. | ||
143 | * This is the normal operational state for a remote device. | ||
144 | */ | ||
145 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, | ||
146 | |||
147 | /** | ||
148 | * This is the suspended state for the remote device. This is the state | ||
149 | * that the device is placed in when a RNC suspend is received by | ||
150 | * the SCU hardware. | ||
151 | */ | ||
152 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, | ||
153 | |||
154 | /** | ||
155 | * This is the final state that the device is placed in before a change | ||
156 | * to the base state machine. | ||
157 | */ | ||
158 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, | ||
159 | |||
160 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES | ||
161 | }; | ||
162 | |||
163 | /** | ||
164 | * enum scic_sds_stp_remote_device_ready_substates - | ||
165 | * | ||
166 | * This is the enumeration for the struct scic_sds_remote_device ready substates | ||
167 | * for the STP remote device. | ||
168 | */ | ||
169 | enum scic_sds_stp_remote_device_ready_substates { | ||
170 | /** | ||
171 | * This is the idle substate for the stp remote device. When there are no | ||
172 | * active IO for the device it is is in this state. | ||
173 | */ | ||
174 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | ||
175 | |||
176 | /** | ||
177 | * This is the command state for for the STP remote device. This state is | ||
178 | * entered when the device is processing a non-NCQ command. The device object | ||
179 | * will fail any new start IO requests until this command is complete. | ||
180 | */ | ||
181 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | ||
182 | |||
183 | /** | ||
184 | * This is the NCQ state for the STP remote device. This state is entered | ||
185 | * when the device is processing an NCQ reuqest. It will remain in this state | ||
186 | * so long as there is one or more NCQ requests being processed. | ||
187 | */ | ||
188 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, | ||
189 | |||
190 | /** | ||
191 | * This is the NCQ error state for the STP remote device. This state is | ||
192 | * entered when an SDB error FIS is received by the device object while in the | ||
193 | * NCQ state. The device object will only accept a READ LOG command while in | ||
194 | * this state. | ||
195 | */ | ||
196 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, | ||
197 | |||
198 | #if !defined(DISABLE_ATAPI) | ||
199 | /** | ||
200 | * This is the ATAPI error state for the STP ATAPI remote device. This state is | ||
201 | * entered when ATAPI device sends error status FIS without data while the device | ||
202 | * object is in CMD state. A suspension event is expected in this state. The device | ||
203 | * object will resume right away. | ||
204 | */ | ||
205 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR, | ||
206 | #endif | ||
207 | |||
208 | /** | ||
209 | * This is the READY substate indicates the device is waiting for the RESET task | ||
210 | * coming to be recovered from certain hardware specific error. | ||
211 | */ | ||
212 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, | ||
213 | }; | ||
214 | |||
215 | /** | ||
216 | * enum scic_sds_smp_remote_device_ready_substates - | ||
217 | * | ||
218 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. | ||
219 | */ | ||
220 | enum scic_sds_smp_remote_device_ready_substates { | ||
221 | /** | ||
222 | * This is the ready operational substate for the remote device. This is the | ||
223 | * normal operational state for a remote device. | ||
224 | */ | ||
225 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | ||
226 | |||
227 | /** | ||
228 | * This is the suspended state for the remote device. This is the state that | ||
229 | * the device is placed in when a RNC suspend is received by the SCU hardware. | ||
230 | */ | ||
231 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | ||
232 | }; | ||
233 | |||
234 | /** | ||
235 | * struct scic_sds_remote_device - This structure contains the data for an SCU | ||
236 | * implementation of the SCU Core device data. | ||
237 | * | ||
238 | * | ||
239 | */ | ||
240 | struct scic_sds_remote_device { | ||
241 | /** | ||
242 | * The field specifies that the parent object for the base remote | ||
243 | * device is the base object itself. | ||
244 | */ | ||
245 | struct sci_base_object parent; | ||
246 | |||
247 | /** | ||
248 | * This field contains the information for the base remote device state | ||
249 | * machine. | ||
250 | */ | ||
251 | struct sci_base_state_machine state_machine; | ||
252 | |||
253 | /** | ||
254 | * This field is the programmed device port width. This value is | ||
255 | * written to the RCN data structure to tell the SCU how many open | ||
256 | * connections this device can have. | ||
257 | */ | ||
258 | u32 device_port_width; | ||
259 | |||
260 | /** | ||
261 | * This field is the programmed connection rate for this remote device. It is | ||
262 | * used to program the TC with the maximum allowed connection rate. | ||
263 | */ | ||
264 | enum sas_linkrate connection_rate; | ||
265 | |||
266 | /** | ||
267 | * This field contains the allowed target protocols for this remote device. | ||
268 | */ | ||
269 | struct smp_discover_response_protocols target_protocols; | ||
270 | |||
271 | /** | ||
272 | * This field contains the device SAS address. | ||
273 | */ | ||
274 | struct sci_sas_address device_address; | ||
275 | |||
276 | /** | ||
277 | * This filed is assinged the value of true if the device is directly | ||
278 | * attached to the port. | ||
279 | */ | ||
280 | bool is_direct_attached; | ||
281 | |||
282 | #if !defined(DISABLE_ATAPI) | ||
283 | /** | ||
284 | * This filed is assinged the value of true if the device is an ATAPI | ||
285 | * device. | ||
286 | */ | ||
287 | bool is_atapi; | ||
288 | #endif | ||
289 | |||
290 | /** | ||
291 | * This filed contains a pointer back to the port to which this device | ||
292 | * is assigned. | ||
293 | */ | ||
294 | struct scic_sds_port *owning_port; | ||
295 | |||
296 | /** | ||
297 | * This field contains the SCU silicon remote node context specific | ||
298 | * information. | ||
299 | */ | ||
300 | struct scic_sds_remote_node_context rnc; | ||
301 | |||
302 | /** | ||
303 | * This field contains the stated request count for the remote device. The | ||
304 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all | ||
305 | * requests are complete and the rnc_posted value is false. | ||
306 | */ | ||
307 | u32 started_request_count; | ||
308 | |||
309 | /** | ||
310 | * This field contains a pointer to the working request object. It is only | ||
311 | * used only for SATA requests since the unsolicited frames we get from the | ||
312 | * hardware have no Tag value to look up the io request object. | ||
313 | */ | ||
314 | struct scic_sds_request *working_request; | ||
315 | |||
316 | /** | ||
317 | * This field contains the reason for the remote device going not_ready. It is | ||
318 | * assigned in the state handlers and used in the state transition. | ||
319 | */ | ||
320 | u32 not_ready_reason; | ||
321 | |||
322 | /** | ||
323 | * This field is true if this remote device has an initialzied ready substate | ||
324 | * machine. SSP devices do not have a ready substate machine and STP devices | ||
325 | * have a ready substate machine. | ||
326 | */ | ||
327 | bool has_ready_substate_machine; | ||
328 | |||
329 | /** | ||
330 | * This field contains the state machine for the ready substate machine for | ||
331 | * this struct scic_sds_remote_device object. | ||
332 | */ | ||
333 | struct sci_base_state_machine ready_substate_machine; | ||
334 | |||
335 | /** | ||
336 | * This field maintains the set of state handlers for the remote device | ||
337 | * object. These are changed each time the remote device enters a new state. | ||
338 | */ | ||
339 | const struct scic_sds_remote_device_state_handler *state_handlers; | ||
340 | }; | ||
341 | |||
342 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) | ||
343 | { | ||
344 | struct scic_sds_remote_device *sci_dev; | ||
345 | |||
346 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); | ||
347 | |||
348 | return sci_dev; | ||
349 | } | ||
350 | |||
351 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( | ||
352 | struct scic_sds_remote_device *device, | ||
353 | struct scic_sds_request *request); | ||
354 | |||
355 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( | ||
356 | struct scic_sds_remote_device *device, | ||
357 | struct scic_sds_request *request, | ||
358 | void *, | ||
359 | enum sci_io_status); | ||
360 | |||
361 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( | ||
362 | struct scic_sds_remote_device *sci_dev); | ||
363 | |||
364 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( | ||
365 | struct scic_sds_remote_device *sci_dev, | ||
366 | u32 suspend_type); | ||
367 | |||
368 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( | ||
369 | struct scic_sds_remote_device *sci_dev); | ||
370 | |||
371 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( | ||
372 | struct scic_sds_remote_device *sci_dev, | ||
373 | u32 frame_index); | ||
374 | |||
375 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( | ||
376 | struct scic_sds_remote_device *sci_dev, | ||
377 | u32 event_code); | ||
378 | |||
379 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( | ||
380 | struct scic_sds_remote_device *sci_dev); | ||
381 | |||
382 | /** | ||
383 | * struct scic_sds_remote_device_state_handler - This structure conains the | ||
384 | * state handlers that are needed to process requests for the SCU remote | ||
385 | * device objects. | ||
386 | * | ||
387 | * | ||
388 | */ | ||
389 | struct scic_sds_remote_device_state_handler { | ||
390 | /** | ||
391 | * The start_handler specifies the method invoked when a user | ||
392 | * attempts to start a remote device. | ||
393 | */ | ||
394 | scic_sds_remote_device_handler_t start_handler; | ||
395 | |||
396 | /** | ||
397 | * The stop_handler specifies the method invoked when a user attempts to | ||
398 | * stop a remote device. | ||
399 | */ | ||
400 | scic_sds_remote_device_handler_t stop_handler; | ||
401 | |||
402 | /** | ||
403 | * The fail_handler specifies the method invoked when a remote device | ||
404 | * failure has occurred. A failure may be due to an inability to | ||
405 | * initialize/configure the device. | ||
406 | */ | ||
407 | scic_sds_remote_device_handler_t fail_handler; | ||
408 | |||
409 | /** | ||
410 | * The destruct_handler specifies the method invoked when attempting to | ||
411 | * destruct a remote device. | ||
412 | */ | ||
413 | scic_sds_remote_device_handler_t destruct_handler; | ||
414 | |||
415 | /** | ||
416 | * The reset handler specifies the method invloked when requesting to | ||
417 | * reset a remote device. | ||
418 | */ | ||
419 | scic_sds_remote_device_handler_t reset_handler; | ||
420 | |||
421 | /** | ||
422 | * The reset complete handler specifies the method invloked when | ||
423 | * reporting that a reset has completed to the remote device. | ||
424 | */ | ||
425 | scic_sds_remote_device_handler_t reset_complete_handler; | ||
426 | |||
427 | /** | ||
428 | * The start_io_handler specifies the method invoked when a user | ||
429 | * attempts to start an IO request for a remote device. | ||
430 | */ | ||
431 | scic_sds_remote_device_request_handler_t start_io_handler; | ||
432 | |||
433 | /** | ||
434 | * The complete_io_handler specifies the method invoked when a user | ||
435 | * attempts to complete an IO request for a remote device. | ||
436 | */ | ||
437 | scic_sds_remote_device_request_handler_t complete_io_handler; | ||
438 | |||
439 | /** | ||
440 | * The continue_io_handler specifies the method invoked when a user | ||
441 | * attempts to continue an IO request for a remote device. | ||
442 | */ | ||
443 | scic_sds_remote_device_request_handler_t continue_io_handler; | ||
444 | |||
445 | /** | ||
446 | * The start_task_handler specifies the method invoked when a user | ||
447 | * attempts to start a task management request for a remote device. | ||
448 | */ | ||
449 | scic_sds_remote_device_request_handler_t start_task_handler; | ||
450 | |||
451 | /** | ||
452 | * The complete_task_handler specifies the method invoked when a user | ||
453 | * attempts to complete a task management request for a remote device. | ||
454 | */ | ||
455 | scic_sds_remote_device_request_handler_t complete_task_handler; | ||
456 | |||
457 | |||
458 | scic_sds_remote_device_suspend_handler_t suspend_handler; | ||
459 | scic_sds_remote_device_resume_handler_t resume_handler; | ||
460 | scic_sds_remote_device_event_handler_t event_handler; | ||
461 | scic_sds_remote_device_frame_handler_t frame_handler; | ||
462 | }; | ||
463 | |||
464 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; | ||
465 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; | ||
466 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; | ||
467 | |||
468 | /** | ||
469 | * scic_sds_remote_device_increment_request_count() - | ||
470 | * | ||
471 | * This macro incrments the request count for this device | ||
472 | */ | ||
473 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ | ||
474 | ((sci_dev)->started_request_count++) | ||
475 | |||
476 | /** | ||
477 | * scic_sds_remote_device_decrement_request_count() - | ||
478 | * | ||
479 | * This macro decrements the request count for this device. This count will | ||
480 | * never decrment past 0. | ||
481 | */ | ||
482 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ | ||
483 | ((sci_dev)->started_request_count > 0 ? \ | ||
484 | (sci_dev)->started_request_count-- : 0) | ||
485 | |||
486 | /** | ||
487 | * scic_sds_remote_device_get_request_count() - | ||
488 | * | ||
489 | * This is a helper macro to return the current device request count. | ||
490 | */ | ||
491 | #define scic_sds_remote_device_get_request_count(sci_dev) \ | ||
492 | ((sci_dev)->started_request_count) | ||
493 | |||
494 | /** | ||
495 | * scic_sds_remote_device_get_port() - | ||
496 | * | ||
497 | * This macro returns the owning port of this remote device obejct. | ||
498 | */ | ||
499 | #define scic_sds_remote_device_get_port(sci_dev) \ | ||
500 | ((sci_dev)->owning_port) | ||
501 | |||
502 | /** | ||
503 | * scic_sds_remote_device_get_controller() - | ||
504 | * | ||
505 | * This macro returns the controller object that contains this device object | ||
506 | */ | ||
507 | #define scic_sds_remote_device_get_controller(sci_dev) \ | ||
508 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) | ||
509 | |||
510 | /** | ||
511 | * scic_sds_remote_device_set_state_handlers() - | ||
512 | * | ||
513 | * This macro sets the remote device state handlers pointer and is set on entry | ||
514 | * to each device state. | ||
515 | */ | ||
516 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ | ||
517 | ((sci_dev)->state_handlers = (handlers)) | ||
518 | |||
519 | /** | ||
520 | * scic_sds_remote_device_get_port() - | ||
521 | * | ||
522 | * This macro returns the owning port of this device | ||
523 | */ | ||
524 | #define scic_sds_remote_device_get_port(sci_dev) \ | ||
525 | ((sci_dev)->owning_port) | ||
526 | |||
527 | /** | ||
528 | * scic_sds_remote_device_get_sequence() - | ||
529 | * | ||
530 | * This macro returns the remote device sequence value | ||
531 | */ | ||
532 | #define scic_sds_remote_device_get_sequence(sci_dev) \ | ||
533 | (\ | ||
534 | scic_sds_remote_device_get_controller(sci_dev)-> \ | ||
535 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ | ||
536 | ) | ||
537 | |||
538 | /** | ||
539 | * scic_sds_remote_device_get_controller_peg() - | ||
540 | * | ||
541 | * This macro returns the controllers protocol engine group | ||
542 | */ | ||
543 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ | ||
544 | (\ | ||
545 | scic_sds_controller_get_protocol_engine_group(\ | ||
546 | scic_sds_port_get_controller(\ | ||
547 | scic_sds_remote_device_get_port(sci_dev) \ | ||
548 | ) \ | ||
549 | ) \ | ||
550 | ) | ||
551 | |||
552 | /** | ||
553 | * scic_sds_remote_device_get_port_index() - | ||
554 | * | ||
555 | * This macro returns the port index for the devices owning port | ||
556 | */ | ||
557 | #define scic_sds_remote_device_get_port_index(sci_dev) \ | ||
558 | (scic_sds_port_get_index(scic_sds_remote_device_get_port(sci_dev))) | ||
559 | |||
560 | /** | ||
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) \ | ||
576 | | (scic_sds_remote_device_get_port_index((device)) << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ | ||
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 | |||
603 | enum sci_status scic_sds_remote_device_complete_io( | ||
604 | struct scic_sds_controller *controller, | ||
605 | struct scic_sds_remote_device *sci_dev, | ||
606 | struct scic_sds_request *io_request); | ||
607 | |||
608 | enum sci_status scic_sds_remote_device_resume( | ||
609 | struct scic_sds_remote_device *sci_dev); | ||
610 | |||
611 | enum sci_status scic_sds_remote_device_suspend( | ||
612 | struct scic_sds_remote_device *sci_dev, | ||
613 | u32 suspend_type); | ||
614 | |||
615 | enum sci_status scic_sds_remote_device_start_task( | ||
616 | struct scic_sds_controller *controller, | ||
617 | struct scic_sds_remote_device *sci_dev, | ||
618 | struct scic_sds_request *io_request); | ||
619 | |||
620 | void scic_sds_remote_device_post_request( | ||
621 | struct scic_sds_remote_device *sci_dev, | ||
622 | u32 request); | ||
623 | |||
624 | #if !defined(DISABLE_ATAPI) | ||
625 | bool scic_sds_remote_device_is_atapi( | ||
626 | struct scic_sds_remote_device *sci_dev); | ||
627 | #else /* !defined(DISABLE_ATAPI) */ | ||
628 | #define scic_sds_remote_device_is_atapi(sci_dev) false | ||
629 | #endif /* !defined(DISABLE_ATAPI) */ | ||
630 | |||
631 | void scic_sds_remote_device_start_request( | ||
632 | struct scic_sds_remote_device *sci_dev, | ||
633 | struct scic_sds_request *sci_req, | ||
634 | enum sci_status status); | ||
635 | |||
636 | void scic_sds_remote_device_continue_request(void *sci_dev); | ||
637 | |||
638 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
639 | struct scic_sds_remote_device *sci_dev); | ||
640 | |||
641 | enum sci_status scic_sds_remote_device_default_fail_handler( | ||
642 | struct scic_sds_remote_device *sci_dev); | ||
643 | |||
644 | enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
645 | struct scic_sds_remote_device *sci_dev); | ||
646 | |||
647 | enum sci_status scic_sds_remote_device_default_reset_handler( | ||
648 | struct scic_sds_remote_device *device); | ||
649 | |||
650 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | ||
651 | struct scic_sds_remote_device *device); | ||
652 | |||
653 | enum sci_status scic_sds_remote_device_default_start_request_handler( | ||
654 | struct scic_sds_remote_device *device, | ||
655 | struct scic_sds_request *request); | ||
656 | |||
657 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | ||
658 | struct scic_sds_remote_device *device, | ||
659 | struct scic_sds_request *request); | ||
660 | |||
661 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | ||
662 | struct scic_sds_remote_device *device, | ||
663 | struct scic_sds_request *request); | ||
664 | |||
665 | enum sci_status scic_sds_remote_device_default_suspend_handler( | ||
666 | struct scic_sds_remote_device *sci_dev, | ||
667 | u32 suspend_type); | ||
668 | |||
669 | enum sci_status scic_sds_remote_device_default_resume_handler( | ||
670 | struct scic_sds_remote_device *sci_dev); | ||
671 | |||
672 | |||
673 | enum sci_status scic_sds_remote_device_default_frame_handler( | ||
674 | struct scic_sds_remote_device *sci_dev, | ||
675 | u32 frame_index); | ||
676 | |||
677 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | ||
678 | struct scic_sds_remote_device *device); | ||
679 | |||
680 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | ||
681 | struct scic_sds_remote_device *device); | ||
682 | |||
683 | enum sci_status scic_sds_remote_device_general_frame_handler( | ||
684 | struct scic_sds_remote_device *sci_dev, | ||
685 | u32 frame_index); | ||
686 | |||
687 | enum sci_status scic_sds_remote_device_general_event_handler( | ||
688 | struct scic_sds_remote_device *sci_dev, | ||
689 | u32 event_code); | ||
690 | |||
691 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( | ||
692 | struct scic_sds_remote_device *sci_dev); | ||
693 | |||
694 | #endif /* _SCIC_SDS_REMOTE_DEVICE_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c index 63ebbf39dc90..dfb94121d445 100644 --- a/drivers/scsi/isci/core/scic_sds_request.c +++ b/drivers/scsi/isci/core/scic_sds_request.c | |||
@@ -59,11 +59,10 @@ | |||
59 | #include "intel_sat.h" | 59 | #include "intel_sat.h" |
60 | #include "scic_controller.h" | 60 | #include "scic_controller.h" |
61 | #include "scic_io_request.h" | 61 | #include "scic_io_request.h" |
62 | #include "scic_remote_device.h" | ||
63 | #include "scic_sds_controller.h" | 62 | #include "scic_sds_controller.h" |
64 | #include "scu_registers.h" | 63 | #include "scu_registers.h" |
65 | #include "scic_sds_port.h" | 64 | #include "scic_sds_port.h" |
66 | #include "scic_sds_remote_device.h" | 65 | #include "remote_device.h" |
67 | #include "scic_sds_request.h" | 66 | #include "scic_sds_request.h" |
68 | #include "scic_sds_smp_request.h" | 67 | #include "scic_sds_smp_request.h" |
69 | #include "scic_sds_stp_request.h" | 68 | #include "scic_sds_stp_request.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.c b/drivers/scsi/isci/core/scic_sds_smp_request.c index 3274d62ac3b2..1790f25758d1 100644 --- a/drivers/scsi/isci/core/scic_sds_smp_request.c +++ b/drivers/scsi/isci/core/scic_sds_smp_request.c | |||
@@ -56,9 +56,8 @@ | |||
56 | #include "intel_sas.h" | 56 | #include "intel_sas.h" |
57 | #include "sci_base_state_machine.h" | 57 | #include "sci_base_state_machine.h" |
58 | #include "scic_controller.h" | 58 | #include "scic_controller.h" |
59 | #include "scic_remote_device.h" | ||
60 | #include "scic_sds_controller.h" | 59 | #include "scic_sds_controller.h" |
61 | #include "scic_sds_remote_device.h" | 60 | #include "remote_device.h" |
62 | #include "scic_sds_request.h" | 61 | #include "scic_sds_request.h" |
63 | #include "scic_sds_smp_request.h" | 62 | #include "scic_sds_smp_request.h" |
64 | #include "sci_environment.h" | 63 | #include "sci_environment.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_stp_packet_request.c b/drivers/scsi/isci/core/scic_sds_stp_packet_request.c index e4d2bf56f491..1cb77bbb7485 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_packet_request.c +++ b/drivers/scsi/isci/core/scic_sds_stp_packet_request.c | |||
@@ -61,9 +61,8 @@ | |||
61 | #include "sati_translator_sequence.h" | 61 | #include "sati_translator_sequence.h" |
62 | #include "sci_base_state.h" | 62 | #include "sci_base_state.h" |
63 | #include "scic_controller.h" | 63 | #include "scic_controller.h" |
64 | #include "scic_remote_device.h" | ||
65 | #include "scic_sds_controller.h" | 64 | #include "scic_sds_controller.h" |
66 | #include "scic_sds_remote_device.h" | 65 | #include "remote_device.h" |
67 | #include "scic_sds_request.h" | 66 | #include "scic_sds_request.h" |
68 | #include "scic_sds_stp_packet_request.h" | 67 | #include "scic_sds_stp_packet_request.h" |
69 | #include "scic_user_callback.h" | 68 | #include "scic_user_callback.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/core/scic_sds_stp_request.c index ab01f8d5506b..59c5f1b8f1f6 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_request.c +++ b/drivers/scsi/isci/core/scic_sds_stp_request.c | |||
@@ -60,9 +60,8 @@ | |||
60 | #include "sci_base_state.h" | 60 | #include "sci_base_state.h" |
61 | #include "sci_base_state_machine.h" | 61 | #include "sci_base_state_machine.h" |
62 | #include "scic_io_request.h" | 62 | #include "scic_io_request.h" |
63 | #include "scic_remote_device.h" | ||
64 | #include "scic_sds_controller.h" | 63 | #include "scic_sds_controller.h" |
65 | #include "scic_sds_remote_device.h" | 64 | #include "remote_device.h" |
66 | #include "scic_sds_request.h" | 65 | #include "scic_sds_request.h" |
67 | #include "scic_sds_stp_pio_request.h" | 66 | #include "scic_sds_stp_pio_request.h" |
68 | #include "scic_sds_stp_request.h" | 67 | #include "scic_sds_stp_request.h" |
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 3aceb9219d7b..676bcdbfc316 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -55,14 +55,12 @@ | |||
55 | 55 | ||
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "scic_io_request.h" | 57 | #include "scic_io_request.h" |
58 | #include "scic_remote_device.h" | ||
59 | #include "scic_port.h" | 58 | #include "scic_port.h" |
60 | |||
61 | #include "port.h" | 59 | #include "port.h" |
62 | #include "request.h" | 60 | #include "request.h" |
63 | #include "host.h" | 61 | #include "host.h" |
64 | #include "probe_roms.h" | 62 | #include "probe_roms.h" |
65 | #include "core/scic_sds_controller.h" | 63 | #include "scic_sds_controller.h" |
66 | 64 | ||
67 | irqreturn_t isci_msix_isr(int vec, void *data) | 65 | irqreturn_t isci_msix_isr(int vec, void *data) |
68 | { | 66 | { |
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h index 21bd7d88e5d8..8dc8d1c46986 100644 --- a/drivers/scsi/isci/host.h +++ b/drivers/scsi/isci/host.h | |||
@@ -61,7 +61,6 @@ | |||
61 | /*#include "task.h"*/ | 61 | /*#include "task.h"*/ |
62 | #include "timers.h" | 62 | #include "timers.h" |
63 | #include "remote_device.h" | 63 | #include "remote_device.h" |
64 | #include "scic_remote_device.h" | ||
65 | 64 | ||
66 | #define DRV_NAME "isci" | 65 | #define DRV_NAME "isci" |
67 | #define SCI_PCI_BAR_COUNT 2 | 66 | #define SCI_PCI_BAR_COUNT 2 |
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index a23ea2c1c7db..f7ca9e8d9146 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c | |||
@@ -62,7 +62,6 @@ | |||
62 | #include "isci.h" | 62 | #include "isci.h" |
63 | #include "task.h" | 63 | #include "task.h" |
64 | #include "sci_controller_constants.h" | 64 | #include "sci_controller_constants.h" |
65 | #include "scic_remote_device.h" | ||
66 | #include "sci_environment.h" | 65 | #include "sci_environment.h" |
67 | #include "probe_roms.h" | 66 | #include "probe_roms.h" |
68 | 67 | ||
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index cf78cf0a6749..430b29ed6c7e 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <linux/workqueue.h> | 63 | #include <linux/workqueue.h> |
64 | #include "isci.h" | 64 | #include "isci.h" |
65 | #include "scic_io_request.h" | 65 | #include "scic_io_request.h" |
66 | #include "scic_remote_device.h" | ||
67 | #include "scic_phy.h" | 66 | #include "scic_phy.h" |
68 | #include "scic_sds_phy.h" | 67 | #include "scic_sds_phy.h" |
69 | #include "scic_port.h" | 68 | #include "scic_port.h" |
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h index 76546fd5b7d0..eeac7bbc9430 100644 --- a/drivers/scsi/isci/port.h +++ b/drivers/scsi/isci/port.h | |||
@@ -64,6 +64,7 @@ | |||
64 | 64 | ||
65 | struct isci_phy; | 65 | struct isci_phy; |
66 | struct isci_host; | 66 | struct isci_host; |
67 | struct scic_sds_phy; | ||
67 | 68 | ||
68 | 69 | ||
69 | enum isci_status { | 70 | enum isci_status { |
diff --git a/drivers/scsi/isci/probe_roms.c b/drivers/scsi/isci/probe_roms.c index 2df8d8e5d5ea..933d81109ea4 100644 --- a/drivers/scsi/isci/probe_roms.c +++ b/drivers/scsi/isci/probe_roms.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include "isci.h" | 33 | #include "isci.h" |
34 | #include "task.h" | 34 | #include "task.h" |
35 | #include "sci_controller_constants.h" | 35 | #include "sci_controller_constants.h" |
36 | #include "scic_remote_device.h" | ||
37 | #include "sci_environment.h" | 36 | #include "sci_environment.h" |
38 | #include "probe_roms.h" | 37 | #include "probe_roms.h" |
39 | 38 | ||
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 1553221fe4d7..6b9ea9022843 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -52,18 +52,1169 @@ | |||
52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
54 | */ | 54 | */ |
55 | 55 | #include "intel_sas.h" | |
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "scic_io_request.h" | ||
58 | #include "scic_remote_device.h" | ||
59 | #include "scic_phy.h" | ||
60 | #include "scic_port.h" | ||
61 | #include "port.h" | 57 | #include "port.h" |
62 | #include "remote_device.h" | 58 | #include "remote_device.h" |
63 | #include "request.h" | 59 | #include "request.h" |
60 | #include "scic_controller.h" | ||
61 | #include "scic_io_request.h" | ||
62 | #include "scic_phy.h" | ||
63 | #include "scic_port.h" | ||
64 | #include "scic_sds_controller.h" | ||
65 | #include "scic_sds_phy.h" | ||
66 | #include "scic_sds_port.h" | ||
67 | #include "remote_node_context.h" | ||
68 | #include "scic_sds_request.h" | ||
69 | #include "sci_environment.h" | ||
70 | #include "sci_util.h" | ||
71 | #include "scu_event_codes.h" | ||
64 | #include "task.h" | 72 | #include "task.h" |
65 | 73 | ||
74 | enum sci_status scic_remote_device_stop( | ||
75 | struct scic_sds_remote_device *sci_dev, | ||
76 | u32 timeout) | ||
77 | { | ||
78 | return sci_dev->state_handlers->stop_handler(sci_dev); | ||
79 | } | ||
80 | |||
81 | |||
82 | enum sci_status scic_remote_device_reset( | ||
83 | struct scic_sds_remote_device *sci_dev) | ||
84 | { | ||
85 | return sci_dev->state_handlers->reset_handler(sci_dev); | ||
86 | } | ||
87 | |||
88 | |||
89 | enum sci_status scic_remote_device_reset_complete( | ||
90 | struct scic_sds_remote_device *sci_dev) | ||
91 | { | ||
92 | return sci_dev->state_handlers->reset_complete_handler(sci_dev); | ||
93 | } | ||
94 | |||
95 | |||
96 | enum sas_linkrate scic_remote_device_get_connection_rate( | ||
97 | struct scic_sds_remote_device *sci_dev) | ||
98 | { | ||
99 | return sci_dev->connection_rate; | ||
100 | } | ||
101 | |||
102 | |||
103 | void scic_remote_device_get_protocols( | ||
104 | struct scic_sds_remote_device *sci_dev, | ||
105 | struct smp_discover_response_protocols *pr) | ||
106 | { | ||
107 | pr->u.all = sci_dev->target_protocols.u.all; | ||
108 | } | ||
109 | |||
110 | #if !defined(DISABLE_ATAPI) | ||
111 | bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev) | ||
112 | { | ||
113 | return sci_dev->is_atapi; | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | |||
118 | /** | ||
119 | * | ||
120 | * | ||
121 | * Remote device timer requirements | ||
122 | */ | ||
123 | #define SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT (0) | ||
124 | #define SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT (SCI_MAX_REMOTE_DEVICES) | ||
125 | |||
126 | |||
127 | /** | ||
128 | * | ||
129 | * @sci_dev: The remote device for which the suspend is being requested. | ||
130 | * | ||
131 | * This method invokes the remote device suspend state handler. enum sci_status | ||
132 | */ | ||
133 | enum sci_status scic_sds_remote_device_suspend( | ||
134 | struct scic_sds_remote_device *sci_dev, | ||
135 | u32 suspend_type) | ||
136 | { | ||
137 | return sci_dev->state_handlers->suspend_handler(sci_dev, suspend_type); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * | ||
142 | * @sci_dev: The remote device for which the event handling is being | ||
143 | * requested. | ||
144 | * @frame_index: This is the frame index that is being processed. | ||
145 | * | ||
146 | * This method invokes the frame handler for the remote device state machine | ||
147 | * enum sci_status | ||
148 | */ | ||
149 | enum sci_status scic_sds_remote_device_frame_handler( | ||
150 | struct scic_sds_remote_device *sci_dev, | ||
151 | u32 frame_index) | ||
152 | { | ||
153 | return sci_dev->state_handlers->frame_handler(sci_dev, frame_index); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * | ||
158 | * @sci_dev: The remote device for which the event handling is being | ||
159 | * requested. | ||
160 | * @event_code: This is the event code that is to be processed. | ||
161 | * | ||
162 | * This method invokes the remote device event handler. enum sci_status | ||
163 | */ | ||
164 | enum sci_status scic_sds_remote_device_event_handler( | ||
165 | struct scic_sds_remote_device *sci_dev, | ||
166 | u32 event_code) | ||
167 | { | ||
168 | return sci_dev->state_handlers->event_handler(sci_dev, event_code); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * | ||
173 | * @controller: The controller that is starting the io request. | ||
174 | * @sci_dev: The remote device for which the start io handling is being | ||
175 | * requested. | ||
176 | * @io_request: The io request that is being started. | ||
177 | * | ||
178 | * This method invokes the remote device start io handler. enum sci_status | ||
179 | */ | ||
180 | enum sci_status scic_sds_remote_device_start_io( | ||
181 | struct scic_sds_controller *controller, | ||
182 | struct scic_sds_remote_device *sci_dev, | ||
183 | struct scic_sds_request *io_request) | ||
184 | { | ||
185 | return sci_dev->state_handlers->start_io_handler( | ||
186 | sci_dev, io_request); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * | ||
191 | * @controller: The controller that is completing the io request. | ||
192 | * @sci_dev: The remote device for which the complete io handling is being | ||
193 | * requested. | ||
194 | * @io_request: The io request that is being completed. | ||
195 | * | ||
196 | * This method invokes the remote device complete io handler. enum sci_status | ||
197 | */ | ||
198 | enum sci_status scic_sds_remote_device_complete_io( | ||
199 | struct scic_sds_controller *controller, | ||
200 | struct scic_sds_remote_device *sci_dev, | ||
201 | struct scic_sds_request *io_request) | ||
202 | { | ||
203 | return sci_dev->state_handlers->complete_io_handler( | ||
204 | sci_dev, io_request); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * | ||
209 | * @controller: The controller that is starting the task request. | ||
210 | * @sci_dev: The remote device for which the start task handling is being | ||
211 | * requested. | ||
212 | * @io_request: The task request that is being started. | ||
213 | * | ||
214 | * This method invokes the remote device start task handler. enum sci_status | ||
215 | */ | ||
216 | enum sci_status scic_sds_remote_device_start_task( | ||
217 | struct scic_sds_controller *controller, | ||
218 | struct scic_sds_remote_device *sci_dev, | ||
219 | struct scic_sds_request *io_request) | ||
220 | { | ||
221 | return sci_dev->state_handlers->start_task_handler( | ||
222 | sci_dev, io_request); | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * | ||
227 | * @controller: The controller that is completing the task request. | ||
228 | * @sci_dev: The remote device for which the complete task handling is | ||
229 | * being requested. | ||
230 | * @io_request: The task request that is being completed. | ||
231 | * | ||
232 | * This method invokes the remote device complete task handler. enum sci_status | ||
233 | */ | ||
234 | |||
235 | /** | ||
236 | * | ||
237 | * @sci_dev: | ||
238 | * @request: | ||
239 | * | ||
240 | * This method takes the request and bulids an appropriate SCU context for the | ||
241 | * request and then requests the controller to post the request. none | ||
242 | */ | ||
243 | void scic_sds_remote_device_post_request( | ||
244 | struct scic_sds_remote_device *sci_dev, | ||
245 | u32 request) | ||
246 | { | ||
247 | u32 context; | ||
248 | |||
249 | context = scic_sds_remote_device_build_command_context(sci_dev, request); | ||
250 | |||
251 | scic_sds_controller_post_request( | ||
252 | scic_sds_remote_device_get_controller(sci_dev), | ||
253 | context | ||
254 | ); | ||
255 | } | ||
256 | |||
257 | #if !defined(DISABLE_ATAPI) | ||
258 | /** | ||
259 | * | ||
260 | * @sci_dev: The device to be checked. | ||
261 | * | ||
262 | * This method check the signature fis of a stp device to decide whether a | ||
263 | * device is atapi or not. true if a device is atapi device. False if a device | ||
264 | * is not atapi. | ||
265 | */ | ||
266 | bool scic_sds_remote_device_is_atapi( | ||
267 | struct scic_sds_remote_device *sci_dev) | ||
268 | { | ||
269 | if (!sci_dev->target_protocols.u.bits.attached_stp_target) | ||
270 | return false; | ||
271 | else if (sci_dev->is_direct_attached) { | ||
272 | struct scic_sds_phy *phy; | ||
273 | struct scic_sata_phy_properties properties; | ||
274 | struct sata_fis_reg_d2h *signature_fis; | ||
275 | phy = scic_sds_port_get_a_connected_phy(sci_dev->owning_port); | ||
276 | scic_sata_phy_get_properties(phy, &properties); | ||
277 | |||
278 | /* decode the signature fis. */ | ||
279 | signature_fis = &(properties.signature_fis); | ||
280 | |||
281 | if ((signature_fis->sector_count == 0x01) | ||
282 | && (signature_fis->lba_low == 0x01) | ||
283 | && (signature_fis->lba_mid == 0x14) | ||
284 | && (signature_fis->lba_high == 0xEB) | ||
285 | && ((signature_fis->device & 0x5F) == 0x00) | ||
286 | ) { | ||
287 | /* An ATA device supporting the PACKET command set. */ | ||
288 | return true; | ||
289 | } else | ||
290 | return false; | ||
291 | } else { | ||
292 | /* Expander supported ATAPI device is not currently supported. */ | ||
293 | return false; | ||
294 | } | ||
295 | } | ||
296 | #endif | ||
297 | |||
298 | /** | ||
299 | * | ||
300 | * @user_parameter: This is cast to a remote device object. | ||
301 | * | ||
302 | * This method is called once the remote node context is ready to be freed. | ||
303 | * The remote device can now report that its stop operation is complete. none | ||
304 | */ | ||
305 | static void scic_sds_cb_remote_device_rnc_destruct_complete( | ||
306 | void *user_parameter) | ||
307 | { | ||
308 | struct scic_sds_remote_device *sci_dev; | ||
309 | |||
310 | sci_dev = (struct scic_sds_remote_device *)user_parameter; | ||
311 | |||
312 | BUG_ON(sci_dev->started_request_count != 0); | ||
313 | |||
314 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
315 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * | ||
320 | * @user_parameter: This is cast to a remote device object. | ||
321 | * | ||
322 | * This method is called once the remote node context has transisitioned to a | ||
323 | * ready state. This is the indication that the remote device object can also | ||
324 | * transition to ready. none | ||
325 | */ | ||
326 | static void scic_sds_remote_device_resume_complete_handler( | ||
327 | void *user_parameter) | ||
328 | { | ||
329 | struct scic_sds_remote_device *sci_dev; | ||
330 | |||
331 | sci_dev = (struct scic_sds_remote_device *)user_parameter; | ||
332 | |||
333 | if ( | ||
334 | sci_base_state_machine_get_state(&sci_dev->state_machine) | ||
335 | != SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
336 | ) { | ||
337 | sci_base_state_machine_change_state( | ||
338 | &sci_dev->state_machine, | ||
339 | SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
340 | ); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * | ||
346 | * @device: This parameter specifies the device for which the request is being | ||
347 | * started. | ||
348 | * @request: This parameter specifies the request being started. | ||
349 | * @status: This parameter specifies the current start operation status. | ||
350 | * | ||
351 | * This method will perform the STP request start processing common to IO | ||
352 | * requests and task requests of all types. none | ||
353 | */ | ||
354 | void scic_sds_remote_device_start_request( | ||
355 | struct scic_sds_remote_device *sci_dev, | ||
356 | struct scic_sds_request *sci_req, | ||
357 | enum sci_status status) | ||
358 | { | ||
359 | /* We still have a fault in starting the io complete it on the port */ | ||
360 | if (status == SCI_SUCCESS) | ||
361 | scic_sds_remote_device_increment_request_count(sci_dev); | ||
362 | else{ | ||
363 | sci_dev->owning_port->state_handlers->complete_io_handler( | ||
364 | sci_dev->owning_port, sci_dev, sci_req | ||
365 | ); | ||
366 | } | ||
367 | } | ||
368 | |||
369 | |||
370 | /** | ||
371 | * | ||
372 | * @request: This parameter specifies the request being continued. | ||
373 | * | ||
374 | * This method will continue to post tc for a STP request. This method usually | ||
375 | * serves as a callback when RNC gets resumed during a task management | ||
376 | * sequence. none | ||
377 | */ | ||
378 | void scic_sds_remote_device_continue_request(void *dev) | ||
379 | { | ||
380 | struct scic_sds_remote_device *sci_dev = dev; | ||
66 | 381 | ||
382 | /* we need to check if this request is still valid to continue. */ | ||
383 | if (sci_dev->working_request) | ||
384 | scic_controller_continue_io(sci_dev->working_request); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * This method will terminate all of the IO requests in the controllers IO | ||
389 | * request table that were targeted for this device. | ||
390 | * @sci_dev: This parameter specifies the remote device for which to | ||
391 | * attempt to terminate all requests. | ||
392 | * | ||
393 | * This method returns an indication as to whether all requests were | ||
394 | * successfully terminated. If a single request fails to be terminated, then | ||
395 | * this method will return the failure. | ||
396 | */ | ||
397 | static enum sci_status scic_sds_remote_device_terminate_requests( | ||
398 | struct scic_sds_remote_device *sci_dev) | ||
399 | { | ||
400 | enum sci_status status = SCI_SUCCESS; | ||
401 | enum sci_status terminate_status = SCI_SUCCESS; | ||
402 | struct scic_sds_request *sci_req; | ||
403 | u32 index; | ||
404 | u32 request_count = sci_dev->started_request_count; | ||
405 | |||
406 | for (index = 0; | ||
407 | (index < SCI_MAX_IO_REQUESTS) && (request_count > 0); | ||
408 | index++) { | ||
409 | sci_req = sci_dev->owning_port->owning_controller->io_request_table[index]; | ||
410 | |||
411 | if ((sci_req != NULL) && (sci_req->target_device == sci_dev)) { | ||
412 | terminate_status = scic_controller_terminate_request( | ||
413 | sci_dev->owning_port->owning_controller, | ||
414 | sci_dev, | ||
415 | sci_req | ||
416 | ); | ||
417 | |||
418 | if (terminate_status != SCI_SUCCESS) | ||
419 | status = terminate_status; | ||
420 | |||
421 | request_count--; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | return status; | ||
426 | } | ||
427 | |||
428 | static enum sci_status | ||
429 | default_device_handler(struct scic_sds_remote_device *sci_dev, | ||
430 | const char *func) | ||
431 | { | ||
432 | dev_warn(scirdev_to_dev(sci_dev), | ||
433 | "%s: in wrong state: %d\n", func, | ||
434 | sci_base_state_machine_get_state(&sci_dev->state_machine)); | ||
435 | return SCI_FAILURE_INVALID_STATE; | ||
436 | } | ||
437 | |||
438 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
439 | struct scic_sds_remote_device *sci_dev) | ||
440 | { | ||
441 | return default_device_handler(sci_dev, __func__); | ||
442 | } | ||
443 | |||
444 | static enum sci_status scic_sds_remote_device_default_stop_handler( | ||
445 | struct scic_sds_remote_device *sci_dev) | ||
446 | { | ||
447 | return default_device_handler(sci_dev, __func__); | ||
448 | } | ||
449 | |||
450 | enum sci_status scic_sds_remote_device_default_fail_handler( | ||
451 | struct scic_sds_remote_device *sci_dev) | ||
452 | { | ||
453 | return default_device_handler(sci_dev, __func__); | ||
454 | } | ||
455 | |||
456 | enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
457 | struct scic_sds_remote_device *sci_dev) | ||
458 | { | ||
459 | return default_device_handler(sci_dev, __func__); | ||
460 | } | ||
461 | |||
462 | enum sci_status scic_sds_remote_device_default_reset_handler( | ||
463 | struct scic_sds_remote_device *sci_dev) | ||
464 | { | ||
465 | return default_device_handler(sci_dev, __func__); | ||
466 | } | ||
467 | |||
468 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | ||
469 | struct scic_sds_remote_device *sci_dev) | ||
470 | { | ||
471 | return default_device_handler(sci_dev, __func__); | ||
472 | } | ||
473 | |||
474 | enum sci_status scic_sds_remote_device_default_suspend_handler( | ||
475 | struct scic_sds_remote_device *sci_dev, u32 suspend_type) | ||
476 | { | ||
477 | return default_device_handler(sci_dev, __func__); | ||
478 | } | ||
479 | |||
480 | enum sci_status scic_sds_remote_device_default_resume_handler( | ||
481 | struct scic_sds_remote_device *sci_dev) | ||
482 | { | ||
483 | return default_device_handler(sci_dev, __func__); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * | ||
488 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
489 | * struct scic_sds_remote_device. | ||
490 | * @event_code: The event code that the struct scic_sds_controller wants the device | ||
491 | * object to process. | ||
492 | * | ||
493 | * This method is the default event handler. It will call the RNC state | ||
494 | * machine handler for any RNC events otherwise it will log a warning and | ||
495 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
496 | */ | ||
497 | static enum sci_status scic_sds_remote_device_core_event_handler( | ||
498 | struct scic_sds_remote_device *sci_dev, | ||
499 | u32 event_code, | ||
500 | bool is_ready_state) | ||
501 | { | ||
502 | enum sci_status status; | ||
503 | |||
504 | switch (scu_get_event_type(event_code)) { | ||
505 | case SCU_EVENT_TYPE_RNC_OPS_MISC: | ||
506 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX: | ||
507 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: | ||
508 | status = scic_sds_remote_node_context_event_handler(&sci_dev->rnc, event_code); | ||
509 | break; | ||
510 | case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: | ||
511 | |||
512 | if (scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT) { | ||
513 | status = SCI_SUCCESS; | ||
514 | |||
515 | /* Suspend the associated RNC */ | ||
516 | scic_sds_remote_node_context_suspend(&sci_dev->rnc, | ||
517 | SCI_SOFTWARE_SUSPENSION, | ||
518 | NULL, NULL); | ||
519 | |||
520 | dev_dbg(scirdev_to_dev(sci_dev), | ||
521 | "%s: device: %p event code: %x: %s\n", | ||
522 | __func__, sci_dev, event_code, | ||
523 | (is_ready_state) | ||
524 | ? "I_T_Nexus_Timeout event" | ||
525 | : "I_T_Nexus_Timeout event in wrong state"); | ||
526 | |||
527 | break; | ||
528 | } | ||
529 | /* Else, fall through and treat as unhandled... */ | ||
530 | |||
531 | default: | ||
532 | dev_dbg(scirdev_to_dev(sci_dev), | ||
533 | "%s: device: %p event code: %x: %s\n", | ||
534 | __func__, sci_dev, event_code, | ||
535 | (is_ready_state) | ||
536 | ? "unexpected event" | ||
537 | : "unexpected event in wrong state"); | ||
538 | status = SCI_FAILURE_INVALID_STATE; | ||
539 | break; | ||
540 | } | ||
541 | |||
542 | return status; | ||
543 | } | ||
544 | /** | ||
545 | * | ||
546 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
547 | * struct scic_sds_remote_device. | ||
548 | * @event_code: The event code that the struct scic_sds_controller wants the device | ||
549 | * object to process. | ||
550 | * | ||
551 | * This method is the default event handler. It will call the RNC state | ||
552 | * machine handler for any RNC events otherwise it will log a warning and | ||
553 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
554 | */ | ||
555 | static enum sci_status scic_sds_remote_device_default_event_handler( | ||
556 | struct scic_sds_remote_device *sci_dev, | ||
557 | u32 event_code) | ||
558 | { | ||
559 | return scic_sds_remote_device_core_event_handler(sci_dev, | ||
560 | event_code, | ||
561 | false); | ||
562 | } | ||
563 | |||
564 | /** | ||
565 | * | ||
566 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
567 | * struct scic_sds_remote_device. | ||
568 | * @frame_index: The frame index for which the struct scic_sds_controller wants this | ||
569 | * device object to process. | ||
570 | * | ||
571 | * This method is the default unsolicited frame handler. It logs a warning, | ||
572 | * releases the frame and returns a failure. enum sci_status | ||
573 | * SCI_FAILURE_INVALID_STATE | ||
574 | */ | ||
575 | enum sci_status scic_sds_remote_device_default_frame_handler( | ||
576 | struct scic_sds_remote_device *sci_dev, | ||
577 | u32 frame_index) | ||
578 | { | ||
579 | dev_warn(scirdev_to_dev(sci_dev), | ||
580 | "%s: SCIC Remote Device requested to handle frame %x " | ||
581 | "while in wrong state %d\n", | ||
582 | __func__, | ||
583 | frame_index, | ||
584 | sci_base_state_machine_get_state( | ||
585 | &sci_dev->state_machine)); | ||
586 | |||
587 | /* Return the frame back to the controller */ | ||
588 | scic_sds_controller_release_frame( | ||
589 | scic_sds_remote_device_get_controller(sci_dev), frame_index | ||
590 | ); | ||
591 | |||
592 | return SCI_FAILURE_INVALID_STATE; | ||
593 | } | ||
594 | |||
595 | enum sci_status scic_sds_remote_device_default_start_request_handler( | ||
596 | struct scic_sds_remote_device *sci_dev, | ||
597 | struct scic_sds_request *request) | ||
598 | { | ||
599 | return default_device_handler(sci_dev, __func__); | ||
600 | } | ||
601 | |||
602 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | ||
603 | struct scic_sds_remote_device *sci_dev, | ||
604 | struct scic_sds_request *request) | ||
605 | { | ||
606 | return default_device_handler(sci_dev, __func__); | ||
607 | } | ||
608 | |||
609 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | ||
610 | struct scic_sds_remote_device *sci_dev, | ||
611 | struct scic_sds_request *request) | ||
612 | { | ||
613 | return default_device_handler(sci_dev, __func__); | ||
614 | } | ||
615 | |||
616 | /** | ||
617 | * | ||
618 | * @device: The struct scic_sds_remote_device which is then cast into a | ||
619 | * struct scic_sds_remote_device. | ||
620 | * @frame_index: The frame index for which the struct scic_sds_controller wants this | ||
621 | * device object to process. | ||
622 | * | ||
623 | * This method is a general ssp frame handler. In most cases the device object | ||
624 | * needs to route the unsolicited frame processing to the io request object. | ||
625 | * This method decodes the tag for the io request object and routes the | ||
626 | * unsolicited frame to that object. enum sci_status SCI_FAILURE_INVALID_STATE | ||
627 | */ | ||
628 | enum sci_status scic_sds_remote_device_general_frame_handler( | ||
629 | struct scic_sds_remote_device *sci_dev, | ||
630 | u32 frame_index) | ||
631 | { | ||
632 | enum sci_status result; | ||
633 | struct sci_ssp_frame_header *frame_header; | ||
634 | struct scic_sds_request *io_request; | ||
635 | |||
636 | result = scic_sds_unsolicited_frame_control_get_header( | ||
637 | &(scic_sds_remote_device_get_controller(sci_dev)->uf_control), | ||
638 | frame_index, | ||
639 | (void **)&frame_header | ||
640 | ); | ||
641 | |||
642 | if (SCI_SUCCESS == result) { | ||
643 | io_request = scic_sds_controller_get_io_request_from_tag( | ||
644 | scic_sds_remote_device_get_controller(sci_dev), frame_header->tag); | ||
645 | |||
646 | if ((io_request == NULL) | ||
647 | || (io_request->target_device != sci_dev)) { | ||
648 | /* | ||
649 | * We could not map this tag to a valid IO request | ||
650 | * Just toss the frame and continue */ | ||
651 | scic_sds_controller_release_frame( | ||
652 | scic_sds_remote_device_get_controller(sci_dev), frame_index | ||
653 | ); | ||
654 | } else { | ||
655 | /* The IO request is now in charge of releasing the frame */ | ||
656 | result = io_request->state_handlers->frame_handler( | ||
657 | io_request, frame_index); | ||
658 | } | ||
659 | } | ||
660 | |||
661 | return result; | ||
662 | } | ||
663 | |||
664 | /** | ||
665 | * | ||
666 | * @[in]: sci_dev This is the device object that is receiving the event. | ||
667 | * @[in]: event_code The event code to process. | ||
668 | * | ||
669 | * This is a common method for handling events reported to the remote device | ||
670 | * from the controller object. enum sci_status | ||
671 | */ | ||
672 | enum sci_status scic_sds_remote_device_general_event_handler( | ||
673 | struct scic_sds_remote_device *sci_dev, | ||
674 | u32 event_code) | ||
675 | { | ||
676 | return scic_sds_remote_device_core_event_handler(sci_dev, | ||
677 | event_code, | ||
678 | true); | ||
679 | } | ||
680 | |||
681 | /* | ||
682 | * ***************************************************************************** | ||
683 | * * STOPPED STATE HANDLERS | ||
684 | * ***************************************************************************** */ | ||
685 | |||
686 | /** | ||
687 | * | ||
688 | * @device: | ||
689 | * | ||
690 | * This method takes the struct scic_sds_remote_device from a stopped state and | ||
691 | * attempts to start it. The RNC buffer for the device is constructed and the | ||
692 | * device state machine is transitioned to the | ||
693 | * SCIC_BASE_REMOTE_DEVICE_STATE_STARTING. enum sci_status SCI_SUCCESS if there is | ||
694 | * an RNC buffer available to construct the remote device. | ||
695 | * SCI_FAILURE_INSUFFICIENT_RESOURCES if there is no RNC buffer available in | ||
696 | * which to construct the remote device. | ||
697 | */ | ||
698 | static enum sci_status scic_sds_remote_device_stopped_state_start_handler( | ||
699 | struct scic_sds_remote_device *sci_dev) | ||
700 | { | ||
701 | enum sci_status status; | ||
702 | |||
703 | status = scic_sds_remote_node_context_resume(&sci_dev->rnc, | ||
704 | scic_sds_remote_device_resume_complete_handler, sci_dev); | ||
705 | |||
706 | if (status == SCI_SUCCESS) | ||
707 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
708 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); | ||
709 | |||
710 | return status; | ||
711 | } | ||
712 | |||
713 | static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( | ||
714 | struct scic_sds_remote_device *sci_dev) | ||
715 | { | ||
716 | return SCI_SUCCESS; | ||
717 | } | ||
718 | |||
719 | /** | ||
720 | * | ||
721 | * @sci_dev: The struct scic_sds_remote_device which is cast into a | ||
722 | * struct scic_sds_remote_device. | ||
723 | * | ||
724 | * This method will destruct a struct scic_sds_remote_device that is in a stopped | ||
725 | * state. This is the only state from which a destruct request will succeed. | ||
726 | * The RNi for this struct scic_sds_remote_device is returned to the free pool and the | ||
727 | * device object transitions to the SCI_BASE_REMOTE_DEVICE_STATE_FINAL. | ||
728 | * enum sci_status SCI_SUCCESS | ||
729 | */ | ||
730 | static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( | ||
731 | struct scic_sds_remote_device *sci_dev) | ||
732 | { | ||
733 | struct scic_sds_controller *scic; | ||
734 | |||
735 | scic = scic_sds_remote_device_get_controller(sci_dev); | ||
736 | scic_sds_controller_free_remote_node_context(scic, sci_dev, | ||
737 | sci_dev->rnc.remote_node_index); | ||
738 | sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; | ||
739 | |||
740 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
741 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL); | ||
742 | |||
743 | return SCI_SUCCESS; | ||
744 | } | ||
745 | |||
746 | /* | ||
747 | * ***************************************************************************** | ||
748 | * * STARTING STATE HANDLERS | ||
749 | * ***************************************************************************** */ | ||
750 | |||
751 | static enum sci_status scic_sds_remote_device_starting_state_stop_handler( | ||
752 | struct scic_sds_remote_device *sci_dev) | ||
753 | { | ||
754 | /* | ||
755 | * This device has not yet started so there had better be no IO requests | ||
756 | */ | ||
757 | BUG_ON(sci_dev->started_request_count != 0); | ||
758 | |||
759 | /* | ||
760 | * Destroy the remote node context | ||
761 | */ | ||
762 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
763 | scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev); | ||
764 | |||
765 | /* | ||
766 | * Transition to the stopping state and wait for the remote node to | ||
767 | * complete being posted and invalidated. | ||
768 | */ | ||
769 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
770 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); | ||
771 | |||
772 | return SCI_SUCCESS; | ||
773 | } | ||
774 | |||
775 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | ||
776 | struct scic_sds_remote_device *sci_dev) | ||
777 | { | ||
778 | enum sci_status status = SCI_SUCCESS; | ||
779 | |||
780 | /* Request the parent state machine to transition to the stopping state */ | ||
781 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
782 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); | ||
783 | |||
784 | if (sci_dev->started_request_count == 0) { | ||
785 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
786 | scic_sds_cb_remote_device_rnc_destruct_complete, | ||
787 | sci_dev); | ||
788 | } else | ||
789 | status = scic_sds_remote_device_terminate_requests(sci_dev); | ||
790 | |||
791 | return status; | ||
792 | } | ||
793 | |||
794 | /** | ||
795 | * | ||
796 | * @device: The struct scic_sds_remote_device object which is cast to a | ||
797 | * struct scic_sds_remote_device object. | ||
798 | * | ||
799 | * This is the ready state device reset handler enum sci_status | ||
800 | */ | ||
801 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | ||
802 | struct scic_sds_remote_device *sci_dev) | ||
803 | { | ||
804 | /* Request the parent state machine to transition to the stopping state */ | ||
805 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
806 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); | ||
807 | |||
808 | return SCI_SUCCESS; | ||
809 | } | ||
810 | |||
811 | /* | ||
812 | * This method will attempt to start a task request for this device object. The | ||
813 | * remote device object will issue the start request for the task and if | ||
814 | * successful it will start the request for the port object then increment its | ||
815 | * own requet count. enum sci_status SCI_SUCCESS if the task request is started for | ||
816 | * this device object. SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request | ||
817 | * object could not get the resources to start. | ||
818 | */ | ||
819 | static enum sci_status scic_sds_remote_device_ready_state_start_task_handler( | ||
820 | struct scic_sds_remote_device *sci_dev, | ||
821 | struct scic_sds_request *request) | ||
822 | { | ||
823 | enum sci_status result; | ||
824 | |||
825 | /* See if the port is in a state where we can start the IO request */ | ||
826 | result = scic_sds_port_start_io( | ||
827 | scic_sds_remote_device_get_port(sci_dev), sci_dev, request); | ||
828 | |||
829 | if (result == SCI_SUCCESS) { | ||
830 | result = scic_sds_remote_node_context_start_task(&sci_dev->rnc, | ||
831 | request); | ||
832 | if (result == SCI_SUCCESS) | ||
833 | result = scic_sds_request_start(request); | ||
834 | |||
835 | scic_sds_remote_device_start_request(sci_dev, request, result); | ||
836 | } | ||
837 | |||
838 | return result; | ||
839 | } | ||
840 | |||
841 | /* | ||
842 | * This method will attempt to start an io request for this device object. The | ||
843 | * remote device object will issue the start request for the io and if | ||
844 | * successful it will start the request for the port object then increment its | ||
845 | * own requet count. enum sci_status SCI_SUCCESS if the io request is started for | ||
846 | * this device object. SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request | ||
847 | * object could not get the resources to start. | ||
848 | */ | ||
849 | static enum sci_status scic_sds_remote_device_ready_state_start_io_handler( | ||
850 | struct scic_sds_remote_device *sci_dev, | ||
851 | struct scic_sds_request *request) | ||
852 | { | ||
853 | enum sci_status result; | ||
854 | |||
855 | /* See if the port is in a state where we can start the IO request */ | ||
856 | result = scic_sds_port_start_io( | ||
857 | scic_sds_remote_device_get_port(sci_dev), sci_dev, request); | ||
858 | |||
859 | if (result == SCI_SUCCESS) { | ||
860 | result = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request); | ||
861 | if (result == SCI_SUCCESS) | ||
862 | result = scic_sds_request_start(request); | ||
863 | |||
864 | scic_sds_remote_device_start_request(sci_dev, request, result); | ||
865 | } | ||
866 | |||
867 | return result; | ||
868 | } | ||
869 | |||
870 | /* | ||
871 | * This method will complete the request for the remote device object. The | ||
872 | * method will call the completion handler for the request object and if | ||
873 | * successful it will complete the request on the port object then decrement | ||
874 | * its own started_request_count. enum sci_status | ||
875 | */ | ||
876 | static enum sci_status scic_sds_remote_device_ready_state_complete_request_handler( | ||
877 | struct scic_sds_remote_device *sci_dev, | ||
878 | struct scic_sds_request *request) | ||
879 | { | ||
880 | enum sci_status result; | ||
881 | |||
882 | result = scic_sds_request_complete(request); | ||
883 | |||
884 | if (result != SCI_SUCCESS) | ||
885 | return result; | ||
886 | |||
887 | /* See if the port is in a state | ||
888 | * where we can start the IO request */ | ||
889 | result = scic_sds_port_complete_io( | ||
890 | scic_sds_remote_device_get_port(sci_dev), | ||
891 | sci_dev, request); | ||
892 | |||
893 | if (result == SCI_SUCCESS) | ||
894 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
895 | |||
896 | return result; | ||
897 | } | ||
898 | |||
899 | /* | ||
900 | * ***************************************************************************** | ||
901 | * * STOPPING STATE HANDLERS | ||
902 | * ***************************************************************************** */ | ||
903 | |||
904 | /** | ||
905 | * | ||
906 | * @sci_dev: The struct scic_sds_remote_device which is cast into a | ||
907 | * struct scic_sds_remote_device. | ||
908 | * | ||
909 | * This method will stop a struct scic_sds_remote_device that is already in the | ||
910 | * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This is not considered an error | ||
911 | * since we allow a stop request on a device that is alreay stopping or | ||
912 | * stopped. enum sci_status SCI_SUCCESS | ||
913 | */ | ||
914 | static enum sci_status scic_sds_remote_device_stopping_state_stop_handler( | ||
915 | struct scic_sds_remote_device *device) | ||
916 | { | ||
917 | /* | ||
918 | * All requests should have been terminated, but if there is an | ||
919 | * attempt to stop a device already in the stopping state, then | ||
920 | * try again to terminate. */ | ||
921 | return scic_sds_remote_device_terminate_requests(device); | ||
922 | } | ||
923 | |||
924 | |||
925 | /** | ||
926 | * | ||
927 | * @device: The device object for which the request is completing. | ||
928 | * @request: The task request that is being completed. | ||
929 | * | ||
930 | * This method completes requests for this struct scic_sds_remote_device while it is | ||
931 | * in the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This method calls the | ||
932 | * complete method for the request object and if that is successful the port | ||
933 | * object is called to complete the task request. Then the device object itself | ||
934 | * completes the task request. If struct scic_sds_remote_device started_request_count | ||
935 | * goes to 0 and the invalidate RNC request has completed the device object can | ||
936 | * transition to the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED. enum sci_status | ||
937 | */ | ||
938 | static enum sci_status scic_sds_remote_device_stopping_state_complete_request_handler( | ||
939 | struct scic_sds_remote_device *sci_dev, | ||
940 | struct scic_sds_request *request) | ||
941 | { | ||
942 | enum sci_status status = SCI_SUCCESS; | ||
943 | |||
944 | status = scic_sds_request_complete(request); | ||
945 | |||
946 | if (status != SCI_SUCCESS) | ||
947 | return status; | ||
948 | |||
949 | status = scic_sds_port_complete_io(scic_sds_remote_device_get_port(sci_dev), | ||
950 | sci_dev, request); | ||
951 | if (status != SCI_SUCCESS) | ||
952 | return status; | ||
953 | |||
954 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
955 | |||
956 | if (scic_sds_remote_device_get_request_count(sci_dev) == 0) | ||
957 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, | ||
958 | scic_sds_cb_remote_device_rnc_destruct_complete, | ||
959 | sci_dev); | ||
960 | return SCI_SUCCESS; | ||
961 | } | ||
962 | |||
963 | /** | ||
964 | * | ||
965 | * @device: The struct scic_sds_remote_device which is to be cast into a | ||
966 | * struct scic_sds_remote_device object. | ||
967 | * | ||
968 | * This method will complete the reset operation when the device is in the | ||
969 | * resetting state. enum sci_status | ||
970 | */ | ||
971 | static enum sci_status scic_sds_remote_device_resetting_state_reset_complete_handler( | ||
972 | struct scic_sds_remote_device *sci_dev) | ||
973 | { | ||
974 | |||
975 | sci_base_state_machine_change_state( | ||
976 | &sci_dev->state_machine, | ||
977 | SCI_BASE_REMOTE_DEVICE_STATE_READY | ||
978 | ); | ||
979 | |||
980 | return SCI_SUCCESS; | ||
981 | } | ||
982 | |||
983 | /** | ||
984 | * | ||
985 | * @device: The struct scic_sds_remote_device which is to be cast into a | ||
986 | * struct scic_sds_remote_device object. | ||
987 | * | ||
988 | * This method will stop the remote device while in the resetting state. | ||
989 | * enum sci_status | ||
990 | */ | ||
991 | static enum sci_status scic_sds_remote_device_resetting_state_stop_handler( | ||
992 | struct scic_sds_remote_device *sci_dev) | ||
993 | { | ||
994 | sci_base_state_machine_change_state( | ||
995 | &sci_dev->state_machine, | ||
996 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
997 | ); | ||
998 | |||
999 | return SCI_SUCCESS; | ||
1000 | } | ||
1001 | |||
1002 | /* | ||
1003 | * This method completes requests for this struct scic_sds_remote_device while it is | ||
1004 | * in the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the | ||
1005 | * complete method for the request object and if that is successful the port | ||
1006 | * object is called to complete the task request. Then the device object itself | ||
1007 | * completes the task request. enum sci_status | ||
1008 | */ | ||
1009 | static enum sci_status scic_sds_remote_device_resetting_state_complete_request_handler( | ||
1010 | struct scic_sds_remote_device *sci_dev, | ||
1011 | struct scic_sds_request *request) | ||
1012 | { | ||
1013 | enum sci_status status = SCI_SUCCESS; | ||
1014 | |||
1015 | status = scic_sds_request_complete(request); | ||
1016 | |||
1017 | if (status == SCI_SUCCESS) { | ||
1018 | status = scic_sds_port_complete_io( | ||
1019 | scic_sds_remote_device_get_port(sci_dev), | ||
1020 | sci_dev, request); | ||
1021 | |||
1022 | if (status == SCI_SUCCESS) { | ||
1023 | scic_sds_remote_device_decrement_request_count(sci_dev); | ||
1024 | } | ||
1025 | } | ||
1026 | |||
1027 | return status; | ||
1028 | } | ||
1029 | |||
1030 | static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { | ||
1031 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { | ||
1032 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1033 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1034 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1035 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1036 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1037 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1038 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1039 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1040 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1041 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1042 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1043 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1044 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1045 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1046 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1047 | }, | ||
1048 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { | ||
1049 | .start_handler = scic_sds_remote_device_stopped_state_start_handler, | ||
1050 | .stop_handler = scic_sds_remote_device_stopped_state_stop_handler, | ||
1051 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1052 | .destruct_handler = scic_sds_remote_device_stopped_state_destruct_handler, | ||
1053 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1054 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1055 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1056 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1057 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1058 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1059 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1060 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1061 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1062 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1063 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1064 | }, | ||
1065 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { | ||
1066 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1067 | .stop_handler = scic_sds_remote_device_starting_state_stop_handler, | ||
1068 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1069 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1070 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1071 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1072 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1073 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1074 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1075 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1076 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1077 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1078 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1079 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1080 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1081 | }, | ||
1082 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { | ||
1083 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1084 | .stop_handler = scic_sds_remote_device_ready_state_stop_handler, | ||
1085 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1086 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1087 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | ||
1088 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1089 | .start_io_handler = scic_sds_remote_device_ready_state_start_io_handler, | ||
1090 | .complete_io_handler = scic_sds_remote_device_ready_state_complete_request_handler, | ||
1091 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1092 | .start_task_handler = scic_sds_remote_device_ready_state_start_task_handler, | ||
1093 | .complete_task_handler = scic_sds_remote_device_ready_state_complete_request_handler, | ||
1094 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1095 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1096 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1097 | .frame_handler = scic_sds_remote_device_general_frame_handler, | ||
1098 | }, | ||
1099 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { | ||
1100 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1101 | .stop_handler = scic_sds_remote_device_stopping_state_stop_handler, | ||
1102 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1103 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1104 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1105 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1106 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1107 | .complete_io_handler = scic_sds_remote_device_stopping_state_complete_request_handler, | ||
1108 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1109 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1110 | .complete_task_handler = scic_sds_remote_device_stopping_state_complete_request_handler, | ||
1111 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1112 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1113 | .event_handler = scic_sds_remote_device_general_event_handler, | ||
1114 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1115 | }, | ||
1116 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { | ||
1117 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1118 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1119 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1120 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1121 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1122 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1123 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1124 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1125 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1126 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1127 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1128 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1129 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1130 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1131 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1132 | }, | ||
1133 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { | ||
1134 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1135 | .stop_handler = scic_sds_remote_device_resetting_state_stop_handler, | ||
1136 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1137 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1138 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1139 | .reset_complete_handler = scic_sds_remote_device_resetting_state_reset_complete_handler, | ||
1140 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1141 | .complete_io_handler = scic_sds_remote_device_resetting_state_complete_request_handler, | ||
1142 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1143 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1144 | .complete_task_handler = scic_sds_remote_device_resetting_state_complete_request_handler, | ||
1145 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1146 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1147 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1148 | .frame_handler = scic_sds_remote_device_general_frame_handler | ||
1149 | }, | ||
1150 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { | ||
1151 | .start_handler = scic_sds_remote_device_default_start_handler, | ||
1152 | .stop_handler = scic_sds_remote_device_default_stop_handler, | ||
1153 | .fail_handler = scic_sds_remote_device_default_fail_handler, | ||
1154 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1155 | .reset_handler = scic_sds_remote_device_default_reset_handler, | ||
1156 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | ||
1157 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | ||
1158 | .complete_io_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1159 | .continue_io_handler = scic_sds_remote_device_default_continue_request_handler, | ||
1160 | .start_task_handler = scic_sds_remote_device_default_start_request_handler, | ||
1161 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, | ||
1162 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, | ||
1163 | .resume_handler = scic_sds_remote_device_default_resume_handler, | ||
1164 | .event_handler = scic_sds_remote_device_default_event_handler, | ||
1165 | .frame_handler = scic_sds_remote_device_default_frame_handler | ||
1166 | } | ||
1167 | }; | ||
1168 | |||
1169 | static void scic_sds_remote_device_initial_state_enter( | ||
1170 | struct sci_base_object *object) | ||
1171 | { | ||
1172 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1173 | |||
1174 | sci_dev = container_of(object, typeof(*sci_dev), parent); | ||
1175 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1176 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); | ||
1177 | |||
1178 | /* Initial state is a transitional state to the stopped state */ | ||
1179 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
1180 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
1181 | } | ||
1182 | |||
1183 | /** | ||
1184 | * isci_remote_device_change_state() - This function gets the status of the | ||
1185 | * remote_device object. | ||
1186 | * @isci_device: This parameter points to the isci_remote_device object | ||
1187 | * | ||
1188 | * status of the object as a isci_status enum. | ||
1189 | */ | ||
1190 | void isci_remote_device_change_state( | ||
1191 | struct isci_remote_device *isci_device, | ||
1192 | enum isci_status status) | ||
1193 | { | ||
1194 | unsigned long flags; | ||
1195 | |||
1196 | spin_lock_irqsave(&isci_device->state_lock, flags); | ||
1197 | isci_device->status = status; | ||
1198 | spin_unlock_irqrestore(&isci_device->state_lock, flags); | ||
1199 | } | ||
1200 | |||
1201 | /** | ||
1202 | * scic_remote_device_destruct() - free remote node context and destruct | ||
1203 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
1204 | * | ||
1205 | * Remote device objects are a limited resource. As such, they must be | ||
1206 | * protected. Thus calls to construct and destruct are mutually exclusive and | ||
1207 | * non-reentrant. The return value shall indicate if the device was | ||
1208 | * successfully destructed or if some failure occurred. enum sci_status This value | ||
1209 | * is returned if the device is successfully destructed. | ||
1210 | * SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the supplied | ||
1211 | * device isn't valid (e.g. it's already been destoryed, the handle isn't | ||
1212 | * valid, etc.). | ||
1213 | */ | ||
1214 | static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) | ||
1215 | { | ||
1216 | return sci_dev->state_handlers->destruct_handler(sci_dev); | ||
1217 | } | ||
67 | 1218 | ||
68 | /** | 1219 | /** |
69 | * isci_remote_device_deconstruct() - This function frees an isci_remote_device. | 1220 | * isci_remote_device_deconstruct() - This function frees an isci_remote_device. |
@@ -98,6 +1249,418 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_ | |||
98 | wake_up(&ihost->eventq); | 1249 | wake_up(&ihost->eventq); |
99 | } | 1250 | } |
100 | 1251 | ||
1252 | /** | ||
1253 | * isci_remote_device_stop_complete() - This function is called by the scic | ||
1254 | * when the remote device stop has completed. We mark the isci device as not | ||
1255 | * ready and remove the isci remote device. | ||
1256 | * @ihost: This parameter specifies the isci host object. | ||
1257 | * @idev: This parameter specifies the remote device. | ||
1258 | * @status: This parameter specifies status of the completion. | ||
1259 | * | ||
1260 | */ | ||
1261 | static void isci_remote_device_stop_complete(struct isci_host *ihost, | ||
1262 | struct isci_remote_device *idev) | ||
1263 | { | ||
1264 | dev_dbg(&ihost->pdev->dev, "%s: complete idev = %p\n", __func__, idev); | ||
1265 | |||
1266 | isci_remote_device_change_state(idev, isci_stopped); | ||
1267 | |||
1268 | /* after stop, we can tear down resources. */ | ||
1269 | isci_remote_device_deconstruct(ihost, idev); | ||
1270 | } | ||
1271 | |||
1272 | static void scic_sds_remote_device_stopped_state_enter( | ||
1273 | struct sci_base_object *object) | ||
1274 | { | ||
1275 | struct scic_sds_remote_device *sci_dev; | ||
1276 | struct scic_sds_controller *scic; | ||
1277 | struct isci_remote_device *idev; | ||
1278 | struct isci_host *ihost; | ||
1279 | u32 prev_state; | ||
1280 | |||
1281 | sci_dev = container_of(object, typeof(*sci_dev), parent); | ||
1282 | scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1283 | ihost = sci_object_get_association(scic); | ||
1284 | idev = sci_object_get_association(sci_dev); | ||
1285 | |||
1286 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1287 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | ||
1288 | |||
1289 | /* If we are entering from the stopping state let the SCI User know that | ||
1290 | * the stop operation has completed. | ||
1291 | */ | ||
1292 | prev_state = sci_dev->state_machine.previous_state_id; | ||
1293 | if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) | ||
1294 | isci_remote_device_stop_complete(ihost, idev); | ||
1295 | |||
1296 | scic_sds_controller_remote_device_stopped(scic, sci_dev); | ||
1297 | } | ||
1298 | |||
1299 | static void scic_sds_remote_device_starting_state_enter(struct sci_base_object *object) | ||
1300 | { | ||
1301 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1302 | parent); | ||
1303 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1304 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1305 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1306 | |||
1307 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1308 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); | ||
1309 | |||
1310 | isci_remote_device_not_ready(ihost, idev, | ||
1311 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); | ||
1312 | } | ||
1313 | |||
1314 | static void scic_sds_remote_device_ready_state_enter(struct sci_base_object *object) | ||
1315 | { | ||
1316 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1317 | parent); | ||
1318 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1319 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1320 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1321 | |||
1322 | SET_STATE_HANDLER(sci_dev, | ||
1323 | scic_sds_remote_device_state_handler_table, | ||
1324 | SCI_BASE_REMOTE_DEVICE_STATE_READY); | ||
1325 | |||
1326 | scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++; | ||
1327 | |||
1328 | if (sci_dev->has_ready_substate_machine) | ||
1329 | sci_base_state_machine_start(&sci_dev->ready_substate_machine); | ||
1330 | else | ||
1331 | isci_remote_device_ready(ihost, idev); | ||
1332 | } | ||
1333 | |||
1334 | static void scic_sds_remote_device_ready_state_exit( | ||
1335 | struct sci_base_object *object) | ||
1336 | { | ||
1337 | struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev), | ||
1338 | parent); | ||
1339 | if (sci_dev->has_ready_substate_machine) | ||
1340 | sci_base_state_machine_stop(&sci_dev->ready_substate_machine); | ||
1341 | else { | ||
1342 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | ||
1343 | struct isci_host *ihost = sci_object_get_association(scic); | ||
1344 | struct isci_remote_device *idev = sci_object_get_association(sci_dev); | ||
1345 | |||
1346 | isci_remote_device_not_ready(ihost, idev, | ||
1347 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED); | ||
1348 | } | ||
1349 | } | ||
1350 | |||
1351 | static void scic_sds_remote_device_stopping_state_enter( | ||
1352 | struct sci_base_object *object) | ||
1353 | { | ||
1354 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1355 | |||
1356 | SET_STATE_HANDLER( | ||
1357 | sci_dev, | ||
1358 | scic_sds_remote_device_state_handler_table, | ||
1359 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
1360 | ); | ||
1361 | } | ||
1362 | |||
1363 | static void scic_sds_remote_device_failed_state_enter( | ||
1364 | struct sci_base_object *object) | ||
1365 | { | ||
1366 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1367 | |||
1368 | SET_STATE_HANDLER( | ||
1369 | sci_dev, | ||
1370 | scic_sds_remote_device_state_handler_table, | ||
1371 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED | ||
1372 | ); | ||
1373 | } | ||
1374 | |||
1375 | static void scic_sds_remote_device_resetting_state_enter( | ||
1376 | struct sci_base_object *object) | ||
1377 | { | ||
1378 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1379 | |||
1380 | SET_STATE_HANDLER( | ||
1381 | sci_dev, | ||
1382 | scic_sds_remote_device_state_handler_table, | ||
1383 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING | ||
1384 | ); | ||
1385 | |||
1386 | scic_sds_remote_node_context_suspend( | ||
1387 | &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); | ||
1388 | } | ||
1389 | |||
1390 | static void scic_sds_remote_device_resetting_state_exit( | ||
1391 | struct sci_base_object *object) | ||
1392 | { | ||
1393 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1394 | |||
1395 | scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); | ||
1396 | } | ||
1397 | |||
1398 | static void scic_sds_remote_device_final_state_enter( | ||
1399 | struct sci_base_object *object) | ||
1400 | { | ||
1401 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; | ||
1402 | |||
1403 | SET_STATE_HANDLER( | ||
1404 | sci_dev, | ||
1405 | scic_sds_remote_device_state_handler_table, | ||
1406 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL | ||
1407 | ); | ||
1408 | } | ||
1409 | |||
1410 | |||
1411 | static const struct sci_base_state scic_sds_remote_device_state_table[] = { | ||
1412 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { | ||
1413 | .enter_state = scic_sds_remote_device_initial_state_enter, | ||
1414 | }, | ||
1415 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { | ||
1416 | .enter_state = scic_sds_remote_device_stopped_state_enter, | ||
1417 | }, | ||
1418 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { | ||
1419 | .enter_state = scic_sds_remote_device_starting_state_enter, | ||
1420 | }, | ||
1421 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { | ||
1422 | .enter_state = scic_sds_remote_device_ready_state_enter, | ||
1423 | .exit_state = scic_sds_remote_device_ready_state_exit | ||
1424 | }, | ||
1425 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { | ||
1426 | .enter_state = scic_sds_remote_device_stopping_state_enter, | ||
1427 | }, | ||
1428 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { | ||
1429 | .enter_state = scic_sds_remote_device_failed_state_enter, | ||
1430 | }, | ||
1431 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { | ||
1432 | .enter_state = scic_sds_remote_device_resetting_state_enter, | ||
1433 | .exit_state = scic_sds_remote_device_resetting_state_exit | ||
1434 | }, | ||
1435 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { | ||
1436 | .enter_state = scic_sds_remote_device_final_state_enter, | ||
1437 | }, | ||
1438 | }; | ||
1439 | |||
1440 | /** | ||
1441 | * scic_remote_device_construct() - This method will perform the construction | ||
1442 | * common to all remote device objects. | ||
1443 | * @sci_port: SAS/SATA port through which this device is accessed. | ||
1444 | * @sci_dev: remote device to construct | ||
1445 | * | ||
1446 | * It isn't necessary to call scic_remote_device_destruct() for device objects | ||
1447 | * that have only called this method for construction. Once subsequent | ||
1448 | * construction methods have been invoked (e.g. | ||
1449 | * scic_remote_device_da_construct()), then destruction should occur. none | ||
1450 | */ | ||
1451 | static void scic_remote_device_construct(struct scic_sds_port *sci_port, | ||
1452 | struct scic_sds_remote_device *sci_dev) | ||
1453 | { | ||
1454 | sci_dev->owning_port = sci_port; | ||
1455 | sci_dev->started_request_count = 0; | ||
1456 | sci_dev->parent.private = NULL; | ||
1457 | |||
1458 | sci_base_state_machine_construct( | ||
1459 | &sci_dev->state_machine, | ||
1460 | &sci_dev->parent, | ||
1461 | scic_sds_remote_device_state_table, | ||
1462 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL | ||
1463 | ); | ||
1464 | |||
1465 | sci_base_state_machine_start( | ||
1466 | &sci_dev->state_machine | ||
1467 | ); | ||
1468 | |||
1469 | scic_sds_remote_node_context_construct(&sci_dev->rnc, | ||
1470 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); | ||
1471 | |||
1472 | sci_object_set_association(&sci_dev->rnc, sci_dev); | ||
1473 | } | ||
1474 | |||
1475 | /** | ||
1476 | * scic_remote_device_da_construct() - This method will construct a | ||
1477 | * SCIC_REMOTE_DEVICE object for a direct attached (da) device. The | ||
1478 | * information (e.g. IAF, Signature FIS, etc.) necessary to build the device | ||
1479 | * is known to the SCI Core since it is contained in the scic_phy object. | ||
1480 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
1481 | * | ||
1482 | * The user must have previously called scic_remote_device_construct() Remote | ||
1483 | * device objects are a limited resource. As such, they must be protected. | ||
1484 | * Thus calls to construct and destruct are mutually exclusive and | ||
1485 | * non-reentrant. Indicate if the remote device was successfully constructed. | ||
1486 | * SCI_SUCCESS Returned if the device was successfully constructed. | ||
1487 | * SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been | ||
1488 | * constructed. If it's an additional phy for the target, then call | ||
1489 | * scic_remote_device_da_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned | ||
1490 | * if the supplied parameters necessitate creation of a remote device for which | ||
1491 | * the protocol is not supported by the underlying controller hardware. | ||
1492 | * SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core | ||
1493 | * controller associated with the supplied parameters is unable to support | ||
1494 | * additional remote devices. | ||
1495 | */ | ||
1496 | static enum sci_status scic_remote_device_da_construct(struct scic_sds_remote_device *sci_dev) | ||
1497 | { | ||
1498 | enum sci_status status; | ||
1499 | u16 remote_node_index; | ||
1500 | struct sci_sas_identify_address_frame_protocols protocols; | ||
1501 | |||
1502 | /* | ||
1503 | * This information is request to determine how many remote node context | ||
1504 | * entries will be needed to store the remote node. | ||
1505 | */ | ||
1506 | scic_sds_port_get_attached_protocols(sci_dev->owning_port, &protocols); | ||
1507 | sci_dev->target_protocols.u.all = protocols.u.all; | ||
1508 | sci_dev->is_direct_attached = true; | ||
1509 | #if !defined(DISABLE_ATAPI) | ||
1510 | sci_dev->is_atapi = scic_sds_remote_device_is_atapi(sci_dev); | ||
1511 | #endif | ||
1512 | |||
1513 | status = scic_sds_controller_allocate_remote_node_context( | ||
1514 | sci_dev->owning_port->owning_controller, | ||
1515 | sci_dev, | ||
1516 | &remote_node_index); | ||
1517 | |||
1518 | if (status == SCI_SUCCESS) { | ||
1519 | sci_dev->rnc.remote_node_index = remote_node_index; | ||
1520 | |||
1521 | scic_sds_port_get_attached_sas_address( | ||
1522 | sci_dev->owning_port, &sci_dev->device_address); | ||
1523 | |||
1524 | if (sci_dev->target_protocols.u.bits.attached_ssp_target) { | ||
1525 | sci_dev->has_ready_substate_machine = false; | ||
1526 | } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { | ||
1527 | sci_dev->has_ready_substate_machine = true; | ||
1528 | |||
1529 | sci_base_state_machine_construct( | ||
1530 | &sci_dev->ready_substate_machine, | ||
1531 | &sci_dev->parent, | ||
1532 | scic_sds_stp_remote_device_ready_substate_table, | ||
1533 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
1534 | } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { | ||
1535 | sci_dev->has_ready_substate_machine = true; | ||
1536 | |||
1537 | /* add the SMP ready substate machine construction here */ | ||
1538 | sci_base_state_machine_construct( | ||
1539 | &sci_dev->ready_substate_machine, | ||
1540 | &sci_dev->parent, | ||
1541 | scic_sds_smp_remote_device_ready_substate_table, | ||
1542 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
1543 | } | ||
1544 | |||
1545 | sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed( | ||
1546 | sci_dev->owning_port); | ||
1547 | |||
1548 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ | ||
1549 | sci_dev->device_port_width = 1; | ||
1550 | } | ||
1551 | |||
1552 | return status; | ||
1553 | } | ||
1554 | |||
1555 | static void scic_sds_remote_device_get_info_from_smp_discover_response( | ||
1556 | struct scic_sds_remote_device *sci_dev, | ||
1557 | struct smp_response_discover *discover_response) | ||
1558 | { | ||
1559 | /* decode discover_response to set sas_address to sci_dev. */ | ||
1560 | sci_dev->device_address.high = | ||
1561 | discover_response->attached_sas_address.high; | ||
1562 | |||
1563 | sci_dev->device_address.low = | ||
1564 | discover_response->attached_sas_address.low; | ||
1565 | |||
1566 | sci_dev->target_protocols.u.all = discover_response->protocols.u.all; | ||
1567 | } | ||
1568 | |||
1569 | /** | ||
1570 | * scic_remote_device_ea_construct() - This method will construct an | ||
1571 | * SCIC_REMOTE_DEVICE object for an expander attached (ea) device from an | ||
1572 | * SMP Discover Response. | ||
1573 | * @remote_device: This parameter specifies the remote device to be destructed. | ||
1574 | * @discover_response: This parameter specifies the SMP Discovery Response to | ||
1575 | * be used in device creation. | ||
1576 | * | ||
1577 | * The user must have previously called scic_remote_device_construct() Remote | ||
1578 | * device objects are a limited resource. As such, they must be protected. | ||
1579 | * Thus calls to construct and destruct are mutually exclusive and | ||
1580 | * non-reentrant. Indicate if the remote device was successfully constructed. | ||
1581 | * SCI_SUCCESS Returned if the device was successfully constructed. | ||
1582 | * SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been | ||
1583 | * constructed. If it's an additional phy for the target, then call | ||
1584 | * scic_ea_remote_device_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned | ||
1585 | * if the supplied parameters necessitate creation of a remote device for which | ||
1586 | * the protocol is not supported by the underlying controller hardware. | ||
1587 | * SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core | ||
1588 | * controller associated with the supplied parameters is unable to support | ||
1589 | * additional remote devices. | ||
1590 | */ | ||
1591 | static enum sci_status scic_remote_device_ea_construct(struct scic_sds_remote_device *sci_dev, | ||
1592 | struct smp_response_discover *discover_response) | ||
1593 | { | ||
1594 | enum sci_status status; | ||
1595 | struct scic_sds_controller *scic; | ||
1596 | |||
1597 | scic = scic_sds_port_get_controller(sci_dev->owning_port); | ||
1598 | |||
1599 | scic_sds_remote_device_get_info_from_smp_discover_response( | ||
1600 | sci_dev, discover_response); | ||
1601 | |||
1602 | status = scic_sds_controller_allocate_remote_node_context( | ||
1603 | scic, sci_dev, &sci_dev->rnc.remote_node_index); | ||
1604 | |||
1605 | if (status == SCI_SUCCESS) { | ||
1606 | if (sci_dev->target_protocols.u.bits.attached_ssp_target) { | ||
1607 | sci_dev->has_ready_substate_machine = false; | ||
1608 | } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { | ||
1609 | sci_dev->has_ready_substate_machine = true; | ||
1610 | |||
1611 | /* add the SMP ready substate machine construction here */ | ||
1612 | sci_base_state_machine_construct( | ||
1613 | &sci_dev->ready_substate_machine, | ||
1614 | &sci_dev->parent, | ||
1615 | scic_sds_smp_remote_device_ready_substate_table, | ||
1616 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
1617 | } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { | ||
1618 | sci_dev->has_ready_substate_machine = true; | ||
1619 | |||
1620 | sci_base_state_machine_construct( | ||
1621 | &sci_dev->ready_substate_machine, | ||
1622 | &sci_dev->parent, | ||
1623 | scic_sds_stp_remote_device_ready_substate_table, | ||
1624 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); | ||
1625 | } | ||
1626 | |||
1627 | /* | ||
1628 | * For SAS-2 the physical link rate is actually a logical link | ||
1629 | * rate that incorporates multiplexing. The SCU doesn't | ||
1630 | * incorporate multiplexing and for the purposes of the | ||
1631 | * connection the logical link rate is that same as the | ||
1632 | * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay | ||
1633 | * one another, so this code works for both situations. */ | ||
1634 | sci_dev->connection_rate = min_t(u16, | ||
1635 | scic_sds_port_get_max_allowed_speed(sci_dev->owning_port), | ||
1636 | discover_response->u2.sas1_1.negotiated_physical_link_rate | ||
1637 | ); | ||
1638 | |||
1639 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ | ||
1640 | sci_dev->device_port_width = 1; | ||
1641 | } | ||
1642 | |||
1643 | return status; | ||
1644 | } | ||
1645 | |||
1646 | /** | ||
1647 | * scic_remote_device_start() - This method will start the supplied remote | ||
1648 | * device. This method enables normal IO requests to flow through to the | ||
1649 | * remote device. | ||
1650 | * @remote_device: This parameter specifies the device to be started. | ||
1651 | * @timeout: This parameter specifies the number of milliseconds in which the | ||
1652 | * start operation should complete. | ||
1653 | * | ||
1654 | * An indication of whether the device was successfully started. SCI_SUCCESS | ||
1655 | * This value is returned if the device was successfully started. | ||
1656 | * SCI_FAILURE_INVALID_PHY This value is returned if the user attempts to start | ||
1657 | * the device when there have been no phys added to it. | ||
1658 | */ | ||
1659 | static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev, | ||
1660 | u32 timeout) | ||
1661 | { | ||
1662 | return sci_dev->state_handlers->start_handler(sci_dev); | ||
1663 | } | ||
101 | 1664 | ||
102 | /** | 1665 | /** |
103 | * isci_remote_device_construct() - This function calls the scic remote device | 1666 | * isci_remote_device_construct() - This function calls the scic remote device |
@@ -307,51 +1870,6 @@ void isci_remote_device_not_ready(struct isci_host *ihost, | |||
307 | } | 1870 | } |
308 | 1871 | ||
309 | /** | 1872 | /** |
310 | * isci_remote_device_stop_complete() - This function is called by the scic | ||
311 | * when the remote device stop has completed. We mark the isci device as not | ||
312 | * ready and remove the isci remote device. | ||
313 | * @isci_host: This parameter specifies the isci host object. | ||
314 | * @isci_device: This parameter specifies the remote device. | ||
315 | * @status: This parameter specifies status of the completion. | ||
316 | * | ||
317 | */ | ||
318 | void isci_remote_device_stop_complete( | ||
319 | struct isci_host *isci_host, | ||
320 | struct isci_remote_device *isci_device, | ||
321 | enum sci_status status) | ||
322 | { | ||
323 | dev_dbg(&isci_host->pdev->dev, | ||
324 | "%s: complete isci_device = %p, status = 0x%x\n", | ||
325 | __func__, | ||
326 | isci_device, | ||
327 | status); | ||
328 | |||
329 | isci_remote_device_change_state(isci_device, isci_stopped); | ||
330 | |||
331 | /* after stop, we can tear down resources. */ | ||
332 | isci_remote_device_deconstruct(isci_host, isci_device); | ||
333 | |||
334 | } | ||
335 | |||
336 | /** | ||
337 | * isci_remote_device_start_complete() - This function is called by the scic | ||
338 | * when the remote device start has completed | ||
339 | * @isci_host: This parameter specifies the isci host object. | ||
340 | * @isci_device: This parameter specifies the remote device. | ||
341 | * @status: This parameter specifies status of the completion. | ||
342 | * | ||
343 | */ | ||
344 | void isci_remote_device_start_complete( | ||
345 | struct isci_host *isci_host, | ||
346 | struct isci_remote_device *isci_device, | ||
347 | enum sci_status status) | ||
348 | { | ||
349 | |||
350 | |||
351 | } | ||
352 | |||
353 | |||
354 | /** | ||
355 | * isci_remote_device_stop() - This function is called internally to stop the | 1873 | * isci_remote_device_stop() - This function is called internally to stop the |
356 | * remote device. | 1874 | * remote device. |
357 | * @isci_host: This parameter specifies the isci host object. | 1875 | * @isci_host: This parameter specifies the isci host object. |
@@ -572,21 +2090,3 @@ void isci_device_clear_reset_pending(struct isci_host *ihost, struct isci_remote | |||
572 | } | 2090 | } |
573 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | 2091 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
574 | } | 2092 | } |
575 | |||
576 | /** | ||
577 | * isci_remote_device_change_state() - This function gets the status of the | ||
578 | * remote_device object. | ||
579 | * @isci_device: This parameter points to the isci_remote_device object | ||
580 | * | ||
581 | * status of the object as a isci_status enum. | ||
582 | */ | ||
583 | void isci_remote_device_change_state( | ||
584 | struct isci_remote_device *isci_device, | ||
585 | enum isci_status status) | ||
586 | { | ||
587 | unsigned long flags; | ||
588 | |||
589 | spin_lock_irqsave(&isci_device->state_lock, flags); | ||
590 | isci_device->status = status; | ||
591 | spin_unlock_irqrestore(&isci_device->state_lock, flags); | ||
592 | } | ||
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h index aeda39568a1c..9d8fcbf72ded 100644 --- a/drivers/scsi/isci/remote_device.h +++ b/drivers/scsi/isci/remote_device.h | |||
@@ -53,11 +53,127 @@ | |||
53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | #if !defined(_ISCI_REMOTE_DEVICE_H_) | 56 | #ifndef _ISCI_REMOTE_DEVICE_H_ |
57 | #define _ISCI_REMOTE_DEVICE_H_ | 57 | #define _ISCI_REMOTE_DEVICE_H_ |
58 | #include "scic_sds_remote_device.h" | 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" | ||
59 | 64 | ||
60 | struct isci_host; | 65 | enum scic_remote_device_not_ready_reason_code { |
66 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, | ||
67 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, | ||
68 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, | ||
69 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, | ||
70 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, | ||
71 | |||
72 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX | ||
73 | |||
74 | }; | ||
75 | |||
76 | struct scic_sds_remote_device { | ||
77 | /** | ||
78 | * The field specifies that the parent object for the base remote | ||
79 | * device is the base object itself. | ||
80 | */ | ||
81 | struct sci_base_object parent; | ||
82 | |||
83 | /** | ||
84 | * This field contains the information for the base remote device state | ||
85 | * machine. | ||
86 | */ | ||
87 | struct sci_base_state_machine state_machine; | ||
88 | |||
89 | /** | ||
90 | * This field is the programmed device port width. This value is | ||
91 | * written to the RCN data structure to tell the SCU how many open | ||
92 | * connections this device can have. | ||
93 | */ | ||
94 | u32 device_port_width; | ||
95 | |||
96 | /** | ||
97 | * This field is the programmed connection rate for this remote device. It is | ||
98 | * used to program the TC with the maximum allowed connection rate. | ||
99 | */ | ||
100 | enum sas_linkrate connection_rate; | ||
101 | |||
102 | /** | ||
103 | * This field contains the allowed target protocols for this remote device. | ||
104 | */ | ||
105 | struct smp_discover_response_protocols target_protocols; | ||
106 | |||
107 | /** | ||
108 | * This field contains the device SAS address. | ||
109 | */ | ||
110 | struct sci_sas_address device_address; | ||
111 | |||
112 | /** | ||
113 | * This filed is assinged the value of true if the device is directly | ||
114 | * attached to the port. | ||
115 | */ | ||
116 | bool is_direct_attached; | ||
117 | |||
118 | #if !defined(DISABLE_ATAPI) | ||
119 | /** | ||
120 | * This filed is assinged the value of true if the device is an ATAPI | ||
121 | * device. | ||
122 | */ | ||
123 | bool is_atapi; | ||
124 | #endif | ||
125 | |||
126 | /** | ||
127 | * This filed contains a pointer back to the port to which this device | ||
128 | * is assigned. | ||
129 | */ | ||
130 | struct scic_sds_port *owning_port; | ||
131 | |||
132 | /** | ||
133 | * This field contains the SCU silicon remote node context specific | ||
134 | * information. | ||
135 | */ | ||
136 | struct scic_sds_remote_node_context rnc; | ||
137 | |||
138 | /** | ||
139 | * This field contains the stated request count for the remote device. The | ||
140 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all | ||
141 | * requests are complete and the rnc_posted value is false. | ||
142 | */ | ||
143 | u32 started_request_count; | ||
144 | |||
145 | /** | ||
146 | * This field contains a pointer to the working request object. It is only | ||
147 | * used only for SATA requests since the unsolicited frames we get from the | ||
148 | * hardware have no Tag value to look up the io request object. | ||
149 | */ | ||
150 | struct scic_sds_request *working_request; | ||
151 | |||
152 | /** | ||
153 | * This field contains the reason for the remote device going not_ready. It is | ||
154 | * assigned in the state handlers and used in the state transition. | ||
155 | */ | ||
156 | u32 not_ready_reason; | ||
157 | |||
158 | /** | ||
159 | * This field is true if this remote device has an initialzied ready substate | ||
160 | * machine. SSP devices do not have a ready substate machine and STP devices | ||
161 | * have a ready substate machine. | ||
162 | */ | ||
163 | bool has_ready_substate_machine; | ||
164 | |||
165 | /** | ||
166 | * This field contains the state machine for the ready substate machine for | ||
167 | * this struct scic_sds_remote_device object. | ||
168 | */ | ||
169 | struct sci_base_state_machine ready_substate_machine; | ||
170 | |||
171 | /** | ||
172 | * This field maintains the set of state handlers for the remote device | ||
173 | * object. These are changed each time the remote device enters a new state. | ||
174 | */ | ||
175 | const struct scic_sds_remote_device_state_handler *state_handlers; | ||
176 | }; | ||
61 | 177 | ||
62 | struct isci_remote_device { | 178 | struct isci_remote_device { |
63 | enum isci_status status; | 179 | enum isci_status status; |
@@ -75,12 +191,6 @@ struct isci_remote_device { | |||
75 | 191 | ||
76 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 | 192 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
77 | 193 | ||
78 | void isci_remote_device_start_complete(struct isci_host *ihost, | ||
79 | struct isci_remote_device *idev, | ||
80 | enum sci_status); | ||
81 | void isci_remote_device_stop_complete(struct isci_host *ihost, | ||
82 | struct isci_remote_device *idev, | ||
83 | enum sci_status); | ||
84 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, | 194 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
85 | struct isci_remote_device *idev); | 195 | struct isci_remote_device *idev); |
86 | void isci_remote_device_nuke_requests(struct isci_host *ihost, | 196 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
@@ -97,5 +207,619 @@ void isci_device_clear_reset_pending(struct isci_host *ihost, | |||
97 | struct isci_remote_device *idev); | 207 | struct isci_remote_device *idev); |
98 | void isci_remote_device_change_state(struct isci_remote_device *idev, | 208 | void isci_remote_device_change_state(struct isci_remote_device *idev, |
99 | enum isci_status status); | 209 | enum isci_status status); |
210 | /** | ||
211 | * scic_remote_device_stop() - This method will stop both transmission and | ||
212 | * reception of link activity for the supplied remote device. This method | ||
213 | * disables normal IO requests from flowing through to the remote device. | ||
214 | * @remote_device: This parameter specifies the device to be stopped. | ||
215 | * @timeout: This parameter specifies the number of milliseconds in which the | ||
216 | * stop operation should complete. | ||
217 | * | ||
218 | * An indication of whether the device was successfully stopped. SCI_SUCCESS | ||
219 | * This value is returned if the transmission and reception for the device was | ||
220 | * successfully stopped. | ||
221 | */ | ||
222 | enum sci_status scic_remote_device_stop( | ||
223 | struct scic_sds_remote_device *remote_device, | ||
224 | u32 timeout); | ||
225 | |||
226 | /** | ||
227 | * scic_remote_device_reset() - This method will reset the device making it | ||
228 | * ready for operation. This method must be called anytime the device is | ||
229 | * reset either through a SMP phy control or a port hard reset request. | ||
230 | * @remote_device: This parameter specifies the device to be reset. | ||
231 | * | ||
232 | * This method does not actually cause the device hardware to be reset. This | ||
233 | * method resets the software object so that it will be operational after a | ||
234 | * device hardware reset completes. An indication of whether the device reset | ||
235 | * was accepted. SCI_SUCCESS This value is returned if the device reset is | ||
236 | * started. | ||
237 | */ | ||
238 | enum sci_status scic_remote_device_reset( | ||
239 | struct scic_sds_remote_device *remote_device); | ||
240 | |||
241 | /** | ||
242 | * scic_remote_device_reset_complete() - This method informs the device object | ||
243 | * that the reset operation is complete and the device can resume operation | ||
244 | * again. | ||
245 | * @remote_device: This parameter specifies the device which is to be informed | ||
246 | * of the reset complete operation. | ||
247 | * | ||
248 | * An indication that the device is resuming operation. SCI_SUCCESS the device | ||
249 | * is resuming operation. | ||
250 | */ | ||
251 | enum sci_status scic_remote_device_reset_complete( | ||
252 | struct scic_sds_remote_device *remote_device); | ||
253 | |||
254 | |||
255 | |||
256 | /** | ||
257 | * scic_remote_device_get_connection_rate() - This method simply returns the | ||
258 | * link rate at which communications to the remote device occur. | ||
259 | * @remote_device: This parameter specifies the device for which to get the | ||
260 | * connection rate. | ||
261 | * | ||
262 | * Return the link rate at which we transfer for the supplied remote device. | ||
263 | */ | ||
264 | enum sas_linkrate scic_remote_device_get_connection_rate( | ||
265 | struct scic_sds_remote_device *remote_device); | ||
266 | |||
267 | /** | ||
268 | * scic_remote_device_get_protocols() - This method will indicate which | ||
269 | * protocols are supported by this remote device. | ||
270 | * @remote_device: This parameter specifies the device for which to return the | ||
271 | * protocol. | ||
272 | * @protocols: This parameter specifies the output values, from the remote | ||
273 | * device object, which indicate the protocols supported by the supplied | ||
274 | * remote_device. | ||
275 | * | ||
276 | * The type of protocols supported by this device. The values are returned as | ||
277 | * part of a bit mask in order to allow for multi-protocol support. | ||
278 | */ | ||
279 | void scic_remote_device_get_protocols( | ||
280 | struct scic_sds_remote_device *remote_device, | ||
281 | struct smp_discover_response_protocols *protocols); | ||
282 | |||
283 | |||
284 | #if !defined(DISABLE_ATAPI) | ||
285 | /** | ||
286 | * scic_remote_device_is_atapi() - | ||
287 | * @this_device: The device whose type is to be decided. | ||
288 | * | ||
289 | * This method first decide whether a device is a stp target, then decode the | ||
290 | * signature fis of a DA STP device to tell whether it is a standard end disk | ||
291 | * or an ATAPI device. bool Indicate a device is ATAPI device or not. | ||
292 | */ | ||
293 | bool scic_remote_device_is_atapi( | ||
294 | struct scic_sds_remote_device *device_handle); | ||
295 | #else /* !defined(DISABLE_ATAPI) */ | ||
296 | #define scic_remote_device_is_atapi(device_handle) false | ||
297 | #endif /* !defined(DISABLE_ATAPI) */ | ||
298 | |||
299 | |||
300 | |||
301 | /** | ||
302 | * enum scic_sds_remote_device_states - This enumeration depicts all the states | ||
303 | * for the common remote device state machine. | ||
304 | * | ||
305 | * | ||
306 | */ | ||
307 | enum scic_sds_remote_device_states { | ||
308 | /** | ||
309 | * Simply the initial state for the base remote device state machine. | ||
310 | */ | ||
311 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, | ||
312 | |||
313 | /** | ||
314 | * This state indicates that the remote device has successfully been | ||
315 | * stopped. In this state no new IO operations are permitted. | ||
316 | * This state is entered from the INITIAL state. | ||
317 | * This state is entered from the STOPPING state. | ||
318 | */ | ||
319 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, | ||
320 | |||
321 | /** | ||
322 | * This state indicates the the remote device is in the process of | ||
323 | * becoming ready (i.e. starting). In this state no new IO operations | ||
324 | * are permitted. | ||
325 | * This state is entered from the STOPPED state. | ||
326 | */ | ||
327 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, | ||
328 | |||
329 | /** | ||
330 | * This state indicates the remote device is now ready. Thus, the user | ||
331 | * is able to perform IO operations on the remote device. | ||
332 | * This state is entered from the STARTING state. | ||
333 | */ | ||
334 | SCI_BASE_REMOTE_DEVICE_STATE_READY, | ||
335 | |||
336 | /** | ||
337 | * This state indicates that the remote device is in the process of | ||
338 | * stopping. In this state no new IO operations are permitted, but | ||
339 | * existing IO operations are allowed to complete. | ||
340 | * This state is entered from the READY state. | ||
341 | * This state is entered from the FAILED state. | ||
342 | */ | ||
343 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | ||
344 | |||
345 | /** | ||
346 | * This state indicates that the remote device has failed. | ||
347 | * In this state no new IO operations are permitted. | ||
348 | * This state is entered from the INITIALIZING state. | ||
349 | * This state is entered from the READY state. | ||
350 | */ | ||
351 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | ||
352 | |||
353 | /** | ||
354 | * This state indicates the device is being reset. | ||
355 | * In this state no new IO operations are permitted. | ||
356 | * This state is entered from the READY state. | ||
357 | */ | ||
358 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | ||
359 | |||
360 | /** | ||
361 | * Simply the final state for the base remote device state machine. | ||
362 | */ | ||
363 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | ||
364 | }; | ||
365 | |||
366 | /** | ||
367 | * enum scic_sds_ssp_remote_device_ready_substates - | ||
368 | * | ||
369 | * This is the enumeration of the ready substates for the | ||
370 | * struct scic_sds_remote_device. | ||
371 | */ | ||
372 | enum scic_sds_ssp_remote_device_ready_substates { | ||
373 | /** | ||
374 | * This is the initial state for the remote device ready substate. | ||
375 | */ | ||
376 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, | ||
377 | |||
378 | /** | ||
379 | * This is the ready operational substate for the remote device. | ||
380 | * This is the normal operational state for a remote device. | ||
381 | */ | ||
382 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, | ||
383 | |||
384 | /** | ||
385 | * This is the suspended state for the remote device. This is the state | ||
386 | * that the device is placed in when a RNC suspend is received by | ||
387 | * the SCU hardware. | ||
388 | */ | ||
389 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, | ||
390 | |||
391 | /** | ||
392 | * This is the final state that the device is placed in before a change | ||
393 | * to the base state machine. | ||
394 | */ | ||
395 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, | ||
396 | |||
397 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES | ||
398 | }; | ||
399 | |||
400 | /** | ||
401 | * enum scic_sds_stp_remote_device_ready_substates - | ||
402 | * | ||
403 | * This is the enumeration for the struct scic_sds_remote_device ready substates | ||
404 | * for the STP remote device. | ||
405 | */ | ||
406 | enum scic_sds_stp_remote_device_ready_substates { | ||
407 | /** | ||
408 | * This is the idle substate for the stp remote device. When there are no | ||
409 | * active IO for the device it is is in this state. | ||
410 | */ | ||
411 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | ||
412 | |||
413 | /** | ||
414 | * This is the command state for for the STP remote device. This state is | ||
415 | * entered when the device is processing a non-NCQ command. The device object | ||
416 | * will fail any new start IO requests until this command is complete. | ||
417 | */ | ||
418 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | ||
419 | |||
420 | /** | ||
421 | * This is the NCQ state for the STP remote device. This state is entered | ||
422 | * when the device is processing an NCQ reuqest. It will remain in this state | ||
423 | * so long as there is one or more NCQ requests being processed. | ||
424 | */ | ||
425 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, | ||
426 | |||
427 | /** | ||
428 | * This is the NCQ error state for the STP remote device. This state is | ||
429 | * entered when an SDB error FIS is received by the device object while in the | ||
430 | * NCQ state. The device object will only accept a READ LOG command while in | ||
431 | * this state. | ||
432 | */ | ||
433 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, | ||
434 | |||
435 | #if !defined(DISABLE_ATAPI) | ||
436 | /** | ||
437 | * This is the ATAPI error state for the STP ATAPI remote device. This state is | ||
438 | * entered when ATAPI device sends error status FIS without data while the device | ||
439 | * object is in CMD state. A suspension event is expected in this state. The device | ||
440 | * object will resume right away. | ||
441 | */ | ||
442 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR, | ||
443 | #endif | ||
444 | |||
445 | /** | ||
446 | * This is the READY substate indicates the device is waiting for the RESET task | ||
447 | * coming to be recovered from certain hardware specific error. | ||
448 | */ | ||
449 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, | ||
450 | }; | ||
451 | |||
452 | /** | ||
453 | * enum scic_sds_smp_remote_device_ready_substates - | ||
454 | * | ||
455 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. | ||
456 | */ | ||
457 | enum scic_sds_smp_remote_device_ready_substates { | ||
458 | /** | ||
459 | * This is the ready operational substate for the remote device. This is the | ||
460 | * normal operational state for a remote device. | ||
461 | */ | ||
462 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | ||
463 | |||
464 | /** | ||
465 | * This is the suspended state for the remote device. This is the state that | ||
466 | * the device is placed in when a RNC suspend is received by the SCU hardware. | ||
467 | */ | ||
468 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | ||
469 | }; | ||
470 | |||
471 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) | ||
472 | { | ||
473 | struct scic_sds_remote_device *sci_dev; | ||
474 | |||
475 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); | ||
476 | |||
477 | return sci_dev; | ||
478 | } | ||
479 | |||
480 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( | ||
481 | struct scic_sds_remote_device *device, | ||
482 | struct scic_sds_request *request); | ||
483 | |||
484 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( | ||
485 | struct scic_sds_remote_device *device, | ||
486 | struct scic_sds_request *request, | ||
487 | void *, | ||
488 | enum sci_io_status); | ||
489 | |||
490 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( | ||
491 | struct scic_sds_remote_device *sci_dev); | ||
492 | |||
493 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( | ||
494 | struct scic_sds_remote_device *sci_dev, | ||
495 | u32 suspend_type); | ||
496 | |||
497 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( | ||
498 | struct scic_sds_remote_device *sci_dev); | ||
499 | |||
500 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( | ||
501 | struct scic_sds_remote_device *sci_dev, | ||
502 | u32 frame_index); | ||
503 | |||
504 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( | ||
505 | struct scic_sds_remote_device *sci_dev, | ||
506 | u32 event_code); | ||
507 | |||
508 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( | ||
509 | struct scic_sds_remote_device *sci_dev); | ||
510 | |||
511 | /** | ||
512 | * struct scic_sds_remote_device_state_handler - This structure conains the | ||
513 | * state handlers that are needed to process requests for the SCU remote | ||
514 | * device objects. | ||
515 | * | ||
516 | * | ||
517 | */ | ||
518 | struct scic_sds_remote_device_state_handler { | ||
519 | /** | ||
520 | * The start_handler specifies the method invoked when a user | ||
521 | * attempts to start a remote device. | ||
522 | */ | ||
523 | scic_sds_remote_device_handler_t start_handler; | ||
524 | |||
525 | /** | ||
526 | * The stop_handler specifies the method invoked when a user attempts to | ||
527 | * stop a remote device. | ||
528 | */ | ||
529 | scic_sds_remote_device_handler_t stop_handler; | ||
530 | |||
531 | /** | ||
532 | * The fail_handler specifies the method invoked when a remote device | ||
533 | * failure has occurred. A failure may be due to an inability to | ||
534 | * initialize/configure the device. | ||
535 | */ | ||
536 | scic_sds_remote_device_handler_t fail_handler; | ||
537 | |||
538 | /** | ||
539 | * The destruct_handler specifies the method invoked when attempting to | ||
540 | * destruct a remote device. | ||
541 | */ | ||
542 | scic_sds_remote_device_handler_t destruct_handler; | ||
543 | |||
544 | /** | ||
545 | * The reset handler specifies the method invloked when requesting to | ||
546 | * reset a remote device. | ||
547 | */ | ||
548 | scic_sds_remote_device_handler_t reset_handler; | ||
549 | |||
550 | /** | ||
551 | * The reset complete handler specifies the method invloked when | ||
552 | * reporting that a reset has completed to the remote device. | ||
553 | */ | ||
554 | scic_sds_remote_device_handler_t reset_complete_handler; | ||
555 | |||
556 | /** | ||
557 | * The start_io_handler specifies the method invoked when a user | ||
558 | * attempts to start an IO request for a remote device. | ||
559 | */ | ||
560 | scic_sds_remote_device_request_handler_t start_io_handler; | ||
561 | |||
562 | /** | ||
563 | * The complete_io_handler specifies the method invoked when a user | ||
564 | * attempts to complete an IO request for a remote device. | ||
565 | */ | ||
566 | scic_sds_remote_device_request_handler_t complete_io_handler; | ||
567 | |||
568 | /** | ||
569 | * The continue_io_handler specifies the method invoked when a user | ||
570 | * attempts to continue an IO request for a remote device. | ||
571 | */ | ||
572 | scic_sds_remote_device_request_handler_t continue_io_handler; | ||
573 | |||
574 | /** | ||
575 | * The start_task_handler specifies the method invoked when a user | ||
576 | * attempts to start a task management request for a remote device. | ||
577 | */ | ||
578 | scic_sds_remote_device_request_handler_t start_task_handler; | ||
579 | |||
580 | /** | ||
581 | * The complete_task_handler specifies the method invoked when a user | ||
582 | * attempts to complete a task management request for a remote device. | ||
583 | */ | ||
584 | scic_sds_remote_device_request_handler_t complete_task_handler; | ||
585 | |||
586 | |||
587 | scic_sds_remote_device_suspend_handler_t suspend_handler; | ||
588 | scic_sds_remote_device_resume_handler_t resume_handler; | ||
589 | scic_sds_remote_device_event_handler_t event_handler; | ||
590 | scic_sds_remote_device_frame_handler_t frame_handler; | ||
591 | }; | ||
592 | |||
593 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; | ||
594 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; | ||
595 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; | ||
596 | |||
597 | /** | ||
598 | * scic_sds_remote_device_increment_request_count() - | ||
599 | * | ||
600 | * This macro incrments the request count for this device | ||
601 | */ | ||
602 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ | ||
603 | ((sci_dev)->started_request_count++) | ||
604 | |||
605 | /** | ||
606 | * scic_sds_remote_device_decrement_request_count() - | ||
607 | * | ||
608 | * This macro decrements the request count for this device. This count will | ||
609 | * never decrment past 0. | ||
610 | */ | ||
611 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ | ||
612 | ((sci_dev)->started_request_count > 0 ? \ | ||
613 | (sci_dev)->started_request_count-- : 0) | ||
614 | |||
615 | /** | ||
616 | * scic_sds_remote_device_get_request_count() - | ||
617 | * | ||
618 | * This is a helper macro to return the current device request count. | ||
619 | */ | ||
620 | #define scic_sds_remote_device_get_request_count(sci_dev) \ | ||
621 | ((sci_dev)->started_request_count) | ||
622 | |||
623 | /** | ||
624 | * scic_sds_remote_device_get_port() - | ||
625 | * | ||
626 | * This macro returns the owning port of this remote device obejct. | ||
627 | */ | ||
628 | #define scic_sds_remote_device_get_port(sci_dev) \ | ||
629 | ((sci_dev)->owning_port) | ||
630 | |||
631 | /** | ||
632 | * scic_sds_remote_device_get_controller() - | ||
633 | * | ||
634 | * This macro returns the controller object that contains this device object | ||
635 | */ | ||
636 | #define scic_sds_remote_device_get_controller(sci_dev) \ | ||
637 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) | ||
638 | |||
639 | /** | ||
640 | * scic_sds_remote_device_set_state_handlers() - | ||
641 | * | ||
642 | * This macro sets the remote device state handlers pointer and is set on entry | ||
643 | * to each device state. | ||
644 | */ | ||
645 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ | ||
646 | ((sci_dev)->state_handlers = (handlers)) | ||
647 | |||
648 | /** | ||
649 | * scic_sds_remote_device_get_port() - | ||
650 | * | ||
651 | * This macro returns the owning port of this device | ||
652 | */ | ||
653 | #define scic_sds_remote_device_get_port(sci_dev) \ | ||
654 | ((sci_dev)->owning_port) | ||
655 | |||
656 | /** | ||
657 | * scic_sds_remote_device_get_sequence() - | ||
658 | * | ||
659 | * This macro returns the remote device sequence value | ||
660 | */ | ||
661 | #define scic_sds_remote_device_get_sequence(sci_dev) \ | ||
662 | (\ | ||
663 | scic_sds_remote_device_get_controller(sci_dev)-> \ | ||
664 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ | ||
665 | ) | ||
666 | |||
667 | /** | ||
668 | * scic_sds_remote_device_get_controller_peg() - | ||
669 | * | ||
670 | * This macro returns the controllers protocol engine group | ||
671 | */ | ||
672 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ | ||
673 | (\ | ||
674 | scic_sds_controller_get_protocol_engine_group(\ | ||
675 | scic_sds_port_get_controller(\ | ||
676 | scic_sds_remote_device_get_port(sci_dev) \ | ||
677 | ) \ | ||
678 | ) \ | ||
679 | ) | ||
680 | |||
681 | /** | ||
682 | * scic_sds_remote_device_get_port_index() - | ||
683 | * | ||
684 | * This macro returns the port index for the devices owning port | ||
685 | */ | ||
686 | #define scic_sds_remote_device_get_port_index(sci_dev) \ | ||
687 | (scic_sds_port_get_index(scic_sds_remote_device_get_port(sci_dev))) | ||
688 | |||
689 | /** | ||
690 | * scic_sds_remote_device_get_index() - | ||
691 | * | ||
692 | * This macro returns the remote node index for this device object | ||
693 | */ | ||
694 | #define scic_sds_remote_device_get_index(sci_dev) \ | ||
695 | ((sci_dev)->rnc.remote_node_index) | ||
696 | |||
697 | /** | ||
698 | * scic_sds_remote_device_build_command_context() - | ||
699 | * | ||
700 | * This macro builds a remote device context for the SCU post request operation | ||
701 | */ | ||
702 | #define scic_sds_remote_device_build_command_context(device, command) \ | ||
703 | ((command) \ | ||
704 | | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \ | ||
705 | | (scic_sds_remote_device_get_port_index((device)) << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ | ||
706 | | (scic_sds_remote_device_get_index((device))) \ | ||
707 | ) | ||
708 | |||
709 | /** | ||
710 | * scic_sds_remote_device_set_working_request() - | ||
711 | * | ||
712 | * This macro makes the working request assingment for the remote device | ||
713 | * object. To clear the working request use this macro with a NULL request | ||
714 | * object. | ||
715 | */ | ||
716 | #define scic_sds_remote_device_set_working_request(device, request) \ | ||
717 | ((device)->working_request = (request)) | ||
718 | |||
719 | enum sci_status scic_sds_remote_device_frame_handler( | ||
720 | struct scic_sds_remote_device *sci_dev, | ||
721 | u32 frame_index); | ||
722 | |||
723 | enum sci_status scic_sds_remote_device_event_handler( | ||
724 | struct scic_sds_remote_device *sci_dev, | ||
725 | u32 event_code); | ||
726 | |||
727 | enum sci_status scic_sds_remote_device_start_io( | ||
728 | struct scic_sds_controller *controller, | ||
729 | struct scic_sds_remote_device *sci_dev, | ||
730 | struct scic_sds_request *io_request); | ||
731 | |||
732 | enum sci_status scic_sds_remote_device_complete_io( | ||
733 | struct scic_sds_controller *controller, | ||
734 | struct scic_sds_remote_device *sci_dev, | ||
735 | struct scic_sds_request *io_request); | ||
736 | |||
737 | enum sci_status scic_sds_remote_device_resume( | ||
738 | struct scic_sds_remote_device *sci_dev); | ||
739 | |||
740 | enum sci_status scic_sds_remote_device_suspend( | ||
741 | struct scic_sds_remote_device *sci_dev, | ||
742 | u32 suspend_type); | ||
743 | |||
744 | enum sci_status scic_sds_remote_device_start_task( | ||
745 | struct scic_sds_controller *controller, | ||
746 | struct scic_sds_remote_device *sci_dev, | ||
747 | struct scic_sds_request *io_request); | ||
748 | |||
749 | void scic_sds_remote_device_post_request( | ||
750 | struct scic_sds_remote_device *sci_dev, | ||
751 | u32 request); | ||
752 | |||
753 | #if !defined(DISABLE_ATAPI) | ||
754 | bool scic_sds_remote_device_is_atapi( | ||
755 | struct scic_sds_remote_device *sci_dev); | ||
756 | #else /* !defined(DISABLE_ATAPI) */ | ||
757 | #define scic_sds_remote_device_is_atapi(sci_dev) false | ||
758 | #endif /* !defined(DISABLE_ATAPI) */ | ||
759 | |||
760 | void scic_sds_remote_device_start_request( | ||
761 | struct scic_sds_remote_device *sci_dev, | ||
762 | struct scic_sds_request *sci_req, | ||
763 | enum sci_status status); | ||
764 | |||
765 | void scic_sds_remote_device_continue_request(void *sci_dev); | ||
766 | |||
767 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
768 | struct scic_sds_remote_device *sci_dev); | ||
769 | |||
770 | enum sci_status scic_sds_remote_device_default_fail_handler( | ||
771 | struct scic_sds_remote_device *sci_dev); | ||
772 | |||
773 | enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
774 | struct scic_sds_remote_device *sci_dev); | ||
775 | |||
776 | enum sci_status scic_sds_remote_device_default_reset_handler( | ||
777 | struct scic_sds_remote_device *device); | ||
778 | |||
779 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | ||
780 | struct scic_sds_remote_device *device); | ||
781 | |||
782 | enum sci_status scic_sds_remote_device_default_start_request_handler( | ||
783 | struct scic_sds_remote_device *device, | ||
784 | struct scic_sds_request *request); | ||
785 | |||
786 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | ||
787 | struct scic_sds_remote_device *device, | ||
788 | struct scic_sds_request *request); | ||
789 | |||
790 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | ||
791 | struct scic_sds_remote_device *device, | ||
792 | struct scic_sds_request *request); | ||
793 | |||
794 | enum sci_status scic_sds_remote_device_default_suspend_handler( | ||
795 | struct scic_sds_remote_device *sci_dev, | ||
796 | u32 suspend_type); | ||
797 | |||
798 | enum sci_status scic_sds_remote_device_default_resume_handler( | ||
799 | struct scic_sds_remote_device *sci_dev); | ||
800 | |||
801 | |||
802 | enum sci_status scic_sds_remote_device_default_frame_handler( | ||
803 | struct scic_sds_remote_device *sci_dev, | ||
804 | u32 frame_index); | ||
805 | |||
806 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | ||
807 | struct scic_sds_remote_device *device); | ||
808 | |||
809 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | ||
810 | struct scic_sds_remote_device *device); | ||
811 | |||
812 | enum sci_status scic_sds_remote_device_general_frame_handler( | ||
813 | struct scic_sds_remote_device *sci_dev, | ||
814 | u32 frame_index); | ||
815 | |||
816 | enum sci_status scic_sds_remote_device_general_event_handler( | ||
817 | struct scic_sds_remote_device *sci_dev, | ||
818 | u32 event_code); | ||
819 | |||
820 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( | ||
821 | struct scic_sds_remote_device *sci_dev); | ||
822 | |||
823 | |||
100 | 824 | ||
101 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ | 825 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_context.c b/drivers/scsi/isci/remote_node_context.c index e1d58f8854f7..bdf0b5101cfa 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_node_context.c +++ b/drivers/scsi/isci/remote_node_context.c | |||
@@ -54,11 +54,10 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "sci_base_state_machine.h" | 56 | #include "sci_base_state_machine.h" |
57 | #include "scic_remote_device.h" | ||
58 | #include "scic_sds_controller.h" | 57 | #include "scic_sds_controller.h" |
59 | #include "scic_sds_port.h" | 58 | #include "scic_sds_port.h" |
60 | #include "scic_sds_remote_device.h" | 59 | #include "remote_device.h" |
61 | #include "scic_sds_remote_node_context.h" | 60 | #include "remote_node_context.h" |
62 | #include "sci_environment.h" | 61 | #include "sci_environment.h" |
63 | #include "sci_util.h" | 62 | #include "sci_util.h" |
64 | #include "scu_event_codes.h" | 63 | #include "scu_event_codes.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_context.h b/drivers/scsi/isci/remote_node_context.h index b3f2546090dd..b3f2546090dd 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_node_context.h +++ b/drivers/scsi/isci/remote_node_context.h | |||
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_table.c b/drivers/scsi/isci/remote_node_table.c index 77919a2cf652..8886146d9db2 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_node_table.c +++ b/drivers/scsi/isci/remote_node_table.c | |||
@@ -61,8 +61,8 @@ | |||
61 | */ | 61 | */ |
62 | #include "sci_util.h" | 62 | #include "sci_util.h" |
63 | #include "sci_environment.h" | 63 | #include "sci_environment.h" |
64 | #include "scic_sds_remote_node_table.h" | 64 | #include "remote_node_table.h" |
65 | #include "scic_sds_remote_node_context.h" | 65 | #include "remote_node_context.h" |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * | 68 | * |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_table.h b/drivers/scsi/isci/remote_node_table.h index 9c02a6ccb2fe..9c02a6ccb2fe 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_node_table.h +++ b/drivers/scsi/isci/remote_node_table.h | |||
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 8d2125b520ea..ff5c05a19543 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -54,7 +54,6 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "scic_remote_device.h" | ||
58 | #include "scic_io_request.h" | 57 | #include "scic_io_request.h" |
59 | #include "scic_task_request.h" | 58 | #include "scic_task_request.h" |
60 | #include "scic_port.h" | 59 | #include "scic_port.h" |
diff --git a/drivers/scsi/isci/sata.c b/drivers/scsi/isci/sata.c index c941d9090b8d..53ce0c281bee 100644 --- a/drivers/scsi/isci/sata.c +++ b/drivers/scsi/isci/sata.c | |||
@@ -54,8 +54,7 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "scic_remote_device.h" | 57 | #include "remote_device.h" |
58 | #include "scic_sds_remote_device.h" | ||
59 | #include "scic_io_request.h" | 58 | #include "scic_io_request.h" |
60 | #include "scic_task_request.h" | 59 | #include "scic_task_request.h" |
61 | #include "task.h" | 60 | #include "task.h" |
diff --git a/drivers/scsi/isci/core/scu_remote_node_context.h b/drivers/scsi/isci/scu_remote_node_context.h index 33745adc826b..33745adc826b 100644 --- a/drivers/scsi/isci/core/scu_remote_node_context.h +++ b/drivers/scsi/isci/scu_remote_node_context.h | |||
diff --git a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c b/drivers/scsi/isci/smp_remote_device.c index cd55c0a8dae3..718ddaf49343 100644 --- a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c +++ b/drivers/scsi/isci/smp_remote_device.c | |||
@@ -53,10 +53,9 @@ | |||
53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "scic_remote_device.h" | ||
57 | #include "scic_sds_controller.h" | 56 | #include "scic_sds_controller.h" |
58 | #include "scic_sds_port.h" | 57 | #include "scic_sds_port.h" |
59 | #include "scic_sds_remote_device.h" | 58 | #include "remote_device.h" |
60 | #include "scic_sds_request.h" | 59 | #include "scic_sds_request.h" |
61 | #include "sci_environment.h" | 60 | #include "sci_environment.h" |
62 | #include "sci_util.h" | 61 | #include "sci_util.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c b/drivers/scsi/isci/stp_remote_device.c index 848cb4711b63..b81f21f47d2a 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c +++ b/drivers/scsi/isci/stp_remote_device.c | |||
@@ -57,10 +57,9 @@ | |||
57 | #include "intel_sata.h" | 57 | #include "intel_sata.h" |
58 | #include "intel_sat.h" | 58 | #include "intel_sat.h" |
59 | #include "sci_base_state.h" | 59 | #include "sci_base_state.h" |
60 | #include "scic_remote_device.h" | ||
61 | #include "scic_sds_controller.h" | 60 | #include "scic_sds_controller.h" |
62 | #include "scic_sds_port.h" | 61 | #include "scic_sds_port.h" |
63 | #include "scic_sds_remote_device.h" | 62 | #include "remote_device.h" |
64 | #include "scic_sds_request.h" | 63 | #include "scic_sds_request.h" |
65 | #include "sci_environment.h" | 64 | #include "sci_environment.h" |
66 | #include "sci_util.h" | 65 | #include "sci_util.h" |
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c index f54f523b8d40..e011d668949d 100644 --- a/drivers/scsi/isci/task.c +++ b/drivers/scsi/isci/task.c | |||
@@ -56,10 +56,9 @@ | |||
56 | #include <linux/completion.h> | 56 | #include <linux/completion.h> |
57 | #include <linux/irqflags.h> | 57 | #include <linux/irqflags.h> |
58 | #include "scic_task_request.h" | 58 | #include "scic_task_request.h" |
59 | #include "scic_remote_device.h" | ||
60 | #include "scic_io_request.h" | 59 | #include "scic_io_request.h" |
61 | #include "scic_sds_remote_device.h" | 60 | #include "remote_device.h" |
62 | #include "scic_sds_remote_node_context.h" | 61 | #include "remote_node_context.h" |
63 | #include "isci.h" | 62 | #include "isci.h" |
64 | #include "request.h" | 63 | #include "request.h" |
65 | #include "sata.h" | 64 | #include "sata.h" |