Commit | Line | Data |
---|---|---|
6f231dda DW |
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 | ||
88f3b62a | 56 | #ifndef _ISCI_REMOTE_DEVICE_H_ |
6f231dda | 57 | #define _ISCI_REMOTE_DEVICE_H_ |
88f3b62a DW |
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" | |
6f231dda | 64 | |
88f3b62a DW |
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 | ||
88f3b62a DW |
102 | /** |
103 | * This filed is assinged the value of true if the device is directly | |
104 | * attached to the port. | |
105 | */ | |
106 | bool is_direct_attached; | |
107 | ||
108 | #if !defined(DISABLE_ATAPI) | |
109 | /** | |
110 | * This filed is assinged the value of true if the device is an ATAPI | |
111 | * device. | |
112 | */ | |
113 | bool is_atapi; | |
114 | #endif | |
115 | ||
116 | /** | |
117 | * This filed contains a pointer back to the port to which this device | |
118 | * is assigned. | |
119 | */ | |
120 | struct scic_sds_port *owning_port; | |
121 | ||
122 | /** | |
123 | * This field contains the SCU silicon remote node context specific | |
124 | * information. | |
125 | */ | |
126 | struct scic_sds_remote_node_context rnc; | |
127 | ||
128 | /** | |
129 | * This field contains the stated request count for the remote device. The | |
130 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all | |
131 | * requests are complete and the rnc_posted value is false. | |
132 | */ | |
133 | u32 started_request_count; | |
134 | ||
135 | /** | |
136 | * This field contains a pointer to the working request object. It is only | |
137 | * used only for SATA requests since the unsolicited frames we get from the | |
138 | * hardware have no Tag value to look up the io request object. | |
139 | */ | |
140 | struct scic_sds_request *working_request; | |
141 | ||
142 | /** | |
143 | * This field contains the reason for the remote device going not_ready. It is | |
144 | * assigned in the state handlers and used in the state transition. | |
145 | */ | |
146 | u32 not_ready_reason; | |
147 | ||
148 | /** | |
149 | * This field is true if this remote device has an initialzied ready substate | |
150 | * machine. SSP devices do not have a ready substate machine and STP devices | |
151 | * have a ready substate machine. | |
152 | */ | |
153 | bool has_ready_substate_machine; | |
154 | ||
155 | /** | |
156 | * This field contains the state machine for the ready substate machine for | |
157 | * this struct scic_sds_remote_device object. | |
158 | */ | |
159 | struct sci_base_state_machine ready_substate_machine; | |
160 | ||
161 | /** | |
162 | * This field maintains the set of state handlers for the remote device | |
163 | * object. These are changed each time the remote device enters a new state. | |
164 | */ | |
165 | const struct scic_sds_remote_device_state_handler *state_handlers; | |
166 | }; | |
6f231dda DW |
167 | |
168 | struct isci_remote_device { | |
6f231dda | 169 | enum isci_status status; |
6ad31fec DW |
170 | #define IDEV_START_PENDING 0 |
171 | #define IDEV_STOP_PENDING 1 | |
d9c37390 | 172 | #define IDEV_ALLOCATED 2 |
6ad31fec | 173 | unsigned long flags; |
6f231dda DW |
174 | struct isci_port *isci_port; |
175 | struct domain_device *domain_dev; | |
6f231dda DW |
176 | struct list_head node; |
177 | struct list_head reqs_in_process; | |
6f231dda | 178 | spinlock_t state_lock; |
57f20f4e | 179 | struct scic_sds_remote_device sci; |
6f231dda DW |
180 | }; |
181 | ||
6f231dda DW |
182 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
183 | ||
6ad31fec DW |
184 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
185 | struct isci_remote_device *idev); | |
4393aa4e DW |
186 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
187 | struct isci_remote_device *idev); | |
037afc78 DW |
188 | void isci_remote_device_ready(struct isci_host *ihost, |
189 | struct isci_remote_device *idev); | |
037afc78 DW |
190 | void isci_remote_device_not_ready(struct isci_host *ihost, |
191 | struct isci_remote_device *idev, u32 reason); | |
4393aa4e DW |
192 | void isci_remote_device_gone(struct domain_device *domain_dev); |
193 | int isci_remote_device_found(struct domain_device *domain_dev); | |
194 | bool isci_device_is_reset_pending(struct isci_host *ihost, | |
195 | struct isci_remote_device *idev); | |
196 | void isci_device_clear_reset_pending(struct isci_host *ihost, | |
197 | struct isci_remote_device *idev); | |
198 | void isci_remote_device_change_state(struct isci_remote_device *idev, | |
199 | enum isci_status status); | |
88f3b62a DW |
200 | /** |
201 | * scic_remote_device_stop() - This method will stop both transmission and | |
202 | * reception of link activity for the supplied remote device. This method | |
203 | * disables normal IO requests from flowing through to the remote device. | |
204 | * @remote_device: This parameter specifies the device to be stopped. | |
205 | * @timeout: This parameter specifies the number of milliseconds in which the | |
206 | * stop operation should complete. | |
207 | * | |
208 | * An indication of whether the device was successfully stopped. SCI_SUCCESS | |
209 | * This value is returned if the transmission and reception for the device was | |
210 | * successfully stopped. | |
211 | */ | |
212 | enum sci_status scic_remote_device_stop( | |
213 | struct scic_sds_remote_device *remote_device, | |
214 | u32 timeout); | |
215 | ||
216 | /** | |
217 | * scic_remote_device_reset() - This method will reset the device making it | |
218 | * ready for operation. This method must be called anytime the device is | |
219 | * reset either through a SMP phy control or a port hard reset request. | |
220 | * @remote_device: This parameter specifies the device to be reset. | |
221 | * | |
222 | * This method does not actually cause the device hardware to be reset. This | |
223 | * method resets the software object so that it will be operational after a | |
224 | * device hardware reset completes. An indication of whether the device reset | |
225 | * was accepted. SCI_SUCCESS This value is returned if the device reset is | |
226 | * started. | |
227 | */ | |
228 | enum sci_status scic_remote_device_reset( | |
229 | struct scic_sds_remote_device *remote_device); | |
230 | ||
231 | /** | |
232 | * scic_remote_device_reset_complete() - This method informs the device object | |
233 | * that the reset operation is complete and the device can resume operation | |
234 | * again. | |
235 | * @remote_device: This parameter specifies the device which is to be informed | |
236 | * of the reset complete operation. | |
237 | * | |
238 | * An indication that the device is resuming operation. SCI_SUCCESS the device | |
239 | * is resuming operation. | |
240 | */ | |
241 | enum sci_status scic_remote_device_reset_complete( | |
242 | struct scic_sds_remote_device *remote_device); | |
243 | ||
244 | ||
245 | ||
246 | /** | |
247 | * scic_remote_device_get_connection_rate() - This method simply returns the | |
248 | * link rate at which communications to the remote device occur. | |
249 | * @remote_device: This parameter specifies the device for which to get the | |
250 | * connection rate. | |
251 | * | |
252 | * Return the link rate at which we transfer for the supplied remote device. | |
253 | */ | |
254 | enum sas_linkrate scic_remote_device_get_connection_rate( | |
255 | struct scic_sds_remote_device *remote_device); | |
256 | ||
88f3b62a DW |
257 | #if !defined(DISABLE_ATAPI) |
258 | /** | |
259 | * scic_remote_device_is_atapi() - | |
260 | * @this_device: The device whose type is to be decided. | |
261 | * | |
262 | * This method first decide whether a device is a stp target, then decode the | |
263 | * signature fis of a DA STP device to tell whether it is a standard end disk | |
264 | * or an ATAPI device. bool Indicate a device is ATAPI device or not. | |
265 | */ | |
266 | bool scic_remote_device_is_atapi( | |
267 | struct scic_sds_remote_device *device_handle); | |
268 | #else /* !defined(DISABLE_ATAPI) */ | |
269 | #define scic_remote_device_is_atapi(device_handle) false | |
270 | #endif /* !defined(DISABLE_ATAPI) */ | |
271 | ||
272 | ||
273 | ||
274 | /** | |
275 | * enum scic_sds_remote_device_states - This enumeration depicts all the states | |
276 | * for the common remote device state machine. | |
277 | * | |
278 | * | |
279 | */ | |
280 | enum scic_sds_remote_device_states { | |
281 | /** | |
282 | * Simply the initial state for the base remote device state machine. | |
283 | */ | |
284 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, | |
285 | ||
286 | /** | |
287 | * This state indicates that the remote device has successfully been | |
288 | * stopped. In this state no new IO operations are permitted. | |
289 | * This state is entered from the INITIAL state. | |
290 | * This state is entered from the STOPPING state. | |
291 | */ | |
292 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, | |
293 | ||
294 | /** | |
295 | * This state indicates the the remote device is in the process of | |
296 | * becoming ready (i.e. starting). In this state no new IO operations | |
297 | * are permitted. | |
298 | * This state is entered from the STOPPED state. | |
299 | */ | |
300 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, | |
301 | ||
302 | /** | |
303 | * This state indicates the remote device is now ready. Thus, the user | |
304 | * is able to perform IO operations on the remote device. | |
305 | * This state is entered from the STARTING state. | |
306 | */ | |
307 | SCI_BASE_REMOTE_DEVICE_STATE_READY, | |
308 | ||
309 | /** | |
310 | * This state indicates that the remote device is in the process of | |
311 | * stopping. In this state no new IO operations are permitted, but | |
312 | * existing IO operations are allowed to complete. | |
313 | * This state is entered from the READY state. | |
314 | * This state is entered from the FAILED state. | |
315 | */ | |
316 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | |
317 | ||
318 | /** | |
319 | * This state indicates that the remote device has failed. | |
320 | * In this state no new IO operations are permitted. | |
321 | * This state is entered from the INITIALIZING state. | |
322 | * This state is entered from the READY state. | |
323 | */ | |
324 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | |
325 | ||
326 | /** | |
327 | * This state indicates the device is being reset. | |
328 | * In this state no new IO operations are permitted. | |
329 | * This state is entered from the READY state. | |
330 | */ | |
331 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | |
332 | ||
333 | /** | |
334 | * Simply the final state for the base remote device state machine. | |
335 | */ | |
336 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | |
337 | }; | |
338 | ||
339 | /** | |
340 | * enum scic_sds_ssp_remote_device_ready_substates - | |
341 | * | |
342 | * This is the enumeration of the ready substates for the | |
343 | * struct scic_sds_remote_device. | |
344 | */ | |
345 | enum scic_sds_ssp_remote_device_ready_substates { | |
346 | /** | |
347 | * This is the initial state for the remote device ready substate. | |
348 | */ | |
349 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, | |
350 | ||
351 | /** | |
352 | * This is the ready operational substate for the remote device. | |
353 | * This is the normal operational state for a remote device. | |
354 | */ | |
355 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, | |
356 | ||
357 | /** | |
358 | * This is the suspended state for the remote device. This is the state | |
359 | * that the device is placed in when a RNC suspend is received by | |
360 | * the SCU hardware. | |
361 | */ | |
362 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, | |
363 | ||
364 | /** | |
365 | * This is the final state that the device is placed in before a change | |
366 | * to the base state machine. | |
367 | */ | |
368 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, | |
369 | ||
370 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES | |
371 | }; | |
372 | ||
373 | /** | |
374 | * enum scic_sds_stp_remote_device_ready_substates - | |
375 | * | |
376 | * This is the enumeration for the struct scic_sds_remote_device ready substates | |
377 | * for the STP remote device. | |
378 | */ | |
379 | enum scic_sds_stp_remote_device_ready_substates { | |
380 | /** | |
381 | * This is the idle substate for the stp remote device. When there are no | |
382 | * active IO for the device it is is in this state. | |
383 | */ | |
384 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | |
385 | ||
386 | /** | |
387 | * This is the command state for for the STP remote device. This state is | |
388 | * entered when the device is processing a non-NCQ command. The device object | |
389 | * will fail any new start IO requests until this command is complete. | |
390 | */ | |
391 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | |
392 | ||
393 | /** | |
394 | * This is the NCQ state for the STP remote device. This state is entered | |
395 | * when the device is processing an NCQ reuqest. It will remain in this state | |
396 | * so long as there is one or more NCQ requests being processed. | |
397 | */ | |
398 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, | |
399 | ||
400 | /** | |
401 | * This is the NCQ error state for the STP remote device. This state is | |
402 | * entered when an SDB error FIS is received by the device object while in the | |
403 | * NCQ state. The device object will only accept a READ LOG command while in | |
404 | * this state. | |
405 | */ | |
406 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, | |
407 | ||
408 | #if !defined(DISABLE_ATAPI) | |
409 | /** | |
410 | * This is the ATAPI error state for the STP ATAPI remote device. This state is | |
411 | * entered when ATAPI device sends error status FIS without data while the device | |
412 | * object is in CMD state. A suspension event is expected in this state. The device | |
413 | * object will resume right away. | |
414 | */ | |
415 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR, | |
416 | #endif | |
417 | ||
418 | /** | |
419 | * This is the READY substate indicates the device is waiting for the RESET task | |
420 | * coming to be recovered from certain hardware specific error. | |
421 | */ | |
422 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, | |
423 | }; | |
424 | ||
425 | /** | |
426 | * enum scic_sds_smp_remote_device_ready_substates - | |
427 | * | |
428 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. | |
429 | */ | |
430 | enum scic_sds_smp_remote_device_ready_substates { | |
431 | /** | |
432 | * This is the ready operational substate for the remote device. This is the | |
433 | * normal operational state for a remote device. | |
434 | */ | |
435 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | |
436 | ||
437 | /** | |
438 | * This is the suspended state for the remote device. This is the state that | |
439 | * the device is placed in when a RNC suspend is received by the SCU hardware. | |
440 | */ | |
441 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | |
442 | }; | |
443 | ||
444 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) | |
445 | { | |
446 | struct scic_sds_remote_device *sci_dev; | |
447 | ||
448 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); | |
449 | ||
450 | return sci_dev; | |
451 | } | |
452 | ||
a1a113b0 DW |
453 | static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev) |
454 | { | |
455 | struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci); | |
456 | ||
457 | return idev->domain_dev; | |
458 | } | |
459 | ||
460 | static inline bool dev_is_expander(struct domain_device *dev) | |
461 | { | |
462 | return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; | |
463 | } | |
464 | ||
88f3b62a DW |
465 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( |
466 | struct scic_sds_remote_device *device, | |
467 | struct scic_sds_request *request); | |
468 | ||
469 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( | |
470 | struct scic_sds_remote_device *device, | |
471 | struct scic_sds_request *request, | |
472 | void *, | |
473 | enum sci_io_status); | |
474 | ||
475 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( | |
476 | struct scic_sds_remote_device *sci_dev); | |
477 | ||
478 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( | |
479 | struct scic_sds_remote_device *sci_dev, | |
480 | u32 suspend_type); | |
481 | ||
482 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( | |
483 | struct scic_sds_remote_device *sci_dev); | |
484 | ||
485 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( | |
486 | struct scic_sds_remote_device *sci_dev, | |
487 | u32 frame_index); | |
488 | ||
489 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( | |
490 | struct scic_sds_remote_device *sci_dev, | |
491 | u32 event_code); | |
492 | ||
493 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( | |
494 | struct scic_sds_remote_device *sci_dev); | |
495 | ||
496 | /** | |
497 | * struct scic_sds_remote_device_state_handler - This structure conains the | |
498 | * state handlers that are needed to process requests for the SCU remote | |
499 | * device objects. | |
500 | * | |
501 | * | |
502 | */ | |
503 | struct scic_sds_remote_device_state_handler { | |
504 | /** | |
505 | * The start_handler specifies the method invoked when a user | |
506 | * attempts to start a remote device. | |
507 | */ | |
508 | scic_sds_remote_device_handler_t start_handler; | |
509 | ||
510 | /** | |
511 | * The stop_handler specifies the method invoked when a user attempts to | |
512 | * stop a remote device. | |
513 | */ | |
514 | scic_sds_remote_device_handler_t stop_handler; | |
515 | ||
516 | /** | |
517 | * The fail_handler specifies the method invoked when a remote device | |
518 | * failure has occurred. A failure may be due to an inability to | |
519 | * initialize/configure the device. | |
520 | */ | |
521 | scic_sds_remote_device_handler_t fail_handler; | |
522 | ||
523 | /** | |
524 | * The destruct_handler specifies the method invoked when attempting to | |
525 | * destruct a remote device. | |
526 | */ | |
527 | scic_sds_remote_device_handler_t destruct_handler; | |
528 | ||
529 | /** | |
530 | * The reset handler specifies the method invloked when requesting to | |
531 | * reset a remote device. | |
532 | */ | |
533 | scic_sds_remote_device_handler_t reset_handler; | |
534 | ||
535 | /** | |
536 | * The reset complete handler specifies the method invloked when | |
537 | * reporting that a reset has completed to the remote device. | |
538 | */ | |
539 | scic_sds_remote_device_handler_t reset_complete_handler; | |
540 | ||
541 | /** | |
542 | * The start_io_handler specifies the method invoked when a user | |
543 | * attempts to start an IO request for a remote device. | |
544 | */ | |
545 | scic_sds_remote_device_request_handler_t start_io_handler; | |
546 | ||
547 | /** | |
548 | * The complete_io_handler specifies the method invoked when a user | |
549 | * attempts to complete an IO request for a remote device. | |
550 | */ | |
551 | scic_sds_remote_device_request_handler_t complete_io_handler; | |
552 | ||
553 | /** | |
554 | * The continue_io_handler specifies the method invoked when a user | |
555 | * attempts to continue an IO request for a remote device. | |
556 | */ | |
557 | scic_sds_remote_device_request_handler_t continue_io_handler; | |
558 | ||
559 | /** | |
560 | * The start_task_handler specifies the method invoked when a user | |
561 | * attempts to start a task management request for a remote device. | |
562 | */ | |
563 | scic_sds_remote_device_request_handler_t start_task_handler; | |
564 | ||
565 | /** | |
566 | * The complete_task_handler specifies the method invoked when a user | |
567 | * attempts to complete a task management request for a remote device. | |
568 | */ | |
569 | scic_sds_remote_device_request_handler_t complete_task_handler; | |
570 | ||
571 | ||
572 | scic_sds_remote_device_suspend_handler_t suspend_handler; | |
573 | scic_sds_remote_device_resume_handler_t resume_handler; | |
574 | scic_sds_remote_device_event_handler_t event_handler; | |
575 | scic_sds_remote_device_frame_handler_t frame_handler; | |
576 | }; | |
577 | ||
578 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; | |
579 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; | |
580 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; | |
581 | ||
582 | /** | |
583 | * scic_sds_remote_device_increment_request_count() - | |
584 | * | |
585 | * This macro incrments the request count for this device | |
586 | */ | |
587 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ | |
588 | ((sci_dev)->started_request_count++) | |
589 | ||
590 | /** | |
591 | * scic_sds_remote_device_decrement_request_count() - | |
592 | * | |
593 | * This macro decrements the request count for this device. This count will | |
594 | * never decrment past 0. | |
595 | */ | |
596 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ | |
597 | ((sci_dev)->started_request_count > 0 ? \ | |
598 | (sci_dev)->started_request_count-- : 0) | |
599 | ||
600 | /** | |
601 | * scic_sds_remote_device_get_request_count() - | |
602 | * | |
603 | * This is a helper macro to return the current device request count. | |
604 | */ | |
605 | #define scic_sds_remote_device_get_request_count(sci_dev) \ | |
606 | ((sci_dev)->started_request_count) | |
607 | ||
608 | /** | |
609 | * scic_sds_remote_device_get_port() - | |
610 | * | |
611 | * This macro returns the owning port of this remote device obejct. | |
612 | */ | |
613 | #define scic_sds_remote_device_get_port(sci_dev) \ | |
614 | ((sci_dev)->owning_port) | |
615 | ||
616 | /** | |
617 | * scic_sds_remote_device_get_controller() - | |
618 | * | |
619 | * This macro returns the controller object that contains this device object | |
620 | */ | |
621 | #define scic_sds_remote_device_get_controller(sci_dev) \ | |
622 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) | |
623 | ||
624 | /** | |
625 | * scic_sds_remote_device_set_state_handlers() - | |
626 | * | |
627 | * This macro sets the remote device state handlers pointer and is set on entry | |
628 | * to each device state. | |
629 | */ | |
630 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ | |
631 | ((sci_dev)->state_handlers = (handlers)) | |
632 | ||
633 | /** | |
634 | * scic_sds_remote_device_get_port() - | |
635 | * | |
636 | * This macro returns the owning port of this device | |
637 | */ | |
638 | #define scic_sds_remote_device_get_port(sci_dev) \ | |
639 | ((sci_dev)->owning_port) | |
640 | ||
641 | /** | |
642 | * scic_sds_remote_device_get_sequence() - | |
643 | * | |
644 | * This macro returns the remote device sequence value | |
645 | */ | |
646 | #define scic_sds_remote_device_get_sequence(sci_dev) \ | |
647 | (\ | |
648 | scic_sds_remote_device_get_controller(sci_dev)-> \ | |
649 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ | |
650 | ) | |
651 | ||
652 | /** | |
653 | * scic_sds_remote_device_get_controller_peg() - | |
654 | * | |
655 | * This macro returns the controllers protocol engine group | |
656 | */ | |
657 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ | |
658 | (\ | |
659 | scic_sds_controller_get_protocol_engine_group(\ | |
660 | scic_sds_port_get_controller(\ | |
661 | scic_sds_remote_device_get_port(sci_dev) \ | |
662 | ) \ | |
663 | ) \ | |
664 | ) | |
665 | ||
666 | /** | |
667 | * scic_sds_remote_device_get_port_index() - | |
668 | * | |
669 | * This macro returns the port index for the devices owning port | |
670 | */ | |
671 | #define scic_sds_remote_device_get_port_index(sci_dev) \ | |
672 | (scic_sds_port_get_index(scic_sds_remote_device_get_port(sci_dev))) | |
673 | ||
674 | /** | |
675 | * scic_sds_remote_device_get_index() - | |
676 | * | |
677 | * This macro returns the remote node index for this device object | |
678 | */ | |
679 | #define scic_sds_remote_device_get_index(sci_dev) \ | |
680 | ((sci_dev)->rnc.remote_node_index) | |
681 | ||
682 | /** | |
683 | * scic_sds_remote_device_build_command_context() - | |
684 | * | |
685 | * This macro builds a remote device context for the SCU post request operation | |
686 | */ | |
687 | #define scic_sds_remote_device_build_command_context(device, command) \ | |
688 | ((command) \ | |
689 | | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \ | |
690 | | (scic_sds_remote_device_get_port_index((device)) << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ | |
691 | | (scic_sds_remote_device_get_index((device))) \ | |
692 | ) | |
693 | ||
694 | /** | |
695 | * scic_sds_remote_device_set_working_request() - | |
696 | * | |
697 | * This macro makes the working request assingment for the remote device | |
698 | * object. To clear the working request use this macro with a NULL request | |
699 | * object. | |
700 | */ | |
701 | #define scic_sds_remote_device_set_working_request(device, request) \ | |
702 | ((device)->working_request = (request)) | |
703 | ||
704 | enum sci_status scic_sds_remote_device_frame_handler( | |
705 | struct scic_sds_remote_device *sci_dev, | |
706 | u32 frame_index); | |
707 | ||
708 | enum sci_status scic_sds_remote_device_event_handler( | |
709 | struct scic_sds_remote_device *sci_dev, | |
710 | u32 event_code); | |
711 | ||
712 | enum sci_status scic_sds_remote_device_start_io( | |
713 | struct scic_sds_controller *controller, | |
714 | struct scic_sds_remote_device *sci_dev, | |
715 | struct scic_sds_request *io_request); | |
716 | ||
717 | enum sci_status scic_sds_remote_device_complete_io( | |
718 | struct scic_sds_controller *controller, | |
719 | struct scic_sds_remote_device *sci_dev, | |
720 | struct scic_sds_request *io_request); | |
721 | ||
722 | enum sci_status scic_sds_remote_device_resume( | |
723 | struct scic_sds_remote_device *sci_dev); | |
724 | ||
725 | enum sci_status scic_sds_remote_device_suspend( | |
726 | struct scic_sds_remote_device *sci_dev, | |
727 | u32 suspend_type); | |
728 | ||
729 | enum sci_status scic_sds_remote_device_start_task( | |
730 | struct scic_sds_controller *controller, | |
731 | struct scic_sds_remote_device *sci_dev, | |
732 | struct scic_sds_request *io_request); | |
733 | ||
734 | void scic_sds_remote_device_post_request( | |
735 | struct scic_sds_remote_device *sci_dev, | |
736 | u32 request); | |
737 | ||
738 | #if !defined(DISABLE_ATAPI) | |
739 | bool scic_sds_remote_device_is_atapi( | |
740 | struct scic_sds_remote_device *sci_dev); | |
741 | #else /* !defined(DISABLE_ATAPI) */ | |
742 | #define scic_sds_remote_device_is_atapi(sci_dev) false | |
743 | #endif /* !defined(DISABLE_ATAPI) */ | |
744 | ||
745 | void scic_sds_remote_device_start_request( | |
746 | struct scic_sds_remote_device *sci_dev, | |
747 | struct scic_sds_request *sci_req, | |
748 | enum sci_status status); | |
749 | ||
750 | void scic_sds_remote_device_continue_request(void *sci_dev); | |
751 | ||
752 | enum sci_status scic_sds_remote_device_default_start_handler( | |
753 | struct scic_sds_remote_device *sci_dev); | |
754 | ||
755 | enum sci_status scic_sds_remote_device_default_fail_handler( | |
756 | struct scic_sds_remote_device *sci_dev); | |
757 | ||
758 | enum sci_status scic_sds_remote_device_default_destruct_handler( | |
759 | struct scic_sds_remote_device *sci_dev); | |
760 | ||
761 | enum sci_status scic_sds_remote_device_default_reset_handler( | |
762 | struct scic_sds_remote_device *device); | |
763 | ||
764 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | |
765 | struct scic_sds_remote_device *device); | |
766 | ||
767 | enum sci_status scic_sds_remote_device_default_start_request_handler( | |
768 | struct scic_sds_remote_device *device, | |
769 | struct scic_sds_request *request); | |
770 | ||
771 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | |
772 | struct scic_sds_remote_device *device, | |
773 | struct scic_sds_request *request); | |
774 | ||
775 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | |
776 | struct scic_sds_remote_device *device, | |
777 | struct scic_sds_request *request); | |
778 | ||
779 | enum sci_status scic_sds_remote_device_default_suspend_handler( | |
780 | struct scic_sds_remote_device *sci_dev, | |
781 | u32 suspend_type); | |
782 | ||
783 | enum sci_status scic_sds_remote_device_default_resume_handler( | |
784 | struct scic_sds_remote_device *sci_dev); | |
785 | ||
786 | ||
787 | enum sci_status scic_sds_remote_device_default_frame_handler( | |
788 | struct scic_sds_remote_device *sci_dev, | |
789 | u32 frame_index); | |
790 | ||
791 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | |
792 | struct scic_sds_remote_device *device); | |
793 | ||
794 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | |
795 | struct scic_sds_remote_device *device); | |
796 | ||
797 | enum sci_status scic_sds_remote_device_general_frame_handler( | |
798 | struct scic_sds_remote_device *sci_dev, | |
799 | u32 frame_index); | |
800 | ||
801 | enum sci_status scic_sds_remote_device_general_event_handler( | |
802 | struct scic_sds_remote_device *sci_dev, | |
803 | u32 event_code); | |
804 | ||
805 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( | |
806 | struct scic_sds_remote_device *sci_dev); | |
807 | ||
808 | ||
6f231dda DW |
809 | |
810 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |